소스 검색

数据打通

yumeng 11 달 전
부모
커밋
6ecb8c388f

+ 3 - 0
ruixuan-admin/src/main/resources/application-dev.yml

@@ -215,3 +215,6 @@ express:
 
 
 accept:
 accept:
   privateKey: JRowMMndTkSlvVORNvtJbw==
   privateKey: JRowMMndTkSlvVORNvtJbw==
+
+ownership:
+  id: ruixuan

+ 4 - 1
ruixuan-admin/src/main/resources/application-mgs.yml

@@ -210,4 +210,7 @@ express:
   callback: http://mgs.api.tjyourong.com.cn/itemCollectSamples/callback
   callback: http://mgs.api.tjyourong.com.cn/itemCollectSamples/callback
 
 
 accept:
 accept:
-  privateKey: Lj8XC4h9m639SjDsptx9Dg==
+  privateKey: Lj8XC4h9m639SjDsptx9Dg==
+
+ownership:
+  id: miaogousi

+ 4 - 1
ruixuan-admin/src/main/resources/application-prod.yml

@@ -210,4 +210,7 @@ express:
   callback: http://ruixuan.api.tjyourong.com.cn/itemCollectSamples/callback
   callback: http://ruixuan.api.tjyourong.com.cn/itemCollectSamples/callback
 
 
 accept:
 accept:
-  privateKey: JRowMMndTkSlvVORNvtJbw==
+  privateKey: JRowMMndTkSlvVORNvtJbw==
+
+ownership:
+  id: ruixuan

+ 4 - 1
ruixuan-admin/src/main/resources/application-rocket.yml

@@ -210,4 +210,7 @@ express:
   callback: http://rocket.api.tjyourong.com.cn/itemCollectSamples/callback
   callback: http://rocket.api.tjyourong.com.cn/itemCollectSamples/callback
 
 
 accept:
 accept:
-  privateKey: xKFElGEYMjCwEl49uS7+cQ==
+  privateKey: xKFElGEYMjCwEl49uS7+cQ==
+
+ownership:
+  id: rocket

+ 153 - 13
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemListController.java

@@ -14,6 +14,7 @@ import com.ruixuan.common.utils.poi.ExcelUtil;
 import com.ruixuan.isc.entity.JYOrderItemList;
 import com.ruixuan.isc.entity.JYOrderItemList;
 import com.ruixuan.isc.entity.KuaishouAccessToken;
 import com.ruixuan.isc.entity.KuaishouAccessToken;
 import com.ruixuan.isc.entity.KuaishouItemList;
 import com.ruixuan.isc.entity.KuaishouItemList;
+import com.ruixuan.isc.mapper.SupplyChainMapper;
 import com.ruixuan.isc.service.IAccessTokenService;
 import com.ruixuan.isc.service.IAccessTokenService;
 import com.ruixuan.isc.service.IKuaishouItemListService;
 import com.ruixuan.isc.service.IKuaishouItemListService;
 import com.ruixuan.isc.service.impl.CityMap;
 import com.ruixuan.isc.service.impl.CityMap;
@@ -22,6 +23,8 @@ import com.ruixuan.system.service.ISysRoleService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -58,6 +61,66 @@ public class KuaishouItemListController extends BaseController {
     private IAccessTokenService accessTokenService;
     private IAccessTokenService accessTokenService;
     @Autowired
     @Autowired
     private IBytedanceService bytedanceService;
     private IBytedanceService bytedanceService;
+    @Autowired
+    private SupplyChainMapper supplyChainMapper;
+    @Value("${ownership.id}")
+    private String ownershipId;
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @GetMapping("/cleanData")
+    @ApiOperation(value = "检查此商品是否被绑定")
+    @PostMapping
+    public void cleanData() {
+        List<JSONObject> itemList = kuaishouItemListService.getCleanData();
+        for (int i = 0; i < itemList.size(); i++) {
+            JSONObject jsonObject = itemList.get(i);
+            Long itemId = jsonObject.getLong("itemId");
+            String ownershipId = jsonObject.getString("ownershipId");
+            kuaishouItemListService.insertItemCheck(itemId, ownershipId);
+            JSONObject mongoVo = new JSONObject();
+            mongoVo.put("_id", itemId);
+            mongoVo.put("ownership", ownershipId);
+            mongoTemplate.save(mongoVo, "itemCheck");
+        }
+    }
+
+    @GetMapping("/addCategoryId")
+    @ApiOperation(value = "商品列表")
+    public void addCategoryId() {
+        try {
+            KuaishouAccessToken accessToken = accessTokenService.getAccessToken(387788401L);
+            kuaishouItemListService.addCategoryId(accessToken);
+        } catch (KsMerchantApiException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    @GetMapping("/test")
+    @ApiOperation(value = "商品列表")
+    public void test() {
+        System.err.println(ownershipId);
+        Long oid = 2304000069428849L;
+        Integer cpsOrderStatus = 30;
+        if ("ruixuan".equals(ownershipId)) {
+            int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                System.err.println(ruixuan);
+            }
+
+            int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                System.err.println(mgs);
+            }
+
+            int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                System.err.println(rocket);
+            }
+        }
+    }
 
 
 
 
     @GetMapping("/bytedanceToken")
     @GetMapping("/bytedanceToken")
@@ -91,6 +154,24 @@ public class KuaishouItemListController extends BaseController {
     }
     }
 
 
 
 
+    @GetMapping("/getDataOwnership")
+    @ApiOperation(value = "团长信息")
+    public JSONObject getDataOwnership() {
+        JSONObject returnJson = new JSONObject();
+        try {
+            List<JSONObject> list = kuaishouItemListService.getDataOwnership();
+            returnJson.put("code", 0);
+            returnJson.put("message", "success");
+            returnJson.put("data", list);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
     @GetMapping("/getActivityIds")
     @GetMapping("/getActivityIds")
     @ApiOperation(value = "活动列表")
     @ApiOperation(value = "活动列表")
     public JSONObject getActivityIds(Long userId) {
     public JSONObject getActivityIds(Long userId) {
@@ -119,7 +200,10 @@ public class KuaishouItemListController extends BaseController {
             @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
             @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
             @ApiParam("团长ID") @RequestParam(value = "regId", required = false) Long regId,
             @ApiParam("团长ID") @RequestParam(value = "regId", required = false) Long regId,
             @ApiParam("媒体ID") @RequestParam(value = "mediaId", required = false) Long mediaId,
             @ApiParam("媒体ID") @RequestParam(value = "mediaId", required = false) Long mediaId,
-            @ApiParam("类型") @RequestParam(value = "byteDanceItemType", required = false) Integer byteDanceItemType
+            @ApiParam("类型") @RequestParam(value = "byteDanceItemType", required = false) Integer byteDanceItemType,
+            @ApiParam("类型") @RequestParam(value = "userName", required = false) String userName,
+            @ApiParam("类型") @RequestParam(value = "ownershipId", required = false) String ownershipId
+
 
 
     ) {
     ) {
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
@@ -218,23 +302,84 @@ public class KuaishouItemListController extends BaseController {
     @GetMapping("/checkItem")
     @GetMapping("/checkItem")
     @ApiOperation(value = "检查此商品是否被绑定")
     @ApiOperation(value = "检查此商品是否被绑定")
     @PostMapping
     @PostMapping
-    public JSONObject checkItem(Long itemId) {
+    public JSONObject checkItem(Long itemId, String targetOwnershipId) {
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
         try {
         try {
             if (Check.isNull(itemId)) {
             if (Check.isNull(itemId)) {
                 throw new Exception("请传入商品ID");
                 throw new Exception("请传入商品ID");
             }
             }
             KuaishouItemList itemInfo = kuaishouItemListService.getItemInfoByItemId(itemId);
             KuaishouItemList itemInfo = kuaishouItemListService.getItemInfoByItemId(itemId);
-            if (Check.isNull(itemInfo)) {
-                returnJson.put("code", 0);
-                returnJson.put("message", "true");
-            } else {
-                returnJson.put("code", 1);
+            if (!Check.isNull(itemInfo)) {
+                returnJson.put("code", 500);
+                returnJson.put("success", false);
                 returnJson.put("message", "此商品已被:" + itemInfo.getUserName() + "绑定!");
                 returnJson.put("message", "此商品已被:" + itemInfo.getUserName() + "绑定!");
+                return returnJson;
+            }
+            String ownership_id = kuaishouItemListService.getItemOwnership(itemId);
+            if (!Check.isNull(ownership_id)) {
+                String s = kuaishouItemListService.selectDataOwnershipNameById(ownership_id);
+                returnJson.put("code", 500);
+                returnJson.put("success", false);
+                returnJson.put("message", "此商品已在" + s + "团下绑定!");
+                return returnJson;
+            }
+
+            if (!ownershipId.equals(targetOwnershipId)) {
+                Integer countOrder = kuaishouItemListService.checkItemData(ownershipId, itemId);
+                if (countOrder > 0) {
+                    String s = kuaishouItemListService.selectDataOwnershipNameById(ownershipId);
+                    returnJson.put("code", 500);
+                    returnJson.put("success", false);
+                    returnJson.put("message", "此商品已在" + s + "团下出单,无法选择其他团作为数据归属!");
+                    return returnJson;
+                }
             }
             }
+
+
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             returnJson.put("code", 500);
             returnJson.put("code", 500);
+            returnJson.put("success", false);
+            returnJson.put("message", e.getMessage());
+            return returnJson;
+        }
+
+        returnJson.put("code", 200);
+        returnJson.put("success", true);
+        returnJson.put("message", "true");
+        return returnJson;
+    }
+
+
+    @GetMapping("/checkUser")
+    @ApiOperation(value = "检查此商品是否被绑定")
+    @PostMapping
+    public JSONObject checkUser(String ownershipId, String userName) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(ownershipId)) {
+                throw new Exception("请选择数据归属");
+            }
+
+            if (Check.isNull(userName)) {
+                throw new Exception("用户名称不能为空");
+            }
+
+            Long userId = kuaishouItemListService.checkUser(ownershipId, userName);
+            if (!Check.isNull(userId)) {
+                returnJson.put("code", 200);
+                returnJson.put("success", true);
+            } else {
+
+                String name = kuaishouItemListService.selectDataOwnershipNameById(ownershipId);
+                returnJson.put("code", 500);
+                returnJson.put("success", false);
+                returnJson.put("message", name + "下未查询到" + userName + ",请联系管理员进行开户");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 500);
+            returnJson.put("success", false);
             returnJson.put("message", e.getMessage());
             returnJson.put("message", e.getMessage());
         }
         }
         return returnJson;
         return returnJson;
@@ -326,11 +471,6 @@ public class KuaishouItemListController extends BaseController {
     }
     }
 
 
 
 
-    @GetMapping("/addCategoryId")
-    public void addCategoryId() throws KsMerchantApiException {
-        //   kuaishouItemListService.addCategoryId();
-    }
-
     @GetMapping("/getCategoryIds")
     @GetMapping("/getCategoryIds")
     public List<JSONObject> getCategoryIds() {
     public List<JSONObject> getCategoryIds() {
         List<JSONObject> array = kuaishouItemListService.getCategoryIds();
         List<JSONObject> array = kuaishouItemListService.getCategoryIds();
@@ -426,7 +566,7 @@ public class KuaishouItemListController extends BaseController {
             }
             }
             KuaishouItemList update = new KuaishouItemList();
             KuaishouItemList update = new KuaishouItemList();
             update.setItemId(itemId);
             update.setItemId(itemId);
-            Long relateId = kuaishouItemListService.selectMaxRelateId();
+            Long relateId = kuaishouItemListService.selectMaxRelateId(ownershipId);
             update.setRelateId(relateId + 1);
             update.setRelateId(relateId + 1);
             int i = kuaishouItemListService.updateKuaishouItemList(update);
             int i = kuaishouItemListService.updateKuaishouItemList(update);
             if (i > 0) {
             if (i > 0) {

+ 0 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -2031,7 +2031,6 @@ public class SupplyChainController extends BaseController {
 
 
     @PostMapping(value = "/accept")
     @PostMapping(value = "/accept")
     public Map<String, Object> acceptEvent(@RequestBody String eventsEncoded) {
     public Map<String, Object> acceptEvent(@RequestBody String eventsEncoded) {
-        // System.err.println(eventsEncoded);
         try {
         try {
             String events = PlatformEventSecurityUtil.decode(eventsEncoded, privateKey);
             String events = PlatformEventSecurityUtil.decode(eventsEncoded, privateKey);
             JSONObject eventJSon = JSONObject.parseObject(events);
             JSONObject eventJSon = JSONObject.parseObject(events);

+ 21 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/ItemCheck.java

@@ -0,0 +1,21 @@
+package com.ruixuan.isc.entity;
+
+import lombok.Data;
+
+
+@Data
+public class ItemCheck {
+
+    private String _id;
+
+    private String ownership;
+
+
+    public ItemCheck() {
+    }
+
+    public ItemCheck(String id, String ownership) {
+        this._id = id;
+        this.ownership = ownership;
+    }
+}

+ 13 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemList.java

@@ -231,6 +231,10 @@ public class KuaishouItemList extends BaseEntity {
     private String ruleName;
     private String ruleName;
     @Transient
     @Transient
     private String mediaName;
     private String mediaName;
+
+    @Transient
+    private String ownershipId;
+
     private Integer samplesReceived;
     private Integer samplesReceived;
     private Integer samplesPeoples;
     private Integer samplesPeoples;
 
 
@@ -238,10 +242,6 @@ public class KuaishouItemList extends BaseEntity {
     private Long ruleId;
     private Long ruleId;
 
 
 
 
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
     public Long getItemId() {
     public Long getItemId() {
         return itemId;
         return itemId;
     }
     }
@@ -570,6 +570,14 @@ public class KuaishouItemList extends BaseEntity {
         this.mediaName = mediaName;
         this.mediaName = mediaName;
     }
     }
 
 
+    public String getOwnershipId() {
+        return ownershipId;
+    }
+
+    public void setOwnershipId(String ownershipId) {
+        this.ownershipId = ownershipId;
+    }
+
     public Integer getSamplesReceived() {
     public Integer getSamplesReceived() {
         return samplesReceived;
         return samplesReceived;
     }
     }
@@ -646,6 +654,7 @@ public class KuaishouItemList extends BaseEntity {
                 ", validAmount=" + validAmount +
                 ", validAmount=" + validAmount +
                 ", ruleName='" + ruleName + '\'' +
                 ", ruleName='" + ruleName + '\'' +
                 ", mediaName='" + mediaName + '\'' +
                 ", mediaName='" + mediaName + '\'' +
+                ", ownershipId='" + ownershipId + '\'' +
                 ", samplesReceived=" + samplesReceived +
                 ", samplesReceived=" + samplesReceived +
                 ", samplesPeoples=" + samplesPeoples +
                 ", samplesPeoples=" + samplesPeoples +
                 ", relateId=" + relateId +
                 ", relateId=" + relateId +

+ 29 - 3
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouItemListMapper.java

@@ -23,7 +23,7 @@ public interface KuaishouItemListMapper {
 
 
     KuaishouItemList getItemInfoByItemId(Long itemId);
     KuaishouItemList getItemInfoByItemId(Long itemId);
 
 
-    void insertItem(KuaishouItemList kuaishouItemList);
+    void insertItem(@Param("kuaishouItemList") KuaishouItemList kuaishouItemList, @Param("ownershipId") String ownershipId);
 
 
     int updateKuaishouItemList(KuaishouItemList kuaishouItemList);
     int updateKuaishouItemList(KuaishouItemList kuaishouItemList);
 
 
@@ -33,7 +33,7 @@ public interface KuaishouItemListMapper {
 
 
     KuaishouItemCategory getCategoryInfo(@Param("categoryId") Long categoryId);
     KuaishouItemCategory getCategoryInfo(@Param("categoryId") Long categoryId);
 
 
-    void insertItemBindUser(@Param("itemId") Long itemId, @Param("userId") Long userId, @Param("userName") String userName);
+    void insertItemBindUser(@Param("itemId") Long itemId, @Param("userId") Long userId, @Param("userName") String userName, @Param("targetOwnershipId") String targetOwnershipId);
 
 
     Long getIdByName(@Param("categoryName") String categoryName);
     Long getIdByName(@Param("categoryName") String categoryName);
 
 
@@ -53,7 +53,7 @@ public interface KuaishouItemListMapper {
 
 
     List<JSONObject> getRegimental();
     List<JSONObject> getRegimental();
 
 
-    Long selectMaxRelateId();
+    Long selectMaxRelateId(@Param("targetOwnershipId") String targetOwnershipId);
 
 
     List<JSONObject> getListByRelateId(@Param("relateId") Long relateId);
     List<JSONObject> getListByRelateId(@Param("relateId") Long relateId);
 
 
@@ -64,5 +64,31 @@ public interface KuaishouItemListMapper {
     JSONObject selectRuleItemByItemId(@Param("itemId") Long itemId);
     JSONObject selectRuleItemByItemId(@Param("itemId") Long itemId);
 
 
     List<JYOrderItemList> getJYOrderItemList(@Param("itemTitle") String itemTitle, @Param("startDate") String startDate, @Param("endDate") String endDate);
     List<JYOrderItemList> getJYOrderItemList(@Param("itemTitle") String itemTitle, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> getDataOwnership();
+
+    Long checkUser(@Param("ownershipId") String ownershipId, @Param("userName") String userName);
+
+    String selectDataOwnershipNameById(@Param("ownershipId") String ownershipId);
+
+    JSONObject getUserInfo(@Param("userName") String userName, @Param("targetOwnershipId") String targetOwnershipId);
+
+    void insertRuiXuanItem(KuaishouItemList kuaishouItemList);
+
+    void insertMiaoGouSiItem(KuaishouItemList kuaishouItemList);
+
+    void insertRocketItem(KuaishouItemList kuaishouItemList);
+
+    void insertItemCheck(@Param("itemId") Long itemId, @Param("targetOwnershipId") String targetOwnershipId);
+
+    String getItemOwnership(@Param("itemId") Long itemId);
+
+    List<JSONObject> getCleanData();
+
+    Integer checkItemData(@Param("ownershipId") String ownershipId, @Param("itemId") Long itemId);
+
+    void batchMgsCategory(@Param("adds") List<KuaishouItemCategory> adds);
+
+    void batchRocketCategory(@Param("adds") List<KuaishouItemCategory> adds);
 }
 }
 
 

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

@@ -193,4 +193,16 @@ public interface SupplyChainMapper {
     List<JSONObject> getBytedanceCourtshipGmvHourByDate(@Param("userList") List<Long> userList, @Param("date") Long date);
     List<JSONObject> getBytedanceCourtshipGmvHourByDate(@Param("userList") List<Long> userList, @Param("date") Long date);
 
 
     List<JSONObject> getPromoterId(@Param("promoterId") Long promoterId);
     List<JSONObject> getPromoterId(@Param("promoterId") Long promoterId);
+
+    int updateRuiXuanOrderRegimentalSettleAmount(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
+
+    int updateMgsOrderRegimentalSettleAmount(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
+
+    int updateRocketOrderRegimentalSettleAmount(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
+
+    int updateRuixuanOrder(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
+
+    int updateMgsOrder(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
+
+    int updateRocketOrder(@Param("oid") Long oid, @Param("cpsOrderStatus") Integer cpsOrderStatus);
 }
 }

+ 17 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouItemListService.java

@@ -2,6 +2,7 @@ package com.ruixuan.isc.service;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.kuaishou.merchant.open.api.KsMerchantApiException;
 import com.ruixuan.isc.entity.JYOrderItemList;
 import com.ruixuan.isc.entity.JYOrderItemList;
 import com.ruixuan.isc.entity.KuaishouAccessToken;
 import com.ruixuan.isc.entity.KuaishouAccessToken;
 import com.ruixuan.isc.entity.KuaishouItemList;
 import com.ruixuan.isc.entity.KuaishouItemList;
@@ -31,7 +32,7 @@ public interface IKuaishouItemListService {
 
 
     int deleteKuaishouItemListByItemIds(Long[] itemIds);
     int deleteKuaishouItemListByItemIds(Long[] itemIds);
 
 
-    //  int addCategoryId() throws KsMerchantApiException;
+      int addCategoryId(KuaishouAccessToken accessToken) throws KsMerchantApiException;
 
 
     List<JSONObject> getCategoryIds();
     List<JSONObject> getCategoryIds();
 
 
@@ -49,7 +50,7 @@ public interface IKuaishouItemListService {
 
 
     List<JSONObject> getListByRelateId(Long relateId);
     List<JSONObject> getListByRelateId(Long relateId);
 
 
-    Long selectMaxRelateId();
+    Long selectMaxRelateId(String ownershipId);
 
 
     JSONObject selectRuleItemByItemId(Long itemId);
     JSONObject selectRuleItemByItemId(Long itemId);
 
 
@@ -58,5 +59,19 @@ public interface IKuaishouItemListService {
     JSONObject getInvestmentActivityOpenItemList(Long activityId, Long itemId, KuaishouAccessToken accessToken);
     JSONObject getInvestmentActivityOpenItemList(Long activityId, Long itemId, KuaishouAccessToken accessToken);
 
 
     List<JYOrderItemList> getJYOrderItemList(String itemTitle, String startDate, String endDate);
     List<JYOrderItemList> getJYOrderItemList(String itemTitle, String startDate, String endDate);
+
+    List<JSONObject> getDataOwnership();
+
+    Long checkUser(String ownershipId, String userName);
+
+    String selectDataOwnershipNameById(String ownershipId);
+
+    String getItemOwnership(Long itemId);
+
+    List<JSONObject> getCleanData();
+
+    void insertItemCheck(Long itemId, String ownershipId);
+
+    Integer checkItemData(String ownershipId, Long itemId);
 }
 }
 
 

+ 186 - 207
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemListServiceImpl.java

@@ -9,9 +9,11 @@ import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityInvalidItemListRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityInvalidItemListRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityItemDetailRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityItemDetailRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenItemListRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityOpenItemListRequest;
+import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionPublicCategoryListRequest;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityInvalidItemListResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityInvalidItemListResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityItemDetailResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityItemDetailResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenItemListResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenItemListResponse;
+import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionPublicCategoryListResponse;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.KsHttpUtils;
 import com.ruixuan.common.utils.KsHttpUtils;
 import com.ruixuan.isc.constants.KuaiShouConstants;
 import com.ruixuan.isc.constants.KuaiShouConstants;
@@ -24,6 +26,8 @@ import com.ruixuan.isc.mapper.SupplyChainMapper;
 import com.ruixuan.isc.service.IKuaishouItemListService;
 import com.ruixuan.isc.service.IKuaishouItemListService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -31,6 +35,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
+import static com.kuaishou.merchant.open.api.common.Constants.Sign.ACCESS_TOKEN;
+import static com.ruixuan.isc.constants.KuaiShouConstants.APP_KEY;
+
 
 
 /**
 /**
  * 【请填写功能名称】Service业务层处理
  * 【请填写功能名称】Service业务层处理
@@ -46,6 +53,11 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
     private static List<JSONObject> categoryIds;
     private static List<JSONObject> categoryIds;
     @Autowired
     @Autowired
     private SupplyChainMapper supplyChainMapper;
     private SupplyChainMapper supplyChainMapper;
+    @Value("${ownership.id}")
+    private String ownershipId;
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
 
 
     private static final String URL = "https://openapi.kwaixiaodian.com";
     private static final String URL = "https://openapi.kwaixiaodian.com";
 
 
@@ -158,165 +170,35 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
     }
     }
 
 
 
 
-    private JSONObject getInvaliItemDetail(Long regId, Long activityId, Long itemId) throws Exception {
-        JSONObject returnJson = new JSONObject();
-        String cookie = supplyChainMapper.getCookie(regId);
-        Map<String, Object> params = new HashMap<>();
-        params.put("retryLimit", true);
-        params.put("carrierType", 0);
-        params.put("itemId", itemId);
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Cookie", cookie);
-        String referer = "https://app.kwaixiaodian.com/page/kwaishop-goods-detail-h5-vue/detail?id=&hyId=kwaishop-goods-detail-h5-vue&_refer=null_refer";
-        String str = "?id=" + itemId;
-        String replace = referer.replace("?id=", str);
-        headers.put("Referer", replace);
-        String resultStr = KsHttpUtils.KuaiShouttpGetRequest("https://app.kwaixiaodian.com/rest/app/grocery/product/self/detail", params, headers);
-        JSONObject result = JSONObject.parseObject(resultStr);
-        if (Check.isNull(result)) {
-            log.error("快分销招商商品数据返回为空");
-            returnJson.put("code", -1);
-            returnJson.put("message", "获取商品信息为空");
-            return returnJson;
-        }
-        Integer code = result.getInteger("result");
-        if (code != 1) {
-            log.info("快分销招商商品数据返回异常:{}", resultStr);
-            returnJson.put("code", -1);
-            returnJson.put("message", "增加快手商品信息抓取失败,请联系技术人员");
-            return returnJson;
-        }
-       /* JSONArray dataArray = result.getJSONArray("data");
-        if (Check.isNull(dataArray)) {
-            log.error("快分销招商商品数据返回为data数据为空");
-            returnJson.put("code", -1);
-            returnJson.put("message", "快分销招商商品数据返回为data数据为空");
-            return returnJson;
-        }*/
-        JSONObject itemJson = new JSONObject();
-        itemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
-        /*String itemCategoryName = itemJson.getString("itemCategoryName");
-        if (!Check.isNull(itemCategoryName)) {
-            String[] split = itemCategoryName.split(">");
-            if (!Check.isNull(split)) {
-                String categoryName = split[0];
-                Long categoryId = kuaishouItemListMapper.getIdByName(categoryName);
-                if (!Check.isNull(categoryId)) {
-                    itemJson.put("categoryId", categoryId);
-                }
-            }
-        }*/
-
-
-        JSONObject productDetail = result.getJSONObject("productDetail");
-        if (!Check.isNull(productDetail)) {
-
-        }
-
-        itemJson.put("commissionRate", itemJson.getLong("itemCommissionRate"));
-        itemJson.put("regimentalPromotionRate", itemJson.getLong("investmentPromotionRate"));
-        JSONObject otherInfo = getOtherInfo(itemId, cookie);
-        if (!Check.isNull(otherInfo)) {
-            itemJson.put("postArea", otherInfo.getString("postArea"));
-            itemJson.put("deliveryRate", otherInfo.getString("deliveryRate"));
-            itemJson.put("itemDescUrls", otherInfo.getJSONArray("itemDescUrls"));
-            itemJson.put("itemGalleryUrls", otherInfo.getJSONArray("itemGalleryUrls"));
-        }
-        returnJson.put("judgeStatus", 2);
-        returnJson.put("itemJson", itemJson);
-        returnJson.put("code", 0);
-        returnJson.put("message", "查询成功");
-        return returnJson;
-    }
-
-
-    private JSONObject getOtherInfo(Long itemId, String cookie) throws Exception {
-        JSONObject returnJson = new JSONObject();
-        Map<String, Object> params = new HashMap<>();
-        params.put("itemId", itemId);
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Cookie", cookie);
-        String resultStr = KsHttpUtils.KuaiShouttpGetRequest("https://app.kwaixiaodian.com/rest/app/grocery/product/self/detail", params, headers);
-        JSONObject result = JSONObject.parseObject(resultStr);
-        if (!Check.isNull(result)) {
-            JSONObject productDetail = result.getJSONObject("productDetail");
-            if (!Check.isNull(productDetail)) {
-                JSONObject expressTemplate = productDetail.getJSONObject("expressTemplate");
-                if (!Check.isNull(expressTemplate)) {
-                    String sendProvinceName = expressTemplate.getString("sendProvinceName");
-                    String sendCityName = expressTemplate.getString("sendCityName");
-                    if (Check.isNull(sendCityName)) {
-                        returnJson.put("postArea", sendProvinceName);
-                    } else {
-                        returnJson.put("postArea", sendProvinceName + "-" + sendCityName);
-                    }
-                }
-                JSONObject expressInfo = productDetail.getJSONObject("expressInfo");
-                if (!Check.isNull(expressInfo)) {
-                    String deliveryDesc = expressInfo.getString("deliveryDesc");
-                    returnJson.put("deliveryRate", deliveryDesc);
-                }
-                // itemDescUrls 商品详情图
-                JSONArray itemDescUrls = productDetail.getJSONArray("detailImageUrls");
-                if (!Check.isNull(itemDescUrls)) {
-                    returnJson.put("itemDescUrls", itemDescUrls);
-                }
-                // 轮播图
-                JSONArray itemGalleryUrls = productDetail.getJSONArray("imageUrls");
-                if (!Check.isNull(itemGalleryUrls)) {
-                    returnJson.put("itemGalleryUrls", itemGalleryUrls);
-                }
-            }
-        }
-        return returnJson;
-    }
-
-    public static void main(String[] args) {
-        String referer = "https://app.kwaixiaodian.com/page/kwaishop-goods-detail-h5-vue/detail?id=&hyId=kwaishop-goods-detail-h5-vue&_refer=null_refer";
-        String str = "?id=" + 122;
-        String replace = referer.replace("?id=", str);
-        System.err.println(replace);
-    }
-
     private JSONObject getCategoryInfo(Long categoryId) {
     private JSONObject getCategoryInfo(Long categoryId) {
         if (Check.isNull(categoryId)) {
         if (Check.isNull(categoryId)) {
             return null;
             return null;
         }
         }
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
-        StringBuffer stringBuffer = new StringBuffer();
         KuaishouItemCategory category = kuaishouItemListMapper.getCategoryInfo(categoryId);
         KuaishouItemCategory category = kuaishouItemListMapper.getCategoryInfo(categoryId);
         if (Check.isNull(category)) {
         if (Check.isNull(category)) {
             return null;
             return null;
         }
         }
-        KuaishouItemCategory secondCategory = new KuaishouItemCategory();
-        KuaishouItemCategory thirdCategory = new KuaishouItemCategory();
-        KuaishouItemCategory fourthCategory = new KuaishouItemCategory();
-        Long id = null;
-        if (category.getCategorySort() == 1) {
-            id = categoryId;
-            stringBuffer.append(category.getCategoryName());
-        } else if (category.getCategorySort() == 2) {
-            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
-            stringBuffer.append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
-            id = secondCategory.getCategoryId();
-        } else if (category.getCategorySort() == 3) {
-            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
-            thirdCategory = kuaishouItemListMapper.getCategoryInfo(secondCategory.getParentId());
-            stringBuffer.append(thirdCategory.getCategoryName()).append(">").append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
-            id = thirdCategory.getCategoryId();
-        } else if (category.getCategorySort() == 4) {
-            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
-            thirdCategory = kuaishouItemListMapper.getCategoryInfo(secondCategory.getParentId());
-            fourthCategory = kuaishouItemListMapper.getCategoryInfo(thirdCategory.getParentId());
-            stringBuffer.append(fourthCategory.getCategoryName()).append(">").append(thirdCategory.getCategoryName()).append(">").append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
-            id = fourthCategory.getCategoryId();
+        Long parentId = category.getParentId();
+        if (parentId == 0) {
+            returnJson.put("categoryName", category.getCategoryName());
+            returnJson.put("categoryId", categoryId);
+            return returnJson;
         }
         }
-
-        returnJson.put("categoryName", stringBuffer.toString());
-        returnJson.put("categoryId", id);
+        StringBuilder stringBuild = new StringBuilder(category.getCategoryName());
+
+        for (int i = 0; i < 10; i++) {
+            stringBuild.insert(0, ">");
+            category = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
+            stringBuild.insert(0, category.getCategoryName());
+            if (category.getParentId() == 0) {
+                categoryId = category.getCategoryId();
+                break;
+            }
+        }
+        returnJson.put("categoryName", stringBuild.toString());
+        returnJson.put("categoryId", categoryId);
         return returnJson;
         return returnJson;
-
-
     }
     }
 
 
     @Override
     @Override
@@ -324,16 +206,39 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         return kuaishouItemListMapper.getItemInfoByItemId(itemId);
         return kuaishouItemListMapper.getItemInfoByItemId(itemId);
     }
     }
 
 
+
     @Override
     @Override
     public void insertItem(KuaishouItemList kuaishouItemList) {
     public void insertItem(KuaishouItemList kuaishouItemList) {
-        Long relateId = kuaishouItemListMapper.selectMaxRelateId();
+
+        String targetOwnershipId = kuaishouItemList.getOwnershipId(); // 目标数据库
+        if (!targetOwnershipId.equals(ownershipId)) { // 如果目标数据库与当前连接数据库不一致 则去目标数据库查询用户信息
+            JSONObject userInfo = kuaishouItemListMapper.getUserInfo(kuaishouItemList.getUserName(), targetOwnershipId);
+            if (!Check.isNull(userInfo)) {
+                kuaishouItemList.setUserId(userInfo.getLong("userId"));
+                kuaishouItemList.setUserName(userInfo.getString("userName"));
+            }
+        }
+        Long relateId = kuaishouItemListMapper.selectMaxRelateId(targetOwnershipId);
         if (Check.isNull(relateId)) {
         if (Check.isNull(relateId)) {
             kuaishouItemList.setRelateId(1L);
             kuaishouItemList.setRelateId(1L);
         } else {
         } else {
             kuaishouItemList.setRelateId(relateId + 1);
             kuaishouItemList.setRelateId(relateId + 1);
         }
         }
-        kuaishouItemListMapper.insertItem(kuaishouItemList);
-        kuaishouItemListMapper.insertItemBindUser(kuaishouItemList.getItemId(), kuaishouItemList.getUserId(), kuaishouItemList.getUserName());
+        if (targetOwnershipId.equals("ruixuan")) {
+            kuaishouItemListMapper.insertRuiXuanItem(kuaishouItemList);
+        }
+        if (targetOwnershipId.equals("miaogousi")) {
+            kuaishouItemListMapper.insertMiaoGouSiItem(kuaishouItemList);
+        }
+        if (targetOwnershipId.equals("rocket")) {
+            kuaishouItemListMapper.insertRocketItem(kuaishouItemList);
+        }
+        JSONObject mongoVo = new JSONObject();
+        mongoVo.put("_id", kuaishouItemList.getItemId());
+        mongoVo.put("ownership", targetOwnershipId);
+        mongoTemplate.save(mongoVo, "itemCheck");
+        kuaishouItemListMapper.insertItemCheck(kuaishouItemList.getItemId(), targetOwnershipId);
+        kuaishouItemListMapper.insertItemBindUser(kuaishouItemList.getItemId(), kuaishouItemList.getUserId(), kuaishouItemList.getUserName(), targetOwnershipId);
     }
     }
 
 
     @Override
     @Override
@@ -346,76 +251,115 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         return kuaishouItemListMapper.deleteKuaishouItemListByItemIds(itemIds);
         return kuaishouItemListMapper.deleteKuaishouItemListByItemIds(itemIds);
     }
     }
 
 
-  /*  @Override
-    public int addCategoryId() throws KsMerchantApiException {
-        String url = "https://openapi.kwaixiaodian.com";
-        String appKey = "ks665688320292774929";
-        String signSecret = "8e21f5bc03b6d2dc63e6256225dac00b";
-        String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJgT28Jn3uMkkU0sSjL_30Jd2X6QCz4B2bs9IsMrIJe1S3J4PhjkaBYIU13FGpBlmy73rx7X-cyNUuuOxKeOloFQeQFZ2Ka8jm_HwDYtqoaoVVm-Y06ILVaPrfs6SjVB84QGhL_b_zNSCZFGYoK2F52yMh0D74iILO5AYTiyqLP-3W1aZ-dql11qIkyhjgvYLXyoNplPgoNKAUwAQ";
-        AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(URL, APP_KEY, SIGN_SECRET);
+    @Override
+    public int addCategoryId(KuaishouAccessToken accessToken) throws KsMerchantApiException {
+        AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(URL, accessToken.getAppKey(), accessToken.getSignSecret());
         OpenDistributionPublicCategoryListRequest request = new OpenDistributionPublicCategoryListRequest();
         OpenDistributionPublicCategoryListRequest request = new OpenDistributionPublicCategoryListRequest();
-        request.setAccessToken(ACCESS_TOKEN);
+        request.setAccessToken(accessToken.getAccessToken());
         request.setApiMethodVersion(1L);
         request.setApiMethodVersion(1L);
         OpenDistributionPublicCategoryListResponse response = client.execute(request);
         OpenDistributionPublicCategoryListResponse response = client.execute(request);
         JSONObject jsonObject = JSONObject.parseObject(GsonUtils.toJSON(response));
         JSONObject jsonObject = JSONObject.parseObject(GsonUtils.toJSON(response));
         JSONArray data = jsonObject.getJSONArray("data");
         JSONArray data = jsonObject.getJSONArray("data");
         List<KuaishouItemCategory> adds = new ArrayList<>();
         List<KuaishouItemCategory> adds = new ArrayList<>();
-
         for (int i = 0; i < data.size(); i++) {
         for (int i = 0; i < data.size(); i++) {
-            JSONObject first = data.getJSONObject(i);
-            KuaishouItemCategory firstCategory = new KuaishouItemCategory();
-            firstCategory.setCategoryId(first.getLong("categoryId"));
-            firstCategory.setCategoryName(first.getString("categoryName"));
-            firstCategory.setCategorySort(1);
-            firstCategory.setParentId(1L);
-            Long firstCategoryId = first.getLong("categoryId");
-            adds.add(firstCategory);
-            JSONArray secondChildCategory = first.getJSONArray("childCategory");
-            if (!Check.isNull(secondChildCategory)) {
-                for (int j = 0; j < secondChildCategory.size(); j++) {
-                    JSONObject second = secondChildCategory.getJSONObject(j);
-                    KuaishouItemCategory secondCategory = new KuaishouItemCategory();
-                    secondCategory.setParentId(firstCategoryId);
-                    secondCategory.setCategoryId(second.getLong("categoryId"));
-                    secondCategory.setCategoryName(second.getString("categoryName"));
-                    secondCategory.setCategorySort(2);
-                    Long secondCategoryId = second.getLong("categoryId");
-                    adds.add(secondCategory);
-                    JSONArray thirdChildCategory = second.getJSONArray("childCategory");
-                    if (!Check.isNull(thirdChildCategory)) {
-                        for (int k = 0; k < thirdChildCategory.size(); k++) {
-                            JSONObject third = thirdChildCategory.getJSONObject(k);
-                            KuaishouItemCategory thirdCategory = new KuaishouItemCategory();
-                            thirdCategory.setParentId(secondCategoryId);
-                            thirdCategory.setCategoryId(third.getLong("categoryId"));
-                            thirdCategory.setCategoryName(third.getString("categoryName"));
-                            thirdCategory.setCategorySort(3);
-                            Long thirdCategoryId = third.getLong("categoryId");
-                            adds.add(thirdCategory);
-                            JSONArray fourthChildCategory = third.getJSONArray("childCategory ");
-                            if (!Check.isNull(fourthChildCategory)) {
-                                for (int l = 0; l < fourthChildCategory.size(); l++) {
-                                    JSONObject fourth = fourthChildCategory.getJSONObject(l);
-                                    KuaishouItemCategory fourthCategory = new KuaishouItemCategory();
-                                    fourthCategory.setParentId(thirdCategoryId);
-                                    fourthCategory.setCategoryId(fourth.getLong("categoryId"));
-                                    fourthCategory.setCategoryName(fourth.getString("categoryName"));
-                                    fourthCategory.setCategorySort(4);
-                                    adds.add(fourthCategory);
+            KuaishouItemCategory addCategory = new KuaishouItemCategory();
+            JSONObject category = data.getJSONObject(i);
+            Long categoryId = category.getLong("categoryId");
+            String categoryName = category.getString("categoryName");
+            Integer categorySort = category.getInteger("sortNum");
+            Long categoryPid = category.getLong("categoryPid");
+            addCategory.setCategoryId(categoryId);
+            addCategory.setCategoryName(categoryName);
+            addCategory.setCategorySort(categorySort);
+            addCategory.setParentId(categoryPid);
+            adds.add(addCategory);
+            JSONArray childCategory = category.getJSONArray("childCategory");
+            if (!Check.isNull(childCategory)) {
+                for (int j = 0; j < childCategory.size(); j++) {
+                    KuaishouItemCategory addCategory1 = new KuaishouItemCategory();
+                    JSONObject category1 = childCategory.getJSONObject(j);
+                    Long categoryId1 = category1.getLong("categoryId");
+                    String categoryName1 = category1.getString("categoryName");
+                    Integer categorySort1 = category1.getInteger("sortNum");
+                    Long categoryPid1 = category1.getLong("categoryPid");
+                    addCategory1.setCategoryId(categoryId1);
+                    addCategory1.setCategoryName(categoryName1);
+                    addCategory1.setCategorySort(categorySort1);
+                    addCategory1.setParentId(categoryPid1);
+                    adds.add(addCategory1);
+                    JSONArray category2 = category1.getJSONArray("childCategory");
+                    if (!Check.isNull(category2)) {
+                        for (int k = 0; k < category2.size(); k++) {
+                            KuaishouItemCategory addCategory2 = new KuaishouItemCategory();
+                            JSONObject categoryJson2 = category2.getJSONObject(k);
+                            Long categoryId2 = categoryJson2.getLong("categoryId");
+                            String categoryName2 = categoryJson2.getString("categoryName");
+                            Integer categorySort2 = categoryJson2.getInteger("sortNum");
+                            Long categoryPid2 = categoryJson2.getLong("categoryPid");
+                            addCategory2.setCategoryId(categoryId2);
+                            addCategory2.setCategoryName(categoryName2);
+                            addCategory2.setCategorySort(categorySort2);
+                            addCategory2.setParentId(categoryPid2);
+                            adds.add(addCategory2);
+                            JSONArray category3 = categoryJson2.getJSONArray("childCategory");
+                            if (!Check.isNull(category3)) {
+                                for (int l = 0; l < category3.size(); l++) {
+                                    KuaishouItemCategory addCategory3 = new KuaishouItemCategory();
+                                    JSONObject categoryJson3 = category3.getJSONObject(l);
+                                    Long categoryId3 = categoryJson3.getLong("categoryId");
+                                    String categoryName3 = categoryJson3.getString("categoryName");
+                                    Integer categorySort3 = categoryJson3.getInteger("sortNum");
+                                    Long categoryPid3 = categoryJson3.getLong("categoryPid");
+                                    addCategory3.setCategoryId(categoryId3);
+                                    addCategory3.setCategoryName(categoryName3);
+                                    addCategory3.setCategorySort(categorySort3);
+                                    addCategory3.setParentId(categoryPid3);
+                                    adds.add(addCategory3);
+                                    JSONArray category4 = categoryJson3.getJSONArray("childCategory");
+                                    if (!Check.isNull(category4)) {
+                                        for (int m = 0; m < category4.size(); m++) {
+                                            KuaishouItemCategory addCategory4 = new KuaishouItemCategory();
+                                            JSONObject categoryJson4 = category4.getJSONObject(m);
+                                            Long categoryId4 = categoryJson4.getLong("categoryId");
+                                            String categoryName4 = categoryJson4.getString("categoryName");
+                                            Integer categorySort4 = categoryJson4.getInteger("sortNum");
+                                            Long categoryPid4 = categoryJson4.getLong("categoryPid");
+                                            addCategory4.setCategoryId(categoryId4);
+                                            addCategory4.setCategoryName(categoryName4);
+                                            addCategory4.setCategorySort(categorySort4);
+                                            addCategory4.setParentId(categoryPid4);
+                                            adds.add(addCategory4);
+                                            JSONArray category5 = categoryJson4.getJSONArray("childCategory");
+                                            if (!Check.isNull(category5)) {
+                                                for (int n = 0; n < category5.size(); n++) {
+                                                    KuaishouItemCategory addCategory5 = new KuaishouItemCategory();
+                                                    JSONObject categoryJson5 = category5.getJSONObject(n);
+                                                    Long categoryId5 = categoryJson5.getLong("categoryId");
+                                                    String categoryName5 = categoryJson5.getString("categoryName");
+                                                    Integer categorySort5 = categoryJson5.getInteger("sortNum");
+                                                    Long categoryPid5 = categoryJson5.getLong("categoryPid");
+                                                    addCategory5.setCategoryId(categoryId5);
+                                                    addCategory5.setCategoryName(categoryName5);
+                                                    addCategory5.setCategorySort(categorySort5);
+                                                    addCategory5.setParentId(categoryPid5);
+                                                    adds.add(addCategory5);
+                                                }
+                                            }
+                                        }
+                                    }
                                 }
                                 }
                             }
                             }
                         }
                         }
                     }
                     }
                 }
                 }
-
             }
             }
-
-
         }
         }
         kuaishouItemListMapper.batchCategory(adds);
         kuaishouItemListMapper.batchCategory(adds);
-        System.err.println(jsonObject);
+        kuaishouItemListMapper.batchMgsCategory(adds);
+        kuaishouItemListMapper.batchRocketCategory(adds);
+
         return 0;
         return 0;
-    }*/
+    }
 
 
     @Override
     @Override
     public List<JSONObject> getCategoryIds() {
     public List<JSONObject> getCategoryIds() {
@@ -461,8 +405,8 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
     }
     }
 
 
     @Override
     @Override
-    public Long selectMaxRelateId() {
-        return kuaishouItemListMapper.selectMaxRelateId();
+    public Long selectMaxRelateId(String ownershipId) {
+        return kuaishouItemListMapper.selectMaxRelateId(ownershipId);
     }
     }
 
 
     @Override
     @Override
@@ -540,6 +484,41 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         return kuaishouItemListMapper.getJYOrderItemList(itemTitle, startDate, endDate);
         return kuaishouItemListMapper.getJYOrderItemList(itemTitle, startDate, endDate);
     }
     }
 
 
+    @Override
+    public List<JSONObject> getDataOwnership() {
+        return kuaishouItemListMapper.getDataOwnership();
+    }
+
+    @Override
+    public Long checkUser(String ownershipId, String userName) {
+        return kuaishouItemListMapper.checkUser(ownershipId, userName);
+    }
+
+    @Override
+    public String selectDataOwnershipNameById(String ownershipId) {
+        return kuaishouItemListMapper.selectDataOwnershipNameById(ownershipId);
+    }
+
+    @Override
+    public String getItemOwnership(Long itemId) {
+        return kuaishouItemListMapper.getItemOwnership(itemId);
+    }
+
+    @Override
+    public List<JSONObject> getCleanData() {
+        return kuaishouItemListMapper.getCleanData();
+    }
+
+    @Override
+    public void insertItemCheck(Long itemId, String ownershipId) {
+        kuaishouItemListMapper.insertItemCheck(itemId, ownershipId);
+    }
+
+    @Override
+    public Integer checkItemData(String ownershipId, Long itemId) {
+        return kuaishouItemListMapper.checkItemData(ownershipId, itemId);
+    }
+
 
 
 }
 }
 
 

+ 225 - 23
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -13,16 +13,17 @@ import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInve
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenListResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityOpenListResponse;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.DateUtils;
-import com.ruixuan.isc.entity.KuaiShouActivityInfo;
-import com.ruixuan.isc.entity.KuaiShouActivityOpenItemList;
-import com.ruixuan.isc.entity.KuaishouAccessToken;
-import com.ruixuan.isc.entity.KuaishouSupplyChain;
+import com.ruixuan.isc.entity.*;
 import com.ruixuan.isc.mapper.KuaishouItemListMapper;
 import com.ruixuan.isc.mapper.KuaishouItemListMapper;
 import com.ruixuan.isc.mapper.SupplyChainMapper;
 import com.ruixuan.isc.mapper.SupplyChainMapper;
 import com.ruixuan.isc.service.IAccessTokenService;
 import com.ruixuan.isc.service.IAccessTokenService;
 import com.ruixuan.isc.service.ISupplyChainService;
 import com.ruixuan.isc.service.ISupplyChainService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -41,6 +42,10 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
 
 
     @Autowired
     @Autowired
     private IAccessTokenService accessTokenService;
     private IAccessTokenService accessTokenService;
+    @Value("${ownership.id}")
+    private String ownershipId;
+    @Autowired
+    private MongoTemplate mongoTemplate;
 
 
     // 获取订单数据 
     // 获取订单数据 
     @Override
     @Override
@@ -401,19 +406,119 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                     return;
                     return;
                 }
                 }
                 if (cpsOrderStatus == 60) {
                 if (cpsOrderStatus == 60) {
-                    supplyChainMapper.updateOrderRegimentalSettleAmount(oid, cpsOrderStatus);
-
+                    Integer i = updateOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+                    if (i > 0) {
+                        log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
+                    } else {
+                        log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
+                    }
                 } else {
                 } else {
-                    supplyChainMapper.updateOrder(oid, cpsOrderStatus);
+                    Integer i = this.updateOrderStatus(oid, cpsOrderStatus);
+                    if (i > 0) {
+                        log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
+                    } else {
+                        log.error("订单ID:{},状态:{} 修改失败", oid, cpsOrderStatus);
+                    }
                 }
                 }
-                log.info("订单ID:{},状态:{} 修改成功", oid, cpsOrderStatus);
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
 
 
         }
         }
+    }
+
+    private Integer updateOrderStatus(Long oid, Integer cpsOrderStatus) {
+        if ("ruixuan".equals(ownershipId)) {
+            int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+            int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+        }
+        if ("miaogousi".equals(ownershipId)) {
+            int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+            int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+        }
+        if ("rocket".equals(ownershipId)) {
+            int rocket = supplyChainMapper.updateRocketOrder(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+            int ruixuan = supplyChainMapper.updateRuixuanOrder(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int mgs = supplyChainMapper.updateMgsOrder(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+        }
+        return 0;
+    }
 
 
 
 
+    private Integer updateOrderRegimentalSettleAmount(Long oid, Integer cpsOrderStatus) {
+        if ("ruixuan".equals(ownershipId)) {
+            int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+            int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+        }
+
+        if ("miaogousi".equals(ownershipId)) {
+            int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+            int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+        }
+        if ("rocket".equals(ownershipId)) {
+            int rocket = supplyChainMapper.updateRocketOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (rocket > 0) {
+                return rocket;
+            }
+            int ruixuan = supplyChainMapper.updateRuiXuanOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (ruixuan > 0) {
+                return ruixuan;
+            }
+            int mgs = supplyChainMapper.updateMgsOrderRegimentalSettleAmount(oid, cpsOrderStatus);
+            if (mgs > 0) {
+                return mgs;
+            }
+        }
+        return 0;
     }
     }
 
 
     @Override
     @Override
@@ -457,7 +562,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     }
     }
 
 
     private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
     private void getInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
-        List<Long> list = new ArrayList<>();
+        List<Long> ruixuanList = new ArrayList<>();
+        List<Long> mgsList = new ArrayList<>();
+        List<Long> rocketList = new ArrayList<>();
         String appKey = accessToken.getAppKey();
         String appKey = accessToken.getAppKey();
         String signSecret = accessToken.getSignSecret();
         String signSecret = accessToken.getSignSecret();
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
@@ -497,7 +604,34 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 JSONObject info = orderView.getJSONObject(i);
                 JSONObject info = orderView.getJSONObject(i);
                 Integer sendStatus = info.getInteger("sendStatus");
                 Integer sendStatus = info.getInteger("sendStatus");
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
-                    list.add(info.getLong("oid"));
+                    JSONArray cpsOrderProductView = info.getJSONArray("cpsOrderProductView");
+                    if (!Check.isNull(cpsOrderProductView)) {
+                        JSONObject itemJson = cpsOrderProductView.getJSONObject(0);
+                        Long itemId = itemJson.getLong("itemId");
+                        Criteria criteria = new Criteria();
+                        criteria = Criteria.where("_id").is(itemId);
+                        Query query = new Query(criteria);
+                        ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
+                        if (Check.isNull(itemCheck)) {
+                            ruixuanList.add(info.getLong("oid"));
+                        }
+
+                        if (!Check.isNull(itemCheck)) {
+                            String ownership = itemCheck.getOwnership();
+                            if ("ruixuan".equals(ownership)) {
+                                ruixuanList.add(info.getLong("oid"));
+                            }
+                            if ("miaogousi".equals(ownership)) {
+                                mgsList.add(info.getLong("oid"));
+                            }
+                            if ("rocket".equals(ownership)) {
+                                rocketList.add(info.getLong("oid"));
+
+                            }
+                        }
+                    }
+
+
                 }
                 }
             }
             }
         } else {
         } else {
@@ -507,17 +641,27 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 getInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
                 getInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
             }
             }
         }
         }
-        if (Check.isNotNull(list) && list.size() > 0) {
-            supplyChainMapper.updateKuaishouSupplyChain(list);
-            Thread.sleep(200);
+        if (!Check.isNull(ruixuanList)) {
+            supplyChainMapper.updateKuaishouSupplyChain(ruixuanList);
+        }
+        if (!Check.isNull(mgsList)) {
+            supplyChainMapper.updateMgsKuaishouSupplyChain(mgsList);
         }
         }
+
+        if (!Check.isNull(rocketList)) {
+            supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
+        }
+
         if (!"nomore".equals(pcursor)) {
         if (!"nomore".equals(pcursor)) {
             getInfo(accessToken, beginTime, endTime, url, pcursor, 1);
             getInfo(accessToken, beginTime, endTime, url, pcursor, 1);
         }
         }
     }
     }
 
 
     private void getMgsInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
     private void getMgsInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
-        List<Long> list = new ArrayList<>();
+        List<Long> ruixuanList = new ArrayList<>();
+        List<Long> mgsList = new ArrayList<>();
+        List<Long> rocketList = new ArrayList<>();
+
         String appKey = accessToken.getAppKey();
         String appKey = accessToken.getAppKey();
         String signSecret = accessToken.getSignSecret();
         String signSecret = accessToken.getSignSecret();
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
@@ -557,9 +701,33 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 JSONObject info = orderView.getJSONObject(i);
                 JSONObject info = orderView.getJSONObject(i);
                 Integer sendStatus = info.getInteger("sendStatus");
                 Integer sendStatus = info.getInteger("sendStatus");
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
-                    list.add(info.getLong("oid"));
+                    JSONArray cpsOrderProductView = info.getJSONArray("cpsOrderProductView");
+                    JSONObject itemJson = cpsOrderProductView.getJSONObject(0);
+                    Long itemId = itemJson.getLong("itemId");
+                    Criteria criteria = new Criteria();
+                    criteria = Criteria.where("_id").is(itemId);
+                    Query query = new Query(criteria);
+                    ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
+                    if (Check.isNull(itemCheck)) {
+                        mgsList.add(info.getLong("oid"));
+                    }
+
+                    if (!Check.isNull(itemCheck)) {
+                        String ownership = itemCheck.getOwnership();
+                        if ("ruixuan".equals(ownership)) {
+                            ruixuanList.add(info.getLong("oid"));
+                        }
+                        if ("miaogousi".equals(ownership)) {
+                            mgsList.add(info.getLong("oid"));
+                        }
+                        if ("rocket".equals(ownership)) {
+                            rocketList.add(info.getLong("oid"));
+
+                        }
+                    }
                 }
                 }
             }
             }
+
         } else {
         } else {
             log.error("===MGS查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
             log.error("===MGS查询分销团长订单列表(open.distribution.cps.leader.order.cursor.list)失败,信息:{}", obj.getString("error_msg"));
             log.error("MGS游标:{},执行次数:{}", pcursor, counts);
             log.error("MGS游标:{},执行次数:{}", pcursor, counts);
@@ -567,17 +735,25 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 getMgsInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
                 getMgsInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
             }
             }
         }
         }
-        if (Check.isNotNull(list) && list.size() > 0) {
-            supplyChainMapper.updateMgsKuaishouSupplyChain(list);
-            Thread.sleep(200);
+        if (!Check.isNull(ruixuanList)) {
+            supplyChainMapper.updateKuaishouSupplyChain(ruixuanList);
+        }
+        if (!Check.isNull(mgsList)) {
+            supplyChainMapper.updateMgsKuaishouSupplyChain(mgsList);
         }
         }
+        if (!Check.isNull(rocketList)) {
+            supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
+        }
+
         if (!"nomore".equals(pcursor)) {
         if (!"nomore".equals(pcursor)) {
             getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
             getMgsInfo(accessToken, beginTime, endTime, url, pcursor, 1);
         }
         }
     }
     }
 
 
     private void getRocketInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
     private void getRocketInfo(KuaishouAccessToken accessToken, Long beginTime, Long endTime, String url, String pcursor, Integer counts) throws InterruptedException {
-        List<Long> list = new ArrayList<>();
+        List<Long> ruixuanList = new ArrayList<>();
+        List<Long> mgsList = new ArrayList<>();
+        List<Long> rocketList = new ArrayList<>();
         String appKey = accessToken.getAppKey();
         String appKey = accessToken.getAppKey();
         String signSecret = accessToken.getSignSecret();
         String signSecret = accessToken.getSignSecret();
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
         if (Check.isNull(signSecret) || Check.isNull(appKey)) {
@@ -617,7 +793,28 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 JSONObject info = orderView.getJSONObject(i);
                 JSONObject info = orderView.getJSONObject(i);
                 Integer sendStatus = info.getInteger("sendStatus");
                 Integer sendStatus = info.getInteger("sendStatus");
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
                 if (Check.isNotNull(sendStatus) && sendStatus == 1) {
-                    list.add(info.getLong("oid"));
+                    JSONArray cpsOrderProductView = info.getJSONArray("cpsOrderProductView");
+                    JSONObject itemJson = cpsOrderProductView.getJSONObject(0);
+                    Long itemId = itemJson.getLong("itemId");
+                    Criteria criteria = new Criteria();
+                    criteria = Criteria.where("_id").is(itemId);
+                    Query query = new Query(criteria);
+                    ItemCheck itemCheck = mongoTemplate.findOne(query, ItemCheck.class);
+                    if (Check.isNull(itemCheck)) {
+                        rocketList.add(info.getLong("oid"));
+                    }
+                    if (!Check.isNull(itemCheck)) {
+                        String ownership = itemCheck.getOwnership();
+                        if ("ruixuan".equals(ownership)) {
+                            ruixuanList.add(info.getLong("oid"));
+                        }
+                        if ("miaogousi".equals(ownership)) {
+                            mgsList.add(info.getLong("oid"));
+                        }
+                        if ("rocket".equals(ownership)) {
+                            rocketList.add(info.getLong("oid"));
+                        }
+                    }
                 }
                 }
             }
             }
         } else {
         } else {
@@ -627,9 +824,14 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
                 getRocketInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
                 getRocketInfo(accessToken, beginTime, endTime, url, pcursor, counts + 1);
             }
             }
         }
         }
-        if (Check.isNotNull(list) && list.size() > 0) {
-            supplyChainMapper.updateRocketKuaishouSupplyChain(list);
-            Thread.sleep(200);
+        if (!Check.isNull(ruixuanList)) {
+            supplyChainMapper.updateKuaishouSupplyChain(ruixuanList);
+        }
+        if (!Check.isNull(mgsList)) {
+            supplyChainMapper.updateMgsKuaishouSupplyChain(mgsList);
+        }
+        if (!Check.isNull(rocketList)) {
+            supplyChainMapper.updateRocketKuaishouSupplyChain(rocketList);
         }
         }
         if (!"nomore".equals(pcursor)) {
         if (!"nomore".equals(pcursor)) {
             getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);
             getRocketInfo(accessToken, beginTime, endTime, url, pcursor, 1);

+ 370 - 4
ruixuan-live/src/main/resources/mapper/isc/KuaishouItemListMapper.xml

@@ -141,7 +141,7 @@
     <select id="getCategoryIds" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getCategoryIds" resultType="com.alibaba.fastjson.JSONObject">
         select category_id as 'categoryId' , category_name as 'categoryName'
         select category_id as 'categoryId' , category_name as 'categoryName'
         from kuaishou_item_category
         from kuaishou_item_category
-        where category_sort = 1
+        where parent_id = 0
         order by category_id
         order by category_id
     </select>
     </select>
     <select id="getActivityIds" resultType="java.lang.Long" parameterType="java.lang.Long">
     <select id="getActivityIds" resultType="java.lang.Long" parameterType="java.lang.Long">
@@ -174,7 +174,7 @@
     </select>
     </select>
     <select id="selectMaxRelateId" resultType="java.lang.Long">
     <select id="selectMaxRelateId" resultType="java.lang.Long">
         select max(relate_id)
         select max(relate_id)
-        from kuaishou_item_list
+        from ${targetOwnershipId}.kuaishou_item_list
     </select>
     </select>
     <select id="getItemImgUrl" resultType="java.lang.String">
     <select id="getItemImgUrl" resultType="java.lang.String">
         select item_img_url
         select item_img_url
@@ -227,6 +227,50 @@
         select item_id as 'itemId', item_commission_rate as 'itemCommissionRate'
         select item_id as 'itemId', item_commission_rate as 'itemCommissionRate'
         from kuaishou_activity_item_list
         from kuaishou_activity_item_list
     </select>
     </select>
+    <select id="getDataOwnership" resultType="com.alibaba.fastjson.JSONObject">
+        select ownership_id as 'ownershipId',ownership_name as 'ownershipName'
+        from ruixuan.kuaishou_data_ownership
+    </select>
+    <select id="checkUser" resultType="java.lang.Long">
+        select user_id
+        from ${ownershipId}.sys_user
+        where nick_name = #{userName} limit 1
+    </select>
+    <select id="selectDataOwnershipNameById" resultType="java.lang.String" parameterType="java.lang.String">
+        select ownership_name
+        from kuaishou_data_ownership
+        where ownership_id = #{ownershipId}
+
+    </select>
+    <select id="getUserInfo" resultType="com.alibaba.fastjson.JSONObject">
+        select user_id as 'userId', nick_name as 'userName'
+        from ${targetOwnershipId}.sys_user
+        where nick_name = #{userName}
+        order by create_time desc limit 1
+    </select>
+    <select id="getItemOwnership" resultType="java.lang.String" parameterType="java.lang.Long">
+        select ownership_id
+        from ruixuan.kuaishou_item_check
+        where item_id = #{itemId}
+    </select>
+    <select id="getCleanData" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select item_id as 'itemId', 'ruixuan' as 'ownershipId'
+              from ruixuan.kuaishou_item_list
+              union all
+              select item_id as 'itemId', 'miaogousi' as 'ownershipId'
+              from miaogousi.kuaishou_item_list
+              union all
+              select item_id as 'itemId', 'rocket' as 'ownershipId'
+              from rocket.kuaishou_item_list) t
+        group by t.itemId
+    </select>
+    <select id="checkItemData" resultType="java.lang.Integer">
+        select count(1)
+        from ${ownershipId}.kuaishou_supply_chain
+        where item_id = #{itemId}
+
+    </select>
 
 
     <insert id="insertItem" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
     <insert id="insertItem" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
         insert into kuaishou_item_list
         insert into kuaishou_item_list
@@ -324,7 +368,7 @@
 
 
     <insert id="insertItemBindUser">
     <insert id="insertItemBindUser">
         replace
         replace
-        into kuaishou_item_bind_user(
+        into ${targetOwnershipId}.kuaishou_item_bind_user(
         item_id,
         item_id,
         user_id,
         user_id,
         user_name
         user_name
@@ -338,7 +382,7 @@
     </insert>
     </insert>
 
 
     <insert id="batchCategory">
     <insert id="batchCategory">
-        replace into kuaishou_item_category(
+        replace into ruixuan.kuaishou_item_category(
         category_id,
         category_id,
         category_name,
         category_name,
         parent_id,
         parent_id,
@@ -355,6 +399,328 @@
         </foreach>
         </foreach>
 
 
     </insert>
     </insert>
+    <insert id="insertRuiXuanItem" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
+        insert into ruixuan.kuaishou_item_list
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">item_id,</if>
+            <if test="mediaId != null">media_id,</if>
+            <if test="itemTitle != null">item_title,</if>
+            <if test="itemPrice != null">item_price,</if>
+            <if test="itemDesc != null">item_desc,</if>
+            <if test="zkFinalPrice != null">zk_final_price,</if>
+            <if test="itemImgUrl != null">item_img_url,</if>
+            <if test="itemDescUrls != null">item_desc_urls,</if>
+            <if test="shopStar != null">shop_star,</if>
+            <if test="mallLogisticsScore != null">mall_logistics_score,</if>
+            <if test="activityItemStatus != null">activity_item_status,</if>
+            <if test="shopScore != null">shop_score,</if>
+            <if test="categoryId != null">category_id,</if>
+            <if test="categoryName != null">category_name,</if>
+            <if test="itemGalleryUrls != null">item_gallery_urls,</if>
+            <if test="identity != null">identity,</if>
+            <if test="activityId != null">activity_id,</if>
+            <if test="shopTitle != null">shop_title,</if>
+            <if test="commissionRate != null">commission_rate,</if>
+            <if test="mallServiceScore != null">mall_service_score,</if>
+            <if test="mallQualityScore != null">mall_quality_score,</if>
+            <if test="skuList != null">sku_list,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="examineId != null">examine_id,</if>
+            <if test="examineName != null">examine_name,</if>
+            <if test="examineStatus != null">examine_status,</if>
+            <if test="refuseDetail != null">refuse_detail,</if>
+            <if test="postArea != null">post_area,</if>
+            <if test="noPostArea != null">no_post_area,</if>
+            <if test="regimentalPromotionRate != null">regimental_promotion_rate,</if>
+            <if test="regimentalPromotion != null">regimental_promotion,</if>
+            <if test="sampleCount != null">sample_count,</if>
+            <if test="sampleRequirement != null">sample_requirement,</if>
+            <if test="deliveryRate != null">delivery_rate,</if>
+            <if test="partnerRecommendText != null">partner_recommend_text,</if>
+            <if test="detailUrl != null">detail_url,</if>
+            <if test="samplesReceived != null">samples_received,</if>
+            <if test="samplesPeoples != null">samples_peoples,</if>
+            <if test="relateId != null">relate_id,</if>
+            <if test="ruleId != null">rule_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">#{itemId},</if>
+            <if test="mediaId != null">#{mediaId},</if>
+            <if test="itemTitle != null">#{itemTitle},</if>
+            <if test="itemPrice != null">#{itemPrice},</if>
+            <if test="itemDesc != null">#{itemDesc},</if>
+            <if test="zkFinalPrice != null">#{zkFinalPrice},</if>
+            <if test="itemImgUrl != null">#{itemImgUrl},</if>
+            <if test="itemDescUrls != null">#{itemDescUrls},</if>
+            <if test="shopStar != null">#{shopStar},</if>
+            <if test="mallLogisticsScore != null">#{mallLogisticsScore},</if>
+            <if test="activityItemStatus != null">#{activityItemStatus},</if>
+            <if test="shopScore != null">#{shopScore},</if>
+            <if test="categoryId != null">#{categoryId},</if>
+            <if test="categoryName != null">#{categoryName},</if>
+            <if test="itemGalleryUrls != null">#{itemGalleryUrls},</if>
+            <if test="identity != null">#{identity},</if>
+            <if test="activityId != null">#{activityId},</if>
+            <if test="shopTitle != null">#{shopTitle},</if>
+            <if test="commissionRate != null">#{commissionRate},</if>
+            <if test="mallServiceScore != null">#{mallServiceScore},</if>
+            <if test="mallQualityScore != null">#{mallQualityScore},</if>
+            <if test="skuList != null">#{skuList},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="examineId != null">#{examineId},</if>
+            <if test="examineName != null">#{examineName},</if>
+            <if test="examineStatus != null">#{examineStatus},</if>
+            <if test="refuseDetail != null">#{refuseDetail},</if>
+            <if test="postArea != null">#{postArea},</if>
+            <if test="noPostArea != null">#{noPostArea},</if>
+            <if test="regimentalPromotionRate != null">#{regimentalPromotionRate},</if>
+            <if test="regimentalPromotion != null">#{regimentalPromotion},</if>
+            <if test="sampleCount != null">#{sampleCount},</if>
+            <if test="sampleRequirement != null">#{sampleRequirement},</if>
+            <if test="deliveryRate != null">#{deliveryRate},</if>
+            <if test="partnerRecommendText != null">#{partnerRecommendText},</if>
+            <if test="detailUrl != null">#{detailUrl},</if>
+            <if test="samplesReceived != null">#{samplesReceived},</if>
+            <if test="samplesPeoples != null">#{samplesPeoples},</if>
+            <if test="relateId != null">#{relateId},</if>
+            <if test="ruleId != null">#{ruleId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+    <insert id="insertMiaoGouSiItem" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
+        insert into miaogousi.kuaishou_item_list
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">item_id,</if>
+            <if test="mediaId != null">media_id,</if>
+            <if test="itemTitle != null">item_title,</if>
+            <if test="itemPrice != null">item_price,</if>
+            <if test="itemDesc != null">item_desc,</if>
+            <if test="zkFinalPrice != null">zk_final_price,</if>
+            <if test="itemImgUrl != null">item_img_url,</if>
+            <if test="itemDescUrls != null">item_desc_urls,</if>
+            <if test="shopStar != null">shop_star,</if>
+            <if test="mallLogisticsScore != null">mall_logistics_score,</if>
+            <if test="activityItemStatus != null">activity_item_status,</if>
+            <if test="shopScore != null">shop_score,</if>
+            <if test="categoryId != null">category_id,</if>
+            <if test="categoryName != null">category_name,</if>
+            <if test="itemGalleryUrls != null">item_gallery_urls,</if>
+            <if test="identity != null">identity,</if>
+            <if test="activityId != null">activity_id,</if>
+            <if test="shopTitle != null">shop_title,</if>
+            <if test="commissionRate != null">commission_rate,</if>
+            <if test="mallServiceScore != null">mall_service_score,</if>
+            <if test="mallQualityScore != null">mall_quality_score,</if>
+            <if test="skuList != null">sku_list,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="examineId != null">examine_id,</if>
+            <if test="examineName != null">examine_name,</if>
+            <if test="examineStatus != null">examine_status,</if>
+            <if test="refuseDetail != null">refuse_detail,</if>
+            <if test="postArea != null">post_area,</if>
+            <if test="noPostArea != null">no_post_area,</if>
+            <if test="regimentalPromotionRate != null">regimental_promotion_rate,</if>
+            <if test="regimentalPromotion != null">regimental_promotion,</if>
+            <if test="sampleCount != null">sample_count,</if>
+            <if test="sampleRequirement != null">sample_requirement,</if>
+            <if test="deliveryRate != null">delivery_rate,</if>
+            <if test="partnerRecommendText != null">partner_recommend_text,</if>
+            <if test="detailUrl != null">detail_url,</if>
+            <if test="samplesReceived != null">samples_received,</if>
+            <if test="samplesPeoples != null">samples_peoples,</if>
+            <if test="relateId != null">relate_id,</if>
+            <if test="ruleId != null">rule_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">#{itemId},</if>
+            <if test="mediaId != null">#{mediaId},</if>
+            <if test="itemTitle != null">#{itemTitle},</if>
+            <if test="itemPrice != null">#{itemPrice},</if>
+            <if test="itemDesc != null">#{itemDesc},</if>
+            <if test="zkFinalPrice != null">#{zkFinalPrice},</if>
+            <if test="itemImgUrl != null">#{itemImgUrl},</if>
+            <if test="itemDescUrls != null">#{itemDescUrls},</if>
+            <if test="shopStar != null">#{shopStar},</if>
+            <if test="mallLogisticsScore != null">#{mallLogisticsScore},</if>
+            <if test="activityItemStatus != null">#{activityItemStatus},</if>
+            <if test="shopScore != null">#{shopScore},</if>
+            <if test="categoryId != null">#{categoryId},</if>
+            <if test="categoryName != null">#{categoryName},</if>
+            <if test="itemGalleryUrls != null">#{itemGalleryUrls},</if>
+            <if test="identity != null">#{identity},</if>
+            <if test="activityId != null">#{activityId},</if>
+            <if test="shopTitle != null">#{shopTitle},</if>
+            <if test="commissionRate != null">#{commissionRate},</if>
+            <if test="mallServiceScore != null">#{mallServiceScore},</if>
+            <if test="mallQualityScore != null">#{mallQualityScore},</if>
+            <if test="skuList != null">#{skuList},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="examineId != null">#{examineId},</if>
+            <if test="examineName != null">#{examineName},</if>
+            <if test="examineStatus != null">#{examineStatus},</if>
+            <if test="refuseDetail != null">#{refuseDetail},</if>
+            <if test="postArea != null">#{postArea},</if>
+            <if test="noPostArea != null">#{noPostArea},</if>
+            <if test="regimentalPromotionRate != null">#{regimentalPromotionRate},</if>
+            <if test="regimentalPromotion != null">#{regimentalPromotion},</if>
+            <if test="sampleCount != null">#{sampleCount},</if>
+            <if test="sampleRequirement != null">#{sampleRequirement},</if>
+            <if test="deliveryRate != null">#{deliveryRate},</if>
+            <if test="partnerRecommendText != null">#{partnerRecommendText},</if>
+            <if test="detailUrl != null">#{detailUrl},</if>
+            <if test="samplesReceived != null">#{samplesReceived},</if>
+            <if test="samplesPeoples != null">#{samplesPeoples},</if>
+            <if test="relateId != null">#{relateId},</if>
+            <if test="ruleId != null">#{ruleId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+    <insert id="insertRocketItem" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
+        insert into rocket.kuaishou_item_list
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">item_id,</if>
+            <if test="mediaId != null">media_id,</if>
+            <if test="itemTitle != null">item_title,</if>
+            <if test="itemPrice != null">item_price,</if>
+            <if test="itemDesc != null">item_desc,</if>
+            <if test="zkFinalPrice != null">zk_final_price,</if>
+            <if test="itemImgUrl != null">item_img_url,</if>
+            <if test="itemDescUrls != null">item_desc_urls,</if>
+            <if test="shopStar != null">shop_star,</if>
+            <if test="mallLogisticsScore != null">mall_logistics_score,</if>
+            <if test="activityItemStatus != null">activity_item_status,</if>
+            <if test="shopScore != null">shop_score,</if>
+            <if test="categoryId != null">category_id,</if>
+            <if test="categoryName != null">category_name,</if>
+            <if test="itemGalleryUrls != null">item_gallery_urls,</if>
+            <if test="identity != null">identity,</if>
+            <if test="activityId != null">activity_id,</if>
+            <if test="shopTitle != null">shop_title,</if>
+            <if test="commissionRate != null">commission_rate,</if>
+            <if test="mallServiceScore != null">mall_service_score,</if>
+            <if test="mallQualityScore != null">mall_quality_score,</if>
+            <if test="skuList != null">sku_list,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="examineId != null">examine_id,</if>
+            <if test="examineName != null">examine_name,</if>
+            <if test="examineStatus != null">examine_status,</if>
+            <if test="refuseDetail != null">refuse_detail,</if>
+            <if test="postArea != null">post_area,</if>
+            <if test="noPostArea != null">no_post_area,</if>
+            <if test="regimentalPromotionRate != null">regimental_promotion_rate,</if>
+            <if test="regimentalPromotion != null">regimental_promotion,</if>
+            <if test="sampleCount != null">sample_count,</if>
+            <if test="sampleRequirement != null">sample_requirement,</if>
+            <if test="deliveryRate != null">delivery_rate,</if>
+            <if test="partnerRecommendText != null">partner_recommend_text,</if>
+            <if test="detailUrl != null">detail_url,</if>
+            <if test="samplesReceived != null">samples_received,</if>
+            <if test="samplesPeoples != null">samples_peoples,</if>
+            <if test="relateId != null">relate_id,</if>
+            <if test="ruleId != null">rule_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="itemId != null">#{itemId},</if>
+            <if test="mediaId != null">#{mediaId},</if>
+            <if test="itemTitle != null">#{itemTitle},</if>
+            <if test="itemPrice != null">#{itemPrice},</if>
+            <if test="itemDesc != null">#{itemDesc},</if>
+            <if test="zkFinalPrice != null">#{zkFinalPrice},</if>
+            <if test="itemImgUrl != null">#{itemImgUrl},</if>
+            <if test="itemDescUrls != null">#{itemDescUrls},</if>
+            <if test="shopStar != null">#{shopStar},</if>
+            <if test="mallLogisticsScore != null">#{mallLogisticsScore},</if>
+            <if test="activityItemStatus != null">#{activityItemStatus},</if>
+            <if test="shopScore != null">#{shopScore},</if>
+            <if test="categoryId != null">#{categoryId},</if>
+            <if test="categoryName != null">#{categoryName},</if>
+            <if test="itemGalleryUrls != null">#{itemGalleryUrls},</if>
+            <if test="identity != null">#{identity},</if>
+            <if test="activityId != null">#{activityId},</if>
+            <if test="shopTitle != null">#{shopTitle},</if>
+            <if test="commissionRate != null">#{commissionRate},</if>
+            <if test="mallServiceScore != null">#{mallServiceScore},</if>
+            <if test="mallQualityScore != null">#{mallQualityScore},</if>
+            <if test="skuList != null">#{skuList},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="examineId != null">#{examineId},</if>
+            <if test="examineName != null">#{examineName},</if>
+            <if test="examineStatus != null">#{examineStatus},</if>
+            <if test="refuseDetail != null">#{refuseDetail},</if>
+            <if test="postArea != null">#{postArea},</if>
+            <if test="noPostArea != null">#{noPostArea},</if>
+            <if test="regimentalPromotionRate != null">#{regimentalPromotionRate},</if>
+            <if test="regimentalPromotion != null">#{regimentalPromotion},</if>
+            <if test="sampleCount != null">#{sampleCount},</if>
+            <if test="sampleRequirement != null">#{sampleRequirement},</if>
+            <if test="deliveryRate != null">#{deliveryRate},</if>
+            <if test="partnerRecommendText != null">#{partnerRecommendText},</if>
+            <if test="detailUrl != null">#{detailUrl},</if>
+            <if test="samplesReceived != null">#{samplesReceived},</if>
+            <if test="samplesPeoples != null">#{samplesPeoples},</if>
+            <if test="relateId != null">#{relateId},</if>
+            <if test="ruleId != null">#{ruleId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+
+    </insert>
+    <insert id="insertItemCheck">
+        replace
+        into ruixuan.kuaishou_item_check(item_id,ownership_id) values (
+        #{itemId},
+        #{targetOwnershipId}
+        )
+    </insert>
+    <insert id="batchMgsCategory">
+        replace into miaogousi.kuaishou_item_category(
+        category_id,
+        category_name,
+        parent_id,
+        category_sort
+        )
+        values
+        <foreach collection="adds" item="add" separator=",">
+            (
+            #{add.categoryId},
+            #{add.categoryName},
+            #{add.parentId},
+            #{add.categorySort}
+            )
+        </foreach>
+
+    </insert>
+    <insert id="batchRocketCategory">
+        replace into rocket.kuaishou_item_category(
+        category_id,
+        category_name,
+        parent_id,
+        category_sort
+        )
+        values
+        <foreach collection="adds" item="add" separator=",">
+            (
+            #{add.categoryId},
+            #{add.categoryName},
+            #{add.parentId},
+            #{add.categorySort}
+            )
+        </foreach>
+    </insert>
 
 
 
 
     <update id="updateKuaishouItemList" parameterType="com.ruixuan.isc.entity.KuaishouItemList">
     <update id="updateKuaishouItemList" parameterType="com.ruixuan.isc.entity.KuaishouItemList">

+ 2 - 6
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -1009,12 +1009,8 @@ group by promoter_id
         #{promoterId},
         #{promoterId},
         #{ruleId},
         #{ruleId},
         #{ruleName},
         #{ruleName},
-        now
-        (
-        ),
-        now
-        (
-        )
+        now(),
+        now()
         )
         )
 
 
     </insert>
     </insert>

+ 36 - 2
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -16,7 +16,7 @@
 
 
     <update id="updateOrderRegimentalSettleAmount">
     <update id="updateOrderRegimentalSettleAmount">
         update kuaishou_supply_chain
         update kuaishou_supply_chain
-        set order_status                   = #{cpsOrderStatus},
+        set order_status = #{cpsOrderStatus},
             total_regimental_settle_amount = regimental_promotion_amount
             total_regimental_settle_amount = regimental_promotion_amount
         where oid = #{oid}
         where oid = #{oid}
     </update>
     </update>
@@ -2714,7 +2714,7 @@
     </insert>
     </insert>
 
 
     <update id="updateKuaishouSupplyChain">
     <update id="updateKuaishouSupplyChain">
-        update kuaishou_supply_chain set send_status = 1
+        update ruixuan.kuaishou_supply_chain set send_status = 1
         where oid in
         where oid in
         <foreach collection="list" item="id" separator=","
         <foreach collection="list" item="id" separator=","
                  open="(" close=")">
                  open="(" close=")">
@@ -2739,6 +2739,40 @@
             #{id}
             #{id}
         </foreach>
         </foreach>
     </update>
     </update>
+    <update id="updateRuiXuanOrderRegimentalSettleAmount">
+        update ruixuan.kuaishou_supply_chain
+        set order_status = #{cpsOrderStatus},
+            total_regimental_settle_amount = regimental_promotion_amount
+        where oid = #{oid}
+
+    </update>
+    <update id="updateMgsOrderRegimentalSettleAmount">
+        update miaogousi.kuaishou_supply_chain
+        set order_status = #{cpsOrderStatus},
+            total_regimental_settle_amount = regimental_promotion_amount
+        where oid = #{oid}
+    </update>
+    <update id="updateRocketOrderRegimentalSettleAmount">
+        update rocket.kuaishou_supply_chain
+        set order_status                   = #{cpsOrderStatus},
+            total_regimental_settle_amount = regimental_promotion_amount
+        where oid = #{oid}
+    </update>
+    <update id="updateRuixuanOrder">
+        update ruixuan.kuaishou_supply_chain
+        set order_status = #{cpsOrderStatus}
+        where oid = #{oid}
+    </update>
+    <update id="updateMgsOrder">
+        update miaogousi.kuaishou_supply_chain
+        set order_status = #{cpsOrderStatus}
+        where oid = #{oid}
+    </update>
+    <update id="updateRocketOrder">
+        update rocket.kuaishou_supply_chain
+        set order_status = #{cpsOrderStatus}
+        where oid = #{oid}
+    </update>
 
 
     <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT pay_success_time_hour as 'hour', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNum', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount'
         SELECT pay_success_time_hour as 'hour', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNum', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount'