Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	ruixuan-live/src/main/java/com/ruixuan/bytedance/service/impl/BytedanceServiceImpl.java
yumeng 2 years ago
parent
commit
05bf1d68ab

+ 12 - 5
ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java

@@ -51,11 +51,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     }
 
 
-
-
-
-
-
     public static String getNowDateStr() {
         SimpleDateFormat simp = new SimpleDateFormat("yyyy-MM-dd");
         return simp.format(new Date());
@@ -194,6 +189,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return Long.valueOf(date.replaceAll("-", ""));
     }
 
+    /**
+     * 时间字符串转long类型
+     * 2022-05-01 00:00:00 ===>>>> 20220501
+     *
+     * @param date
+     * @return
+     */
+    public static Long strDateTimsToInt(String date) {
+        String[] datas = date.split(" ");
+        return Long.valueOf(datas[0].replaceAll("-", ""));
+    }
+
 
     /**
      * @param

+ 14 - 4
ruixuan-live/src/main/java/com/ruixuan/bytedance/controller/BytedanceController.java

@@ -1,6 +1,5 @@
 package com.ruixuan.bytedance.controller;
 
-import com.ruixuan.bytedance.service.IBytedanceColonelActivityService;
 import com.ruixuan.bytedance.service.IBytedanceService;
 import com.ruixuan.common.core.controller.BaseController;
 import io.swagger.annotations.Api;
@@ -62,10 +61,21 @@ public class BytedanceController extends BaseController {
     @ApiOperation(value = "新增团长订单")
     @GetMapping("/addBytedanceInstituteOrderColonel")
     public void addBytedanceInstituteOrderColonel(@ApiParam("startTime") @RequestParam(value = "开始时间", required = true) String startTime,
-                                                  @ApiParam("endTime") @RequestParam(value = "结束时间", required = true) String endTime,
-                                                  @ApiParam("cursor") @RequestParam(value = "索引", required = true) String cursor
+                                                  @ApiParam("endTime") @RequestParam(value = "结束时间", required = true) String endTime
     ) {
-        bytedanceService.addBytedanceInstituteOrderColonel(startTime, endTime, cursor);
+        bytedanceService.addBytedanceInstituteOrderColonel(startTime, endTime, null);
+    }
+
+
+    /**
+     * 新增 团长分次结算订单
+     */
+    @ApiOperation(value = "新增团长分次结算订单")
+    @GetMapping("/addBytedanceMultiSettlementOrders")
+    public void addBytedanceMultiSettlementOrders(@ApiParam("startTime") @RequestParam(value = "开始时间", required = true) String startTime,
+                                                  @ApiParam("endTime") @RequestParam(value = "结束时间", required = true) String endTime
+    ) {
+        bytedanceService.addBytedanceMultiSettlementOrders(startTime, endTime, null);
     }
 
 

+ 5 - 5
ruixuan-live/src/main/java/com/ruixuan/bytedance/entity/BytedanceOrderList.java

@@ -80,7 +80,7 @@ public class BytedanceOrderList implements Serializable {
      * 店铺ID
      */
     @Excel(name = "店铺ID")
-    private Integer shopId;
+    private Long shopId;
 
     /**
      * 商家名称
@@ -92,7 +92,7 @@ public class BytedanceOrderList implements Serializable {
      * 订单支付金额,单位分
      */
     @Excel(name = "订单支付金额,单位分")
-    private Integer totalPayAmount;
+    private Long totalPayAmount;
 
     /**
      * 订单状态(PAY_SUCC:支付完成 REFUND:退款 SETTLE:结算 CONFIRM: 确认收货)
@@ -122,19 +122,19 @@ public class BytedanceOrderList implements Serializable {
      * 预估参与结算金额,单位分
      */
     @Excel(name = "预估参与结算金额,单位分")
-    private Integer payGoodsAmount;
+    private Long payGoodsAmount;
 
     /**
      * 实际参与结算金额,单位分
      */
     @Excel(name = "实际参与结算金额,单位分")
-    private Integer settledGoodsAmount;
+    private Long settledGoodsAmount;
 
     /**
      * 商品数目
      */
     @Excel(name = "商品数目")
-    private Integer itemNum;
+    private Long itemNum;
 
     /**
      * 退款订单退款时间

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/bytedance/mapper/BytedanceMapper.java

@@ -17,5 +17,5 @@ public interface BytedanceMapper {
 
     BytedanceColonelActivityDetail getDetailByActivityId(@Param("activityId") Long activityId);
 
-    void replaceBatchOrders(List<BytedanceOrderList> list);
+    void replaceBatchOrders(@Param("list") List<BytedanceOrderList> list);
 }

+ 9 - 1
ruixuan-live/src/main/java/com/ruixuan/bytedance/service/IBytedanceService.java

@@ -22,9 +22,17 @@ public interface IBytedanceService {
 
 
     /**
-     * job 新增活动商品
+     * 新增活动商品
      */
     JSONObject addBytedanceColonelActivityProduct(Long activityId, Long productInfo);
 
+    /**
+     * job 新增团长订单
+     */
     void addBytedanceInstituteOrderColonel(String startTime, String endTime, String cursor);
+
+    /**
+     * job 新增 团长分次结算订单
+     */
+    void addBytedanceMultiSettlementOrders(String startTime, String endTime, String cursor);
 }

+ 43 - 11
ruixuan-live/src/main/java/com/ruixuan/bytedance/service/impl/BytedanceServiceImpl.java

@@ -13,6 +13,9 @@ import com.doudian.open.api.buyin_colonelActivityDetail.BuyinColonelActivityDeta
 import com.doudian.open.api.buyin_colonelActivityDetail.BuyinColonelActivityDetailResponse;
 import com.doudian.open.api.buyin_colonelActivityDetail.data.BuyinColonelActivityDetailData;
 import com.doudian.open.api.buyin_colonelActivityDetail.param.BuyinColonelActivityDetailParam;
+import com.doudian.open.api.buyin_colonelMultiSettlementOrders.BuyinColonelMultiSettlementOrdersRequest;
+import com.doudian.open.api.buyin_colonelMultiSettlementOrders.BuyinColonelMultiSettlementOrdersResponse;
+import com.doudian.open.api.buyin_colonelMultiSettlementOrders.param.BuyinColonelMultiSettlementOrdersParam;
 import com.doudian.open.api.buyin_decryptContactInfo.BuyinDecryptContactInfoRequest;
 import com.doudian.open.api.buyin_decryptContactInfo.BuyinDecryptContactInfoResponse;
 import com.doudian.open.api.buyin_decryptContactInfo.data.BuyinDecryptContactInfoData;
@@ -255,7 +258,7 @@ public class BytedanceServiceImpl implements IBytedanceService {
     @Override
     public void addBytedanceInstituteOrderColonel(String startTime, String endTime, String cursor) {
         AccessToken accessToken = tokenService.getAccessToken(1L);
-
+        cursor = Check.isNull(cursor) ? "0" : cursor;
         BuyinInstituteOrderColonelRequest request = new BuyinInstituteOrderColonelRequest();
         BuyinInstituteOrderColonelParam param = request.getParam();
         param.setSize(200L);
@@ -266,7 +269,7 @@ public class BytedanceServiceImpl implements IBytedanceService {
         BuyinInstituteOrderColonelResponse response = request.execute(accessToken);
         System.out.println(response);
         if (Check.isNull(response) || !"10000".equals(response.getCode())) {
-            log.error("\n【请求接口】: {}\n【请求参数】:{}\n【响应数据】:{}", "/buyin/colonelActivityDetail;(获取团长活动详情)", param, response);
+            log.error("\n【请求接口】: {}\n【请求参数】:{}\n【响应数据】:{}", "/buyin/instituteOrderColonel;(查询团长订单)", param, response);
             return;
         }
 
@@ -276,13 +279,26 @@ public class BytedanceServiceImpl implements IBytedanceService {
             cursor = data.getCursor();
             if (Check.isNotNull(orders) && orders.size() > 0) {
                 List<BytedanceOrderList> list = new ArrayList<>();
-                BytedanceOrderList orderList = new BytedanceOrderList();
                 for (OrdersItem order : orders) {
+                    BytedanceOrderList orderList = new BytedanceOrderList();
                     BeanUtils.copyProperties(order, orderList);
-                    orderList.setUpdateTime(DateUtils.strDateToInt(order.getUpdateTime()));
-                    orderList.setPaySuccessTime(DateUtils.strDateToInt(order.getPaySuccessTime()));
-                    orderList.setRefundTime(DateUtils.strDateToInt(order.getRefundTime()));
-                    orderList.setSettleTime(DateUtils.strDateToInt(order.getSettleTime()));
+                    orderList.setOrderId(Long.valueOf(order.getOrderId()));
+                    if (Check.isNotNull(order.getUpdateTime())) {
+                        orderList.setUpdateTime(DateUtils.strDateTimsToInt(order.getUpdateTime()));
+                    }
+                    if (Check.isNotNull(order.getPaySuccessTime())) {
+                        orderList.setPaySuccessTime(DateUtils.strDateTimsToInt(order.getPaySuccessTime()));
+                    }
+                    if (Check.isNotNull(order.getRefundTime())) {
+                        orderList.setRefundTime(DateUtils.strDateTimsToInt(order.getRefundTime()));
+                    }
+                    if (Check.isNotNull(order.getSettleTime())) {
+                        orderList.setSettleTime(DateUtils.strDateTimsToInt(order.getSettleTime()));
+                    }
+                    if (Check.isNotNull(order.getIsTrusteeship())) {
+                        orderList.setIsTrusteeship(order.getIsTrusteeship() ? "1" : "0");
+                    }
+
                     ColonelOrderInfo colonelInfo = order.getColonelOrderInfo();
                     if (Check.isNotNull(colonelInfo)) {
                         orderList.setColonelCommissionRate(colonelInfo.getCommissionRate());
@@ -308,19 +324,35 @@ public class BytedanceServiceImpl implements IBytedanceService {
                     }
                     list.add(orderList);
                 }
-
                 bytedanceMapper.replaceBatchOrders(list);
-
                 int size = orders.size();
                 if (size >= 200) {
                     addBytedanceInstituteOrderColonel(startTime, endTime, cursor);
                 }
-
             }
-
         }
+    }
 
 
+    @Override
+    public void addBytedanceMultiSettlementOrders(String startTime, String endTime, String cursor) {
+        AccessToken accessToken = tokenService.getAccessToken(1L);
+        cursor = Check.isNull(cursor) ? "0" : cursor;
+        BuyinColonelMultiSettlementOrdersRequest request = new BuyinColonelMultiSettlementOrdersRequest();
+        BuyinColonelMultiSettlementOrdersParam param = request.getParam();
+        param.setSize(100L);
+        param.setCursor(cursor);
+        param.setTimeType("settle");//查询时间类型。settle: 结算时间); update:更新时间(默认)
+        param.setStartTime(startTime.concat(" 00:00:00"));
+        param.setEndTime(endTime.concat(" 23:59:59"));
+        BuyinColonelMultiSettlementOrdersResponse response = request.execute(accessToken);
+
+        System.out.println(response);
+        if (Check.isNull(response) || !"10000".equals(response.getCode())) {
+            log.error("\n【请求接口】: {}\n【请求参数】:{}\n【响应数据】:{}", "/buyin/colonelMultiSettlementOrders;(团长分次结算订单)", param, response);
+            return;
+        }
+        com.doudian.open.api.buyin_colonelMultiSettlementOrders.data.Data data = response.getData();
     }
 
     /**

+ 2 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -48,11 +48,12 @@ public class KuaishouPromoterController extends BaseController {
     public TableDataInfo list(@ApiParam("创建人ID") @RequestParam(value = "userId", required = true) Long userId,
                               @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId,
                               @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
+                              @ApiParam("媒体") @RequestParam(value = "mediaId", required = false) String mediaId,
                               @ApiParam("排序参数") @RequestParam(value = "parameter", required = false) String parameter,
                               @ApiParam("正序倒叙") @RequestParam(value = "orderBy", required = false) String orderBy
 
     ) {
-        List<KuaishouPromoter> list = kuaishouPromoterService.selectKuaishouPromoterList(userId, promoterId, promoterNickName, parameter, orderBy);
+        List<KuaishouPromoter> list = kuaishouPromoterService.selectKuaishouPromoterList(userId, promoterId, promoterNickName, mediaId, parameter, orderBy);
         return getDataTable(list);
     }
 

+ 5 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouPromoter.java

@@ -23,6 +23,11 @@ public class KuaishouPromoter {
     private Long id;
 
     /**
+     * 媒体:1头条,2快手
+     */
+    private String mediaId;
+
+    /**
      * 创建人ID
      */
     @ApiModelProperty(name = "创建人ID")

+ 3 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouPromoterMapper.java

@@ -22,7 +22,9 @@ public interface KuaishouPromoterMapper {
      * @return 快手达人 信息集合
      */
     public List<KuaishouPromoter> selectKuaishouPromoterList(@Param("userList") List<Long> userList, @Param("promoterId") Long promoterId,
-                                                             @Param("promoterNickName") String promoterNickName, @Param("parameter") String parameter, @Param("orderBy") String orderBy);
+                                                             @Param("promoterNickName") String promoterNickName,
+                                                             @Param("mediaId") String mediaId,
+                                                             @Param("parameter") String parameter, @Param("orderBy") String orderBy);
 
     /**
      * 新增快手达人 信息

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -28,7 +28,7 @@ public interface IKuaishouPromoterService {
      * @param kuaishouPromoter 快手达人 信息
      * @return 快手达人 信息集合
      */
-    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName, String parameter, String orderBy);
+    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName, String mediaId, String parameter, String orderBy);
 
     /**
      * 新增快手达人 信息

+ 7 - 7
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -71,7 +71,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
      * @return 快手达人 信息
      */
     @Override
-    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName, String parameter, String orderBy) {
+    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName, String mediaId, String parameter, String orderBy) {
         String roleKey = sysUserService.getRoleKeyByUserId(userId);
         List<Long> userList = null;
         //角色:供应链管理员、招商、招商经理可以看到所有的达人信息
@@ -109,7 +109,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
             orderBy = "desc";
         }
         PageUtils.startPage();
-        List<KuaishouPromoter> list = kuaishouPromoterMapper.selectKuaishouPromoterList(userList, promoterId, promoterNickName, parameter, orderBy);
+        List<KuaishouPromoter> list = kuaishouPromoterMapper.selectKuaishouPromoterList(userList, promoterId, promoterNickName, mediaId, parameter, orderBy);
         list.forEach(ent -> {
             JSONObject follow = kuaishouPromoterMapper.getFollowUpRecordsByUserId(ent.getPromoterId(), ent.getUserId());
             ent.setFollowUpRecord(Check.isNull(follow) ? "-" : follow.getString("txt"));
@@ -153,7 +153,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                     @Override
                     public void run() {
                         try {
-                            editPromoter(promoter.getId(), promoter.getPromoterId(), true);
+                            editPromoter(promoter.getId(), promoter.getMediaId(), promoter.getPromoterId(), true);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
@@ -232,7 +232,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
             promoter.setUserName(sysUser.getNickName());
         }
         kuaishouPromoterMapper.insertKuaishouPromoter(promoter);
-        editPromoter(promoter.getId(), promoter.getPromoterId(), true);
+        editPromoter(promoter.getId(), promoter.getMediaId(), promoter.getPromoterId(), true);
         result.put("code", 200);
         result.put("msg", "success");
         return result;
@@ -241,7 +241,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     /**
      * 同步更新数据
      */
-    private void editPromoter(Long id, Long promoterId, boolean flag) {
+    private void editPromoter(Long id, String mediaId, Long promoterId, boolean flag) {
         try {
             if (flag) {
                 /*缓存标记,每日第一次访问调用该接口,更新达人部分(昵称,省市,粉丝,总销售,头像等)数据*/
@@ -289,7 +289,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
             @Override
             public void run() {
                 try {
-                    list.forEach(kuaishouPromoter -> editPromoter(kuaishouPromoter.getId(), kuaishouPromoter.getPromoterId(), false));
+                    list.forEach(kuaishouPromoter -> editPromoter(kuaishouPromoter.getId(), kuaishouPromoter.getMediaId(), kuaishouPromoter.getPromoterId(), false));
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
@@ -409,7 +409,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                     @Override
                     public void run() {
                         try {
-                            editPromoter(promoter.getId(), promoter.getPromoterId(), true);
+                            editPromoter(promoter.getId(), promoter.getMediaId(), promoter.getPromoterId(), true);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }

+ 1 - 2
ruixuan-live/src/main/resources/mapper/bytedance/BytedanceMapper.xml

@@ -123,7 +123,6 @@
     </select>
 
 
-
     <insert id="replaceBatchOrders">
         replace into bytedance_order_list(
         order_id,
@@ -175,7 +174,7 @@
         second_colonel_buyin_id
         )
         values
-        <foreach collection="activityList" item="cell" separator=",">
+        <foreach collection="list" item="cell" separator=",">
             (
             #{cell.orderId},
             #{cell.buyerAppId},

+ 10 - 0
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -7,6 +7,7 @@
     <resultMap type="com.ruixuan.isc.entity.KuaishouPromoter" id="KuaishouPromoterResult">
         <result property="id" column="id"/>
         <result property="userId" column="user_id"/>
+        <result property="mediaId" column="media_id"/>
         <result property="userName" column="user_name"/>
         <result property="promoterId" column="promoter_id"/>
         <result property="promoterNickName" column="promoter_nick_name"/>
@@ -32,6 +33,7 @@
 
     <sql id="selectKuaishouPromoterVo">
         select id,
+               media_id,
                user_id,
                user_name,
                promoter_id,
@@ -57,6 +59,7 @@
         SELECT
         t1.id,
         t1.user_id,
+        t1.media_id,
         t1.user_name,
         t1.promoter_id,
         t1.promoter_nick_name,
@@ -91,6 +94,9 @@
             <if test="promoterNickName != null  and promoterNickName != ''">
                 and t1.promoter_nick_name like concat('%', #{promoterNickName}, '%')
             </if>
+            <if test="mediaId != null  and mediaId != ''">
+                and t1.media_id = #{mediaId}
+            </if>
         </where>
         order by ${parameter} ${orderBy}
     </select>
@@ -238,6 +244,7 @@
         insert into kuaishou_promoter
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="userId != null">user_id,</if>
+            <if test="mediaId != null">media_id,</if>
             <if test="userName != null">user_name,</if>
             <if test="promoterId != null">promoter_id,</if>
             <if test="promoterNickName != null">promoter_nick_name,</if>
@@ -256,6 +263,7 @@
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
+            <if test="mediaId != null">#{mediaId},</if>
             <if test="userName != null">#{userName},</if>
             <if test="promoterId != null">#{promoterId},</if>
             <if test="promoterNickName != null">#{promoterNickName},</if>
@@ -294,6 +302,7 @@
         update kuaishou_promoter
         <trim prefix="SET" suffixOverrides=",">
             <if test="userId != null">user_id = #{userId},</if>
+            <if test="mediaId != null">media_id = #{mediaId},</if>
             <if test="userName != null">user_name = #{userName},</if>
             <if test="promoterId != null">promoter_id = #{promoterId},</if>
             <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
@@ -319,6 +328,7 @@
         update kuaishou_promoter
         <trim prefix="SET" suffixOverrides=",">
             <if test="userId != null">user_id = #{userId},</if>
+            <if test="mediaId != null">media_id = #{mediaId},</if>
             <if test="userName != null">user_name = #{userName},</if>
             <if test="promoterId != null">promoter_id = #{promoterId},</if>
             <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>