Explorar o código

达人补全,添加miaogousi rocket

zhaoxian hai 1 ano
pai
achega
c3b42e3736

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

@@ -128,4 +128,13 @@ public interface KuaishouPromoterMapper {
     List<JYKuaishouPromoter> getFailInfo3();
 
     JSONObject selectKuaishouRulePromoterById(@Param("promoterId") Long promoterId);
-}
+
+    List<JYKuaishouPromoter> getMiaogousiInfoFailInfo();
+
+    void updateMiaogousiKuaishouPromoterByPromoterId(KuaishouPromoter kuaishouPromoter);
+
+    List<JYKuaishouPromoter> getRocketFailInfo();
+
+    void updateRocketKuaishouPromoterByPromoterId(KuaishouPromoter kuaishouPromoter);
+
+}

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

@@ -346,6 +346,7 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
                         result.getString("totalSale"),
                         promoterId
                 );
+
                 if ("1".equals(mediaId)) {
                     String followerincr = result.getString("follower_incr");
                     if (Check.isNotNull(followerincr) && !"-".equals(followerincr)) {
@@ -419,6 +420,108 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         }
     }
 
+    /**
+     * 同步更新数据
+     */
+    private void editMiaogousiPromoter(Long id, String mediaId, String promoterId, boolean flag) {
+        try {
+            if (flag) {
+                /*缓存标记,每日第一次访问调用该接口,更新达人部分(昵称,省市,粉丝,总销售,头像等)数据*/
+                String key = DateUtils.getDate() + "mgs_" + promoterId + "_" + id;
+                String value = (String) redisUtil.get(key);
+                if (Check.isNotNull(value) && "1".equals(value)) {
+                    return;
+                }
+                redisUtil.set(key, "1", 60 * 60 * 24);
+            }
+
+            /*更新达人数据*/
+            Map<String, Object> param = new HashMap<>();
+            param.put("promoterId", promoterId);
+            param.put("mediaId", mediaId);
+            Long startTime = System.currentTimeMillis();
+            String content = HttpUtil.httpPostRequest(startIpPath + "promoterInfo/getPromoterId", param, null);
+            Thread.sleep(3000);
+
+            JSONObject result = JSONObject.parseObject(content);
+            if (Check.isNotNull(result) && Check.isNotNull(result.getString("promoterNickName"))) {
+                String province = "";
+                if (Check.isNotNull(result.getString("province"))) {
+                    province = result.getString("province").concat("-").concat(result.getString("city"));
+                }
+                KuaishouPromoter kuaishouPromoter = new KuaishouPromoter(
+                        id,
+                        result.getString("promoterNickName"),
+                        province,
+                        result.getString("promoterHeadImgUrl"),
+                        result.getString("fanNum"),
+                        result.getString("avgVideoSales"),
+                        result.getString("videoSales"),
+                        result.getString("totalSale"),
+                        promoterId
+                );
+
+                kuaishouPromoterMapper.updateMiaogousiKuaishouPromoterByPromoterId(kuaishouPromoter);
+            } else {
+                log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("更新达人信息异常", e);
+        }
+    }
+
+
+    /**
+     * 同步更新数据
+     */
+    private void editRocketPromoter(Long id, String mediaId, String promoterId, boolean flag) {
+        try {
+            if (flag) {
+                /*缓存标记,每日第一次访问调用该接口,更新达人部分(昵称,省市,粉丝,总销售,头像等)数据*/
+                String key = DateUtils.getDate() + "rocket_" + promoterId + "_" + id;
+                String value = (String) redisUtil.get(key);
+                if (Check.isNotNull(value) && "1".equals(value)) {
+                    return;
+                }
+                redisUtil.set(key, "1", 60 * 60 * 24);
+            }
+
+            /*更新达人数据*/
+            Map<String, Object> param = new HashMap<>();
+            param.put("promoterId", promoterId);
+            param.put("mediaId", mediaId);
+            Long startTime = System.currentTimeMillis();
+            String content = HttpUtil.httpPostRequest(startIpPath + "promoterInfo/getPromoterId", param, null);
+            Thread.sleep(3000);
+
+            JSONObject result = JSONObject.parseObject(content);
+            if (Check.isNotNull(result) && Check.isNotNull(result.getString("promoterNickName"))) {
+                String province = "";
+                if (Check.isNotNull(result.getString("province"))) {
+                    province = result.getString("province").concat("-").concat(result.getString("city"));
+                }
+                KuaishouPromoter kuaishouPromoter = new KuaishouPromoter(
+                        id,
+                        result.getString("promoterNickName"),
+                        province,
+                        result.getString("promoterHeadImgUrl"),
+                        result.getString("fanNum"),
+                        result.getString("avgVideoSales"),
+                        result.getString("videoSales"),
+                        result.getString("totalSale"),
+                        promoterId
+                );
+                kuaishouPromoterMapper.updateRocketKuaishouPromoterByPromoterId(kuaishouPromoter);
+            } else {
+                log.error("更新达人失败,达人ID:{} 【返回结果】:{}", promoterId, result);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("更新达人信息异常", e);
+        }
+    }
+
     @Override
     public JSONObject insertKuaishouPromoter3(JYKuaishouPromoter promoter) {
         JSONObject result = new JSONObject();
@@ -457,8 +560,9 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         thread.start();
         List<String> promoters = new ArrayList<>();
         list.forEach(kuaishouPromoter -> promoters.add(kuaishouPromoter.getPromoterId() + "【" + kuaishouPromoter.getMediaId() + "】"));
-        String jyMsg = supplementInfo3();
-        promoters.add(jyMsg);
+        promoters.add(supplementInfo3());
+        promoters.add(miaogousiInfo());
+        promoters.add(rocketInfo());
         return Result.success("共计" + list.size() + "条,数据补充中...", promoters);
     }
 
@@ -481,6 +585,44 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         return "-------------骄阳共计" + list.size() + "条,达人IDS: " + promoters.toString();
     }
 
+    //miaogousi
+    public String miaogousiInfo() {
+        List<JYKuaishouPromoter> list = kuaishouPromoterMapper.getMiaogousiInfoFailInfo();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    list.forEach(kuaishouPromoter -> editMiaogousiPromoter(kuaishouPromoter.getId(), kuaishouPromoter.getMediaId(), kuaishouPromoter.getPromoterId(), false));
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+        thread.start();
+        List<String> promoters = new ArrayList<>();
+        list.forEach(kuaishouPromoter -> promoters.add(kuaishouPromoter.getPromoterId()));
+        return "-------------miaogousi共计" + list.size() + "条,达人IDS: " + promoters.toString();
+    }
+
+    //rocket
+    public String rocketInfo() {
+        List<JYKuaishouPromoter> list = kuaishouPromoterMapper.getRocketFailInfo();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    list.forEach(kuaishouPromoter -> editRocketPromoter(kuaishouPromoter.getId(), kuaishouPromoter.getMediaId(), kuaishouPromoter.getPromoterId(), false));
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+        thread.start();
+        List<String> promoters = new ArrayList<>();
+        list.forEach(kuaishouPromoter -> promoters.add(kuaishouPromoter.getPromoterId()));
+        return "-------------rocket共计" + list.size() + "条,达人IDS: " + promoters.toString();
+    }
+
 
     @Override
     public int addFollowUpRecords(JSONObject result) {

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

@@ -334,6 +334,7 @@
           AND state = 1
     </select>
 
+
     <select id="getBoundPromoterRoleKey" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.user_id,
                t3.role_key,
@@ -684,6 +685,123 @@
         where id = #{id}
     </delete>
 
+    <select id="getMiaogousiInfoFailInfo" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
+        select id,
+               media_id,
+               user_id,
+               user_name,
+               promoter_id,
+               promoter_nick_name,
+               `state`,
+               province,
+               commission_requirement,
+               category_requirement,
+               promoter_url,
+               phone,
+               consignee,
+               promoter_address,
+               total_sale,
+               fans_number,
+               avg_video_sales,
+               video_sales,
+               create_time,
+               update_time
+        from miaogousi.kuaishou_promoter
+        where (promoter_nick_name = '' or promoter_nick_name is null)
+          AND state = 1
+    </select>
+
+
+    <update id="updateMiaogousiKuaishouPromoterByPromoterId" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
+        update miaogousi.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>
+            <if test="totalSale != null">total_sale = #{totalSale},</if>
+            <if test="fansNumber != null">fans_number = #{fansNumber},</if>
+            <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="consignee != null">consignee = #{consignee},</if>
+            <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
+            <if test="state != null">state = #{state},</if>
+            <if test="province != null">province = #{province},</if>
+            <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
+            <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
+            <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
+            <if test="videoSales != null">video_sales = #{videoSales},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="followerIncr != null">follower_incr = #{followerIncr},</if>
+            <if test="liveCount30 != null">live_count_30 = #{liveCount30},</if>
+            <if test="awemeAvgDiggCount30 != null">aweme_avg_digg_count_30 = #{awemeAvgDiggCount30},</if>
+            <if test="awemeDiggFollowerRation != null">aweme_digg_follower_ration = #{awemeDiggFollowerRation},</if>
+            <if test="liveAverageUser30 != null">live_average_user_30 = #{liveAverageUser30},</if>
+        </trim>
+        where promoter_id = #{promoterId}
+    </update>
+
+    <select id="getRocketFailInfo" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
+        select id,
+               media_id,
+               user_id,
+               user_name,
+               promoter_id,
+               promoter_nick_name,
+               `state`,
+               province,
+               commission_requirement,
+               category_requirement,
+               promoter_url,
+               phone,
+               consignee,
+               promoter_address,
+               total_sale,
+               fans_number,
+               avg_video_sales,
+               video_sales,
+               create_time,
+               update_time
+        from rocket.kuaishou_promoter
+        where (promoter_nick_name = '' or promoter_nick_name is null)
+          AND state = 1
+    </select>
+
+
+    <update id="updateRocketKuaishouPromoterByPromoterId" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
+        update rocket.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>
+            <if test="totalSale != null">total_sale = #{totalSale},</if>
+            <if test="fansNumber != null">fans_number = #{fansNumber},</if>
+            <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="consignee != null">consignee = #{consignee},</if>
+            <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
+            <if test="state != null">state = #{state},</if>
+            <if test="province != null">province = #{province},</if>
+            <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
+            <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
+            <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
+            <if test="videoSales != null">video_sales = #{videoSales},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="followerIncr != null">follower_incr = #{followerIncr},</if>
+            <if test="liveCount30 != null">live_count_30 = #{liveCount30},</if>
+            <if test="awemeAvgDiggCount30 != null">aweme_avg_digg_count_30 = #{awemeAvgDiggCount30},</if>
+            <if test="awemeDiggFollowerRation != null">aweme_digg_follower_ration = #{awemeDiggFollowerRation},</if>
+            <if test="liveAverageUser30 != null">live_average_user_30 = #{liveAverageUser30},</if>
+        </trim>
+        where promoter_id = #{promoterId}
+    </update>
+
+
     <delete id="deleteKuaishouPromoterByIds" parameterType="String">
         delete from kuaishou_promoter where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">