后端 BUG

This commit is contained in:
zhaohengkun 2024-09-26 14:52:54 +08:00
parent 1ee96d674e
commit c274a7f9e1
5 changed files with 275 additions and 252 deletions

View File

@ -317,11 +317,11 @@
<select id="getAmountAndConsume" resultType="java.util.Map">
select
count(*) as consumeNum,
sum(amount) as amount
sum(COALESCE(amount, 0)) as amount
from card_value_record
<where>
mt_user_id = #{mtUserId}
</where>
where
mt_user_id = #{mtUserId}
</select>
<!-- where store_id = #{storeId} and mt_user_id = #{userId}-->
<!-- group by chain_store_id

View File

@ -87,6 +87,8 @@ public interface AllOrderInfoMapper extends BaseMapper<AllOrderInfo> {
Map<String, Object> getLeiJiInfo(@Param("order") UserBalanceVo record);
Map<String, Object> getShuJuVipInfo(@Param("order") UserBalanceVo record);
String getCardGift(@Param("order") UserBalanceVo record);
AllOrderInfoVo getPaymentChannelData(Integer storeId);

View File

@ -8,37 +8,37 @@
<where>
pay_type != 'CASH'
and store_id IN
<foreach collection="list" item="list" separator="," open="(" close=")">
#{list.storeId}
</foreach>
<foreach collection="list" item="list" separator="," open="(" close=")">
#{list.storeId}
</foreach>
</where>
</select>
<select id="getTradingPage" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
<select id="getTradingPage" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
aoi.id AS id,
aoi.order_no AS orderNo,
aoi.type AS type,
aoi.transaction_id AS transactionId,
aoi.store_id AS storeId,
aoi.goods_money AS goodsMoney,
aoi.pay_money AS payMoney,
aoi.pay_time AS payTime,
aoi.pay_type AS payType,
aoi.user_id AS userId,
aoi.pay_channel AS payChannel,
aoi.status AS status,
aoi.content AS orderContent,
aoi.create_time AS createTime,
aoi.create_by AS createBy,
aoi.update_time AS updateTime,
aoi.update_by AS updateBy,
aoi.reason_Refund AS reasonRefund,
aoi.ref_order_no AS refOrderNo,
aoi.ref_money AS refMoney,
aoi.ref_by AS refBy,
aoi.discount_amount AS discountAmount,
mu.name userName,
mu.mobile userMobile
aoi.id AS id,
aoi.order_no AS orderNo,
aoi.type AS type,
aoi.transaction_id AS transactionId,
aoi.store_id AS storeId,
aoi.goods_money AS goodsMoney,
aoi.pay_money AS payMoney,
aoi.pay_time AS payTime,
aoi.pay_type AS payType,
aoi.user_id AS userId,
aoi.pay_channel AS payChannel,
aoi.status AS status,
aoi.content AS orderContent,
aoi.create_time AS createTime,
aoi.create_by AS createBy,
aoi.update_time AS updateTime,
aoi.update_by AS updateBy,
aoi.reason_Refund AS reasonRefund,
aoi.ref_order_no AS refOrderNo,
aoi.ref_money AS refMoney,
aoi.ref_by AS refBy,
aoi.discount_amount AS discountAmount,
mu.name userName,
mu.mobile userMobile
from all_order_info aoi
left join mt_user mu ON aoi.user_id = mu.id
<where>
@ -55,10 +55,10 @@
<if test="allOrderInfo.payType != null and allOrderInfo.payType != ''">
and aoi.pay_type = #{allOrderInfo.payType}
</if>
<if test="allOrderInfo.status != null and allOrderInfo.status != ''">
<if test="allOrderInfo.status != null and allOrderInfo.status != ''">
and aoi.status = #{allOrderInfo.status}
</if>
<if test="allOrderInfo.staffId != null and allOrderInfo.staffId != ''">
<if test="allOrderInfo.staffId != null and allOrderInfo.staffId != ''">
and aoi.staff_id = #{allOrderInfo.staffId}
</if>
<if test="allOrderInfo.params.beginTime != null and allOrderInfo.params.beginTime != ''"><!-- 开始时间检索 -->
@ -83,8 +83,8 @@
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(COUNT(*), 0) AS strokeCount,
CASE
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
END AS unitPrice
from all_order_info aoi
@ -104,10 +104,10 @@
</where>
</select>
<!-- sum(pay_money) amount,-->
<!-- count(*) strokeCount,-->
<!-- SUM(pay_money) / COUNT(*) AS unitPrice,-->
<!-- store_id storeId,-->
<!-- sum(pay_money) amount,-->
<!-- count(*) strokeCount,-->
<!-- SUM(pay_money) / COUNT(*) AS unitPrice,-->
<!-- store_id storeId,-->
<select id="getStoreNDynamic" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
COUNT(DISTINCT aoi.store_id) AS storeCount
@ -130,10 +130,10 @@
</select>
<!-- &#45;&#45; aoi.store_id = #{allOrderInfo.storeId}-->
<!-- &#45;&#45; aoi.store_id = #{allOrderInfo.storeId}-->
<select id="sumPayMoney" resultType="java.lang.String">
select
sum(aoi.pay_money) sumPayMoney
sum(aoi.pay_money) sumPayMoney
from all_order_info aoi
left join mt_user mu ON aoi.user_id = mu.id
where aoi.store_id = #{allOrderInfo.storeId}
@ -161,7 +161,6 @@
</select>
<select id="getPageList" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
aoi.id AS id,
@ -244,23 +243,23 @@
</select>
<!-- SUM(CASE WHEN payType = 'balance' THEN pay_money ELSE 0 END) AS balance,-->
<!-- SUM(CASE WHEN payType = 'balance' THEN pay_money ELSE 0 END) AS balance,-->
<select id="getRunningWaterByDay" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
DATE(pay_time) AS pay_time,
COUNT(DISTINCT aoi.store_id) AS storeCount,
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(SUM(goods_money), 0) AS goodsMoney,
COALESCE(COUNT(*), 0) AS strokeCount,
DATE(pay_time) AS pay_time,
COUNT(DISTINCT aoi.store_id) AS storeCount,
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(SUM(goods_money), 0) AS goodsMoney,
COALESCE(COUNT(*), 0) AS strokeCount,
COALESCE(SUM(discount_amount), 0) AS discountAmount,
SUM(CASE WHEN status = 'refund' THEN ref_money ELSE 0 END) AS refund,
SUM(CASE WHEN content = '储值卡充值' THEN pay_money ELSE 0 END) AS vipAmount,
SUM(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) AS balance,
ROUND(
CASE WHEN COUNT(*) = 0 THEN 0 ELSE SUM(pay_money) / COUNT(*) END,
2
) AS unitPrice
ROUND(
CASE WHEN COUNT(*) = 0 THEN 0 ELSE SUM(pay_money) / COUNT(*) END,
2
) AS unitPrice
from all_order_info aoi
WHERE
date_format(aoi.pay_time, '%y%m%d') BETWEEN date_format(#{allOrderInfo.params.beginTime}, '%y%m%d')
@ -281,18 +280,19 @@
<select id="getRunningWaterByDayData" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT DATE(pay_time) AS pay_time,
COUNT(DISTINCT aoi.store_id) storeCount,
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(COUNT(*), 0) AS strokeCount,
ROUND(
CASE
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
END,
2
) AS unitPrice
COUNT(DISTINCT aoi.store_id) storeCount,
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(COUNT(*), 0) AS strokeCount,
ROUND(
CASE
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
END,
2
) AS unitPrice
from all_order_info aoi
WHERE date_format(aoi.pay_time,'%y%m%d') BETWEEN date_format(#{allOrderInfo.params.beginTime},'%y%m%d') AND date_format(#{allOrderInfo.params.endTime},'%y%m%d')
WHERE date_format(aoi.pay_time,'%y%m%d') BETWEEN date_format(#{allOrderInfo.params.beginTime},'%y%m%d') AND
date_format(#{allOrderInfo.params.endTime},'%y%m%d')
<if test="allOrderInfo.storeIds != null">
and aoi.store_id in
<foreach collection="allOrderInfo.storeIds" item="item" open="(" close=")" separator=",">
@ -307,11 +307,11 @@
COALESCE(SUM(pay_money), 0) AS amount,
COALESCE(COUNT(*), 0) AS strokeCount,
ROUND(
CASE
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
END,
2
CASE
WHEN COUNT(*) = 0 THEN 0
ELSE SUM(pay_money) / COUNT(*)
END,
2
) AS unitPrice
from all_order_info aoi
<where>
@ -332,64 +332,64 @@
</select>
<select id="getHandoverByOrderNo" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
aoi.id AS id,
aoi.order_no AS orderNo,
aoi.type AS type,
aoi.transaction_id AS transactionId,
aoi.store_id AS storeId,
aoi.goods_money AS goodsMoney,
aoi.pay_money AS payMoney,
aoi.pay_time AS payTime,
aoi.pay_type AS payType,
aoi.user_id AS userId,
aoi.pay_channel AS payChannel,
aoi.status AS status,
aoi.content AS orderContent,
aoi.create_time AS createTime,
aoi.create_by AS createBy,
aoi.update_time AS updateTime,
aoi.update_by AS updateBy,
aoi.reason_Refund AS reasonRefund,
aoi.ref_order_no AS refOrderNo,
aoi.ref_money AS refMoney,
aoi.ref_by AS refBy,
mu.name userName,
mu.mobile userMobile
select aoi.id AS id,
aoi.order_no AS orderNo,
aoi.type AS type,
aoi.transaction_id AS transactionId,
aoi.store_id AS storeId,
aoi.goods_money AS goodsMoney,
aoi.pay_money AS payMoney,
aoi.pay_time AS payTime,
aoi.pay_type AS payType,
aoi.user_id AS userId,
aoi.pay_channel AS payChannel,
aoi.status AS status,
aoi.content AS orderContent,
aoi.create_time AS createTime,
aoi.create_by AS createBy,
aoi.update_time AS updateTime,
aoi.update_by AS updateBy,
aoi.reason_Refund AS reasonRefund,
aoi.ref_order_no AS refOrderNo,
aoi.ref_money AS refMoney,
aoi.ref_by AS refBy,
mu.name userName,
mu.mobile userMobile
from all_order_info aoi
left join mt_user mu ON aoi.user_id = mu.id
where
order_no like concat('%', #{allOrderInfo.orderNo}, '%')
left join mt_user mu ON aoi.user_id = mu.id
where order_no like concat('%', #{allOrderInfo.orderNo}, '%')
order by aoi.create_time desc
</select>
<select id="getTradingData" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
select
SUM(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) AS CASH,
SUM(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS WECHAT,
SUM(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS ALIPAY,
SUM(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) AS balance,
COUNT(CASE WHEN pay_type = 'CASH' THEN 0 END) AS CASHCount,
COUNT(CASE WHEN pay_type = 'WECHAT' THEN 0 END) AS WECHATCount,
COUNT(CASE WHEN pay_type = 'ALIPAY' THEN 0 END) AS ALIPAYCount,
COUNT(CASE WHEN pay_type = 'balance' THEN 0 END) AS balanceCount,
SUM(CASE WHEN aoi.status = 'refund' THEN pay_money ELSE 0 END) AS refBalance,
COUNT(CASE WHEN aoi.status = 'refund' THEN 0 END) AS refBalanceCount,
SUM(pay_money) AS sumBalance,
count(*) AS countBalance,
SUM(CASE WHEN aoi.content = '储值卡订单' THEN pay_money ELSE 0 END) AS userBalance,
COUNT(CASE WHEN aoi.content = '储值卡订单' THEN 0 END) AS userBalanceCount,
SUM(CASE WHEN aoi.content = '油品充值' THEN pay_money ELSE 0 END) AS oilBalance,
COUNT(CASE WHEN aoi.content = '油品充值' THEN 0 END) AS oilBalanceCount,
SUM(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS userBalanceByWechat,
COUNT(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'WECHAT' THEN 0 END) AS userBalanceCountByWechat,
SUM(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS userBalanceByAli,
COUNT(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'ALIPAY' THEN 0 END) AS userBalanceCountByali
SUM(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) AS CASH,
SUM(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS WECHAT,
SUM(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS ALIPAY,
SUM(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) AS balance,
COUNT(CASE WHEN pay_type = 'CASH' THEN 0 END) AS CASHCount,
COUNT(CASE WHEN pay_type = 'WECHAT' THEN 0 END) AS WECHATCount,
COUNT(CASE WHEN pay_type = 'ALIPAY' THEN 0 END) AS ALIPAYCount,
COUNT(CASE WHEN pay_type = 'balance' THEN 0 END) AS balanceCount,
SUM(CASE WHEN aoi.status = 'refund' THEN pay_money ELSE 0 END) AS refBalance,
COUNT(CASE WHEN aoi.status = 'refund' THEN 0 END) AS refBalanceCount,
SUM(pay_money) AS sumBalance,
count(*) AS countBalance,
SUM(CASE WHEN aoi.content = '储值卡订单' THEN pay_money ELSE 0 END) AS userBalance,
COUNT(CASE WHEN aoi.content = '储值卡订单' THEN 0 END) AS userBalanceCount,
SUM(CASE WHEN aoi.content = '油品充值' THEN pay_money ELSE 0 END) AS oilBalance,
COUNT(CASE WHEN aoi.content = '油品充值' THEN 0 END) AS oilBalanceCount,
SUM(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'WECHAT' THEN pay_money ELSE 0 END)
AS userBalanceByWechat,
COUNT(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'WECHAT' THEN 0 END) AS
userBalanceCountByWechat,
SUM(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'ALIPAY' THEN pay_money ELSE 0 END)
AS userBalanceByAli,
COUNT(CASE WHEN (aoi.content = '储值卡订单' or aoi.content = '油品充值') and pay_type = 'ALIPAY' THEN 0 END) AS
userBalanceCountByali
from all_order_info aoi
@ -427,26 +427,24 @@
</select>
<select id="getIndexData4Pos" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
SUM(pay_money) AS totalPayMoney,
COUNT(*) AS totalCount,
COUNT(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) AS totalRefund -- 计算退款订单的总数
SELECT SUM(pay_money) AS totalPayMoney,
COUNT(*) AS totalCount,
COUNT(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) AS totalRefund -- 计算退款订单的总数
-- SUM(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) AS totalRefund
FROM
all_order_info
-- SUM(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) AS totalRefund
FROM all_order_info
where store_id = #{allOrderInfo.storeId}
AND DATE(pay_time) = CURDATE()
AND DATE (pay_time) = CURDATE()
</select>
<select id="getHandOverList" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
SUM(pay_money) AS totalPayMoney,
COUNT(*) AS totalCount,
COUNT(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) AS totalRefund -- 计算退款订单的总数
SUM(pay_money) AS totalPayMoney,
COUNT(*) AS totalCount,
COUNT(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) AS totalRefund -- 计算退款订单的总数
-- SUM(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) AS totalRefund
FROM
all_order_info
all_order_info
<where>
staff_id = #{staffId}
@ -460,8 +458,7 @@
</select>
<select id="getOneByOrderNo" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
*
SELECT *
from all_order_info
where order_no = #{orderNo}
</select>
@ -517,42 +514,64 @@
</select>
<select id="getLeiJiInfo" resultType="java.util.Map">
SELECT
SUM(CASE WHEN type = 3 THEN pay_money ELSE 0 END) AS leijiMoney, -- 累计消费金额
COUNT(CASE WHEN type = 3 THEN 0 END) AS leijiNum,
SUM(CASE WHEN type = 3 and status = 'refund' THEN ref_money ELSE 0 END) AS leijiMoneyRef, -- 累计退款金额
COUNT(CASE WHEN type = 3 and status = 'refund' THEN 0 END) AS leijiNum
from all_order_info
-- 总消费
COALESCE(SUM(CASE WHEN type NOT IN (3, 5) AND ref_by IS NULL THEN pay_money ELSE 0 END), 0) AS s1,
COUNT(CASE WHEN type NOT IN (3, 5) AND ref_by IS NULL THEN pay_money ELSE 0 END) AS s1c,
-- 总充值
COALESCE(SUM(CASE WHEN type = 3 AND ref_by IS NULL THEN pay_money ELSE 0 END), 0) AS s2,
COUNT(CASE WHEN type = 3 AND ref_by IS NULL THEN pay_money ELSE 0 END) AS s2c,
-- 退款总金额 次数
COALESCE(SUM(CASE WHEN ref_by IS NOT NULL THEN ref_money ELSE 0 END), 0) AS s3,
COUNT(CASE WHEN ref_by IS NOT NULL THEN ref_money ELSE 0 END) AS s3c
FROM all_order_info
where user_id = #{order.mtUserId}
</select>
<!-- group by user_id-->
<!-- group by user_id-->
<select id="getShuJuVipInfo" resultType="java.util.Map">
SELECT
SUM(CASE WHEN content = "储值卡充值" THEN pay_money ELSE 0 END) AS tongjMoney, -- 累计充值金额
SUM(CASE WHEN type = 3 THEN pay_money ELSE 0 END) AS tongjXfMoney -- 累计消费金额
from all_order_info
<where>
<if test="order.storeIds != null">
store_id in
<foreach collection="order.storeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="order.params.beginTime != null and order.params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')
</if>
<if test="order.params.endTime != null and order.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')
</if>
</where>
-- 总消费
SUM(CASE WHEN all_order_info.type NOT IN (3, 5) AND all_order_info.ref_by IS NULL THEN all_order_info.pay_money
ELSE 0 END) AS tongjXfMoney,
-- 总充值
SUM(CASE WHEN all_order_info.type = 3 AND all_order_info.ref_by IS NULL THEN all_order_info.pay_money ELSE 0
END) AS tongjMoney
FROM all_order_info
INNER JOIN (
SELECT mt_user.*
FROM mt_user_balance
LEFT JOIN mt_user ON mt_user_balance.mt_user_id = mt_user.id
WHERE mt_user_balance.user_status = 0 AND mt_user_balance.store_id IN
<foreach collection="order.storeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
) AS mtUser ON mtUser.id = all_order_info.user_id;
</select>
<select id="getCardGift" resultType="java.lang.String">
select
SUM(CASE WHEN card_gift.status=1 THEN card_gift.card_amount ELSE 0 END) as cardGiftMoney
from card_gift
JOIN (
SELECT mt_user.*
FROM mt_user_balance
LEFT JOIN mt_user ON mt_user_balance.mt_user_id = mt_user.id
WHERE mt_user_balance.user_status = 0 AND mt_user_balance.store_id IN
<foreach collection="order.storeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
) AS mtUser ON mtUser.id = card_gift.user_id;
</select>
<select id="getFenxiByDaili" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
store_id storeId,
SUM(pay_money) payMoney,
count(*) count
store_id storeId,
SUM(pay_money) payMoney,
count(*) count
from all_order_info
<where>
<if test="order.storeIds != null">
@ -581,15 +600,15 @@
</select>
<select id="getFenxiByDailiType" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
store_id storeId,
SUM(pay_money) payMoney,
count(*) count,
sum(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) wechatMoney,
sum(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) cashMoney,
sum(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) balanceMoney,
sum(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) alipayMoney,
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
# count(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refCount
store_id storeId,
SUM(pay_money) payMoney,
count(*) count,
sum(CASE WHEN pay_type = 'WECHAT' THEN pay_money ELSE 0 END) wechatMoney,
sum(CASE WHEN pay_type = 'CASH' THEN pay_money ELSE 0 END) cashMoney,
sum(CASE WHEN pay_type = 'balance' THEN pay_money ELSE 0 END) balanceMoney,
sum(CASE WHEN pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) alipayMoney,
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
# count(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refCount
count(CASE WHEN status = 'refund' THEN 1 ELSE NULL END) refCount
from all_order_info
<where>
@ -609,25 +628,24 @@
group by store_id
</select>
<select id="getFenxiByDaili2" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
payment_channel paymentChannel,
SUM(pay_money) payMoneyChannel,
count(*) countChannel
SELECT payment_channel paymentChannel,
SUM(pay_money) payMoneyChannel,
count(*) countChannel
from all_order_info
group by payment_channel
</select>
<!-- <select id="getFenxiByDailiBydata" resultType="com.fuint.business.order.vo.AllOrderInfoVo">-->
<!-- SELECT-->
<!-- SUM(pay_amount) payAmount,-->
<!-- count(*)-->
<!-- from all_order_info-->
<!-- </select>-->
<!-- <select id="getFenxiByDailiBydata" resultType="com.fuint.business.order.vo.AllOrderInfoVo">-->
<!-- SELECT-->
<!-- SUM(pay_amount) payAmount,-->
<!-- count(*)-->
<!-- from all_order_info-->
<!-- </select>-->
<select id="getFenxiByDaili2ByData" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
payment_channel paymentChannel,
SUM(pay_money) payMoneyChannel,
count(*) countChannel
payment_channel paymentChannel,
SUM(pay_money) payMoneyChannel,
count(*) countChannel
from all_order_info
<where>
<if test="order.storeIds != null">
@ -647,8 +665,8 @@
</select>
<select id="getFenxiByDailiBydata" resultType="java.util.Map">
SELECT
SUM(pay_money) payMoney,
count(*) count
SUM(pay_money) payMoney,
count(*) count
from all_order_info
<where>
<if test="order.storeIds != null">
@ -667,9 +685,8 @@
</select>
<select id="getFenxiByDailiTypeDaty" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
SUM(pay_money) payMoney,
count(*) count,
SELECT SUM(pay_money) payMoney,
count(*) count,
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
count(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refCount
@ -678,11 +695,11 @@
</select>
<select id="getFenxiByDailiTypeBydata" resultType="java.util.Map">
SELECT
count(distinct store_id) storeId,
SUM(pay_money) payMoney,
count(*) count,
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
count(CASE WHEN status = 'refund' THEN 1 ELSE 0 END) refCount
count(distinct store_id) storeId,
SUM(pay_money) payMoney,
count(*) count,
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
count(CASE WHEN status = 'refund' THEN 1 ELSE 0 END) refCount
from all_order_info
<where>
<if test="order.storeIds != null">
@ -701,7 +718,6 @@
</select>
<select id="getPaymentChannelData" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
sum(CASE WHEN payment_channel = '富友' THEN pay_money ELSE 0 END) fuYouAmount,
@ -715,11 +731,10 @@
</where>
</select>
<select id="runningWaterByInstituion2" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
SELECT
SUM(pay_money) payMoney,
SUM(goods_money) goodsMoney,
SUM(ref_money) refMoney,
count(*) count,
SELECT SUM(pay_money) payMoney,
SUM(goods_money) goodsMoney,
SUM(ref_money) refMoney,
count(*) count,
count(CASE WHEN status = 'refund' THEN 1 ELSE 0 END) AS refund,
content content
@ -753,33 +768,34 @@
</if>
</where>
</select>
<!-- <where>-->
<!-- store_id = #{order.storeId}-->
<!-- <if test="order.params.beginTime != null and order.params.beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
<!-- and date_format(create_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="order.params.endTime != null and order.params.endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
<!-- and date_format(create_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')-->
<!-- </if>-->
<!-- </where>-->
<!-- store_id = #{order.storeId}-->
<!-- <if test="order.params.beginTime != null and order.params.beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
<!-- and date_format(create_time,'%y%m%d') &gt;= date_format(#{order.params.beginTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="order.params.endTime != null and order.params.endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
<!-- and date_format(create_time,'%y%m%d') &lt;= date_format(#{order.params.endTime},'%y%m%d')-->
<!-- </if>-->
<!-- </where>-->
<!-- SUM(CASE WHEN transaction_type = 'sale' THEN amount ELSE 0 END) AS total_sales-->
<!-- COUNT(CASE WHEN pay_type = 'WECHAT' THEN 0 END) AS wechat, &#45;&#45; 微信-->
<!-- WHERE-->
<!-- DATE(pay_time) = CURDATE();-->
<!-- <if test="startTime != null ">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
<!-- and date_format(pay_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="endTime != null ">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
<!-- and date_format(pay_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')-->
<!-- </if>-->
<!-- DATE(pay_time) = CURDATE();-->
<!-- <if test="startTime != null ">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
<!-- and date_format(pay_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="endTime != null ">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
<!-- and date_format(pay_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="startTime1 != null and startTime1 != ''">-->
<!-- AND pay_time >= #{startTime1} &#45;&#45; 开始时间检索-->
<!-- </if>-->
<!-- <if test="endTime1 != null and endTime1 != ''">-->
<!-- AND pay_time &lt;= #{endTime} &#45;&#45; 结束时间检索-->
<!-- </if>-->
<!-- <if test="startTime1 != null and startTime1 != ''">-->
<!-- AND pay_time >= #{startTime1} &#45;&#45; 开始时间检索-->
<!-- </if>-->
<!-- <if test="endTime1 != null and endTime1 != ''">-->
<!-- AND pay_time &lt;= #{endTime} &#45;&#45; 结束时间检索-->
<!-- </if>-->
</mapper>

View File

@ -41,10 +41,13 @@
mub.store_id storeId,
mub.card_balance cardBalance,
mub.create_time,
mu.id mtUserId
mu.id mtUserId,
mub.grade_id
from mt_user_balance mub
left join mt_user mu on mub.mt_user_id = mu.id
left join mt_user mu on mub.mt_user_id = mu.id
<where>
mub.user_status = 0 and
mub.store_id in
<foreach collection="user.storeIds" item="item" open="(" close=")" separator=",">
#{item}
@ -58,8 +61,13 @@
count(*) sumnum,
sum(mub.card_balance) balanceSum
from mt_user_balance mub
left join mt_user mu on mub.mt_user_id = mu.id
left join mt_user mu on mub.mt_user_id = mu.id
where
mub.user_status = 0 and
mub.store_id in
<foreach collection="storeIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="selectHoverBalance" resultType="java.util.Map">
select

View File

@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.generator.config.IFileCreate;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord;
import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableRecordMapper;
import com.fuint.business.marketingActivity.cardGift.entity.CardGift;
@ -97,16 +98,17 @@ public class UserBalanceServiceImpl extends ServiceImpl<UserBalanceMapper, UserB
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
user.setDeptId(nowAccountInfo.getDeptId());
}
// 查询指定id部门下所有子部门id
List<Long> strings = sysDeptMapper.selectChildByDeptIdR(user.getDeptId());
// 根据部门id 查询 店铺id
List<Long> longs = mtStoreMapper.queryStoresByDeptIdsR(strings);
user.setStoreIds(longs);
IPage<UserBalanceVo> userBalanceVoIPage = userBalanceMapper.listByZt(page, user);
for (UserBalanceVo record : userBalanceVoIPage.getRecords()) {
// 店铺名称
LJStore ljStore = storeService.selectStoreByIdUni(record.getStoreId());
if (ObjectUtil.isNotEmpty(ljStore)) {
record.setStoreName(ljStore.getName());
}
// 会员等级
LJUserGrade ljUserGrade = ljUserGradeMapper.selectById(record.getGradeId());
@ -115,34 +117,23 @@ public class UserBalanceServiceImpl extends ServiceImpl<UserBalanceMapper, UserB
} else {
record.setGradeName("--");
}
// 累计充值金额
Map<String, Object> amountAndConsume = cardValueRecordMapper.getAmountAndConsume(record);
if (ObjectUtil.isNotEmpty(amountAndConsume)) {
record.setCountNum(amountAndConsume.get("consumeNum").toString()); // 累计重置次数
record.setAmount(ObjectUtil.isNotEmpty(amountAndConsume.get("amount")) ? amountAndConsume.get("amount").toString() : "0");
}
Map<String, Object> leiJiInfo = allOrderInfoMapper.getLeiJiInfo(record);
if (ObjectUtil.isNotEmpty(leiJiInfo)) {
// log.info("累计消费信息:"+JSON.toJSONString(leiJiInfo));
if (ObjectUtil.isNotEmpty(leiJiInfo.get("leijiMoneyRef"))) {
record.setLeijiMoney(leiJiInfo.get("leijiMoney").toString());// 累计消费金额
}
if (ObjectUtil.isNotEmpty(leiJiInfo.get("leijiMoneyRef"))) {
record.setLeijiNum(leiJiInfo.get("leijiNum").toString()); // 累计消费次数
}
if (ObjectUtil.isNotEmpty(leiJiInfo.get("leijiMoneyRef"))) {
record.setLeijiMoneyRef(leiJiInfo.get("leijiMoneyRef").toString()); // 累计退款余额
}
if (ObjectUtil.isNotEmpty(leiJiInfo.get("leijiNumRef"))) {
record.setLeijiNumRef(leiJiInfo.get("leijiNum").toString()); // 累计退款笔数
}
// public String leijiMoney; 消费总金额
// public String leijiNum; 消费次数
// amount 累计充值金额
// CountNum 次数
// public String leijiMoneyRef; 退款总金额
// public String leijiNumRef; 退款次数
record.setLeijiMoney(leiJiInfo.get("s1").toString());
record.setLeijiNum(leiJiInfo.get("s1c").toString());
record.setAmount(leiJiInfo.get("s2").toString());
record.setCountNum(leiJiInfo.get("s2c").toString());
record.setLeijiMoneyRef(leiJiInfo.get("s3").toString());
record.setLeijiNumRef(leiJiInfo.get("s3c").toString());
}
// 电子礼品卡余额
}
return userBalanceVoIPage;
}
@ -152,13 +143,18 @@ public class UserBalanceServiceImpl extends ServiceImpl<UserBalanceMapper, UserB
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
user.setDeptId(nowAccountInfo.getDeptId());
}
// 查询指定id部门下所有子部门id
List<Long> strings = sysDeptMapper.selectChildByDeptIdR(user.getDeptId());
// 查询所有店铺id
List<Long> longs = mtStoreMapper.queryStoresByDeptIdsR(strings);
user.setStoreIds(longs);
// 会员总数 sumnum 累计储值卡余额 balanceSum
Map<String, Object> dataByZt = userBalanceMapper.getDataByZt(user);
// 累计总消费金额 累计总充值金额 店铺统计的时候 要把注销的会员去掉
Map<String, Object> leiJiInfo = allOrderInfoMapper.getShuJuVipInfo(user);
// 累计礼品卡余额
String cardGift = allOrderInfoMapper.getCardGift(user);
if (ObjectUtil.isEmpty(dataByZt)) {
dataByZt = new HashMap<>();
}
@ -168,8 +164,9 @@ public class UserBalanceServiceImpl extends ServiceImpl<UserBalanceMapper, UserB
leiJiInfo.put("tongjMoney", "0");
}
dataByZt.put("tongjMoney", ObjectUtil.isNotEmpty(leiJiInfo.get("tongjMoney")) ? convertYuanToWanYuan((BigDecimal) leiJiInfo.get("tongjMoney")) : "0");
dataByZt.put("tongjXfMoney", ObjectUtil.isNotEmpty(leiJiInfo.get("tongjXfMoney")) ? convertYuanToWanYuan((BigDecimal) leiJiInfo.get("tongjXfMoney")) : "0");
dataByZt.put("tongjMoney", ObjectUtil.isNotEmpty(leiJiInfo.get("tongjMoney")) ? leiJiInfo.get("tongjMoney") : "0");
dataByZt.put("tongjXfMoney", ObjectUtil.isNotEmpty(leiJiInfo.get("tongjXfMoney")) ? leiJiInfo.get("tongjXfMoney") : "0");
dataByZt.put("cardGift", ObjectUtil.isNotEmpty(cardGift) ? cardGift : "0");
return dataByZt;
}