This commit is contained in:
2026-04-07 16:02:27 +08:00
parent be37a2d92b
commit 7b948b514a
10 changed files with 309 additions and 533 deletions

View File

@@ -7,7 +7,6 @@ import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
@@ -38,7 +37,6 @@ public class HandoverRecordController {
* @param endDate 结束时间 格式yyyy-MM-dd
*/
@GetMapping("page")
@OperationLog("交班记录-分页")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:page", name = "交班记录-分页")
public CzgResult<Page<HandoverRecordDTO>> page(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) {
Page<HandoverRecordDTO> page = handoverRecordService.getHandoverRecordPage(beginDate, endDate);
@@ -46,20 +44,33 @@ public class HandoverRecordController {
}
/**
* 交班记录-查看
* 交班记录-详情
*
* @param id 交班记录ID
*/
@GetMapping("/detail/{id}")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
public CzgResult<HandoverRecordDTO> detail(@PathVariable Long id) {
HandoverRecord entity = handoverRecordService.getById(id);
HandoverRecordDTO data = BeanUtil.copyProperties(entity, HandoverRecordDTO.class);
return CzgResult.success(data);
}
/**
* 交班记录-商品详情
*
* @param id 交班记录ID
*/
@GetMapping("{id}")
@OperationLog("交班记录-查看")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:info", name = "交班记录-查看")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
public CzgResult<List<HandoverProductListVo>> info(@PathVariable Long id) {
List<HandoverProductListVo> data = handoverRecordService.getHandoverProductListById(id);
return CzgResult.success(data);
}
/**
* 交班记录-导出
* 交班记录-商品详情导出
*
* @param id 交班记录ID
*/
@@ -71,13 +82,13 @@ public class HandoverRecordController {
ExcelExportUtil.exportToResponse(list, HandoverProductListVo.class, "交班售出商品明细", response);
}
/**
* 收银机-交班数据统计
* 收银机-实时交班数据
*/
@GetMapping("total")
@OperationLog("收银机-交班数据统计")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:total", name = "收银机-交班数据统计")
public CzgResult<HandoverTotalVo> total() {
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:realTime", name = "收银机-实时交班数据")
public CzgResult<HandoverTotalVo> realTime() {
HandoverTotalVo data = handoverRecordService.totalHandoverData();
return CzgResult.success(data);
}
@@ -92,35 +103,7 @@ public class HandoverRecordController {
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:handover", name = "收银机-交班/关班")
public CzgResult<Long> handover(@RequestParam Integer isPrint) {
Long id = handoverRecordService.handover();
handoverRecordService.printHandoverReceipt(id, isPrint);
return CzgResult.success(id);
}
/**
* 收银机-交班/关班-网络打印机打印交班小票
*
* @param id 交班记录id
*/
@PostMapping("/network/print/{id}")
@OperationLog("收银机-交班/关班-网络打印机打印交班小票")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:networkPrint", name = "收银机-交班/关班-网络打印机打印交班小票")
public CzgResult<Void> handover(@PathVariable Long id) {
handoverRecordService.printHandoverReceipt(id, SystemConstants.OneZero.ONE);
return CzgResult.success();
}
/**
* 交班记录-详情
*
* @param id 交班记录ID
*/
@GetMapping("/detail/{id}")
@OperationLog("交班记录-详情")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
public CzgResult<HandoverRecordDTO> detail(@PathVariable Long id) {
HandoverRecord entity = handoverRecordService.getById(id);
HandoverRecordDTO data = BeanUtil.copyProperties(entity, HandoverRecordDTO.class);
return CzgResult.success(data);
}
}

View File

@@ -53,30 +53,60 @@ public class HandoverRecordDTO implements Serializable {
* 员工姓名
*/
private String staffName;
/**
* 当班总收入
* 营业额
*/
private BigDecimal handAmount;
private BigDecimal turnover;
/**
* 现金收
* 现金收款 cash_pay
*/
private BigDecimal cashAmount;
private BigDecimal cash;
/**
* 微信收入
* 微信支付金额 wechat_mini
*/
private BigDecimal wechatAmount;
private BigDecimal wechat;
/**
* 支付宝收入
* 支付宝支付金额 alipay_mini
*/
private BigDecimal alipayAmount;
private BigDecimal alipay;
/**
* 会员支付
* 二维码收款 main_scan
*/
private BigDecimal vipPay;
private BigDecimal selfScan;
/**
* 会员充值
* 扫码收款 back_scan
*/
private BigDecimal vipRecharge;
private BigDecimal barScan;
/**
* 充值
*/
private BigDecimal recharge;
/**
* 挂账 credit_pay
*/
private BigDecimal owed;
/**
* 余额支付 vip_pay
*/
private BigDecimal balance;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退菜数量
*/
private Integer returnDishCount;
/**
* 分类数据 json
*/
@@ -87,18 +117,7 @@ public class HandoverRecordDTO implements Serializable {
*/
@JSONField(serialize = false)
private String productData;
/**
* 快捷收款金额
*/
private BigDecimal quickInAmount;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 挂账金额
*/
private BigDecimal creditAmount;
/**
* 订单数量
*/
@@ -124,11 +143,4 @@ public class HandoverRecordDTO implements Serializable {
*/
private List<HandoverProductListVo> productDataList;
public List<HandoverCategoryListVo> getCategoryDataList() {
return JSON.parseArray(categoryData, HandoverCategoryListVo.class);
}
public List<HandoverProductListVo> getProductDataList() {
return JSON.parseArray(productData, HandoverProductListVo.class);
}
}

View File

@@ -53,30 +53,65 @@ public class HandoverRecord implements Serializable {
* 员工姓名
*/
private String staffName;
/**
* 当班总收入
* 营业额
*/
private BigDecimal handAmount;
private BigDecimal turnover;
/**
* 现金收
* 现金收款 cash_pay
*/
private BigDecimal cashAmount;
private BigDecimal cash;
/**
* 微信收入
* 微信支付金额 wechat_mini
*/
private BigDecimal wechatAmount;
private BigDecimal wechat;
/**
* 支付宝收入
* 支付宝支付金额 alipay_mini
*/
private BigDecimal alipayAmount;
private BigDecimal alipay;
/**
* 会员支付
* 二维码收款 main_scan
*/
private BigDecimal vipPay;
private BigDecimal selfScan;
/**
* 会员充值
* 扫码收款 back_scan
*/
private BigDecimal vipRecharge;
private BigDecimal barScan;
/**
* 挂账 credit_pay
*/
private BigDecimal owed;
/**
* 余额支付 vip_pay
*/
private BigDecimal balance;
/**
* 充值
*/
private BigDecimal recharge;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退菜数量
*/
private Integer returnDishCount;
/**
* 订单数量
*/
private Integer orderCount;
/**
* 分类数据 json
*/
@@ -85,20 +120,4 @@ public class HandoverRecord implements Serializable {
* 商品数据 json
*/
private String productData;
/**
* 快捷收款金额
*/
private BigDecimal quickInAmount;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 挂账金额
*/
private BigDecimal creditAmount;
/**
* 订单数量
*/
private Integer orderCount;
}

View File

@@ -55,17 +55,58 @@ public class HandoverTotalVo implements Serializable {
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime handoverTime;
/**
* 现金支付
* 营业额
*/
private BigDecimal cashAmount;
private BigDecimal turnover;
/**
* 现金收款 cash_pay
*/
private BigDecimal cash;
/**
* 微信支付金额 wechat_mini
*/
private BigDecimal wechat;
/**
* 支付宝支付金额 alipay_mini
*/
private BigDecimal alipay;
/**
* 二维码收款 main_scan
*/
private BigDecimal selfScan;
/**
* 扫码收款 back_scan
*/
private BigDecimal barScan;
/**
* 充值
*/
private BigDecimal recharge;
/**
* 挂账 credit_pay
*/
private BigDecimal owed;
/**
* 余额支付 vip_pay
*/
private BigDecimal balance;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 当班总收入(营业额)
* 退菜数量
*/
private BigDecimal handAmount;
private Integer returnDishCount;
/**
* 订单数量
*/

View File

@@ -1,10 +1,10 @@
package com.czg.order.service;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import java.math.BigDecimal;
import java.util.List;
/**
@@ -15,126 +15,6 @@ import java.util.List;
*/
public interface OrderInfoRpcService {
/**
* 交班现金支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 现金支付总额
*/
BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班微信支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 现金支付总额
*/
BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班支付宝支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 支付宝支付总额
*/
BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班VIP支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return VIP支付总额
*/
BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班VIP充值统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return VIP充值总额
*/
BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班快捷支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 快捷支付总额
*/
BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班退款统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 退款总额
*/
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班挂账统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 挂账总额
*/
BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班营业额统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 营业额
*/
BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班订单数统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 交班订单数
*/
int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime);
/**
* 交班售出商品明细
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 交班售出商品明细
*/
List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime);
/**
* 交班售出商品分类统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 售出商品分类统计
*/
List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime);
/**
* 订单支付成功回调 扣减商品库存及耗材库存
*
@@ -162,4 +42,44 @@ public interface OrderInfoRpcService {
* @param handoverRecordId 交班记录id
*/
void sendHandoverReceiptPrintMsgToMq(Long handoverRecordId);
/**
* 交班售出商品明细
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 交班售出商品明细
*/
List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime);
/**
* 交班售出商品分类统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 售出商品分类统计
*/
List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime);
//---------------------------------------------------------------------------------------->
/**
* 支付金额统计
* 营业额为 订单收款额度 不包括充值
*/
HandoverRecord getOnlinePayTypeDate(Long shopId, String loginTime, String handoverTime);
/**
* 订单退菜数量
*/
int countReturnDish(Long shopId, String loginTime, String handoverTime);
/**
* 会员充值金额 退款金额
*/
HandoverRecord countShopUserFlow(Long shopId, String loginTime, String handoverTime);
}

View File

@@ -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);
}
}

View File

@@ -1,10 +1,12 @@
package com.czg.service.market.mapper;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.order.entity.OrderInfo;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List;
@@ -16,105 +18,6 @@ import java.util.List;
* @since 2025-02-13
*/
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
/**
* 交班现金支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 现金支付总额
*/
BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班微信支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 现金支付总额
*/
BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班支付宝支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 支付宝支付总额
*/
BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班VIP支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return VIP支付总额
*/
BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班VIP充值统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return VIP充值总额
*/
BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班快捷支付统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 快捷支付总额
*/
BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班退款统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 退款总额
*/
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班挂账统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 挂账总额
*/
BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班营业额统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 营业额
*/
BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班订单数统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 交班订单数
*/
int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime);
/**
* 交班售出商品明细
@@ -140,4 +43,49 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
int updatePayOrderId(@Param("orderId") Long orderId, @Param("paymentId") Long paymentId, @Param("payType") String payType, @Param("remark") String remark);
}
/**
* 订单支付方式统计 当日实时数据
*/
@Select("SELECT" +
" SUM(tb_order_info.pay_amount) AS turnover," +
" SUM(CASE WHEN pay_type = 'main_scan' THEN pay_amount ELSE 0 END) AS selfScan," +
" SUM(CASE WHEN pay_type = 'back_scan' THEN pay_amount ELSE 0 END) AS barScan," +
" SUM(CASE WHEN pay_type = 'wechat_mini' THEN pay_amount ELSE 0 END) AS wechat," +
" SUM(CASE WHEN pay_type = 'alipay_mini' THEN pay_amount ELSE 0 END) AS alipay," +
" SUM(CASE WHEN pay_type = 'vip_pay' THEN pay_amount ELSE 0 END) AS balance," +
" SUM(CASE WHEN pay_type = 'cash_pay' THEN pay_amount ELSE 0 END) AS cash," +
" SUM(CASE WHEN pay_type = 'credit_pay' THEN pay_amount ELSE 0 END) AS owed," +
" IFNULL(SUM(refund_amount), 0) as refundAmount," +
" count(1) as orderCount " +
" FROM" +
" tb_order_info " +
" WHERE" +
" shop_id = #{shopId} " +
"and create_time >= #{loginTime} and create_time <= #{handoverTime} " +
"and paid_time is not null ")
HandoverRecord getOnlinePayTypeDate(Long shopId, String loginTime, String handoverTime);
/**
* 订单退菜数量
*/
@Select("SELECT" +
" SUM(o.return_num) AS returnDishCount " +
" FROM" +
" tb_order_info left join tb_order_detail o on tb_order_info.id = o.order_id" +
" WHERE" +
" tb_order_info.shop_id = #{shopId} " +
"and tb_order_info.create_time >= #{loginTime} and tb_order_info.create_time <= #{handoverTime} " +
"and tb_order_info.paid_time is not null ")
int countReturnDish(Long shopId, String loginTime, String handoverTime);
@Select("SELECT " +
" SUM(CASE WHEN biz_code IN ('cashIn', 'wechatIn', 'alipayIn', 'adminIn') THEN amount ELSE 0 END) AS recharge," +
" SUM(CASE WHEN biz_code IN ('rechargeRefund', 'rechargeCashRefund') THEN amount ELSE 0 END) AS refundAmount " +
"FROM `tb_shop_user_flow` " +
" WHERE" +
" shop_id = #{shopId} " +
"and create_time >= #{loginTime} and create_time <= #{handoverTime} ")
HandoverRecord countShopUserFlow(Long shopId, String loginTime, String handoverTime);
}

View File

@@ -45,39 +45,7 @@
where id = #{orderId};
</update>
<select id="getHandoverCashAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'cash_pay'
</where>
</select>
<select id="getHandoverRefundAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.refund_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverTotalAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverOrderNum" resultType="java.lang.Integer">
SELECT
count(*)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverDetailList" resultType="com.czg.account.vo.HandoverProductListVo">
SELECT
t2.product_id,
@@ -86,6 +54,7 @@
GROUP_CONCAT( DISTINCT t2.sku_name ) AS sku_name,
sum( ifnull(t2.num,0) ) AS num,
sum( ifnull(t2.pay_amount,0) ) amount
sum( ifnull(t2.pay_amount,0) ) amount
FROM
tb_order_detail t2
LEFT JOIN tb_order_info t1 ON t1.id = t2.order_id
@@ -96,53 +65,7 @@
t2.product_id,
t2.sku_id
</select>
<select id="getHandoverWechatAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'wechat_mini'
</where>
</select>
<select id="getHandoverAlipayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'alipay_mini'
</where>
</select>
<select id="getHandoverVipPayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'vip_pay'
</where>
</select>
<select id="getHandoverVipChargeAmount" resultType="java.math.BigDecimal">
select ifnull(sum(t1.amount), 0)
from tb_shop_user_flow t1
where t1.shop_id = #{shopId}
and t1.biz_code in ('cashIn', 'wechatIn', 'alipayIn', 'adminIn')
and t1.recharge_id is not null
<![CDATA[
AND t1.create_time >= str_to_date(#{loginTime}, '%Y-%m-%d %H:%i:%s')
AND t1.create_time <= str_to_date(#{handoverTime}, '%Y-%m-%d %H:%i:%s')
]]>
</select>
<select id="getHandoverQuickPayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type in ('main_scan','back_scan')
</where>
</select>
<select id="getHandoverCategoryList" resultType="com.czg.account.vo.HandoverCategoryListVo">
SELECT case when t3.category_id is null then 0 else t3.category_id end as category_id,
case when t4.name is null then '未分类' else t4.name end as category_name,
@@ -158,13 +81,4 @@
</where>
GROUP BY t3.category_id
</select>
<select id="getHandoverCreditAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'credit_pay'
</where>
</select>
</mapper>

View File

@@ -189,23 +189,23 @@ public interface PrinterImpl {
.append(signLabelInfo.br)
.append(signLabelInfo.br)
.append(getFormatLabel("当班营业总额: " + handoverRecord.getHandAmount(), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("当班营业总额: " + handoverRecord.getTurnover(), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 现金:", handoverRecord.getCashAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 微信:", handoverRecord.getWechatAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 支付宝:", handoverRecord.getAlipayAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 二维码收款:", "", 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 扫码收款:", "", 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 充值:", handoverRecord.getVipRecharge().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 现金:", handoverRecord.getCash().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 微信:", handoverRecord.getWechat().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 支付宝:", handoverRecord.getAlipay().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 二维码收款:", handoverRecord.getSelfScan().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 扫码收款:", handoverRecord.getBarScan().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 充值:", handoverRecord.getRecharge().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("非实际收款的支付方式", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 挂账:", handoverRecord.getCreditAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 余额:", handoverRecord.getVipPay().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 挂账:", handoverRecord.getOwed().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 余额:", handoverRecord.getBalance().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("退菜/退款", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退款金额:", handoverRecord.getRefundAmount().toPlainString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退菜数量:", "", 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign(" 退菜数量:", handoverRecord.getReturnDishCount().toString(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign("订单(数量/订单总额)", handoverRecord.getOrderCount() + "/" + handoverRecord.getHandAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(leftRightAlign("订单(数量/订单总额)", handoverRecord.getOrderCount() + "/" + handoverRecord.getTurnover(), 32), signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br)
.append(getFormatLabel(formatItemLine("商品分类", "数量", "总计", 14, 8), signLabelInfo.s))
.append(signLabelInfo.br);

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.config.RabbitPublisher;
@@ -12,8 +13,8 @@ import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoRpcService;
import com.czg.product.service.ProductRpcService;
import com.czg.service.order.mapper.OrderDetailMapper;
import com.czg.service.market.mapper.OrderInfoMapper;
import com.czg.service.order.mapper.OrderDetailMapper;
import com.mybatisflex.core.query.QueryWrapper;
import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;
@@ -47,55 +48,6 @@ public class OrderInfoRpcServiceImpl implements OrderInfoRpcService {
@Resource
private RabbitPublisher rabbitPublisher;
@Override
public BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverWechatAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverAlipayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverVipPayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverVipChargeAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverQuickPayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverCashAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverRefundAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverCreditAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverTotalAmount(shopId, loginTime, handoverTime);
}
@Override
public int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getHandoverOrderNum(shopId, loginTime, handoverTime);
}
@Override
public List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime) {
@@ -107,6 +59,22 @@ public class OrderInfoRpcServiceImpl implements OrderInfoRpcService {
return orderInfoMapper.getHandoverCategoryList(shopId, loginTime, handoverTime);
}
@Override
public HandoverRecord getOnlinePayTypeDate(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.getOnlinePayTypeDate(shopId, loginTime, handoverTime);
}
@Override
public int countReturnDish(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.countReturnDish(shopId, loginTime, handoverTime);
}
@Override
public HandoverRecord countShopUserFlow(Long shopId, String loginTime, String handoverTime) {
return orderInfoMapper.countShopUserFlow(shopId, loginTime, handoverTime);
}
@Override
@GlobalTransactional
public void paySuccessCallback(Long orderId) {