فهرست منبع

售后单和积分字典开发统计

zhangxin 1 هفته پیش
والد
کامیت
2e0570dd0a

+ 15 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/Channel.java

@@ -10,6 +10,7 @@
 
 package com.yami.shop.bean.model;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -17,6 +18,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 渠道管理
@@ -58,4 +60,17 @@ public class Channel implements Serializable {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
+    /**
+     * 企业ID列表
+     */
+    @TableField(exist = false)
+    private List<Long> channelIdList;
+
+    /**
+     * 20251203 v1.1.3
+     * 人员属性 0-全部 1-正常人员 2-测试人员
+     */
+    @TableField(exist = false)
+    private String userAttrType;
+
 }

+ 6 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/PointsRecharge.java

@@ -112,5 +112,11 @@ public class PointsRecharge implements Serializable {
      */
     @TableField(exist = false)
     private List<Long> channelIdList;
+    /**
+     * 20251203 v1.1.3
+     * 人员属性 0-全部 1-正常人员 2-测试人员
+     */
+    @TableField(exist = false)
+    private String userAttrType;
 
 }

+ 6 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/param/OrderRefundStaisticsParam.java

@@ -69,4 +69,10 @@ public class OrderRefundStaisticsParam {
      */
     private List<Long> channelIdList;
 
+    /**
+     * 20251203 v1.1.3
+     * 人员属性 0-全部 1-正常人员 2-测试人员
+     */
+    private String userAttrType;
+
 }

+ 28 - 0
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ChannelController.java

@@ -2,10 +2,13 @@
 package com.yami.shop.platform.controller;
 
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.Channel;
+import com.yami.shop.bean.param.OrderRefundStaisticsParam;
 import com.yami.shop.bean.vo.ChannelVO;
 import com.yami.shop.common.config.Constant;
+import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.R;
 import com.yami.shop.security.platform.util.SecurityUtils;
@@ -76,6 +79,7 @@ public class ChannelController {
     @GetMapping("/statisticsPage")
     @ApiOperation(value = "分页获取政企列表统计")
     public R<IPage<ChannelVO>> statisticsPage(PageParam pageParam, Channel channel ) {
+        getChannel(channel);
         IPage<ChannelVO> page = channelService.statisticsPage(pageParam,channel);
         return R.SUCCESS(page);
     }
@@ -120,4 +124,28 @@ public class ChannelController {
         channels.add(0,channel);
         return R.SUCCESS(channels);
     }
+
+    private void getChannel(Channel channel){
+        if (channel.getChannelIdList()==null||channel.getChannelIdList().isEmpty()){
+            throw new GlobalException("请求参数-所属企业不允许为空");
+        }
+        if (ObjectUtil.isEmpty(channel.getUserAttrType())){
+            channel.setUserAttrType("1");//默认查询正常人员属性
+        }
+        if (channel.getChannelIdList().contains(0L)){
+            Long userId = null;
+            try {
+                userId = SecurityUtils.getSysUser().getUserId();
+            } catch (Exception e) {
+                throw new GlobalException("获取当前登录用户失败");
+            }
+            List<Long> channelIdList =  sysUserService.findByUserIdListId(userId);
+            channel.setChannelIdList(channelIdList);
+            if (userId != Constant.SUPER_ADMIN_ID&&(channel.getChannelIdList()==null||channel.getChannelIdList().isEmpty())){
+                List<Long> longs = new ArrayList<>();
+                longs.add(0L);
+                channel.setChannelIdList(longs);
+            }
+        }
+    }
 }

+ 11 - 28
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/OrderRefundController.java

@@ -1,6 +1,7 @@
 package com.yami.shop.platform.controller;
 
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.dto.OrderRefundDto;
@@ -119,19 +120,7 @@ public class OrderRefundController {
     @ApiOperation("后台分页获取退款订单列表")
     @GetMapping("/orderRefundPage")
     public R<IPage<OrderRefundVo>> orderRefundPage(PageParam<OrderRefund> page, OrderRefundStaisticsParam orderRefund) {
-        if (orderRefund.getChannelIdList()==null||orderRefund.getChannelIdList().isEmpty()){
-            return R.FAIL("请求参数-所属企业不允许为空");
-        }
-        if (orderRefund.getChannelIdList().contains(0L)){
-            Long userId = SecurityUtils.getSysUser().getUserId();
-            List<Long> channelIdList =  sysUserService.findByUserIdListId(userId);
-            orderRefund.setChannelIdList(channelIdList);
-            if (userId != Constant.SUPER_ADMIN_ID&&(orderRefund.getChannelIdList()==null||orderRefund.getChannelIdList().isEmpty())){
-                List<Long> longs = new ArrayList<>();
-                longs.add(0L);
-                orderRefund.setChannelIdList(longs);
-            }
-        }
+        getOrderRefundStaisticsParam(orderRefund);
         IPage<OrderRefundVo> page1 = orderRefundService.orderRefundPage(page, orderRefund);
         for (OrderRefundVo record : page1.getRecords()) {
             record.setOrderRefundSkuList(orderRefundskuMapper.selectByRefundId(record.getRefundId()));
@@ -145,19 +134,7 @@ public class OrderRefundController {
     @ApiOperation("统计退款订单数量")
     @GetMapping("/orderRefundCount")
     public R<OrderRefundCountParam> orderRefundCount(OrderRefundStaisticsParam orderRefund) {
-        if (orderRefund.getChannelIdList()==null||orderRefund.getChannelIdList().isEmpty()){
-            return R.FAIL("请求参数-所属企业不允许为空");
-        }
-        if (orderRefund.getChannelIdList().contains(0L)){
-            Long userId = SecurityUtils.getSysUser().getUserId();
-            List<Long> channelIdList =  sysUserService.findByUserIdListId(userId);
-            orderRefund.setChannelIdList(channelIdList);
-            if (userId != Constant.SUPER_ADMIN_ID&&(orderRefund.getChannelIdList()==null||orderRefund.getChannelIdList().isEmpty())){
-                List<Long> longs = new ArrayList<>();
-                longs.add(0L);
-                orderRefund.setChannelIdList(longs);
-            }
-        }
+        getOrderRefundStaisticsParam(orderRefund);
         return R.SUCCESS(orderRefundService.orderRefundCount(orderRefund));
     }
 
@@ -169,9 +146,17 @@ public class OrderRefundController {
     @GetMapping("/export")
     @ApiOperation("后管端-退款订单列表导出")
     public void export(OrderRefundStaisticsParam orderRefund, HttpServletResponse response) {
+        getOrderRefundStaisticsParam(orderRefund);
+        orderRefundService.export(orderRefund,response);
+    }
+
+    private void getOrderRefundStaisticsParam(OrderRefundStaisticsParam orderRefund){
         if (orderRefund.getChannelIdList()==null||orderRefund.getChannelIdList().isEmpty()){
             throw new GlobalException("请求参数-所属企业不允许为空");
         }
+        if (ObjectUtil.isEmpty(orderRefund.getUserAttrType())){
+            orderRefund.setUserAttrType("1");//默认查询正常人员属性
+        }
         if (orderRefund.getChannelIdList().contains(0L)){
             Long userId = null;
             try {
@@ -187,7 +172,5 @@ public class OrderRefundController {
                 orderRefund.setChannelIdList(longs);
             }
         }
-        orderRefundService.export(orderRefund,response);
     }
-
 }

+ 16 - 34
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/PointsRechargeController.java

@@ -1,6 +1,7 @@
 // PointsRechargeController.java
 package com.yami.shop.platform.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -52,25 +53,13 @@ public class PointsRechargeController {
      */
     @GetMapping("/page")
     public R<IPage<PointsRecharge>> page(PageParam<PointsRecharge> pageParam, PointsRecharge pointsRecharge) {
-        if (pointsRecharge==null||pointsRecharge.getChannelIdList()==null||pointsRecharge.getChannelIdList().isEmpty()){
-            return R.FAIL("请求参数-所属企业不允许为空");
-        }
-        if (pointsRecharge.getChannelIdList().contains(0L)){
-            Long userId = SecurityUtils.getSysUser().getUserId();
-            List<Long> channelIdList =  sysUserService.findByUserIdListId(userId);
-            pointsRecharge.setChannelIdList(channelIdList);
-            if (userId != Constant.SUPER_ADMIN_ID&&(pointsRecharge.getChannelIdList()==null||pointsRecharge.getChannelIdList().isEmpty())){
-                List<Long> longs = new ArrayList<>();
-                longs.add(0L);
-                pointsRecharge.setChannelIdList(longs);
-            }
-        }
-        IPage<PointsRecharge> page = pointsRechargeService.page(pageParam,new LambdaQueryWrapper<PointsRecharge>()
-                .in(ObjectUtils.isNotEmpty(pointsRecharge.getChannelIdList()),PointsRecharge::getChannelId,pointsRecharge.getChannelIdList())
-                .eq(ObjectUtils.isNotEmpty(pointsRecharge.getUserPhone()),PointsRecharge::getUserPhone,pointsRecharge.getUserPhone())
-                .orderByDesc(PointsRecharge::getCreateTime)
-        );
-        return R.SUCCESS(page);
+        getPointsRecharge(pointsRecharge);
+//        IPage<PointsRecharge> page = pointsRechargeService.page(pageParam,new LambdaQueryWrapper<PointsRecharge>()
+//                .in(ObjectUtils.isNotEmpty(pointsRecharge.getChannelIdList()),PointsRecharge::getChannelId,pointsRecharge.getChannelIdList())
+//                .eq(ObjectUtils.isNotEmpty(pointsRecharge.getUserPhone()),PointsRecharge::getUserPhone,pointsRecharge.getUserPhone())
+//                .orderByDesc(PointsRecharge::getCreateTime)
+//        );
+        return R.SUCCESS(pointsRechargeService.findPage(pageParam,pointsRecharge));
     }
 
 
@@ -79,19 +68,7 @@ public class PointsRechargeController {
      */
     @GetMapping("/statisticsList")
     public R<IPage<PointsRechargeVO>> statisticsList(PageParam<PointsRecharge> pageParam, PointsRecharge pointsRecharge) {
-        if (pointsRecharge.getChannelIdList()==null||pointsRecharge.getChannelIdList().isEmpty()){
-            throw new GlobalException("请求参数-所属企业不允许为空");
-        }
-        if (pointsRecharge.getChannelIdList().contains(0L)){
-            Long userId = SecurityUtils.getSysUser().getUserId();
-            List<Long> channelIdList =  sysUserService.findByUserIdListId(userId);
-            pointsRecharge.setChannelIdList(channelIdList);
-            if (userId != Constant.SUPER_ADMIN_ID&&(pointsRecharge.getChannelIdList()==null||pointsRecharge.getChannelIdList().isEmpty())){
-                List<Long> longs = new ArrayList<>();
-                longs.add(0L);
-                pointsRecharge.setChannelIdList(longs);
-            }
-        }
+        getPointsRecharge(pointsRecharge);
         IPage<PointsRechargeVO> page = pointsRechargeService.statisticsList(pointsRecharge);
         return R.SUCCESS(page);
     }
@@ -171,9 +148,16 @@ public class PointsRechargeController {
     @GetMapping("/export")
     @ApiOperation("后管端-积分列表导出")
     public void export(PointsRecharge pointsRecharge, HttpServletResponse response) {
+        getPointsRecharge(pointsRecharge);
+        pointsRechargeService.export(pointsRecharge,response);
+    }
+    private void getPointsRecharge(PointsRecharge pointsRecharge){
         if (pointsRecharge.getChannelIdList()==null||pointsRecharge.getChannelIdList().isEmpty()){
             throw new GlobalException("请求参数-所属企业不允许为空");
         }
+        if (ObjectUtil.isEmpty(pointsRecharge.getUserAttrType())){
+            pointsRecharge.setUserAttrType("1");//默认查询正常人员属性
+        }
         if (pointsRecharge.getChannelIdList().contains(0L)){
             Long userId = null;
             try {
@@ -189,8 +173,6 @@ public class PointsRechargeController {
                 pointsRecharge.setChannelIdList(longs);
             }
         }
-
-        pointsRechargeService.export(pointsRecharge,response);
     }
 
 

+ 6 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/PointsRechargeMapper.java

@@ -1,6 +1,7 @@
 package com.yami.shop.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.PointsRecharge;
 import com.yami.shop.bean.vo.PointsRechargeVO;
 import com.yami.shop.common.util.PageParam;
@@ -22,4 +23,9 @@ public interface PointsRechargeMapper extends BaseMapper<PointsRecharge> {
      * @return 积分充值统计列表
      */
     List<PointsRechargeVO> statisticsList(@Param("pointsRecharge") PointsRecharge pointsRecharge);
+
+    IPage<PointsRecharge> findPage(@Param("page")PageParam<PointsRecharge> pageParam,@Param("pointsRecharge") PointsRecharge pointsRecharge);
+
+    List<PointsRecharge> findList(@Param("pointsRecharge") PointsRecharge pointsRecharge);
+
 }

+ 2 - 0
yami-shop-service/src/main/java/com/yami/shop/service/PointsRechargeService.java

@@ -44,4 +44,6 @@ public interface PointsRechargeService extends IService<PointsRecharge> {
     IPage<PointsRechargeVO> statisticsList(PointsRecharge pointsRecharge);
 
     void export(PointsRecharge pointsRecharge, HttpServletResponse response);
+
+    IPage<PointsRecharge> findPage(PageParam<PointsRecharge> pageParam, PointsRecharge pointsRecharge);
 }

+ 7 - 4
yami-shop-service/src/main/java/com/yami/shop/service/impl/PointsRechargeServiceImpl.java

@@ -229,15 +229,18 @@ public class PointsRechargeServiceImpl extends ServiceImpl<PointsRechargeMapper,
      */
     @Override
     public void export(PointsRecharge pointsRecharge, HttpServletResponse response) {
-        List<PointsRecharge> enterpriseUserVos= pointsRechargeMapper.selectList(new LambdaQueryWrapper<PointsRecharge>()
-                .in(ObjectUtils.isNotEmpty(pointsRecharge.getChannelIdList()),PointsRecharge::getChannelId,pointsRecharge.getChannelIdList())
-                .eq(ObjectUtils.isNotEmpty(pointsRecharge.getUserPhone()),PointsRecharge::getUserPhone,pointsRecharge.getUserPhone())
-                .orderByDesc(PointsRecharge::getCreateTime));
+        List<PointsRecharge> enterpriseUserVos= pointsRechargeMapper.findList(pointsRecharge);
         if (enterpriseUserVos.isEmpty()){
             throw new GlobalException("该次导出未查询到数据,不允许导出");
         }
         exportNormalOrders(enterpriseUserVos,response,"积分列表");
     }
+
+    @Override
+    public IPage<PointsRecharge> findPage(PageParam<PointsRecharge> pageParam, PointsRecharge pointsRecharge) {
+        return pointsRechargeMapper.findPage(pageParam,pointsRecharge);
+    }
+
     /**
      * 导出正常订单数据到Excel(直接输出到HttpServletResponse)
      */

+ 9 - 0
yami-shop-service/src/main/resources/mapper/ChannelMapper.xml

@@ -27,6 +27,15 @@
             <if test="channel.status != null">
                 and c.status = #{channel.status}
             </if>
+            <if test="channel.channelIdList != null and  !channel.channelIdList.isEmpty()">
+                and o.channel_id  in
+                <foreach collection="channel.channelIdList" item="channelId" open="(" close=")" separator=",">
+                    #{channelId}
+                </foreach>
+            </if>
+            <if test="channel.userAttrType != null and channel.userAttrType != '' and channel.userAttrType != 0">
+                AND tu.user_attr_type = #{channel.userAttrType}
+            </if>
         </where>
         group by c.id
 

+ 11 - 0
yami-shop-service/src/main/resources/mapper/OrderRefundMapper.xml

@@ -448,6 +448,7 @@
         COUNT(CASE WHEN re.return_money_sts = 70 THEN 1 END) AS refundCompleteCount
         FROM tz_order_refund re
         left join tz_order o on re.order_id = o.order_id
+        left join tz_user u on re.user_id = u.user_id
         <where>
             <if test="orderRefund.orderNumber != null">
                 and re.order_number = #{orderRefund.orderNumber}
@@ -461,6 +462,9 @@
             <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
                 and o.dvy_type = #{orderRefund.dvyType}
             </if>
+            <if test="orderRefund.userAttrType != null and orderRefund.userAttrType != '' and orderRefund.userAttrType != 0">
+                AND u.user_attr_type = #{orderRefund.userAttrType}
+            </if>
             <if test="orderRefund.refundSn != null">
                 and re.refund_sn = #{orderRefund.refundSn}
             </if>
@@ -488,6 +492,7 @@
         from tz_order_refund refund
         join tz_shop_detail tsd on refund.shop_id = tsd.shop_id
         join tz_order o on refund.order_id = o.order_id
+        join tz_user u on refund.user_id = u.user_id
         <where>
             <if test="orderRefund.orderNumber != null">
                 and refund.order_number = #{orderRefund.orderNumber}
@@ -501,6 +506,9 @@
             <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
                 and o.dvy_type = #{orderRefund.dvyType}
             </if>
+            <if test="orderRefund.userAttrType != null and orderRefund.userAttrType != '' and orderRefund.userAttrType != 0">
+                AND u.user_attr_type = #{orderRefund.userAttrType}
+            </if>
             <if test="orderRefund.refundSn != null">
                 and refund.refund_sn = #{orderRefund.refundSn}
             </if>
@@ -563,6 +571,9 @@
             <if test="orderRefund.dvyType != null and orderRefund.dvyType != ''">
                 and o.dvy_type = #{orderRefund.dvyType}
             </if>
+            <if test="orderRefund.userAttrType != null and orderRefund.userAttrType != '' and orderRefund.userAttrType != 0">
+                AND u.user_attr_type = #{orderRefund.userAttrType}
+            </if>
             <if test="orderRefund.refundSn != null">
                 and refund.refund_sn = #{orderRefund.refundSn}
             </if>

+ 49 - 9
yami-shop-service/src/main/resources/mapper/PointsRechargeMapper.xml

@@ -4,21 +4,61 @@
 
     <select id="statisticsList" resultType="com.yami.shop.bean.vo.PointsRechargeVO">
         SELECT
-        sum(points) AS totalPoints,
-        count(id) AS totalUserCount,
-        channel_name AS channelName,
-        max(create_time) AS createTime
-        FROM tz_points_recharge
+        sum(tpr.points) AS totalPoints,
+        count(tpr.id) AS totalUserCount,
+        tpr.channel_name AS channelName,
+        max(tpr.create_time) AS createTime
+        FROM tz_points_recharge tpr
+        left join tz_user tu on tpr.user_id = tu.user_id
         <where>
-              <if test="pointsRecharge.channelId != null"> channel_id = #{pointsRecharge.channelId}</if>
+              <if test="pointsRecharge.channelId != null"> tpr.channel_id = #{pointsRecharge.channelId}</if>
             <if test="pointsRecharge.channelIdList != null and !pointsRecharge.channelIdList.isEmpty()">
-                and channel_id  in
+                and tpr.channel_id  in
                 <foreach collection="pointsRecharge.channelIdList" item="channelId" open="(" close=")" separator=",">
                     #{channelId}
                 </foreach>
             </if>
+            <if test="pointsRecharge.userAttrType != null and pointsRecharge.userAttrType != '' and pointsRecharge.userAttrType != 0">
+                AND tu.user_attr_type = #{pointsRecharge.userAttrType}
+            </if>
+        </where>
+        GROUP BY tpr.channel_id, tpr.channel_name
+        ORDER BY max(tpr.create_time) DESC
+    </select>
+    <select id="findPage" resultType="com.yami.shop.bean.model.PointsRecharge">
+        select *
+        FROM tz_points_recharge tpr
+        left join tz_user tu on tpr.user_id = tu.user_id
+        <where>
+            <if test="pointsRecharge.channelId != null"> tpr.user_phone = #{pointsRecharge.userPhone}</if>
+            <if test="pointsRecharge.channelIdList != null and !pointsRecharge.channelIdList.isEmpty()">
+                and tpr.channel_id  in
+                <foreach collection="pointsRecharge.channelIdList" item="channelId" open="(" close=")" separator=",">
+                    #{channelId}
+                </foreach>
+            </if>
+            <if test="pointsRecharge.userAttrType != null and pointsRecharge.userAttrType != '' and pointsRecharge.userAttrType != 0">
+                AND tu.user_attr_type = #{pointsRecharge.userAttrType}
+            </if>
+        </where>
+        order by create_time desc
+    </select>
+    <select id="findList" resultType="com.yami.shop.bean.model.PointsRecharge">
+        select *
+        FROM tz_points_recharge tpr
+        left join tz_user tu on tpr.user_id = tu.user_id
+        <where>
+            <if test="pointsRecharge.channelId != null"> tpr.user_phone = #{pointsRecharge.userPhone}</if>
+            <if test="pointsRecharge.channelIdList != null and !pointsRecharge.channelIdList.isEmpty()">
+                and tpr.channel_id  in
+                <foreach collection="pointsRecharge.channelIdList" item="channelId" open="(" close=")" separator=",">
+                    #{channelId}
+                </foreach>
+            </if>
+            <if test="pointsRecharge.userAttrType != null and pointsRecharge.userAttrType != '' and pointsRecharge.userAttrType != 0">
+                AND tu.user_attr_type = #{pointsRecharge.userAttrType}
+            </if>
         </where>
-        GROUP BY channel_id, channel_name
-        ORDER BY max(create_time) DESC
+        order by create_time desc
     </select>
 </mapper>