From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java | 1372 +++++++++++++++++++++++----------------------------------- 1 files changed, 549 insertions(+), 823 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java index 14cd59a..6e709b1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java @@ -1,823 +1,549 @@ -package com.yeshi.fanli.job; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import net.sf.json.JSONObject; - -import org.quartz.Job; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule; -import com.yeshi.fanli.entity.bus.lable.Label; -import com.yeshi.fanli.entity.bus.lable.QualityFactory; -import com.yeshi.fanli.entity.common.AdminUser; -import com.yeshi.fanli.entity.taobao.SearchFilter; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.lable.LabelService; -import com.yeshi.fanli.service.inter.lable.QualityFactoryService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; -import com.yeshi.fanli.tag.PageEntity; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.taobao.TaoBaoUtil; -import com.yeshi.fanli.util.taobao.TaoKeApiUtil; - -/** - * 绮鹃�夊晢鍝佽嚜鍔ㄥ叆搴� - * - * @author yj - * - */ -// @Component -public class QualityFactoryJob implements Job { - - // 9.9 19.9 29.9 49.9 绛涢�� - public final static String IS_9K9 = "IS_9K9"; - - // 闄愭椂鎶㈣喘 - public final static String FLASH_SALE = "IS_XSQG"; - - @Resource - private LabelService labelService; - @Resource - private QualityFactoryService qualityFactoryService; - @Resource - private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; - - public QualityFactoryJob() { - System.out.println("--UpdateQualityFactoryJob 鏋勯�犲嚱鏁�--"); - } - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - LogHelper.test("---UpdateQualityFactoryJob----execute "); - - // 鐖彇鍟嗗搧淇℃伅 - searchGoods(context); - } - - public void searchGoods(JobExecutionContext context) { - try { - - JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); - - BoutiqueAutoRule autoRule = new BoutiqueAutoRule(); - - /* 瑙勫垯id */ - if (jobDataMap.get("ruleId") != null && !StringUtil.isNullOrEmpty(jobDataMap.get("ruleId").toString())) { - Long ruleId = Long.parseLong(jobDataMap.get("ruleId").toString()); - autoRule.setId(ruleId); - } - - /* 绛涢�夋潯浠� */ - JSONObject jsonData = null; - if (jobDataMap.get("searchContent") != null) { - String jsonContent = jobDataMap.get("searchContent").toString(); - jsonData = JSONObject.fromObject(jsonContent); - } - - if (jsonData == null) { - jsonData = new JSONObject(); - } - - /* 鏉ユ簮鍚嶇О */ - if (jsonData.get("sourceCalss") != null && !StringUtil.isNullOrEmpty(jsonData.get("sourceCalss").toString())) { - String sourceCalss = jsonData.get("sourceCalss").toString(); - autoRule.setSourceCalss(sourceCalss); - } - - /* 瑙勫垯鍚嶇О */ - String title = ""; - if (jsonData.get("title") != null && !StringUtil.isNullOrEmpty(jsonData.get("title").toString())) { - title = jsonData.get("title").toString(); - } - autoRule.setTitle(title); - - /* 绯荤粺绫荤洰id */ - String systemCid = ""; - if (jsonData.get("systemCid") != null && !StringUtil.isNullOrEmpty(jsonData.get("systemCid").toString())) { - systemCid = jsonData.get("systemCid").toString(); - } - autoRule.setSystemCid(systemCid); - - /* 鎿嶄綔浜猴細 寮�鍙戣处鍙� */ - AdminUser admin = new AdminUser(2L); - autoRule.setAdminUser(admin); - - /* 鏍囩鍒楄〃 */ - List<Label> listLabs = new ArrayList<Label>(); - - if (jsonData.get("lableNames") != null && !StringUtil.isNullOrEmpty(jsonData.get("lableNames").toString())) { - - // 绌烘牸闅斿紑 - String[] arrtitles = jsonData.get("lableNames").toString().split("\\s+"); - - /* 閬嶅巻鏍囩鍚嶇О锛氭煡璇㈡暟鎹簱涓槸鍚﹀凡瀛樺湪 */ - for (String name : arrtitles) { - List<Label> labels = labelService.selectByTitle(name.trim()); - - if (labels != null && labels.size() > 0) { - Label label = labels.get(0); - - listLabs.add(label); - } else { - // 鏂板 - Label addLabel = addLabel(name, admin); - listLabs.add(addLabel); - } - - } - } - - int source = Integer.parseInt(jobDataMap.get("source").toString()); - autoRule.setSource(QualityFactory.SOURCE_TAOBAO); - - if (BoutiqueAutoRule.TB_OPTIONAL == source) { - // 鏉ユ簮娣樺疂鏅�氭帴鍙� - autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO); - - searchTaoBao(jsonData, listLabs, autoRule); - } - - if (BoutiqueAutoRule.TB_MATERIAL == source) { - autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_MATERIAL); - // 娣樺疂鎺ㄨ崘 - searchMaterial(jsonData, listLabs, autoRule); - } - - } catch (Exception e) { - try { - LogHelper.test("--searchGoods--鎵ц寮傚父----"); - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - } - - /** - * 娣樺疂api 鎺ュ彛鏁版嵁鐖彇 - * - * @param jobDataMap - */ - private void searchTaoBao(JSONObject jsonData, List<Label> listLabs, BoutiqueAutoRule autoRule) { - - try { - Date time = new Date(); - String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(time); - - // 椤靛ぇ灏忥紝榛樿100鏉� - int pageSize = 100; - - boolean isCrawl = true; - // 鏉冮噸璧峰 - int startWeight = 0; - // 鏉冮噸缁撴潫 - int endWeight = 0; - - // 鏄惁鍔犲叆闄愭椂鎶㈣喘 - boolean isFlashSale = false; - String title = autoRule.getTitle(); - if (title.contains(FLASH_SALE)) { - isFlashSale = true; - } - autoRule.setFlashSale(isFlashSale); - - // 鏈�澶氱埇鍙栭〉鐮� - int pageMax = 200; - if (jsonData.get("maxPage") != null) { - pageMax = Integer.parseInt(jsonData.get("maxPage").toString()); - } - - /* 鍙傛暟澶勭悊 */ - SearchFilter filter = getSearchFilter(jsonData); - // 灞曠ず鏉$洰 - filter.setPageSize(pageSize); - - for (int page = 1; page <= pageMax; page++) { - - filter.setPage(page); - - TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(filter); - LogHelper.test(title + "searchWuLiao 宸茬埇鍙�- " + page + "-椤�-"); - - // 缁撴灉涓虹┖ 鏃朵笉鍐嶈姹� - if (result == null) { - LogHelper.test(title + "searchWuLiao杩斿洖 result涓虹┖"); - return; - } - - // 缁撴灉鏁版嵁澶勭悊 - List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs(); - if (listGoods == null || listGoods.size() == 0) { - LogHelper.test(title + "searchWuLiao杩斿洖ListGoods 缁撴灉涓虹┖"); - return; - } - - /* 鏉冮噸鑼冨洿 */ - if (page < 3) { - startWeight = 10000; - endWeight = 12000; - } else { - startWeight = 10; - endWeight = 3000; - } - - autoRule.setStartWeight(startWeight); - autoRule.setEndWeight(endWeight); - - /* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */ - if (StringUtil.isNullOrEmpty(title)) { - screen(listGoods, jsonData, filter, listLabs, autoRule); - } else { - if (title.contains(IS_9K9)) { - screen9K9(filter, listGoods, jsonData, listLabs, autoRule); - } else { - screen(listGoods, jsonData, filter, listLabs, autoRule); - } - } - - /* 閿�鍞噺灏忓�� */ - int minSales = 0; - if (jsonData.get("startSales") != null) { - minSales = (int) jsonData.get("startSales"); - } - - /* 閿�鍞噺澶у�� */ - int maxSales = 0; - if (jsonData.get("endSales") != null) { - maxSales = (int) jsonData.get("endSales"); - } - - // 閿�閲忔帶鍒� - for (TaoBaoGoodsBrief goodsBrief : listGoods) { - - int biz30day = goodsBrief.getBiz30day(); - /* 楠岃瘉閿�鍞噺 -- 缁撴潫鐖彇鏁版嵁 */ - if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) { - isCrawl = false; - } else if (maxSales > 0 && biz30day > maxSales) { - isCrawl = false; - } else if (minSales > 0 && biz30day < minSales) { - isCrawl = false; - } - } - - // 鎬婚〉鏁扮埇鍙栧畬鎴� - PageEntity pageEntity = result.getPageEntity(); - int totalPage = pageEntity.getTotalPage(); - LogHelper.test(title + "鎬婚〉鐮�" + totalPage); - - // 鏈�鍚庝竴椤垫暟鎹埇鍙栧畬鎴� - if (page == totalPage) - isCrawl = false; - - if (!isCrawl) { - LogHelper.test("----" + title + "--姝e父缁撴潫-------"); - break;// 缁撴潫鐖彇鏁版嵁 - } - } - - // 9k9 闄愭椂鎶㈣喘 涓嶆搷浣滃垹闄� - if (title.contains(IS_9K9) || title.contains(FLASH_SALE)) { - return; - } - - /* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */ - if (jsonData.get("systemCid") != null && !StringUtil.isNullOrEmpty(jsonData.get("systemCid").toString())) { - - Long systemCid = Long.parseLong(jsonData.get("systemCid").toString()); - - List<Long> list = qualityFactoryService.getAuctionIdbyClassId(systemCid, autoRule.getGoodsSource(), formatDate); - - if (list != null && list.size() > 0) { - if (list.size() <= 100) { - qualityFactoryService.deleteBatchByTaoBaoGoodsId(list); - } else { - - int start = 0; - int end = 100; - int countRow = 100; - - int count = list.size() / countRow; - - if (list.size() % countRow > 0) { - count += 1; - } - - for (int i = 0; i < count; i++) { - List<Long> sublist = new ArrayList<Long>(); - if (i == count - 1) { - //System.out.println(list.subList(start, list.size())); - sublist = list.subList(start, list.size()); - qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist); - break; - } - sublist = list.subList(start, end); - qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist); - start += countRow; - end += countRow; - } - - } - } - } - - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - } - - /** - * 娣樺疂api 鎺ュ彛鏁版嵁鐖彇 - * - * @param jobDataMap - */ - private void searchMaterial(JSONObject jsonData, List<Label> listLabs, BoutiqueAutoRule autoRule) { - - try { - // 榛樿20鏉� - int pageSize = 20; - - boolean isCrawl = true; - - // 鏉冮噸璧峰 - int startWeight = 1000; - // 鏉冮噸缁撴潫 - int endWeight = 3000; - autoRule.setStartWeight(startWeight); - autoRule.setEndWeight(endWeight); - - // 鏄惁鍔犲叆闄愭椂鎶㈣喘 - boolean isFlashSale = false; - String title = autoRule.getTitle(); - if (title.contains(FLASH_SALE)) { - isFlashSale = true; - } - autoRule.setFlashSale(isFlashSale); - - // 鏈�澶氱埇鍙栭〉鐮� - int pageMax = 200; - if (jsonData.get("maxPage") != null) { - pageMax = Integer.parseInt(jsonData.get("maxPage").toString()); - } - - /* 鍙傛暟澶勭悊 */ - SearchFilter filter = getSearchFilter(jsonData); - - for (int page = 1; page <= pageMax; page++) { - - int materialId = 0; - String cateIds = filter.getCateIds(); - if (!StringUtil.isNullOrEmpty(cateIds)) { - materialId = Integer.parseInt(cateIds); - } - - // 璇锋眰瀹樻柟鎺ㄨ崘鍟嗗搧搴� - TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, page, pageSize); - - // 缁撴灉涓虹┖ 鏃朵笉鍐嶈姹� - if (result == null) { - LogHelper.test(title + "searchMaterial杩斿洖 result涓虹┖"); - return; - } - - // 缁撴灉鏁版嵁澶勭悊 - List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs(); - if (listGoods == null || listGoods.size() == 0) { - LogHelper.test(title + "searchMaterial杩斿洖ListGoods 缁撴灉涓虹┖"); - return; - } - - /* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */ - if (StringUtil.isNullOrEmpty(title)) { - screen(listGoods, jsonData, filter, listLabs, autoRule); - } else { - if (title.contains(IS_9K9)) { - screen9K9(filter, listGoods, jsonData, listLabs, autoRule); - } else { - screen(listGoods, jsonData, filter, listLabs, autoRule); - } - } - - // 鎬婚〉鏁扮埇鍙栧畬鎴� - PageEntity pageEntity = result.getPageEntity(); - long count = pageEntity.getTotalCount(); - int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); - - // 鏈�鍚庝竴椤垫暟鎹埇鍙栧畬鎴� - if (page == totalPage) - isCrawl = false; - - if (!isCrawl) { - LogHelper.test("----" + title + "--缁撴潫-------"); - break;// 缁撴潫鐖彇鏁版嵁 - } - } - - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - } - - /** - * 鍙傛暟澶勭悊鍔犲伐 - * - * @param jobDataMap - * @return - */ - public SearchFilter getSearchFilter(JSONObject jsonData) { - - SearchFilter filter = new SearchFilter(); - - // 鎺掑簭瀛楁 閿�閲忛珮鍒颁綆(榛樿) - filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); - - if (jsonData.get("key") != null) { - String key = jsonData.get("key").toString(); - if (!StringUtil.isNullOrEmpty(key)) { - // 鎼滅储鍏抽敭璇� - filter.setKey(key); - } - } - - if (jsonData.get("cateIds") != null) { - // 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎 - filter.setCateIds(jsonData.get("cateIds").toString()); - } - - if (jsonData.get("startZkPrice") != null) { - // 鍦ㄥ敭浠疯寖鍥村皬鍊� - Double startZkPrice = Double.valueOf(jsonData.get("startZkPrice").toString()); - filter.setStartPrice(new BigDecimal(startZkPrice)); - } - - if (jsonData.get("endZkPrice") != null) { - // 鍦ㄥ敭浠疯寖鍥村ぇ鍊� - Double endZxPrice = Double.valueOf(jsonData.get("endZkPrice").toString()); - filter.setEndPrice(new BigDecimal(endZxPrice)); - } - - if (jsonData.get("startTkRate") != null) { - // 浣i噾鑼冨洿灏忓�� - BigDecimal b = new BigDecimal(jsonData.get("startTkRate").toString()); - double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); - int tkRate = (int) (df * 100); - filter.setStartTkRate(tkRate); - } - - if (jsonData.get("endTkRate") != null) { - // 浣i噾鑼冨洿澶у�� - BigDecimal b = new BigDecimal(jsonData.get("endTkRate").toString()); - double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); - int tkRate = (int) (df * 100); - filter.setEndTkRate(tkRate); - } - - if (jsonData.get("isTmall") != null && jsonData.get("isTmall").toString().equals("1")) { - // 鏄惁澶╃尗if ("1".equals(isTmall)) { - filter.setTmall(true); - } - - if (jsonData.get("hasCoupon") != null && jsonData.get("hasCoupon").toString().equals("1")) { - // 鏄惁鏈夊埜锛�1 鏈� 0 鏃� - filter.setQuan(1); - } - - if (jsonData.get("freeShipment") != null && jsonData.get("freeShipment").toString().equals("1")) { - // 鏄惁鍖呴偖锛�1 鏈� 0 鏃� - filter.setBaoYou(true); - // ip鍦板潃 - // filter.setIp("113.251.22.10");// 閲嶅簡 - filter.setIp("218.72.111.105");// 鏉窞 - } - - if (jsonData.get("needPrepay") != null && jsonData.get("needPrepay").toString().equals("1")) { - // 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃� - filter.setNeedPrepay(true); - } - - if (jsonData.get("npxLevel") != null) { - // 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井 - filter.setNpxLevel((int) jsonData.get("npxLevel")); - } - - if (jsonData.get("includePayRate30") != null && jsonData.get("includePayRate30").toString().equals("1")) { - // 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧�� - filter.setIncludePayRate30(true); - } - - if (jsonData.get("includeGoodRate") != null && jsonData.get("includeGoodRate").toString().equals("1")) { - // 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊� 1 鏈� 0 鏃� - filter.setIncludeGoodRate(true); - } - - if (jsonData.get("includeRfdRate") != null && jsonData.get("includeRfdRate").toString().equals("1")) { - // 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧�� 1 鏈� 0 鏃� - filter.setIncludeRfdRate(true); - } - - return filter; - } - - /** - * 楠岃瘉鏄惁婊¤冻鏉′欢 - * - * @return - */ - public boolean validate(SearchFilter filter, JSONObject jsonData, TaoBaoGoodsBrief goodsBrief, int source) { - - /* 閿�鍞噺灏忓�� */ - int minSales = 0; - if (jsonData.get("startSales") != null) { - minSales = (int) jsonData.get("startSales"); - } - - /* 閿�鍞噺澶у�� */ - int maxSales = 0; - if (jsonData.get("endSales") != null) { - maxSales = (int) jsonData.get("endSales"); - } - - int biz30day = goodsBrief.getBiz30day(); - - /* 楠岃瘉閿�鍞噺 */ - if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) { - return false; - } else if (maxSales > 0 && biz30day > maxSales) { - return false; - } else if (minSales > 0 && biz30day < minSales) { - return false; - } - - /* 楠岃瘉姣斾緥 */ - if (BoutiqueAutoRule.TB_MATERIAL == source) { - - int startTkRate = filter.getStartTkRate(); - int endTkRate = filter.getEndTkRate(); - - BigDecimal tkRate = goodsBrief.getTkRate(); - - if (startTkRate > 0 && endTkRate > 0 - && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0 || tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) { - return false; - } else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) { - return false; - } else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) { - return false; - } - } - - /* 鍒稿悗浠疯寖鍥翠笅闄� */ - BigDecimal startPrice = null; - if (jsonData.get("startPrice") != null) { - startPrice = new BigDecimal(jsonData.get("startPrice").toString()); - } - - /* 鍒稿悗浠疯寖鍥翠笂闄� */ - BigDecimal endPrice = null; - if (jsonData.get("endPrice") != null) { - endPrice = new BigDecimal(jsonData.get("endPrice").toString()); - } - - /* 鍒稿悗浠�--璁$畻 */ - BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief); - - /* 楠岃瘉鍦ㄥ埜鍚庝环 */ - if (startPrice != null && endPrice != null && (couponPrice.compareTo(startPrice) < 0 || couponPrice.compareTo(endPrice) > 0)) { - return false; - } else if (endPrice != null && couponPrice.compareTo(endPrice) > 0) { - return false; - } else if (startPrice != null && couponPrice.compareTo(startPrice) < 0) { - return false; - } - - /* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */ - if (filter.getQuan() > 0) { - String couponInfo = goodsBrief.getCouponInfo(); - if (StringUtil.isNullOrEmpty(couponInfo)) { - return false; - } - } - - return true; - } - - /** - * 9.9 19.9 29.9 39.9 鍟嗗搧绛涢�� - * - * @param taoBaoGoodsBriefs - */ - public void screen9K9(SearchFilter filter, List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, List<Label> listLabs, - BoutiqueAutoRule autoRule) throws Exception { - - // 9k9鏁版嵁- - List<TaoBaoGoodsBrief> list9k9 = new ArrayList<TaoBaoGoodsBrief>(); - - // 19k9鏁版嵁- - List<TaoBaoGoodsBrief> list19k9 = new ArrayList<TaoBaoGoodsBrief>(); - - // 29k9鏁版嵁- - List<TaoBaoGoodsBrief> list29k9 = new ArrayList<TaoBaoGoodsBrief>(); - - // 49k9鏁版嵁- - List<TaoBaoGoodsBrief> list49k9 = new ArrayList<TaoBaoGoodsBrief>(); - - // 楠岃瘉鏄惁绗﹀悎瑕佹眰鍏ュ簱 - for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) { - - /* 閿�鍞噺灏忓�� */ - int minSales = 0; - if (jsonData.get("startSales") != null) { - minSales = (int) jsonData.get("startSales"); - } - - /* 閿�鍞噺澶у�� */ - int maxSales = 0; - if (jsonData.get("endSales") != null) { - maxSales = (int) jsonData.get("endSales"); - } - - int biz30day = goodsBrief.getBiz30day(); - - /* 楠岃瘉閿�鍞噺 */ - if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) { - continue; - } else if (maxSales > 0 && biz30day > maxSales) { - continue; - } else if (minSales > 0 && biz30day < minSales) { - continue; - } - - /* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */ - if (filter.getQuan() > 0) { - String couponInfo = goodsBrief.getCouponInfo(); - if (StringUtil.isNullOrEmpty(couponInfo)) { - continue; - } - } - - /* 楠岃瘉姣斾緥 */ - if (BoutiqueAutoRule.TB_MATERIAL == autoRule.getSource()) { - - int startTkRate = filter.getStartTkRate(); - int endTkRate = filter.getEndTkRate(); - - BigDecimal tkRate = goodsBrief.getTkRate(); - - if (startTkRate > 0 && endTkRate > 0 - && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0 || tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) { - continue; - } else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) { - continue; - } else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) { - continue; - } - } - - /* 9k9 */ - BigDecimal price9k9 = new BigDecimal(10); - - /* 19k9 */ - BigDecimal price19k9 = new BigDecimal(20); - - /* 29.9 */ - BigDecimal price29K9 = new BigDecimal(30); - - /* 49.9 */ - BigDecimal price49K9 = new BigDecimal(50); - /* 鍒稿悗浠�--璁$畻 */ - BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief); - - if (couponPrice.compareTo(price9k9) < 0) { - list9k9.add(goodsBrief); - } else if (couponPrice.compareTo(price19k9) < 0) { - list19k9.add(goodsBrief); - } else if (couponPrice.compareTo(price29K9) < 0) { - list29k9.add(goodsBrief); - } else if (couponPrice.compareTo(price49K9) < 0) { - list49k9.add(goodsBrief); - } - } - - autoRule.setCalss9k9(true); - AdminUser admin = autoRule.getAdminUser(); - - if (list9k9.size() > 0) { - List<Label> labs9K9 = new ArrayList<Label>(); - labs9K9.addAll(listLabs); - - List<Label> list = labelService.selectByTitleCache("labKey", "9.9"); - - if (list == null || list.size() == 0) { - // 鏂板 - Label addLabel = addLabel("9.9", admin); - labs9K9.add(addLabel); - } else { - labs9K9.add(list.get(0)); - } - - qualityFactoryService.autoInsertOrUpadateStorage(list9k9, labs9K9, autoRule); - } - - if (list19k9.size() > 0) { - List<Label> labs19K9 = new ArrayList<Label>(); - labs19K9.addAll(listLabs); - List<Label> list = labelService.selectByTitleCache("labKey", "19.9"); - if (list == null || list.size() == 0) { - // 鏂板 - Label addLabel = addLabel("19.9", admin); - labs19K9.add(addLabel); - } else { - labs19K9.add(list.get(0)); - } - qualityFactoryService.autoInsertOrUpadateStorage(list19k9, labs19K9, autoRule); - } - - if (list29k9.size() > 0) { - List<Label> labs29K9 = new ArrayList<Label>(); - labs29K9.addAll(listLabs); - List<Label> list = labelService.selectByTitleCache("labKey", "29.9"); - if (list == null || list.size() == 0) { - // 鏂板 - Label addLabel = addLabel("29.9", admin); - labs29K9.add(addLabel); - } else { - labs29K9.add(list.get(0)); - } - - qualityFactoryService.autoInsertOrUpadateStorage(list29k9, labs29K9, autoRule); - } - - if (list49k9.size() > 0) { - List<Label> labs49K9 = new ArrayList<Label>(); - labs49K9.addAll(listLabs); - List<Label> list = labelService.selectByTitleCache("labKey", "49.9"); - if (list == null || list.size() == 0) { - // 鏂板 - Label addLabel = addLabel("49.9", admin); - labs49K9.add(addLabel); - } else { - labs49K9.add(list.get(0)); - } - - qualityFactoryService.autoInsertOrUpadateStorage(list49k9, labs49K9, autoRule); - } - - } - - public void screen(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, SearchFilter filter, List<Label> listLabs, - BoutiqueAutoRule autoRule) throws Exception { - - // 閬嶅巻杩斿洖鏁版嵁- - List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>(); - - for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) { - // 楠岃瘉鏄惁绗﹀悎瑕佹眰 - if (validate(filter, jsonData, goodsBrief, 1)) { - listGoods.add(goodsBrief); - } - } - - if (listGoods.size() > 0) { - autoRule.setCalss9k9(false); - qualityFactoryService.autoInsertOrUpadateStorage(listGoods, listLabs, autoRule); - } - } - - public Label addLabel(String title, AdminUser admin) throws Exception { - // 鏂板 - Label label = new Label(); - label.setTitle(title);// 鍚嶇О - label.setEntrymode(Label.MODE_SYSTEM); - label.setCreatetime(new Date()); - label.setUpdatetime(new Date()); - label.setCreateUser(admin); - label.setIosClick(0l); - label.setAndroidClick(0l); - labelService.insertSelective(label); - - return label; - } - -} +package com.yeshi.fanli.job; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule; +import com.yeshi.fanli.entity.bus.lable.Label; +import com.yeshi.fanli.entity.bus.lable.QualityFactory; +import com.yeshi.fanli.entity.common.AdminUser; +import com.yeshi.fanli.entity.taobao.SearchFilter; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; +import com.yeshi.fanli.service.inter.lable.LabelService; +import com.yeshi.fanli.service.inter.lable.QualityFactoryService; +import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; +import com.yeshi.common.entity.PageEntity; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; + +/** + * 绮鹃�夊晢鍝佽嚜鍔ㄥ叆搴� + * + * @author yj + * + */ +// @Component +public class QualityFactoryJob implements Job { + + // 9.9 19.9 29.9 49.9 绛涢�� + public final static String IS_9K9 = "IS_9K9"; + + // 闄愭椂鎶㈣喘 + public final static String FLASH_SALE = "IS_XSQG"; + + @Resource + private LabelService labelService; + @Resource + private QualityFactoryService qualityFactoryService; + @Resource + private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; + @Resource + private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + + + public QualityFactoryJob() { + System.out.println("--UpdateQualityFactoryJob 鏋勯�犲嚱鏁�--"); + } + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + // 鐖彇鍟嗗搧淇℃伅 + searchGoods(context); + } + + public void searchGoods(JobExecutionContext context) { + try { + JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); + Object object = jobDataMap.get("key"); + if (object == null) { + return; + } + + BoutiqueAutoRule autoRule = (BoutiqueAutoRule) object; + /* 鎿嶄綔浜猴細 寮�鍙戣处鍙� */ + AdminUser admin = new AdminUser(2L); + autoRule.setAdminUser(admin); + + /* 鏍囩鍒楄〃 */ + List<Label> listLabs = new ArrayList<Label>(); + String lableNames = autoRule.getLableNames(); + if (!StringUtil.isNullOrEmpty(lableNames)) { + String[] arrtitles = lableNames.split("\\s+"); // 绌烘牸闅斿紑 + for (String name : arrtitles) { + Label label = labelService.getByTitleCache("labKey", name.trim()); + if (label == null) { + label = insertLabel(name, admin); + } + listLabs.add(label); + } + } + + if (BoutiqueAutoRule.TB_OPTIONAL == autoRule.getSource()) { // 1銆佹潵婧愭窐瀹濇櫘閫氭帴鍙� + autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO); + searchTaoBao(listLabs, autoRule); + } else if (BoutiqueAutoRule.TB_MATERIAL == autoRule.getSource()) { // 2銆佹窐瀹濇帹鑽� + autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_MATERIAL); + searchMaterial(listLabs, autoRule); + } + + } catch (Exception e) { + try { + LogHelper.test("--searchGoods--鎵ц寮傚父----"); + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + + /** + * 娣樺疂api 鎺ュ彛鏁版嵁鐖彇 + * + * @param jobDataMap + */ + private void searchTaoBao(List<Label> listLabs, BoutiqueAutoRule autoRule) { + try { + String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()); + boolean isCrawl = true; + // 鏉冮噸璧峰 + int startWeight = 0; + // 鏉冮噸缁撴潫 + int endWeight = 0; + + // 鏄惁鍔犲叆闄愭椂鎶㈣喘 + boolean isFlashSale = false; + String title = autoRule.getTitle(); + if (title.contains(FLASH_SALE)) { + isFlashSale = true; + } + autoRule.setFlashSale(isFlashSale); + + // 鏈�澶氱埇鍙栭〉鐮� + int pageMax = 200; + if (autoRule.getMaxPage() != null) { + pageMax = autoRule.getMaxPage(); + } + + /* 鍙傛暟澶勭悊 */ + SearchFilter filter = getSearchFilter(autoRule); + filter.setPageSize(100); + + for (int page = 1; page <= pageMax; page++) { + filter.setPage(page); + TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiaoNew(filter,null,null); + + // 缁撴灉涓虹┖ 缁撴潫璇锋眰 + if (result == null) { + LogHelper.test(title + "searchWuLiao杩斿洖 result涓虹┖"); + break; + } + + // 缁撴灉鏁版嵁澶勭悊 + List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs(); + if (listGoods == null || listGoods.size() == 0) { + LogHelper.test(title + "searchWuLiao杩斿洖ListGoods 缁撴灉涓虹┖"); + return; + } + + /* 鏉冮噸鑼冨洿 */ + if (page < 3) { + startWeight = 4000; + endWeight = 6000; + } else { + startWeight = 10; + endWeight = 3000; + } + + autoRule.setStartWeight(startWeight); + autoRule.setEndWeight(endWeight); + + // 绛涢�夊叆搴� + screen(listGoods, filter, listLabs, autoRule); + + /* 閿�鍞噺灏忓�� */ + int minSales = 0; + if (autoRule.getStartSales() != null) { + minSales = autoRule.getStartSales(); + } + + /* 閿�鍞噺澶у�� */ + int maxSales = 0; + if (autoRule.getEndSales() != null) { + maxSales = autoRule.getEndSales(); + } + + // 閿�閲忔帶鍒� + for (TaoBaoGoodsBrief goodsBrief : listGoods) { + int biz30day = goodsBrief.getBiz30day(); + /* 楠岃瘉閿�鍞噺 -- 缁撴潫鐖彇鏁版嵁 */ + if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) { + isCrawl = false; + } else if (maxSales > 0 && biz30day > maxSales) { + isCrawl = false; + } else if (minSales > 0 && biz30day < minSales) { + isCrawl = false; + } + } + + // 鎬婚〉鏁扮埇鍙栧畬鎴� + PageEntity pageEntity = result.getPageEntity(); + int totalPage = pageEntity.getTotalPage(); + LogHelper.test(title + "鎬婚〉鐮�" + totalPage); + + // 鏈�鍚庝竴椤垫暟鎹埇鍙栧畬鎴� + if (page == totalPage) + isCrawl = false; + + if (!isCrawl) { + LogHelper.test("----" + title + "--姝e父缁撴潫-------"); + break;// 缁撴潫鐖彇鏁版嵁 + } + } + + // 9k9 闄愭椂鎶㈣喘 涓嶆搷浣滃垹闄� + if (!StringUtil.isNullOrEmpty(title) && (title.contains(IS_9K9) || title.contains(FLASH_SALE))) { + return; + } + + /* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */ + if (!StringUtil.isNullOrEmpty(autoRule.getSystemCid())) { + Long systemCid = Long.parseLong(autoRule.getSystemCid()); + qualityFactoryService.deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource()); + } + + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + + /** + * 娣樺疂api 鎺ュ彛鏁版嵁鐖彇 + * + * @param jobDataMap + */ + private void searchMaterial(List<Label> listLabs, BoutiqueAutoRule autoRule) { + + try { + String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()); + + // 榛樿20鏉� + int pageSize = 20; + boolean isCrawl = true; + // 鏉冮噸璧峰 + int startWeight = 1000; + // 鏉冮噸缁撴潫 + int endWeight = 3000; + autoRule.setStartWeight(startWeight); + autoRule.setEndWeight(endWeight); + + // 鏄惁鍔犲叆闄愭椂鎶㈣喘 + boolean isFlashSale = false; + String title = autoRule.getTitle(); + if (title.contains(FLASH_SALE)) { + isFlashSale = true; + } + autoRule.setFlashSale(isFlashSale); + + // 鏈�澶氱埇鍙栭〉鐮� + int pageMax = 200; + if (autoRule.getMaxPage() != null) + pageMax = autoRule.getMaxPage(); + + /* 鍙傛暟澶勭悊 */ + SearchFilter filter = getSearchFilter(autoRule); + + for (int page = 1; page <= pageMax; page++) { + + int materialId = 0; + String cateIds = filter.getCateIds(); + if (!StringUtil.isNullOrEmpty(cateIds)) { + materialId = Integer.parseInt(cateIds); + } + + // 璇锋眰瀹樻柟鎺ㄨ崘鍟嗗搧搴� + TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, page, pageSize); + + // 缁撴灉涓虹┖ 鏃朵笉鍐嶈姹� + if (result == null) { + LogHelper.test(title + "searchMaterial杩斿洖 result涓虹┖"); + return; + } + + // 缁撴灉鏁版嵁澶勭悊 + List<TaoBaoGoodsBrief> listGoods = result.getTaoBaoGoodsBriefs(); + if (listGoods == null || listGoods.size() == 0) { + LogHelper.test(title + "searchMaterial杩斿洖ListGoods 缁撴灉涓虹┖"); + return; + } + + // 绛涢�夊叆搴� + screen(listGoods, filter, listLabs, autoRule); + + + // 鎬婚〉鏁扮埇鍙栧畬鎴� + PageEntity pageEntity = result.getPageEntity(); + long count = pageEntity.getTotalCount(); + int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); + + // 鏈�鍚庝竴椤垫暟鎹埇鍙栧畬鎴� + if (page == totalPage) + isCrawl = false; + + if (!isCrawl) { + LogHelper.test("----" + title + "--缁撴潫-------"); + break;// 缁撴潫鐖彇鏁版嵁 + } + } + + // 9k9 闄愭椂鎶㈣喘 涓嶆搷浣滃垹闄� + if (!StringUtil.isNullOrEmpty(title) && (title.contains(IS_9K9) || title.contains(FLASH_SALE))) { + return; + } + + /* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */ + if (!StringUtil.isNullOrEmpty(autoRule.getSystemCid())) { + Long systemCid = Long.parseLong(autoRule.getSystemCid()); + qualityFactoryService.deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource()); + } + + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + + /** + * 鍙傛暟澶勭悊鍔犲伐 + * + * @param jobDataMap + * @return + */ + public SearchFilter getSearchFilter(BoutiqueAutoRule autoRule) { + SearchFilter filter = new SearchFilter(); + // 鎺掑簭瀛楁 閿�閲忛珮鍒颁綆(榛樿) + filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); + // 鎼滅储鍏抽敭璇� + filter.setKey(autoRule.getKey()); + // 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎 + filter.setCateIds(autoRule.getCateIds()); + + // 鍦ㄥ敭浠疯寖鍥村皬鍊� + if (autoRule.getStartZkPrice() != null) { + filter.setStartPrice(new BigDecimal(autoRule.getStartPrice())); + } + + // 鍦ㄥ敭浠疯寖鍥村ぇ鍊� + if (autoRule.getEndZkPrice() != null) { + filter.setEndPrice(new BigDecimal(autoRule.getEndZkPrice())); + } + + // 浣i噾鑼冨洿灏忓�� + if (autoRule.getStartTkRate() != null) { + BigDecimal b = new BigDecimal(autoRule.getStartTkRate()); + double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); + int tkRate = (int) (df * 100); + filter.setStartTkRate(tkRate); + } + + // 浣i噾鑼冨洿澶у�� + if (autoRule.getEndTkRate() != null) { + BigDecimal b = new BigDecimal(autoRule.getEndTkRate()); + double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue(); + int tkRate = (int) (df * 100); + filter.setEndTkRate(tkRate); + } + + // 鏄惁澶╃尗 + if (autoRule.getIsTmall() != null && autoRule.getIsTmall() == 1) { + filter.setTmall(true); + } + + // 鏄惁鏈夊埜锛�1 鏈� 0 鏃� + if (autoRule.getHasCoupon() != null && autoRule.getHasCoupon() == 1) { + filter.setQuan(1); + } + + // 鏄惁鍖呴偖锛�1 鏈� 0 鏃� + if (autoRule.getFreeShipment() != null && autoRule.getFreeShipment() == 1) { + filter.setBaoYou(true); + filter.setIp("218.72.111.105");// 鏉窞 + } + + // 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃� + if (autoRule.getNeedPrepay() != null && autoRule.getNeedPrepay() == 1) { + filter.setNeedPrepay(true); + } + + // 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井 + if (autoRule.getNpxLevel() != null && autoRule.getNpxLevel() == 1) { + filter.setNpxLevel(autoRule.getNpxLevel()); + } + + // 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧�� + if (autoRule.getIncludePayRate30() != null && autoRule.getIncludePayRate30() == 1) { + filter.setIncludePayRate30(true); + } + + // 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊� 1 鏈� 0 鏃� + if (autoRule.getIncludeGoodRate() != null && autoRule.getIncludeGoodRate() == 1) { + filter.setIncludeGoodRate(true); + } + + // 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧�� 1 鏈� 0 鏃� + if (autoRule.getIncludeRfdRate() != null && autoRule.getIncludeRfdRate() == 1) { + filter.setIncludeRfdRate(true); + } + return filter; + } + + + + /** + * 绛涢�夌鍚堟潯浠剁殑鍟嗗搧 + * + * @param taoBaoGoodsBriefs + * @param jsonData + * @param filter + * @param listLabs + * @param autoRule + * @throws Exception + */ + public void screen(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, SearchFilter filter, + List<Label> listLabs, BoutiqueAutoRule autoRule) { + try { + List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>(); + for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) { + // 楠岃瘉鏄惁绗﹀悎瑕佹眰 + if (validate(filter, autoRule, goodsBrief, 1)) { + listGoods.add(goodsBrief); + } + } + qualityFactoryService.autoInsertOrUpadateStorage(autoRule, listGoods, listLabs); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + + } + + /** + * 楠岃瘉鏄惁婊¤冻鏉′欢 + * + * @return + */ + public boolean validate(SearchFilter filter, BoutiqueAutoRule autoRule, TaoBaoGoodsBrief goodsBrief, int source) { + int minSales = 0; + if (autoRule.getStartSales() != null) + minSales = autoRule.getStartSales(); + + int maxSales = 0; + if (autoRule.getEndSales() != null) + maxSales = autoRule.getEndSales(); + + /* 楠岃瘉閿�鍞噺 */ + if (maxSales == 0 && minSales ==0) { + + } else { + int biz30day = goodsBrief.getBiz30day(); + if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) { + return false; + } else if (maxSales > 0 && biz30day > maxSales) { + return false; + } else if (minSales > 0 && biz30day < minSales) { + return false; + } + } + + /* 楠岃瘉姣斾緥 */ + if (BoutiqueAutoRule.TB_MATERIAL == source) { + int startTkRate = filter.getStartTkRate(); + int endTkRate = filter.getEndTkRate(); + BigDecimal tkRate = goodsBrief.getTkRate(); + if (startTkRate > 0 && endTkRate > 0 && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0 + || tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) { + return false; + } else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) { + return false; + } else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) { + return false; + } + } + + /* 鍒稿悗浠疯寖鍥翠笅闄� */ + BigDecimal startPrice = null; + if (autoRule.getStartPrice() != null) + startPrice = new BigDecimal(autoRule.getStartPrice().toString()); + /* 鍒稿悗浠疯寖鍥翠笂闄� */ + BigDecimal endPrice = null; + if (autoRule.getEndPrice() != null) + endPrice = new BigDecimal(autoRule.getEndPrice().toString()); + + if (startPrice == null && endPrice == null) { + + } else { + BigDecimal couponPrice = TaoBaoUtil.getCouponPrice(goodsBrief); + if (startPrice != null && endPrice != null + && (couponPrice.compareTo(startPrice) < 0 || couponPrice.compareTo(endPrice) > 0)) { + return false; + } else if (endPrice != null && couponPrice.compareTo(endPrice) > 0) { + return false; + } else if (startPrice != null && couponPrice.compareTo(startPrice) < 0) { + return false; + } + } + + /* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */ + if (filter.getQuan() > 0) { + String couponInfo = goodsBrief.getCouponInfo(); + if (StringUtil.isNullOrEmpty(couponInfo)) + return false; + } + return true; + } + + /** + * 鎻掑叆鏂扮殑鏍囩 + * + * @param title + * @param admin + * @return + * @throws Exception + */ + public Label insertLabel(String title, AdminUser admin) throws Exception { + // 鏂板 + Label label = new Label(); + label.setTitle(title);// 鍚嶇О + label.setEntrymode(Label.MODE_SYSTEM); + label.setCreatetime(new Date()); + label.setUpdatetime(new Date()); + label.setCreateUser(admin); + label.setIosClick(0l); + label.setAndroidClick(0l); + labelService.insertSelective(label); + return label; + } + +} -- Gitblit v1.8.0