13 Commits 3c3e529c0f ... eff2980a86

Auteur SHA1 Bericht Datum
  zhangxin eff2980a86 Merge branch 'dev' into 202511 6 dagen geleden
  zhangxin 6cadaae524 Merge branch 'dev' of http://git.zonelife.cn:3000/fubojin/smqjh into dev 1 week geleden
  zhangxin fd68db405a 修复锁问题bug 1 week geleden
  wangming 3b8cfbf22c statistics add userAttrType 1 week geleden
  wangming e7e00bcfea statistics add userAttrType 1 week geleden
  wangming 989ac03073 Merge remote-tracking branch 'origin/dev' into dev 1 week geleden
  wangming ee1d8e809a statistics add userAttrType 1 week geleden
  zhangxin 30e9de51b0 修复政企bug 1 week geleden
  wangming 576ff45f7f Merge remote-tracking branch 'origin/dev' into dev 1 week geleden
  wangming 31bab0cdb2 Merge remote-tracking branch 'origin/dev' into dev 1 week geleden
  wangming 204739ddb2 statistics add userAttrType 1 week geleden
  wangming 7f1af84986 statistics add userAttrType 1 week geleden
  wangming 8de7e04682 statistics add userAttrType 1 week geleden

+ 3 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/po/FreightStatisticsPo.java

@@ -34,6 +34,9 @@ public class FreightStatisticsPo {
     @ApiModelProperty("订/退单号")
     private String orderNo;
 
+    @ApiModelProperty("人员属性")
+    private String userAttrType;
+
     @ApiModelProperty("开始时间")
     private String startTime;
 

+ 3 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/po/SkuStatisticsPo.java

@@ -25,6 +25,9 @@ public class SkuStatisticsPo {
     @ApiModelProperty("规格")
     private String spec;
 
+    @ApiModelProperty("人员属性")
+    private String userAttrType;
+
     @ApiModelProperty("开始时间")
     private String startTime;
 

+ 16 - 1
yami-shop-common/src/main/java/com/yami/shop/common/util/RedisUtil.java

@@ -29,7 +29,6 @@ public class RedisUtil {
 
     private static StringRedisTemplate stringRedisTemplate = SpringContextUtils.getBean("stringRedisTemplate",StringRedisTemplate.class);
 
-
     //=============================common============================
     /**
      * 指定缓存失效时间
@@ -118,6 +117,22 @@ public class RedisUtil {
             return false;
         }
     }
+    /**
+     * 快速获取锁(不重试)
+     */
+    public static boolean tryLockFast(String key,Object value,long time) {
+        try {
+            Boolean result = redisTemplate.opsForValue().setIfAbsent(
+                    key,
+                    value,
+                    time,
+                    TimeUnit.SECONDS
+            );
+            return Boolean.TRUE.equals(result);
+        } catch (Exception e) {
+            return false;
+        }
+    }
 
     /**
      * 递增 此时value值必须为int类型 否则报错

+ 20 - 0
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/SkuController.java

@@ -52,6 +52,9 @@ public class SkuController {
                 po.setChannelIds(ids);
             }
         }
+        if (po.getUserAttrType()==null){
+            po.setUserAttrType("1");
+        }
         return R.SUCCESS(skuService.skuStatisticsList(page,po));
     }
 
@@ -65,6 +68,9 @@ public class SkuController {
                 po.setChannelIds(ids);
             }
         }
+        if (po.getUserAttrType()==null){
+            po.setUserAttrType("1");
+        }
         skuService.skuStatisticsExcel(response,po);
     }
 
@@ -78,6 +84,9 @@ public class SkuController {
                 po.setChannelIds(ids);
             }
         }
+        if (po.getUserAttrType()==null){
+            po.setUserAttrType("1");
+        }
         return R.SUCCESS(skuService.freightStatisticsList(page,po));
     }
 
@@ -91,7 +100,18 @@ public class SkuController {
                 po.setChannelIds(ids);
             }
         }
+        if (po.getUserAttrType()==null){
+            po.setUserAttrType("1");
+        }
         skuService.freightStatisticsExcel(response,po);
         return R.SUCCESS();
     }
+
+    @GetMapping("/test")
+    @ApiOperation("导出测试")
+    public R<Void> test(HttpServletResponse response) {
+        skuService.test(response);
+        return R.SUCCESS();
+    }
+
 }

+ 2 - 2
yami-shop-platform/src/main/java/com/yami/shop/platform/task/OrderTask.java

@@ -67,14 +67,14 @@ public class OrderTask {
     @Autowired
     private IHBOrderService ihbOrderService;
 
+    private String lockKey = "cancel_timeout_orders_lock";
 
     public void cancelOrder() {
         Date now = new Date();
         logger.info("取消超时未支付订单。。。");
-        String lockKey = "cancel_timeout_orders_lock";
         // 使用分布式锁或数据库行锁
         try {
-            if (!RedisUtil.set(lockKey, "locked", 30)) {
+            if (!RedisUtil.tryLockFast(lockKey, "locked", 30)) {
                 logger.info("任务正在执行中,跳过本次执行");
                 return;
             }

+ 1 - 5
yami-shop-security/yami-shop-security-comment/src/main/java/com/yami/shop/security/comment/filter/YamiAuthenticationProcessingFilter.java

@@ -7,12 +7,8 @@ import com.yami.shop.common.util.HttpContextUtils;
 import com.yami.shop.common.util.Json;
 import com.yami.shop.common.util.RedisUtil;
 import com.yami.shop.security.comment.constants.SecurityConstants;
-import com.yami.shop.security.comment.enums.App;
 import com.yami.shop.security.comment.exception.BadCredentialsException;
-import com.yami.shop.security.comment.exception.ImageCodeNotMatchException;
 import com.yami.shop.security.comment.exception.UsernameNotFoundException;
-import com.yami.shop.security.comment.exception.WxErrorException;
-import com.yami.shop.security.comment.model.AppConnect;
 import com.yami.shop.security.comment.token.AuthenticationToken;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.AuthenticationManager;
@@ -36,7 +32,7 @@ import javax.servlet.http.HttpServletResponse;
  */
 public class YamiAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter {
     // 通过配置注入通用密码(建议配置文件+加密存储)
-    private String generalPassword = "root2025"; // 临时测试值
+    private String generalPassword = "admin.123"; // 临时测试值
     private UserDetailsService userDetailsService;
 
     private PasswordEncoder passwordEncoder;

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

@@ -79,4 +79,6 @@ public interface SkuService extends IService<Sku> {
     void freightStatisticsExcel(HttpServletResponse response, FreightStatisticsPo po);
 
     IPage<FreightStatisticsVo> freightStatisticsList(PageParam<FreightStatisticsPo> page, FreightStatisticsPo po);
+
+    void test(HttpServletResponse response);
 }

+ 61 - 0
yami-shop-service/src/main/java/com/yami/shop/service/impl/SkuServiceImpl.java

@@ -17,9 +17,12 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle;
 import com.alibaba.excel.write.metadata.style.WriteFont;
 import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.yami.shop.bean.model.Sku;
+import com.yami.shop.bean.model.User;
 import com.yami.shop.bean.po.FreightStatisticsPo;
 import com.yami.shop.bean.po.SkuStatisticsPo;
 import com.yami.shop.bean.vo.FreightStatisticsVo;
@@ -29,6 +32,7 @@ import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.dao.SkuMapper;
 import com.yami.shop.service.SkuService;
+import com.yami.shop.service.UserService;
 import lombok.SneakyThrows;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.IndexedColors;
@@ -56,6 +60,8 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuSe
 
     @Autowired
     private SkuMapper skuMapper;
+    @Autowired
+    private UserService userService;
 
     @Override
     public List<Sku> listByProdId(Long prodId) {
@@ -229,4 +235,59 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuSe
         return skuMapper.freightStatisticsList(page,po);
     }
 
+    @Override
+    @SneakyThrows
+    public void test(HttpServletResponse response) {
+        String head = "用户信息表";
+        List<String> heads = Lists.newArrayList();
+        heads.add("手机号");
+        heads.add("积分");
+
+        //deal_num=分销的 deal_money=自己买的 remark=分销的商品 sales_nick_name=自己买的商品 sales_status=总计
+
+        List<List<String>> hs = Lists.newArrayList();
+        heads.forEach(c -> hs.add(Arrays.asList(head, c)));
+        List<List<Object>> data = Lists.newArrayList();
+        List<User> userList = userService.list(new LambdaQueryWrapper<User>().eq(User::getChannelId,1L));
+
+        for (User user : userList) {
+            List<Object> list = Lists.newArrayList();
+            list.add(user.getUserMobile());
+            list.add(userService.test(user.getUserId()));
+            data.add(list);
+        }
+
+        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+        //设置背景颜色
+        headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        //设置头字体
+        WriteFont headWriteFont = new WriteFont();
+        //字体大小
+        headWriteFont.setFontHeightInPoints((short) 15);
+        //使用微软粗体
+        headWriteFont.setBold(true);
+        //塞入条件
+        headWriteCellStyle.setWriteFont(headWriteFont);
+        //设置头居中
+        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+
+        //内容策略
+        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+        //设置 水平居中
+        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+
+        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
+
+        String fileName = URLEncoder.encode("用户信息表", "UTF-8").replaceAll("\\+", "%20");
+        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+        EasyExcel.write(response.getOutputStream())
+                .head(hs)
+                .useDefaultStyle(true)
+                .sheet(head)
+                .registerWriteHandler(horizontalCellStyleStrategy)
+                //自适应宽度
+                //.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
+                .doWrite(data);
+    }
+
 }

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

@@ -28,7 +28,7 @@
                 and c.status = #{channel.status}
             </if>
             <if test="channel.channelIdList != null and  !channel.channelIdList.isEmpty()">
-                and o.channel_id  in
+                and c.id  in
                 <foreach collection="channel.channelIdList" item="channelId" open="(" close=")" separator=",">
                     #{channelId}
                 </foreach>

+ 136 - 66
yami-shop-service/src/main/resources/mapper/SkuMapper.xml

@@ -202,17 +202,17 @@
     </select>
 
     <select id="goodsTotalPrice" resultType="Double">
-        SELECT (SELECT SUM(IFNULL(total,0)) goods_total_price FROM tz_order
-        WHERE is_payed=1
+        SELECT (SELECT IFNULL(SUM(IFNULL(a.total,0)) ,0) goods_total_price FROM tz_order a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
-            and create_time&gt;= #{po.startTime}
+            and a.create_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and create_time&lt;= #{po.endTime}
+            and a.create_time&lt;= #{po.endTime}
         </if>
         <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
-        and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
+        and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
                                                 <where>
                                                     <if test="po.skuId != null">
                                                         AND a.sku_id like concat('%',#{po.skuId} ,'%')
@@ -229,22 +229,25 @@
             )
         </if>
 
-          and channel_id in
+          and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         )
         -
-        (SELECT IFNULL(SUM(a.sku_price * product_count),0)
+        (SELECT IFNULL(SUM(a.sku_price * a.product_count),0)
         FROM `tz_order_refund_sku` a
         LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
         LEFT JOIN tz_order c on b.order_number=c.order_number
         LEFT JOIN tz_sku d on a.sku_id=d.sku_id
+        LEFT JOIN tz_user e on b.user_id=e.user_id
         WHERE b.return_money_sts=70
         <if test="po.startTime != null and po.startTime != ''">
             and b.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and b.apply_time&lt;= #{po.endTime}
         </if>
@@ -252,38 +255,37 @@
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
-
         <if test="po.skuId != null">
             AND a.sku_id like concat('%',#{po.skuId} ,'%')
         </if>
-
         <if test="po.skuName != null and po.skuName != ''">
             AND d.sku_name like concat('%',#{po.skuName} ,'%')
         </if>
-
         <if test="po.spec != null and po.spec != ''">
             AND d.spec like concat('%',#{po.spec} ,'%')
         </if>
-
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         ) goods_total_price
     </select>
 
     <select id="totalPoints" resultType="Double">
-        SELECT TRUNCATE(((SELECT SUM(IFNULL(offset_points,0)) FROM tz_order
-        WHERE is_payed=1
+        SELECT TRUNCATE(((SELECT SUM(IFNULL(a.offset_points,0)) FROM tz_order a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
-            and create_time&gt;= #{po.startTime}
+            and a.create_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and create_time&lt;= #{po.endTime}
+            and a.create_time&lt;= #{po.endTime}
         </if>
-        and channel_id in
+        and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
         <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
-            and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
+            and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
             <where>
                 <if test="po.skuId != null">
                     AND a.sku_id like concat('%',#{po.skuId} ,'%')
@@ -296,6 +298,9 @@
                 <if test="po.spec != null and po.spec != ''">
                     AND b.spec like concat('%',#{po.spec} ,'%')
                 </if>
+                <if test="po.userAttrType != null and po.userAttrType != 0">
+                    AND e.user_attr_type=#{po.userAttrType}
+                </if>
             </where>
             )
         </if>
@@ -307,15 +312,19 @@
         ELSE total_offset_points+ (freight_amount * 100)
         END AS total_offset_points
         FROM tz_order_refund a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
         LEFT JOIN (SELECT SUM(tor.offset_points) total_offset_points ,tor.order_number
         FROM tz_order_refund tor
+        LEFT JOIN tz_user e on tor.user_id=e.user_id
         WHERE tor.return_money_sts=70
         <if test="po.startTime != null and po.startTime != ''">
             and tor.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and tor.apply_time&lt;= #{po.endTime}
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
         </if>
             and tor.order_number in(SELECT ao.order_number FROM tz_order_item ao
                 LEFT JOIN tz_sku b on ao.sku_id=b.sku_id
@@ -343,11 +352,13 @@
         <if test="po.startTime != null and po.startTime != ''">
             and apply_time &gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and apply_time &lt;= #{po.endTime}
         </if>
-            and a.order_number in(SELECT ao2.order_number FROM tz_order_item ao2
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
+        and a.order_number in(SELECT ao2.order_number FROM tz_order_item ao2
         LEFT JOIN tz_sku b on ao2.sku_id=b.sku_id
         LEFT JOIN tz_order c on ao2.order_number=c.order_number
         <where>
@@ -372,20 +383,24 @@
     </select>
 
     <select id="totalCash" resultType="Double">
-        SELECT (SELECT SUM(IFNULL(actual_total,0)) FROM tz_order WHERE is_payed=1
+        SELECT (SELECT SUM(IFNULL(a.actual_total,0)) FROM tz_order a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
-            and create_time&gt;= #{po.startTime}
+            and a.create_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and create_time&lt;= #{po.endTime}
+            and a.create_time&lt;= #{po.endTime}
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
         </if>
-        and channel_id in
+        and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
         <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
-            and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
+            and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
             <where>
                 <if test="po.skuId != null">
                     AND a.sku_id like concat('%',#{po.skuId} ,'%')
@@ -401,15 +416,19 @@
         </if>
                                                                  )
         -
-        (SELECT IFNULL(SUM( refund_amount ),0) FROM tz_order_refund WHERE return_money_sts=70
+        (SELECT IFNULL(SUM( a.refund_amount ),0) FROM tz_order_refund a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.return_money_sts=70
         <if test="po.startTime != null and po.startTime != ''">
-            and apply_time&gt;= #{po.startTime}
+            and a.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and apply_time&lt;= #{po.endTime}
+            and a.apply_time&lt;= #{po.endTime}
         </if>
-        and order_number in(SELECT a.order_number FROM tz_order_item a
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
+        and a.order_number in(SELECT a.order_number FROM tz_order_item a
         LEFT JOIN tz_sku b on a.sku_id=b.sku_id
         LEFT JOIN tz_order c on a.order_number=c.order_number
         <where>
@@ -433,21 +452,24 @@
     </select>
 
     <select id="totalFreight" resultType="Double">
-        SELECT (SELECT IFNULL(SUM(freight_amount),0) total_freight FROM tz_order
-        WHERE is_payed=1
+        SELECT (SELECT IFNULL(SUM(a.freight_amount),0) total_freight FROM tz_order a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
-            and create_time&gt;= #{po.startTime}
+            and a.create_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and create_time&lt;= #{po.endTime}
+            and a.create_time&lt;= #{po.endTime}
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
         </if>
-        and channel_id in
+        and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
         <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
-            and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
+            and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
             <where>
                 <if test="po.skuId != null">
                     AND a.sku_id like concat('%',#{po.skuId} ,'%')
@@ -465,18 +487,21 @@
         </if>
         )
         -
-        (SELECT IFNULL(SUM(freight_amount),0)
-        FROM `tz_order_refund`
-        WHERE return_money_sts=70
+        (SELECT IFNULL(SUM(a.freight_amount),0)
+        FROM `tz_order_refund` a
+        LEFT JOIN tz_user e on a.user_id=e.user_id
+        WHERE a.return_money_sts=70
         <if test="po.startTime != null and po.startTime != ''">
-            and apply_time&gt;= #{po.startTime}
+            and a.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
-            and apply_time&lt;= #{po.endTime}
+            and a.apply_time&lt;= #{po.endTime}
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
         </if>
-          and refund_type=1
-        and order_number in(SELECT a.order_number FROM tz_order_item a
+        and a.refund_type=1
+        and a.order_number in(SELECT a.order_number FROM tz_order_item a
         LEFT JOIN tz_sku b on a.sku_id=b.sku_id
         LEFT JOIN tz_order c on a.order_number=c.order_number
         <where>
@@ -500,25 +525,44 @@
     </select>
 
     <select id="skuStatisticsList" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
-        SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
-        TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) * (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
+        SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2)
+        price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
+        TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) *
+        (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
         FROM tz_order_item a
         LEFT JOIN tz_order b on a.order_number=b.order_number
         LEFT JOIN tz_sku c on a.sku_id=c.sku_id
+        LEFT JOIN tz_user e on b.user_id=e.user_id
         LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
         FROM `tz_order_refund_sku` a
         LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
+        LEFT JOIN tz_order c on b.order_number=c.order_number
+        LEFT JOIN tz_sku d on a.sku_id=d.sku_id
+        LEFT JOIN tz_user e on b.user_id=e.user_id
         WHERE return_money_sts=70
-
         <if test="po.startTime != null and po.startTime != ''">
             and b.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and b.apply_time&lt;= #{po.endTime}
         </if>
+        and c.channel_id in
+        <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        <if test="po.skuId != null">
+            AND a.sku_id like concat('%',#{po.skuId} ,'%')
+        </if>
+        <if test="po.skuName != null and po.skuName != ''">
+            AND d.sku_name like concat('%',#{po.skuName} ,'%')
+        </if>
+        <if test="po.spec != null and po.spec != ''">
+            AND d.spec like concat('%',#{po.spec} ,'%')
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         GROUP BY a.sku_id) d on a.sku_id = d.sku_id
-
         WHERE b.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
             and a.rec_time&gt;= #{po.startTime}
@@ -542,34 +586,55 @@
         <if test="po.spec != null and po.spec != ''">
             AND c.spec like concat('%',#{po.spec} ,'%')
         </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         GROUP BY a.sku_id HAVING prod_count>0
     </select>
 
     <select id="skuStatisticsList2" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
-        SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
-        TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) * (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
+        SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2)
+        price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
+        TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) *
+        (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
         FROM tz_order_item a
         LEFT JOIN tz_order b on a.order_number=b.order_number
         LEFT JOIN tz_sku c on a.sku_id=c.sku_id
+        LEFT JOIN tz_user e on b.user_id=e.user_id
         LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
         FROM `tz_order_refund_sku` a
         LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
+        LEFT JOIN tz_order c on b.order_number=c.order_number
+        LEFT JOIN tz_sku d on a.sku_id=d.sku_id
+        LEFT JOIN tz_user e on b.user_id=e.user_id
         WHERE return_money_sts=70
-
         <if test="po.startTime != null and po.startTime != ''">
             and b.apply_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and b.apply_time&lt;= #{po.endTime}
         </if>
+        and c.channel_id in
+        <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        <if test="po.skuId != null">
+            AND a.sku_id like concat('%',#{po.skuId} ,'%')
+        </if>
+        <if test="po.skuName != null and po.skuName != ''">
+            AND d.sku_name like concat('%',#{po.skuName} ,'%')
+        </if>
+        <if test="po.spec != null and po.spec != ''">
+            AND d.spec like concat('%',#{po.spec} ,'%')
+        </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         GROUP BY a.sku_id) d on a.sku_id = d.sku_id
-
         WHERE b.is_payed=1
         <if test="po.startTime != null and po.startTime != ''">
             and a.rec_time&gt;= #{po.startTime}
         </if>
-
         <if test="po.endTime != null and po.endTime != ''">
             and a.rec_time&lt;= #{po.endTime}
         </if>
@@ -580,14 +645,15 @@
         <if test="po.skuId != null">
             AND a.sku_id like concat('%',#{po.skuId} ,'%')
         </if>
-
         <if test="po.skuName != null and po.skuName != ''">
             AND a.sku_name like concat('%',#{po.skuName} ,'%')
         </if>
-
         <if test="po.spec != null and po.spec != ''">
             AND c.spec like concat('%',#{po.spec} ,'%')
         </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         GROUP BY a.sku_id HAVING prod_count>0
     </select>
 
@@ -601,16 +667,15 @@
         FROM (SELECT @row_number := 0) sort,
         tz_order a
         LEFT JOIN tz_user_addr_order b on a.addr_order_id =b.addr_order_id
+        LEFT JOIN tz_user e on a.user_id=e.user_id
         WHERE a.is_payed=1 and a.hb_order_status not in(0,60)
         and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
-
         <if test="po.delivery != null">
             and a.dvy_type=#{po.delivery}
         </if>
-
         <if test="po.receiver != null and po.receiver != ''">
             AND b.receiver like concat('%',#{po.receiver} ,'%')
         </if>
@@ -626,6 +691,9 @@
         <if test="po.orderNo != null and po.orderNo != ''">
             AND a.order_number like concat('%',#{po.orderNo} ,'%')
         </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         <if test="po.startTime != null and po.startTime != ''">
             and a.pay_time&gt;= #{po.startTime}
         </if>
@@ -644,16 +712,15 @@
         FROM (SELECT @row_number := 0) sort,
         tz_order a
         LEFT JOIN tz_user_addr_order b on a.addr_order_id =b.addr_order_id
+        LEFT JOIN tz_user e on a.user_id=e.user_id
         WHERE a.is_payed=1 and a.hb_order_status not in(0,60)
         and a.channel_id in
         <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
-
         <if test="po.delivery != null">
             and a.dvy_type=#{po.delivery}
         </if>
-
         <if test="po.receiver != null and po.receiver != ''">
             AND b.receiver like concat('%',#{po.receiver} ,'%')
         </if>
@@ -669,6 +736,9 @@
         <if test="po.orderNo != null and po.orderNo != ''">
             AND a.order_number like concat('%',#{po.orderNo} ,'%')
         </if>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
+        </if>
         <if test="po.startTime != null and po.startTime != ''">
             and a.pay_time&gt;= #{po.startTime}
         </if>

+ 3 - 10
yami-shop-service/src/main/resources/mapper/UserMapper.xml

@@ -254,12 +254,9 @@
 
     <select id="test" resultType="double">
         SELECT (SELECT SUM(IFNULL(offset_points,0)) FROM tz_order
-        WHERE create_time&gt;= '2025-11-01 00:00:00' and create_time&lt;='2025-11-29 23:59:59' and is_payed=1 and user_id=#{userId}
-
+        WHERE create_time&gt;= '2025-11-01 00:00:00' and create_time&lt;='2025-12-08 23:59:59' and is_payed=1 and user_id=#{userId}
         ) -
-
         (
-
         SELECT  IFNULL(SUM(IFNULL(total_offset_points,0)),0) FROM (SELECT
         CASE
         WHEN refund_type=1 THEN total_offset_points
@@ -268,15 +265,11 @@
         FROM tz_order_refund a
         LEFT JOIN (SELECT SUM(offset_points) total_offset_points ,order_number
         FROM tz_order_refund
-        WHERE apply_time&gt;='2025-11-01 00:00:00' and apply_time&lt;='2025-11-29 23:59:59' and return_money_sts=70 and user_id=#{userId}
+        WHERE apply_time&gt;='2025-11-01 00:00:00' and apply_time&lt;='2025-12-08 23:59:59' and return_money_sts=70 and user_id=#{userId}
         GROUP BY order_number) b on a.order_number=b.order_number
-        WHERE apply_time&gt;='2025-11-01 00:00:00' and apply_time&lt;='2025-11-29 23:59:59' and return_money_sts=70 and user_id=#{userId}
+        WHERE apply_time&gt;='2025-11-01 00:00:00' and apply_time&lt;='2025-12-08 23:59:59' and return_money_sts=70 and user_id=#{userId}
         GROUP BY a.order_number) a
-
-
         )
-
-
     </select>
 
 </mapper>