From 9d35ba657fa5e3add766405d76e3ff8c4dcd4ad4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 04 七月 2020 15:38:00 +0800
Subject: [PATCH] 多系统兼容优化

---
 fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java |  841 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 422 insertions(+), 419 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java b/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
index c17a307..135c9c4 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -8,6 +8,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -54,474 +55,476 @@
 @Component
 public class DynamicInfoJob {
 
-	@Resource
-	private DynamicInfoService dynamicInfoService;
+    @Resource
+    private DynamicInfoService dynamicInfoService;
 
-	@Resource
-	private ActivityService activityService;
+    @Resource
+    private ActivityService activityService;
 
-	@Resource
-	private NYouHuiService nyouHuiService;
+    @Resource
+    private NYouHuiService nyouHuiService;
 
-	@Resource
-	private ActivityUserService activityUserService;
+    @Resource
+    private ActivityUserService activityUserService;
 
-	@Resource
-	private WXMPDynamicInfoService wxmpDynamicInfoService;
+    @Resource
+    private WXMPDynamicInfoService wxmpDynamicInfoService;
 
-	@Resource
-	private ConvertLinkManager convertLinkManager;
+    @Resource
+    private ConvertLinkManager convertLinkManager;
 
-	@Resource
-	private HongBaoManageService hongBaoManageService;
+    @Resource
+    private HongBaoManageService hongBaoManageService;
 
-	@Resource
-	private JumpDetailV2Service jumpDetailV2Service;
+    @Resource
+    private JumpDetailV2Service jumpDetailV2Service;
 
-	@Resource
-	private GoodsEvaluateService goodsEvaluateService;
-	
-	@Resource
-	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+    @Resource
+    private GoodsEvaluateService goodsEvaluateService;
 
-	/**
-	 * 姣�10鍒嗛挓 鏅氫笂00:00~06:00涓嶄笅鍙戜换浣曚竴涓晢鍝�
-	 */
-	@Scheduled(cron = "0 0/10 6-23 * * ?")
-	public void insetDynamicInfo() {
+    @Resource
+    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 姣�10鍒嗛挓 鏅氫笂00:00~06:00涓嶄笅鍙戜换浣曚竴涓晢鍝�
+     */
+    @Scheduled(cron = "0 0/10 6-23 * * ?")
+    public void insetDynamicInfo() {
 
-		try {
-			dynamicInfoService.insertTimeHotSale();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-		try {
-			dynamicInfoService.insertTimeRecommend();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        try {
+            dynamicInfoService.insertTimeHotSale();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
 
-	/**
-	 * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆�
-	 */
-	@Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ")
-	public void insetShopInfo1() {
+        try {
+            dynamicInfoService.insertTimeRecommend();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆�
+     */
+    @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ")
+    public void insetShopInfo1() {
 
-		try {
-			dynamicInfoService.insertShopInfo();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 鏃╀笂8:00~10:00姣忓崐涓皬鏃舵洿鏂�
-	 */
-	@Scheduled(cron = "0 0/30 8,9,10 * * ?")
-	public void insetShopInfo2() {
+        try {
+            dynamicInfoService.insertShopInfo();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 鏃╀笂8:00~10:00姣忓崐涓皬鏃舵洿鏂�
+     */
+    @Scheduled(cron = "0 0/30 8,9,10 * * ?")
+    public void insetShopInfo2() {
 
-		try {
-			dynamicInfoService.insertShopInfo();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 鏃╀笂11:00~14:00姣忓崐涓皬鏃舵洿鏂�
-	 */
-	@Scheduled(cron = "0 0/30 11,12,13,14 * * ?")
-	public void insetShopInfo3() {
+        try {
+            dynamicInfoService.insertShopInfo();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 鏃╀笂11:00~14:00姣忓崐涓皬鏃舵洿鏂�
+     */
+    @Scheduled(cron = "0 0/30 11,12,13,14 * * ?")
+    public void insetShopInfo3() {
 
-		try {
-			dynamicInfoService.insertShopInfo();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 涓嬪崍17:00~20:00姣忓崐涓皬鏃舵洿鏂�
-	 */
-	@Scheduled(cron = "0 0/30 17,18,19,20 * * ? ")
-	public void insetShopInfo4() {
+        try {
+            dynamicInfoService.insertShopInfo();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 涓嬪崍17:00~20:00姣忓崐涓皬鏃舵洿鏂�
+     */
+    @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ")
+    public void insetShopInfo4() {
 
-		try {
-			dynamicInfoService.insertShopInfo();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 姣忓ぉ闆剁偣鍒犻櫎3澶╀箣鍓嶆暟鎹�
-	 */
-	@Scheduled(cron = "0 0 1,10 * * ?")
-	public void remove() {
+        try {
+            dynamicInfoService.insertShopInfo();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		if (!Constant.IS_TASK) {
-			return;
-		}
+    /**
+     * 姣忓ぉ闆剁偣鍒犻櫎3澶╀箣鍓嶆暟鎹�
+     */
+    @Scheduled(cron = "0 0 1,10 * * ?")
+    public void remove() {
 
-		try {
-			LogHelper.test("DynamicInfoJob-remove-寮�濮嬫墽琛屾��");
-			dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date()));
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 鍚庡彴缂栬緫鍔ㄦ�侊細 姣�3鍒嗛挓妫�绱�
-	 */
-	@Scheduled(cron = "0 0/3 * * * ?")
-	public void activityNeedPublish() {
-		if (!Constant.IS_TASK) {
-			return;
-		}
+        try {
+            LogHelper.test("DynamicInfoJob-remove-寮�濮嬫墽琛屾��");
+            dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date()));
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		try {
-			List<RecommendActivity> list = activityService.getNeedPublish();
-			if (list == null || list.size() == 0) {
-				return;
-			}
+    /**
+     * 鍚庡彴缂栬緫鍔ㄦ�侊細 姣�3鍒嗛挓妫�绱�
+     */
+    @Scheduled(cron = "0 0/3 * * * ?")
+    public void activityNeedPublish() {
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-			for (RecommendActivity activity : list) {
-				Integer type = activity.getType();
-				if (RecommendActivity.TYPE_SHARE_GOODS == type) {
-					// 鍟嗗搧鍔ㄦ��
-					dynamicInfoService.insertActivityRecommend(activity);
+        try {
+            List<RecommendActivity> list = activityService.getNeedPublish();
+            if (list == null || list.size() == 0) {
+                return;
+            }
 
-					activity.setState(1);
-					activityService.updateByPrimaryKeySelective(activity);
+            for (RecommendActivity activity : list) {
+                Integer type = activity.getType();
+                if (RecommendActivity.TYPE_SHARE_GOODS == type) {
+                    // 鍟嗗搧鍔ㄦ��
+                    dynamicInfoService.insertActivityRecommend(activity);
 
-				} else if (RecommendActivity.TYPE_INVITE == type) {
-					// 閭�璇风礌鏉�
-					RecommendActivityInviteInfo inviteInfo = activityService
-							.getRecommendActivityInviteInfoByActivityId(activity.getId());
-					activity.setInviteInfo(inviteInfo);
+                    activity.setState(1);
+                    activityService.updateByPrimaryKeySelective(activity);
 
-					dynamicInfoService.insertInviteActivity(activity);
+                } else if (RecommendActivity.TYPE_INVITE == type) {
+                    // 閭�璇风礌鏉�
+                    RecommendActivityInviteInfo inviteInfo = activityService
+                            .getRecommendActivityInviteInfoByActivityId(activity.getId());
+                    activity.setInviteInfo(inviteInfo);
 
-					activity.setState(1);
-					activityService.updateByPrimaryKeySelective(activity);
-				}
-			}
+                    dynamicInfoService.insertInviteActivity(activity);
 
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+                    activity.setState(1);
+                    activityService.updateByPrimaryKeySelective(activity);
+                }
+            }
 
-	/**
-	 * 姣忓ぉ6鐐瑰ぉ鏇存柊閭�璇风礌鏉�
-	 */
-	@Scheduled(cron = "0 0 6 * * ?")
-	public void insertTimeInvite() {
-		if (!Constant.IS_TASK) {
-			return;
-		}
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-		try {
-			dynamicInfoService.insertTimeInvite();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
+    /**
+     * 姣忓ぉ6鐐瑰ぉ鏇存柊閭�璇风礌鏉�
+     */
+    @Scheduled(cron = "0 0 6 * * ?")
+    public void insertTimeInvite() {
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-	/**
-	 * 
-	 * @Title: demoJobHandler @Description: 鏇存柊灏忕▼搴忓姩鎬佸晢鍝� @param
-	 * param @return @throws Exception ReturnT<String> 杩斿洖绫诲瀷 @throws
-	 */
-	@XxlJob("dynamic-updateWXMPDynamicInfo")
-	public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception {
-		addJDNYHInfo();
-		return ReturnT.SUCCESS;
-	}
+        try {
+            dynamicInfoService.insertTimeInvite();
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-	/**
-	 * 娣诲姞鍐呬紭鎯犵浉鍏冲晢鍝� @Title: addJDNYHInfo @Description: void 杩斿洖绫诲瀷 @throws
-	 */
-	private void addJDNYHInfo() throws Exception {
+    /**
+     * @Title: demoJobHandler @Description: 鏇存柊灏忕▼搴忓姩鎬佸晢鍝� @param
+     * param @return @throws Exception ReturnT<String> 杩斿洖绫诲瀷 @throws
+     */
+    @XxlJob("dynamic-updateWXMPDynamicInfo")
+    public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception {
+        addJDNYHInfo();
+        return ReturnT.SUCCESS;
+    }
 
-		List<NYouHuiGoods> list = nyouHuiService.list(1, 1);
-		if (list != null && list.size() > 0) {
-			NYouHuiGoods goods = list.get(0);
-			String id = goods.toId();
-			WXMPDynamicInfo info = new WXMPDynamicInfo();
-			info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id);
-			String desc = goods.getDesc();
+    /**
+     * 娣诲姞鍐呬紭鎯犵浉鍏冲晢鍝� @Title: addJDNYHInfo @Description: void 杩斿洖绫诲瀷 @throws
+     */
+    private void addJDNYHInfo() throws Exception {
 
-			info.setSource(WXMPDynamicInfo.SOURCE_NYH);
-			info.setUser(activityUserService.getRandomHaoHuo());
-			// 鍋氶摼鎺ヨ浆鎹�
-			for (String link : goods.getLinkList()) {
-				desc = desc.replaceFirst("\\[閾炬帴\\]", link);
-			}
+        List<NYouHuiGoods> list = nyouHuiService.list(1, 1);
+        if (list != null && list.size() > 0) {
+            NYouHuiGoods goods = list.get(0);
+            String id = goods.toId();
+            WXMPDynamicInfo info = new WXMPDynamicInfo();
+            info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id);
+            String desc = goods.getDesc();
 
-			desc = convertLinkManager.convertJDLinkFromText(desc, 0L, true);
-			info.setContent(desc);
+            info.setSource(WXMPDynamicInfo.SOURCE_NYH);
+            info.setUser(activityUserService.getRandomHaoHuo());
+            // 鍋氶摼鎺ヨ浆鎹�
+            for (String link : goods.getLinkList()) {
+                desc = desc.replaceFirst("\\[閾炬帴\\]", link);
+            }
 
-			List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList());
-			List<GoodsPicture> imgs = new ArrayList<>();
+            desc = convertLinkManager.convertJDLinkFromText(desc, 0L, true);
+            info.setContent(desc);
 
-			BigDecimal totalMoney = new BigDecimal(0);
-			List<String> lastPicture = new ArrayList<>();
-			for (JDGoods jdGoods : goodsList) {
-				GoodsPicture picture = new GoodsPicture();
-				BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate());
-				totalMoney = totalMoney.add(money);
-				picture.setGoodsVO(
-						GoodsDetailVOFactory.convertJDGoods(jdGoods,
-								new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
-										hongBaoManageService.getShareRate(), null,
-										hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
-				picture.setGoodState(0);
-				picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
-				picture.setParams(null);
-				picture.setUrl(jdGoods.getPicUrl());
-				imgs.add(picture);
-				if (jdGoods.getImageList() != null)
-					if (jdGoods.getImageList().size() > 4)
-						lastPicture.addAll(jdGoods.getImageList().subList(1, 4));
-					else if (jdGoods.getImageList().size() > 1)
-						lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size()));
-			}
-			info.setShareMoney(totalMoney);
-			int count = 0;
-			while (imgs.size() < 4 && count < 4) {
-				count++;
-				String picurl = lastPicture.get((int) (lastPicture.size() * Math.random()));
-				if (picurl != null) {
-					lastPicture.remove(picurl);
-					GoodsPicture picture = new GoodsPicture();
-					picture.setUrl(picurl);
-					imgs.add(picture);
-				}
-			}
+            List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList());
+            List<GoodsPicture> imgs = new ArrayList<>();
 
-			info.setImgs(imgs);
+            BigDecimal totalMoney = new BigDecimal(0);
+            List<String> lastPicture = new ArrayList<>();
+            for (JDGoods jdGoods : goodsList) {
+                GoodsPicture picture = new GoodsPicture();
+                BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate());
+                totalMoney = totalMoney.add(money);
+                picture.setGoodsVO(
+                        GoodsDetailVOFactory.convertJDGoods(jdGoods,
+                                new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
+                                        hongBaoManageService.getShareRate(), null,
+                                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
+                picture.setGoodState(0);
+                picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
+                picture.setParams(null);
+                picture.setUrl(jdGoods.getPicUrl());
+                imgs.add(picture);
+                if (jdGoods.getImageList() != null)
+                    if (jdGoods.getImageList().size() > 4)
+                        lastPicture.addAll(jdGoods.getImageList().subList(1, 4));
+                    else if (jdGoods.getImageList().size() > 1)
+                        lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size()));
+            }
+            info.setShareMoney(totalMoney);
+            int count = 0;
+            while (imgs.size() < 4 && count < 4) {
+                count++;
+                String picurl = lastPicture.get((int) (lastPicture.size() * Math.random()));
+                if (picurl != null) {
+                    lastPicture.remove(picurl);
+                    GoodsPicture picture = new GoodsPicture();
+                    picture.setUrl(picurl);
+                    imgs.add(picture);
+                }
+            }
 
-			wxmpDynamicInfoService.addWXMPDynamicInfo(info);
-		}
-	}
+            info.setImgs(imgs);
 
-	
-	/**
-	 *  姣忎竴涓皬鏃堕殢鏈哄湪鍒嗕韩鏁扮殑鍩虹涓婂姞10~100銆傚鍔犵殑鏃堕棿娈垫槸姣忓ぉ8~22鐐广��
-	 * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆�
-	 */
-	@Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ")
-	public void addRanDomShareCount() {
-		if (!Constant.IS_TASK) {
-			return;
-		}
+            wxmpDynamicInfoService.addWXMPDynamicInfo(info);
+        }
+    }
 
-		try {
-			goodsEvaluateService.addRanDomShareCount();
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-	}
-	
-	
-	/**
-	 * 鍟嗗搧鍔犲叆鍙戝湀
-	 */
-	@XxlJob("dynamic-insertEvaluate")
-	public ReturnT<String> insertEvaluate(String param) throws Exception {
-		// 濂藉崟搴�
-		boolean addResult = addHDKListSelected();
-		// 澶ф窐瀹㈠鐢�
-		if (!addResult) {
-			addDTKFriendsFircleList();
-		}
-		return ReturnT.SUCCESS;
-	}
-	
-	
-	/**
-	 * 濂藉崟搴撳晢鍝佸姞鍏ュ彂鍦�
-	 * @return
-	 */
-	private boolean addHDKListSelected () {
-		boolean addResult = false;
-		Integer minId = 1;
-		while (minId != null) {
-			HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listSelected(minId);
-			if (dto == null) {
-				minId = null;
-			} else {
-				minId = dto.getMinId();
-				List<HDKWXCircleContentDTO>  list = dto.getList();
-				if (list== null || list.size() == 0) {
-					continue;
-				}
-				
-				for (HDKWXCircleContentDTO circleContentDTO: list) {
-					try {
-						String itemid = circleContentDTO.getItemid();
-						HDKGoodsDetail hdkGoods = HaoDanKuApiUtil.getInstance().getItemDetail(itemid);
-						if (hdkGoods == null) {
-							continue;
-						}
-						
-						List<String> pics = circleContentDTO.getItempic();
-						String copy_content = circleContentDTO.getCopy_content();
-						String showtitle = StringEscapeUtils.unescapeHtml(copy_content);
-						showtitle = showtitle.replace("<br>", "\r\n");
-						
-						List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
-						ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
-						
-						int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle);
-						if (addProcess == 0) {
-							addResult = true;
-							break;
-						}
-					} catch (GoodsEvaluateException e) {
-						e.printStackTrace();
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-				}
-			}
-			if(addResult)
-			 break;
-		}
-		return addResult;
-	}
-	
-	
-	/**
-	 * 澶ф窐瀹㈠晢鍝佸姞鍏ュ彂鍦�
-	 * @return
-	 */
-	private boolean addDTKFriendsFircleList() {
-		boolean addResult = false;
-		try {
-			DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100);
-			while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
-				for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) {
-					try {
-						Long goodsId = detailV2.getGoodsId();
-						
-						String circleText = detailV2.getCircleText();
-						if (circleText == null) {
-							continue;
-						}
-						String showtitle = URLDecoder.decode(circleText, "UTF-8");
-						showtitle = showtitle.replace("&nbsp;", " ");
 
-						DaTaoKeDetailV2 tkGoods = DaTaoKeApiUtil.getGoodsDetailByGoodsId(goodsId);
-						if(tkGoods == null) {
-							continue;
-						}
-						
-						ActivityUser user = null;
-						if (detailV2.getCid() != null) {
-							user = activityUserService.getRandomByDaTaoKeCid(detailV2.getCid());
-						}
-						if (user == null) {
-							List<ActivityRuleUser> ruleList = activityUserService
-									.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
-							user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
-						}
-						
-						int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle);
-						if (addProcess == 0) {
-							addResult = true;
-							break;
-						}
-					} catch (GoodsEvaluateException e) {
-						e.printStackTrace();
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-				}
+    /**
+     * 姣忎竴涓皬鏃堕殢鏈哄湪鍒嗕韩鏁扮殑鍩虹涓婂姞10~100銆傚鍔犵殑鏃堕棿娈垫槸姣忓ぉ8~22鐐广��
+     * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆�
+     */
+    @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ")
+    public void addRanDomShareCount() {
+        if (!Constant.IS_TASK) {
+            return;
+        }
 
-				if (addResult) {
-					break;
-				}
+        try {
+            for (SystemEnum system : SystemEnum.values())
+                goodsEvaluateService.addRanDomShareCount(system);
+        } catch (Exception e) {
+            try {
+                LogHelper.errorDetailInfo(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
 
-				try {
-					result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
-				} catch (Exception e) {
-					result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
-				}
-				try {
-					Thread.sleep(10);
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-				}
-			}
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-		return addResult;
-	}
-	
+
+    /**
+     * 鍟嗗搧鍔犲叆鍙戝湀
+     */
+    @XxlJob("dynamic-insertEvaluate")
+    public ReturnT<String> insertEvaluate(String param) throws Exception {
+        // 濂藉崟搴�
+        boolean addResult = addHDKListSelected();
+        // 澶ф窐瀹㈠鐢�
+        if (!addResult) {
+            addDTKFriendsFircleList();
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+    /**
+     * 濂藉崟搴撳晢鍝佸姞鍏ュ彂鍦�
+     *
+     * @return
+     */
+    private boolean addHDKListSelected() {
+        boolean addResult = false;
+        Integer minId = 1;
+        while (minId != null) {
+            HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listSelected(minId);
+            if (dto == null) {
+                minId = null;
+            } else {
+                minId = dto.getMinId();
+                List<HDKWXCircleContentDTO> list = dto.getList();
+                if (list == null || list.size() == 0) {
+                    continue;
+                }
+
+                for (HDKWXCircleContentDTO circleContentDTO : list) {
+                    try {
+                        String itemid = circleContentDTO.getItemid();
+                        HDKGoodsDetail hdkGoods = HaoDanKuApiUtil.getInstance().getItemDetail(itemid);
+                        if (hdkGoods == null) {
+                            continue;
+                        }
+
+                        List<String> pics = circleContentDTO.getItempic();
+                        String copy_content = circleContentDTO.getCopy_content();
+                        String showtitle = StringEscapeUtils.unescapeHtml(copy_content);
+                        showtitle = showtitle.replace("<br>", "\r\n");
+
+                        List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
+                        ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
+
+                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle, SystemEnum.blks);
+                        if (addProcess == 0) {
+                            addResult = true;
+                            break;
+                        }
+                    } catch (GoodsEvaluateException e) {
+                        e.printStackTrace();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+            if (addResult)
+                break;
+        }
+        return addResult;
+    }
+
+
+    /**
+     * 澶ф窐瀹㈠晢鍝佸姞鍏ュ彂鍦�
+     *
+     * @return
+     */
+    private boolean addDTKFriendsFircleList() {
+        boolean addResult = false;
+        try {
+            DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100);
+            while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
+                for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) {
+                    try {
+                        Long goodsId = detailV2.getGoodsId();
+
+                        String circleText = detailV2.getCircleText();
+                        if (circleText == null) {
+                            continue;
+                        }
+                        String showtitle = URLDecoder.decode(circleText, "UTF-8");
+                        showtitle = showtitle.replace("&nbsp;", " ");
+
+                        DaTaoKeDetailV2 tkGoods = DaTaoKeApiUtil.getGoodsDetailByGoodsId(goodsId);
+                        if (tkGoods == null) {
+                            continue;
+                        }
+
+                        ActivityUser user = null;
+                        if (detailV2.getCid() != null) {
+                            user = activityUserService.getRandomByDaTaoKeCid(detailV2.getCid());
+                        }
+                        if (user == null) {
+                            List<ActivityRuleUser> ruleList = activityUserService
+                                    .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
+                            user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
+                        }
+
+                        int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle, SystemEnum.blks);
+                        if (addProcess == 0) {
+                            addResult = true;
+                            break;
+                        }
+                    } catch (GoodsEvaluateException e) {
+                        e.printStackTrace();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+
+                if (addResult) {
+                    break;
+                }
+
+                try {
+                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
+                } catch (Exception e) {
+                    result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100);
+                }
+                try {
+                    Thread.sleep(10);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        } catch (Exception e) {
+            LogHelper.errorDetailInfo(e);
+        }
+        return addResult;
+    }
+
 }

--
Gitblit v1.8.0