Merge remote-tracking branch 'origin/master'

This commit is contained in:
张松 2025-02-28 11:08:39 +08:00
commit f18d3021a9
8 changed files with 341 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -34,4 +35,16 @@ public class HandoverRecordController {
return CzgResult.success(data);
}
/**
* 收银机-交班/关班
*/
@PostMapping("handover")
@OperationLog("收银机-交班/关班")
//@SaAdminCheckPermission("handoverRecord:handover")
public CzgResult<Void> handover() {
Long id = handoverRecordService.handover();
// TODO 后续需要发生mq消息给打印机
return CzgResult.success();
}
}

View File

@ -23,4 +23,11 @@ public interface HandoverRecordService extends IService<HandoverRecord> {
*/
void initHandoverRecord(HandoverRecord entity);
/**
* 交班/关班
*
* @return 交班记录ID
*/
Long handover();
}

View File

@ -0,0 +1,40 @@
package com.czg.account.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 交班售出商品分类统计
*
* @author tankaikai
* @since 2025-02-27 15:34
*/
@Data
public class HandoverCategoryListVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 商品分类id
*/
private Long categoryId;
/**
* 商品分类名称
*/
private String categoryName;
/**
* 分类下商品数量
*/
private Integer quantity;
/**
* 售出数量合计
*/
private BigDecimal num;
/**
* 小计商品金额
*/
private BigDecimal amount;
}

View File

@ -1,6 +1,7 @@
package com.czg.order.service;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.order.dto.CheckOrderPay;
import com.czg.order.dto.OrderInfoAddDTO;
@ -50,6 +51,56 @@ public interface OrderInfoService extends IService<OrderInfo> {
*/
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);
/**
* 交班退款统计
*
@ -60,6 +111,16 @@ public interface OrderInfoService extends IService<OrderInfo> {
*/
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班挂账统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 挂账总额
*/
BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班营业额统计
*
@ -89,4 +150,14 @@ public interface OrderInfoService extends IService<OrderInfo> {
* @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);
}

View File

@ -1,10 +1,14 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.order.service.OrderInfoService;
@ -15,6 +19,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
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;
@ -46,7 +51,6 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
@Override
public HandoverTotalVo totalHandoverData() {
orderInfoService.historyOrder(0L, "11");
Long shopId = StpKit.USER.getShopId(0L);
LocalDateTime handoverTime = LocalDateTime.now();
HandoverRecord record = super.getOne(query().eq(HandoverRecord::getShopId, shopId).isNull(HandoverRecord::getHandoverTime));
@ -81,6 +85,30 @@ public class HandoverRecordServiceImpl extends ServiceImpl<HandoverRecordMapper,
super.save(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long handover() {
Long shopId = StpKit.USER.getShopId(0L);
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(orderInfoService.getHandoverWechatAmount(shopId, loginTimeStr, handoverTimeStr));
entity.setAlipayAmount(orderInfoService.getHandoverAlipayAmount(shopId, loginTimeStr, handoverTimeStr));
entity.setVipPay(orderInfoService.getHandoverVipPayAmount(shopId, loginTimeStr, handoverTimeStr));
entity.setVipRecharge(orderInfoService.getHandoverVipChargeAmount(shopId, loginTimeStr, handoverTimeStr));
entity.setQuickInAmount(orderInfoService.getHandoverQuickPayAmount(shopId, loginTimeStr, handoverTimeStr));
entity.setCreditAmount(orderInfoService.getHandoverCreditAmount(shopId, loginTimeStr, handoverTimeStr));
List<HandoverCategoryListVo> categoryData = orderInfoService.getHandoverCategoryList(shopId, loginTimeStr, handoverTimeStr);
entity.setCategoryData(JSON.toJSONString(categoryData, JSONWriter.Feature.WriteMapNullValue));
List<HandoverProductListVo> productData = data.getDetailList();
entity.setProductData(JSON.toJSONString(productData, JSONWriter.Feature.WriteMapNullValue));
super.updateById(entity);
return entity.getId();
}
private BigDecimal sumCashAmount(Long shopId, String loginTime, String handoverTime) {
return orderInfoService.getHandoverCashAmount(shopId, loginTime, handoverTime);
}

View File

@ -1,5 +1,6 @@
package com.czg.service.order.mapper;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.order.entity.OrderInfo;
import com.mybatisflex.core.BaseMapper;
@ -25,6 +26,56 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
*/
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);
/**
* 交班退款统计
*
@ -35,6 +86,16 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
*/
BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班挂账统计
*
* @param shopId 店铺id
* @param loginTime 上岗时间
* @param handoverTime 交班时间
* @return 挂账总额
*/
BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime);
/**
* 交班营业额统计
*
@ -65,4 +126,13 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
*/
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);
}

View File

@ -10,6 +10,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.account.vo.HandoverCategoryListVo;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
@ -567,6 +568,31 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
}
}
@Override
public BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime) {
return null;
}
@Override
public BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverAlipayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverVipPayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverVipChargeAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverQuickPayAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverCashAmount(shopId, loginTime, handoverTime);
@ -577,6 +603,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
return super.mapper.getHandoverRefundAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverCreditAmount(shopId, loginTime, handoverTime);
}
@Override
public BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverTotalAmount(shopId, loginTime, handoverTime);
@ -592,6 +623,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
return super.mapper.getHandoverDetailList(shopId, loginTime, handoverTime);
}
@Override
public List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime) {
return super.mapper.getHandoverCategoryList(shopId, loginTime, handoverTime);
}
/**
* 初始化订单信息
*/

View File

@ -33,7 +33,7 @@
<select id="getHandoverCashAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(pay_amount),0)
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
@ -42,7 +42,7 @@
</select>
<select id="getHandoverRefundAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(refund_amount),0)
ifnull(sum(t1.refund_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
@ -50,7 +50,7 @@
</select>
<select id="getHandoverTotalAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(pay_amount),0)
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
@ -82,4 +82,76 @@
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,
count(DISTINCT t2.product_id) AS quantity,
sum(ifnull(t2.num, 0)) AS num,
sum(ifnull(t2.pay_amount, 0)) amount
FROM tb_order_detail t2
LEFT JOIN tb_order_info t1 ON t1.id = t2.order_id
LEFT JOIN tb_product t3 ON t3.id = t2.product_id
LEFT JOIN tb_shop_prod_category t4 ON t4.id = t3.category_id
<where>
<include refid="handoverCommonWhere"/>
</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>