交班
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
@@ -13,6 +15,7 @@ import com.czg.account.vo.HandoverCategoryListVo;
|
||||
import com.czg.account.vo.HandoverProductListVo;
|
||||
import com.czg.account.vo.HandoverTotalVo;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.service.OrderInfoRpcService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.HandoverRecordMapper;
|
||||
@@ -24,7 +27,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,53 +42,40 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
|
||||
@DubboReference
|
||||
private OrderInfoRpcService orderInfoRpcService;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(HandoverRecordDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
if (StrUtil.isNotEmpty(param.getBeginDate())) {
|
||||
queryWrapper.ge(HandoverRecord::getHandoverTime, param.getBeginDate() + " 00:00:00");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(param.getEndDate())) {
|
||||
queryWrapper.le(HandoverRecord::getHandoverTime, param.getEndDate() + " 23:59:59");
|
||||
}
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(HandoverRecord::getShopId, shopId);
|
||||
queryWrapper.isNotNull(HandoverRecord::getHandoverTime);
|
||||
queryWrapper.orderBy(HandoverRecord::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<HandoverRecordDTO> getHandoverRecordPage(String beginDate, String endDate) {
|
||||
HandoverRecordDTO param = new HandoverRecordDTO();
|
||||
param.setBeginDate(beginDate);
|
||||
param.setEndDate(endDate);
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
QueryWrapper queryWrapper = query().eq(HandoverRecord::getShopId, StpKit.USER.getShopId());
|
||||
if (StrUtil.isNotEmpty(param.getBeginDate())) {
|
||||
queryWrapper.ge(HandoverRecord::getHandoverTime, param.getBeginDate() + " 00:00:00");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(param.getEndDate())) {
|
||||
queryWrapper.le(HandoverRecord::getHandoverTime, param.getEndDate() + " 23:59:59");
|
||||
}
|
||||
return super.pageAs(PageUtil.buildPage(), queryWrapper, HandoverRecordDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HandoverProductListVo> getHandoverProductListById(Long id) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
HandoverRecord data = super.getOne(query().eq(HandoverRecord::getId, id).eq(HandoverRecord::getShopId, shopId));
|
||||
if (data == null) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
HandoverRecord data = getOne(query().eq(HandoverRecord::getId, id).eq(HandoverRecord::getShopId, shopId));
|
||||
if (data == null || data.getProductData() == null) {
|
||||
return List.of();
|
||||
}
|
||||
String productData = data.getProductData();
|
||||
if (StrUtil.isBlank(productData)) {
|
||||
return List.of();
|
||||
}
|
||||
return JSON.parseArray(productData, HandoverProductListVo.class);
|
||||
return JSON.parseArray(data.getProductData(), HandoverProductListVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandoverTotalVo totalHandoverData() {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
LocalDateTime handoverTime = LocalDateTime.now();
|
||||
HandoverRecord record = super.getOne(query().eq(HandoverRecord::getShopId, shopId).isNull(HandoverRecord::getHandoverTime));
|
||||
HandoverTotalVo data = new HandoverTotalVo();
|
||||
if (record == null) {
|
||||
return data;
|
||||
throw new CzgException("未处在当班状态");
|
||||
}
|
||||
data.setId(record.getId());
|
||||
data.setShopId(record.getShopId());
|
||||
@@ -98,11 +87,19 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
|
||||
data.setHandoverTime(handoverTime);
|
||||
String loginTimeStr = LocalDateTimeUtil.formatNormal(record.getLoginTime());
|
||||
String handoverTimeStr = LocalDateTimeUtil.formatNormal(handoverTime);
|
||||
data.setCashAmount(sumCashAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setRefundAmount(sumRefundAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setHandAmount(sumHandAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setOrderCount(countOrderNum(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setDetailList(getDetailList(shopId, loginTimeStr, handoverTimeStr));
|
||||
data.setDetailList(orderInfoRpcService.getHandoverDetailList(shopId, loginTimeStr, handoverTimeStr));
|
||||
HandoverRecord onlinePayTypeDate = orderInfoRpcService.getOnlinePayTypeDate(shopId, loginTimeStr, handoverTimeStr);
|
||||
// 合并结果
|
||||
CopyOptions copyOptions = CopyOptions.create().setIgnoreNullValue(true);
|
||||
if (onlinePayTypeDate != null) {
|
||||
BeanUtil.copyProperties(onlinePayTypeDate, data, copyOptions);
|
||||
}
|
||||
HandoverRecord handoverRecord = orderInfoRpcService.countShopUserFlow(shopId, loginTimeStr, handoverTimeStr);
|
||||
if(handoverRecord != null){
|
||||
data.setTurnover(NumberUtil.add(data.getTurnover(), handoverRecord.getRecharge()));
|
||||
data.setRefundAmount(NumberUtil.add(data.getRefundAmount(), handoverRecord.getRefundAmount()));
|
||||
}
|
||||
data.setReturnDishCount(orderInfoRpcService.countReturnDish(shopId, loginTimeStr, handoverTimeStr));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -113,25 +110,19 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
|
||||
return;
|
||||
}
|
||||
entity.setLoginTime(LocalDateTime.now());
|
||||
super.save(entity);
|
||||
save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long handover() {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
HandoverTotalVo data = totalHandoverData();
|
||||
LocalDateTime loginTime = data.getLoginTime();
|
||||
LocalDateTime handoverTime = data.getHandoverTime();
|
||||
String loginTimeStr = LocalDateTimeUtil.formatNormal(loginTime);
|
||||
String handoverTimeStr = LocalDateTimeUtil.formatNormal(handoverTime);
|
||||
HandoverRecord entity = BeanUtil.copyProperties(data, HandoverRecord.class);
|
||||
entity.setWechatAmount(orderInfoRpcService.getHandoverWechatAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
entity.setAlipayAmount(orderInfoRpcService.getHandoverAlipayAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
entity.setVipPay(orderInfoRpcService.getHandoverVipPayAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
entity.setVipRecharge(orderInfoRpcService.getHandoverVipChargeAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
entity.setQuickInAmount(orderInfoRpcService.getHandoverQuickPayAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
entity.setCreditAmount(orderInfoRpcService.getHandoverCreditAmount(shopId, loginTimeStr, handoverTimeStr));
|
||||
List<HandoverCategoryListVo> categoryData = orderInfoRpcService.getHandoverCategoryList(shopId, loginTimeStr, handoverTimeStr);
|
||||
entity.setCategoryData(JSON.toJSONString(categoryData, JSONWriter.Feature.WriteMapNullValue));
|
||||
List<HandoverProductListVo> productData = data.getDetailList();
|
||||
@@ -146,24 +137,4 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
|
||||
orderInfoRpcService.sendHandoverReceiptPrintMsgToMq(handoverRecordId);
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal sumCashAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoRpcService.getHandoverCashAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private BigDecimal sumRefundAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoRpcService.getHandoverRefundAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private BigDecimal sumHandAmount(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoRpcService.getHandoverTotalAmount(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private int countOrderNum(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoRpcService.getHandoverOrderNum(shopId, loginTime, handoverTime);
|
||||
}
|
||||
|
||||
private List<HandoverProductListVo> getDetailList(Long shopId, String loginTime, String handoverTime) {
|
||||
return orderInfoRpcService.getHandoverDetailList(shopId, loginTime, handoverTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user