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

@@ -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>