后端 BUG
This commit is contained in:
parent
1ee96d674e
commit
c274a7f9e1
@ -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>
|
||||
where
|
||||
mt_user_id = #{mtUserId}
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<!-- where store_id = #{storeId} and mt_user_id = #{userId}-->
|
||||
<!-- group by chain_store_id
|
||||
|
@ -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);
|
||||
|
||||
|
@ -161,7 +161,6 @@
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="getPageList" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
select
|
||||
aoi.id AS id,
|
||||
@ -292,7 +291,8 @@
|
||||
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=",">
|
||||
@ -332,8 +332,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getHandoverByOrderNo" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
select
|
||||
aoi.id AS id,
|
||||
select aoi.id AS id,
|
||||
aoi.order_no AS orderNo,
|
||||
aoi.type AS type,
|
||||
aoi.transaction_id AS transactionId,
|
||||
@ -358,8 +357,7 @@
|
||||
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}, '%')
|
||||
where order_no like concat('%', #{allOrderInfo.orderNo}, '%')
|
||||
|
||||
|
||||
order by aoi.create_time desc
|
||||
@ -384,12 +382,14 @@
|
||||
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 (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,14 +427,12 @@
|
||||
|
||||
</select>
|
||||
<select id="getIndexData4Pos" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
SELECT
|
||||
SUM(pay_money) AS totalPayMoney,
|
||||
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
|
||||
FROM all_order_info
|
||||
where store_id = #{allOrderInfo.storeId}
|
||||
AND DATE (pay_time) = CURDATE()
|
||||
</select>
|
||||
@ -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,37 +514,59 @@
|
||||
</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-->
|
||||
|
||||
<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
|
||||
-- 总消费
|
||||
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>
|
||||
</if>
|
||||
<if test="order.params.beginTime != null and order.params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= 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') <= date_format(#{order.params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
) 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,
|
||||
@ -609,8 +628,7 @@
|
||||
group by store_id
|
||||
</select>
|
||||
<select id="getFenxiByDaili2" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
SELECT
|
||||
payment_channel paymentChannel,
|
||||
SELECT payment_channel paymentChannel,
|
||||
SUM(pay_money) payMoneyChannel,
|
||||
count(*) countChannel
|
||||
from all_order_info
|
||||
@ -667,8 +685,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getFenxiByDailiTypeDaty" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
SELECT
|
||||
SUM(pay_money) payMoney,
|
||||
SELECT SUM(pay_money) payMoney,
|
||||
count(*) count,
|
||||
|
||||
sum(CASE WHEN status = 'refund' THEN pay_money ELSE 0 END) refMoney,
|
||||
@ -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,8 +731,7 @@
|
||||
</where>
|
||||
</select>
|
||||
<select id="runningWaterByInstituion2" resultType="com.fuint.business.order.vo.AllOrderInfoVo">
|
||||
SELECT
|
||||
SUM(pay_money) payMoney,
|
||||
SELECT SUM(pay_money) payMoney,
|
||||
SUM(goods_money) goodsMoney,
|
||||
SUM(ref_money) refMoney,
|
||||
count(*) count,
|
||||
@ -753,6 +768,7 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- <where>-->
|
||||
<!-- store_id = #{order.storeId}-->
|
||||
<!-- <if test="order.params.beginTime != null and order.params.beginTime != ''"><!– 开始时间检索 –>-->
|
||||
|
@ -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
|
||||
<where>
|
||||
mub.user_status = 0 and
|
||||
mub.store_id in
|
||||
<foreach collection="user.storeIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
@ -59,7 +62,12 @@
|
||||
sum(mub.card_balance) balanceSum
|
||||
from mt_user_balance mub
|
||||
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
|
||||
|
@ -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,33 +117,22 @@ 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user