فهرست منبع

statistics add userAttrType

wangming 1 هفته پیش
والد
کامیت
8de7e04682

+ 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;
 

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

@@ -45,13 +45,13 @@ public class SkuController {
     @GetMapping("/skuStatisticsList")
     @ApiOperation(value = "对账单汇总表(商品)-列表")
     public R<IPage<SkuStatisticsVo>> skuStatisticsList(PageParam<SkuStatisticsPo> page, SkuStatisticsPo po) {
-        if (po.getChannelIds().contains(0L)){
-            List<IdNameVo> idNameVos = channelService.queryMyChannel(SecurityUtils.getSysUser().getUserId());
-            if (!idNameVos.isEmpty()){
-                List<Long> ids = idNameVos.stream().map(IdNameVo::getId).collect(Collectors.toList());
-                po.setChannelIds(ids);
-            }
-        }
+//        if (po.getChannelIds().contains(0L)){
+//            List<IdNameVo> idNameVos = channelService.queryMyChannel(SecurityUtils.getSysUser().getUserId());
+//            if (!idNameVos.isEmpty()){
+//                List<Long> ids = idNameVos.stream().map(IdNameVo::getId).collect(Collectors.toList());
+//                po.setChannelIds(ids);
+//            }
+//        }
         return R.SUCCESS(skuService.skuStatisticsList(page,po));
     }
 

+ 98 - 57
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>
+        <if test="po.userAttrType != null and po.userAttrType != 0">
+            AND e.user_attr_type=#{po.userAttrType}
         </if>
-        and order_number in(SELECT a.order_number FROM tz_order_item a
+        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,11 +525,14 @@
     </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
@@ -542,15 +570,21 @@
         <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
@@ -588,6 +622,9 @@
         <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 +638,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 +662,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 +683,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 +707,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>