Explorar el Código

供应商首页,协销机构画像

huangzhiguo hace 1 año
padre
commit
d6c1f0ce13

+ 6 - 3
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -163,13 +163,16 @@ public class ShopApi {
      * @param userId 用户Id
      */
     @ApiOperation("供应商个人中心数据(旧:/supplier/homePageData)")
-    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "productOrganize", value = "商品上架平台")
+    })
     @GetMapping("/personal/data")
-    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId) {
+    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId, Integer productOrganize) {
         if (null == userId) {
             return ResponseJson.error("参数异常:用户Id不能为空!", null);
         }
-        return shopService.getShopPersonalData(userId);
+        return shopService.getShopPersonalData(userId, productOrganize);
     }
 
     @ApiOperation("供应商文章表单")

+ 5 - 3
src/main/java/com/caimei365/user/mapper/ShopMapper.java

@@ -7,6 +7,7 @@ import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -89,14 +90,15 @@ public interface ShopMapper {
      * 统计商品数量
      *
      * @param shopId    供应商id
+     * @param productOrganize    上架平台
      * @param validFlag 商品状态
      */
-    Integer getShopProductCount(Integer shopId, Integer validFlag);
+    Integer getShopProductCount(@Param("shopId") Integer shopId, @Param("productOrganize") Integer productOrganize, @Param("validFlag") Integer validFlag);
     /**
      * 统计前五的商品销售信息
      */
     @MapKey("productId")
-    List<Map<String, Object>> getSalesRankingList(Integer shopId);
+    List<Map<String, Object>> getSalesRankingList(@Param("shopId") Integer shopId, @Param("organizeId") Integer organizeId);
     /**
      * 获取商品信息
      */
@@ -105,7 +107,7 @@ public interface ShopMapper {
      * 销售统计
      */
     @MapKey("orderQuantity")
-    Map<String, Object> getSalesStatistics(Integer shopId, String startTime, String endTime);
+    Map<String, Object> getSalesStatistics(Integer shopId, Integer organizeId, String startTime, String endTime);
     /**
      * 轮播图片数量
      */

+ 1 - 1
src/main/java/com/caimei365/user/service/ShopService.java

@@ -84,7 +84,7 @@ public interface ShopService {
      * 供应商个人中心数据
      * @param userId 用户Id
      */
-    ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId);
+    ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId, Integer productOrganize);
 
     /**
      * 供应商-更新轮播图片

+ 8 - 8
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -2233,24 +2233,24 @@ public class ClubServiceImpl implements ClubService {
                     // 普通订单
                     if (("0".equals(order.getSecondHandOrderFlag()) || StringUtils.isEmpty(order.getSecondHandOrderFlag()))
                             && (!"1".equals(order.getRebateFlag()) || "".equals(order.getRebateFlag()) || StringUtils.isEmpty(order.getRebateFlag()))
-                            && ((!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) || "".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType()))
-                            && !"6".equals(order.getStatus())) {
+                            && (!"2".equals(order.getRefundType()) || "".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType()))
+                            && !"4".equals(order.getStatus())) {
                         ordinary++;
                     }
                     // 二手订单
                     if ("1".equals(order.getSecondHandOrderFlag()) && !"1".equals(order.getRebateFlag())
-                            && (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                            && (!"2".equals(order.getRefundType())) && !"4".equals(order.getStatus())) {
                         secondHand++;
                     }
                     // 返佣订单
                     if ("1".equals(order.getRebateFlag()) &&
-                            (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                            (!"2".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType())) && !"4".equals(order.getStatus())) {
                         rebate++;
                     }
                     // 部分退款
-                    if ("1".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
+                    /*if ("1".equals(order.getRefundType()) && !"4".equals(order.getStatus())) {
                         partialRefund++;
-                    }
+                    }*/
                     // 全部退款
                     /*if ("2".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
                         fullRefund++;
@@ -2297,7 +2297,7 @@ public class ClubServiceImpl implements ClubService {
                     orderPortrait.setPer("0");
                 }
                 orderPortraits.add(orderPortrait);
-                orderPortrait = new PortraitMap();
+                /*orderPortrait = new PortraitMap();
                 orderPortrait.setValue(partialRefund);
                 if (partialRefund != 0) {
                     orderPortrait.setName("部分退款");
@@ -2306,7 +2306,7 @@ public class ClubServiceImpl implements ClubService {
                     orderPortrait.setName("部分退款");
                     orderPortrait.setPer("0");
                 }
-                orderPortraits.add(orderPortrait);
+                orderPortraits.add(orderPortrait);*/
                 /*orderPortrait = new PortraitMap();
                 orderPortrait.setValue(fullRefund);
                 if (fullRefund != 0) {

+ 10 - 9
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -324,7 +324,7 @@ public class ShopServiceImpl implements ShopService {
      * @param userId 用户Id
      */
     @Override
-    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId) {
+    public ResponseJson<Map<String, Object>> getShopPersonalData(Integer userId, Integer productOrganize) {
         Map<String, Object> result = new HashMap<>(11);
         // 1.用户信息
         UserVo user = baseMapper.getUserByUserId(userId);
@@ -366,13 +366,14 @@ public class ShopServiceImpl implements ShopService {
         Integer unReadMessageCount = personalCenterMapper.getUnReadMessageCount(userId);
         result.put("unReadMessageCount", unReadMessageCount);
         // 7.商品数量统计,validFlag 商品状态,见ProductStatus,0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已冻结'
-        Integer allNum = shopMapper.getShopProductCount(user.getShopId(), null);
+        productOrganize = null == productOrganize ? 0 : productOrganize;
+        Integer allNum = shopMapper.getShopProductCount(user.getShopId(), productOrganize, null);
         result.put("allNum", allNum);
         // 8.已上架数量
-        Integer upNum = shopMapper.getShopProductCount(user.getShopId(), 2);
+        Integer upNum = shopMapper.getShopProductCount(user.getShopId(), productOrganize, 2);
         result.put("upNum", upNum);
         // 9.已下架数量
-        Integer downNum = shopMapper.getShopProductCount(user.getShopId(), 3);
+        Integer downNum = shopMapper.getShopProductCount(user.getShopId(), productOrganize, 3);
         result.put("downNum", downNum);
         Jedis jedis = new Jedis("172.31.165.27", 6379);
         jedis.auth("6#xsI%b4o@5c3RoE");
@@ -380,7 +381,7 @@ public class ShopServiceImpl implements ShopService {
         result.put("constraint", jedis.rpop("constraint"));
 
         // 10.单品销售排名
-        List<Map<String, Object>> salesRankingList = shopMapper.getSalesRankingList(user.getShopId());
+        List<Map<String, Object>> salesRankingList = shopMapper.getSalesRankingList(user.getShopId(), productOrganize);
         if (salesRankingList != null && salesRankingList.size() > 0) {
             salesRankingList.forEach(map -> {
                 ProductItemVo product = shopMapper.getProductShown((Integer) map.get("productId"));
@@ -396,22 +397,22 @@ public class ShopServiceImpl implements ShopService {
         Date endDayOfDay = DateUtil.getDayEnd();
         // 近一个月销售情况统计
         Date beginDayOfYesterday = DateUtil.addMonth(endDayOfDay, -1);
-        Map<String, Object> m1 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfYesterday), DateUtil.formatDateTime(endDayOfDay));
+        Map<String, Object> m1 = shopMapper.getSalesStatistics(user.getShopId(), productOrganize, DateUtil.formatDateTime(beginDayOfYesterday), DateUtil.formatDateTime(endDayOfDay));
         m1.put("time", "近一月");
         salesStatisticsList.add(m1);
         // 近三个月销售情况统计
         Date beginDayOfLastWeek = DateUtil.addMonth(endDayOfDay, -3);
-        Map<String, Object> m2 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastWeek), DateUtil.formatDateTime(endDayOfDay));
+        Map<String, Object> m2 = shopMapper.getSalesStatistics(user.getShopId(), productOrganize, DateUtil.formatDateTime(beginDayOfLastWeek), DateUtil.formatDateTime(endDayOfDay));
         m2.put("time", "近三月");
         salesStatisticsList.add(m2);
         // 近半年销售情况统计
         Date beginDayOfLastMonth = DateUtil.addMonth(endDayOfDay, -6);
-        Map<String, Object> m3 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastMonth), DateUtil.formatDateTime(endDayOfDay));
+        Map<String, Object> m3 = shopMapper.getSalesStatistics(user.getShopId(), productOrganize, DateUtil.formatDateTime(beginDayOfLastMonth), DateUtil.formatDateTime(endDayOfDay));
         m3.put("time", "近半年");
         salesStatisticsList.add(m3);
         // 近一年销售情况统计
         Date beginDayOfLastYear = DateUtil.addMonth(endDayOfDay, -12);
-        Map<String, Object> m4 = shopMapper.getSalesStatistics(user.getShopId(), DateUtil.formatDateTime(beginDayOfLastYear), DateUtil.formatDateTime(endDayOfDay));
+        Map<String, Object> m4 = shopMapper.getSalesStatistics(user.getShopId(), productOrganize, DateUtil.formatDateTime(beginDayOfLastYear), DateUtil.formatDateTime(endDayOfDay));
         m4.put("time", "近一年");
         salesStatisticsList.add(m4);
         result.put("salesStatisticsList", salesStatisticsList);

+ 15 - 14
src/main/resources/mapper/ClubMapper.xml

@@ -1008,8 +1008,8 @@
         WHERE csg.serviceId = #{spId}
     </select>
     <select id="selTotal" resultType="com.caimei365.user.model.dto.CmPortraitDto">
-        SELECT (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubId} AND STATUS != 6 AND STATUS != 7 AND refundType != 2 AND orderTime <![CDATA[ < ]]> now())      AS orderTotal,
-               (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubId} AND STATUS != 6 AND STATUS != 7 AND refundType != 2 AND orderTime <![CDATA[ < ]]> now())                                                                 AS orderTotalAmount,
+        SELECT (SELECT COUNT(shopOrderId) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotal,
+               (SELECT IFNULL(SUM(totalAmount), 0) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotalAmount,
                (SELECT COUNT(cbr.recordID) FROM cm_behavior_record cbr LEFT JOIN club c ON cbr.userID = c.userID
                 WHERE cbr.pageType IN (8, 9) AND c.clubID = #{clubId} AND cbr.accessDate <![CDATA[ < ]]> now())                                                            AS totalkeywords,
                (SELECT COUNT(remarks) FROM cm_club_remarks WHERE clubID = #{clubId} AND addTime <![CDATA[ < ]]> now()) AS remarksTotal
@@ -1042,20 +1042,21 @@
     </select>
     <select id="selOrderList" resultType="com.caimei365.user.model.po.NewOrderPo">
         SELECT
-        (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubId} AND STATUS != 6 AND STATUS != 7 AND refundType != 2) as numbers,
-        (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubId} AND STATUS != 6 AND STATUS != 7 AND refundType != 2) as totalMoney,
-        clubID,
-        secondHandOrderFlag,
-        rebateFlag,
-        refundType,
-        payTotalFee,
-        STATUS,
-        orderTime
-        FROM cm_order
+        (SELECT COUNT(shopOrderId) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotal,
+        (SELECT IFNULL(SUM(totalAmount), 0) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotalAmount,
+        cso.clubID,
+        co.secondHandOrderFlag,
+        co.rebateFlag,
+        cso.totalAmount AS payTotalFee,
+        ifnull(cso.refundStatus,1) as refundType,
+        cso.shopStatus AS STATUS,
+        cso.orderTime
+        FROM cm_shop_order cso
+        LEFT JOIN cm_order co ON cso.orderId = co.orderId
         <where>
-            clubID = #{clubId} AND STATUS != 6 AND STATUS != 7 AND refundType != 2
+            cso.clubID = #{clubID} AND cso.shopStatus != 4 AND cso.shopStatus != 5 AND cso.refundStatus != 2 AND cop.productId != 999
             <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-                AND orderTime <![CDATA[ >= ]]> #{startTime} AND orderTime <![CDATA[ <= ]]> #{endTime}
+                AND cso.orderTime <![CDATA[ >= ]]> #{startTime} AND cso.orderTime <![CDATA[ <= ]]> #{endTime}
             </if>
         </where>
     </select>

+ 4 - 3
src/main/resources/mapper/ShopMapper.xml

@@ -180,15 +180,15 @@
         SELECT COUNT(*)
         FROM product p
         left join cm_organize_product_info copi on p.productID = copi.productId
-        WHERE shopID = #{shopId}
+        WHERE p.shopID = #{shopId} and copi.organizeId = #{productOrganize}
         <if test="validFlag != null">
-            AND validFlag = #{validFlag}
+            AND copi.validFlag = #{validFlag}
         </if>
     </select>
     <select id="getSalesRankingList" resultType="java.util.Map">
         SELECT cop.productID AS productId, SUM(cop.num) AS total
         FROM cm_order_product cop JOIN cm_order co ON co.orderID = cop.orderID
-        WHERE cop.shopID = #{shopId}
+        WHERE cop.shopID = #{shopId} and cop.organizeID = #{organizeId}
           AND co.STATUS NOT IN ('0', '6', '7')
           AND co.delFlag = '0'
           AND co.secondHandOrderFlag != '1'
@@ -210,6 +210,7 @@
         AND o.delFlag = '0'
         AND so.delFlag = '0'
         AND so.shopID = #{shopId}
+        AND so.organizeID = #{organizeId}
         AND o.secondHandOrderFlag != '1'
         <if test="startTime != null and startTime != ''">
             AND o.orderTime <![CDATA[  >=  ]]> #{startTime}