Browse Source

店铺报表调整

yumeng 10 months ago
parent
commit
4be857d57f

+ 68 - 3
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -10,6 +10,8 @@ import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.data.utils.ExportExcelUtils;
 import com.ruixuan.isc.service.IKuaishouPromoterService;
 import com.ruixuan.isc.service.ISupplyChainService;
+import com.ruixuan.system.service.ISysDeptService;
+import com.ruixuan.system.service.ISysUserService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.SneakyThrows;
@@ -2317,6 +2319,11 @@ public class SupplyChainController extends BaseController {
     }
 
 
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private ISysDeptService deptService;
+
     @GetMapping("/shopList")
     @ApiOperation(value = "商品列表")
     public TableDataInfo shopList(
@@ -2324,6 +2331,7 @@ public class SupplyChainController extends BaseController {
             @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
             @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
             @ApiParam("结束时间") @RequestParam(value = "sellerId", required = false) Long sellerId,
+            @ApiParam("结束时间") @RequestParam(value = "userId", required = false) Long userId,
             @ApiParam("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
             @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort) {
         TableDataInfo dataInfo = new TableDataInfo();
@@ -2332,8 +2340,24 @@ public class SupplyChainController extends BaseController {
                 throw new Exception("请输入开始时间和结束时间");
             }
 
+            if (Check.isNull(userId)) {
+                throw new Exception("请输入用户id");
+            }
             Map<String, Object> requestMap = new HashMap<>();
 
+            String roleKey = sysUserService.getRoleKeyByUserId(userId);
+            if (roleKey.equals("courtship")) {
+                List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
+                requestMap.put("itemIds", itemIds);
+            }
+
+            if (roleKey.equals("courtshipManager")) {
+                Long deptId = deptService.getDeptIdByUserId(userId);
+                List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
+                requestMap.put("itemIds", itemIds);
+            }
+
+
             requestMap.put("start", orderStartDate);
             requestMap.put("end", orderEndDate);
             if (!Check.isNull(sellerId)) {
@@ -2368,6 +2392,7 @@ public class SupplyChainController extends BaseController {
             @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
             @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
             @ApiParam("结束时间") @RequestParam(value = "sellerId", required = false) Long sellerId,
+            @ApiParam("结束时间") @RequestParam(value = "userId", required = false) Long userId,
             @ApiParam("结束时间") @RequestParam(value = "itemId", required = false) Long itemId,
             @ApiParam("结束时间") @RequestParam(value = "itemTitle", required = false) String itemTitle
 
@@ -2382,6 +2407,19 @@ public class SupplyChainController extends BaseController {
             }
 
             Map<String, Object> requestMap = new HashMap<>();
+            String roleKey = sysUserService.getRoleKeyByUserId(userId);
+            if (roleKey.equals("courtship")) {
+                List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
+                requestMap.put("itemIds", itemIds);
+            }
+
+            if (roleKey.equals("courtshipManager")) {
+                Long deptId = deptService.getDeptIdByUserId(userId);
+                List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
+                requestMap.put("itemIds", itemIds);
+            }
+
+
             requestMap.put("start", orderStartDate);
             requestMap.put("end", orderEndDate);
             requestMap.put("sellerId", sellerId);
@@ -2411,7 +2449,6 @@ public class SupplyChainController extends BaseController {
     }
 
     @PostMapping("/exportShopDetail")
-    @ApiOperation(value = "认领商品列表")
     @ResponseBody
     public void exportShopDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
 
@@ -2422,13 +2459,26 @@ public class SupplyChainController extends BaseController {
             if (Check.isNull(requestJson.getLong("sellerId"))) {
                 throw new Exception("请输入店铺Id");
             }
-
+            Long userId = requestJson.getLong("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("请输入用户ID");
+            }
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("start", requestJson.getString("orderStartDate"));
             requestMap.put("end", requestJson.getString("orderEndDate"));
             requestMap.put("sellerId", requestJson.getLong("sellerId"));
 
+            String roleKey = sysUserService.getRoleKeyByUserId(userId);
+            if (roleKey.equals("courtship")) {
+                List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
+                requestMap.put("itemIds", itemIds);
+            }
 
+            if (roleKey.equals("courtshipManager")) {
+                Long deptId = deptService.getDeptIdByUserId(userId);
+                List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
+                requestMap.put("itemIds", itemIds);
+            }
             List<JSONObject> list = supplyChainService.shopDetail(requestMap);
             List<List<Object>> exportList = new ArrayList<>();
             if (!Check.isNull(list)) {
@@ -2470,7 +2520,6 @@ public class SupplyChainController extends BaseController {
 
 
     @PostMapping("/exportShopList")
-    @ApiOperation(value = "认领商品列表")
     @ResponseBody
     public void exportShopList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
 
@@ -2479,6 +2528,11 @@ public class SupplyChainController extends BaseController {
                 throw new Exception("请输入开始时间和结束时间");
             }
 
+            Long userId = requestJson.getLong("userId");
+            if (Check.isNull(userId)) {
+                throw new Exception("请输入用户ID");
+            }
+
 
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("start", requestJson.getString("orderStartDate"));
@@ -2486,6 +2540,17 @@ public class SupplyChainController extends BaseController {
             requestMap.put("fieId", "orderNum");
             requestMap.put("sort", "desc");
 
+            String roleKey = sysUserService.getRoleKeyByUserId(userId);
+            if (roleKey.equals("courtship")) {
+                List<Long> itemIds = supplyChainService.getItemIdsByUserId(userId);
+                requestMap.put("itemIds", itemIds);
+            }
+
+            if (roleKey.equals("courtshipManager")) {
+                Long deptId = deptService.getDeptIdByUserId(userId);
+                List<Long> itemIds = supplyChainService.getItemIdsByDeptId(deptId);
+                requestMap.put("itemIds", itemIds);
+            }
             List<JSONObject> list = supplyChainService.shopList(requestMap);
             List<List<Object>> exportList = new ArrayList<>();
             if (!Check.isNull(list)) {

+ 4 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -230,4 +230,8 @@ public interface SupplyChainMapper {
     List<JSONObject> shopList(Map<String, Object> requestMap);
 
     List<JSONObject> shopDetail(Map<String, Object> requestMap);
+
+    List<Long> getItemIdsByUserId(@Param("userId") Long userId);
+
+    List<Long> getItemIdsByDeptId(@Param("deptId") Long deptId);
 }

+ 4 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -206,4 +206,8 @@ public interface ISupplyChainService {
     List<JSONObject> shopList(Map<String, Object> requestMap);
 
     List<JSONObject> shopDetail(Map<String, Object> requestMap);
+
+    List<Long> getItemIdsByUserId(Long userId);
+
+    List<Long> getItemIdsByDeptId(Long deptId);
 }

+ 10 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -1196,6 +1196,16 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
         return supplyChainMapper.shopDetail(requestMap);
     }
 
+    @Override
+    public List<Long> getItemIdsByUserId(Long userId) {
+        return supplyChainMapper.getItemIdsByUserId(userId);
+    }
+
+    @Override
+    public List<Long> getItemIdsByDeptId(Long deptId) {
+        return supplyChainMapper.getItemIdsByDeptId(deptId);
+    }
+
     private void getInfoKuaishouActivityInfo(KuaishouAccessToken accessToken, String url) {
         List<KuaiShouActivityInfo> list = new ArrayList<>();
         String appKey = accessToken.getAppKey();

+ 31 - 1
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -3236,7 +3236,6 @@
         2) as 'deliveryRadio'
         from kuaishou_supply_chain
         where 1 = 1
-
         <if test="start != null and start != ''">
             and stat_date &gt;= #{start}
         </if>
@@ -3246,6 +3245,14 @@
         <if test="sellerId != null and sellerId != ''">
             and seller_id = #{sellerId}
         </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            and item_id in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+
+        </if>
         group by seller_id) t1
         left join kuaishou_seller_info t2
         on t1.sellerId = t2.seller_id
@@ -3305,6 +3312,15 @@
         <if test="itemTitle != null and itemTitle != ''">
             and item_title like concat(concat('%',#{itemTitle}),'%')
         </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            and item_id in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+
+        </if>
+
         group by item_id) t1 left join kuaishou_item_ccr_info t2
         on t1.itemId = t2.item_id
         LEFT JOIN (select item_id as 'itemId',user_name as 'userName' from kuaishou_item_list WHERE media_id = 2 group
@@ -3313,6 +3329,20 @@
         order by t1.orderNum desc
 
     </select>
+    <select id="getItemIdsByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
+        SELECT item_id
+        FROM kuaishou_item_list
+        WHERE user_id = #{userId}
+        GROUP BY item_id
+    </select>
+    <select id="getItemIdsByDeptId" resultType="java.lang.Long" parameterType="java.lang.Long">
+        SELECT item_id
+        FROM kuaishou_item_list
+        WHERE user_id IN (SELECT sys_user.user_id
+                          FROM sys_user
+                          WHERE dept_id = #{deptId})
+        GROUP BY item_id
+    </select>
 
     <update id="updateKuaiShouActivityOpenItemList">
         UPDATE ruixuan.kuaishou_activity_open_item_list