From 3340ed122e19e3943ce4f93eb52103b623a3fc2c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 27 四月 2022 15:43:58 +0800
Subject: [PATCH] 订单消息bug修改
---
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java | 2459 +++++++++++++++++++++++++++++------------------------------
1 files changed, 1,222 insertions(+), 1,237 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java
index 017382a..9e33555 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5QualityGoodsController.java
@@ -1,1237 +1,1222 @@
-package com.yeshi.fanli.controller.apph5;
-
-import java.io.PrintWriter;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.yeshi.utils.JsonUtil;
-import org.yeshi.utils.taobao.TbImgUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.yeshi.fanli.entity.accept.AcceptData;
-import com.yeshi.fanli.entity.bus.lable.Label;
-import com.yeshi.fanli.entity.bus.lable.MergeClass;
-import com.yeshi.fanli.entity.bus.lable.QualityFactory;
-import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
-import com.yeshi.fanli.entity.taobao.TaoBaoHongBaoInfo;
-import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
-import com.yeshi.fanli.exception.taobao.TaoKeApiException;
-import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
-import com.yeshi.fanli.log.LogHelper;
-import com.yeshi.fanli.service.inter.config.SystemService;
-import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
-import com.yeshi.fanli.service.inter.goods.GoodsClassService;
-import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
-import com.yeshi.fanli.service.inter.lable.LabelService;
-import com.yeshi.fanli.service.inter.lable.MergeClassService;
-import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
-import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
-import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
-import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
-import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.taobao.TaoBaoUtil;
-import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
-
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
-@Controller
-@RequestMapping("api/apph5/v1/quality")
-public class AppH5QualityGoodsController {
-
- @Resource
- private LabelService labelService;
-
- @Resource
- private QualityFactoryService selectionGoodsService;
-
- @Resource
- private TaobaoMeterialService taobaoMeterialService;
-
- @Resource
- private TaoKeGoodsService taoKeGoodsService;
-
- @Resource
- private GoodsClassService goodsClassService;
-
- @Resource
- private HongBaoManageService manageService;
-
- @Resource
- private MergeClassService mergeClassService;
-
- @Resource
- private TaoBaoClassService taoBaoClassService;
-
- @Resource
- private SystemService systemService;
-
- @Resource
- private QualityGoodsService qualityGoodsService;
-
- @Resource
- private QualityFlashSaleService qualityFlashSaleService;
-
- @Resource
- private CollectionGoodsV2Service collectionGoodsV2Service;
-
- @Resource
- private HongBaoManageService hongBaoManageService;
-
- /**
- * 9.9鍟嗗搧
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get9k9")
- public void get9k9(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassGoods("9.9", callback, page, mcid, out);
- }
-
- /**
- * 19.9鍟嗗搧
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get19k9")
- public void get19k9(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassGoods("19.9", callback, page, mcid, out);
- }
-
- /**
- * 29.9鍟嗗搧
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get29k9")
- public void get29k9(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassGoods("29.9", callback, page, mcid, out);
- }
-
- /**
- * 49.9鍟嗗搧
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get49k9")
- public void get49k9(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassGoods("49.9", callback, page, mcid, out);
- }
-
- /**
- * 9k9绫诲瀷鐨勫晢鍝佹煡璇�
- *
- * @param labName
- * 鏍囩鍚嶇О
- * @param callback
- * @param page
- * @param mcid
- * 瀵瑰簲绫荤洰id
- * @param out
- */
- public void get9k9ClassGoods(String labName, String callback, Integer page, Long mcid, PrintWriter out) {
-
- try {
-
- List<Label> labs = labelService.selectByTitleCache("labKey", labName);
- if (labs == null || labs.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- Long labId = labs.get(0).getId();
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonGoods = queryGoodsSmallAmount(page, pageSize, mcid, labId);
- if (jsonGoods == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonGoods));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 鑾峰彇鍟嗗搧
- *
- * @param page
- * @param pageSize
- * @param labIds
- * @return
- * @throws Exception
- */
- public JSONObject queryGoodsSmallAmount(int page, int pageSize, Long mcid, Long labId) throws Exception {
-
- String mergeCids = null;
- if (mcid != null && (!mcid.equals(0) || mcid != 0)) {
-
- MergeClass mergeClass = mergeClassService.selectByPrimaryKeyCache(mcid);
- if (mergeClass != null) {
- // 鍒嗙被id,闅斿紑
- mergeCids = mergeClass.getMergeCids();
- }
- }
-
- // 鏍规嵁鏍囩id 鏌ヨ鏁版嵁
- List<QualityFactory> listQuery = qualityGoodsService.listQuerySmallAmount((page - 1) * pageSize, pageSize, null,
- labId, mergeCids);
-
- // 鎬绘潯鏁�
- long count = qualityGoodsService.countQuerySmallAmount(null, labId, mergeCids);
- if (listQuery == null || listQuery.size() == 0) {
- return null;
- }
-
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = hongBaoManageService.getFanLiRate();
- /* 閬嶅巻鍒楄〃鏁版嵁 */
- for (QualityFactory selectionGoods : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
-
- data.put("count", count);
- data.put("result_list", array);
-
- return data;
- }
-
- /**
- * 9.9鍟嗗搧-姣忔棩蹇呮姠
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get9k9EverydayRob")
- public void get9k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassToDayRob("9.9", callback, page, mcid, out, 1.0, 50.0);
- }
-
- /**
- * 19.9鍟嗗搧-姣忔棩蹇呮姠
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get19k9EverydayRob")
- public void get19k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassToDayRob("19.9", callback, page, mcid, out, 1.0, 50.0);
- }
-
- /**
- * 29.9鍟嗗搧-姣忔棩蹇呮姠
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get29k9EverydayRob")
- public void get29k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassToDayRob("29.9", callback, page, mcid, out, 1.0, 50.0);
- }
-
- /**
- * 49.9鍟嗗搧-姣忔棩蹇呮姠
- *
- * @param pageIndex
- * @param out
- */
- @RequestMapping(value = "get49k9EverydayRob")
- public void get49k9EverydayRob(String callback, Integer page, Long mcid, PrintWriter out) {
- get9k9ClassToDayRob("49.9", callback, page, mcid, out, 1.0, 50.0);
- }
-
- /**
- * 9k9绫诲瀷鍟嗗搧瀵瑰簲鐨勬瘡鏃ュ繀鎶�
- *
- * @param labName
- * @param callback
- * @param page
- * @param mcid
- * @param out
- * @param startCouponAmount
- * @param endCouponAmount
- */
- public void get9k9ClassToDayRob(String labName, String callback, Integer page, Long mcid, PrintWriter out,
- Double startCouponAmount, Double endCouponAmount) {
-
- try {
-
- List<Label> labs = labelService.selectByTitleCache("labKey", labName);
- if (labs == null || labs.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- Long labId = labs.get(0).getId();
- JSONObject jsonGoods = queryEverydayRob(page, labId, 2, startCouponAmount, endCouponAmount);
-
- if (jsonGoods == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonGoods));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 姣忔棩蹇呮姠
- *
- * @param page
- * @param pageSize
- * @param labId
- * @return
- * @throws Exception
- */
- public JSONObject queryEverydayRob(Integer page, Long labId, int sortField, Double startCouponAmount,
- Double endCouponAmount) throws Exception {
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- if (page > 3) {
- return null;// 20 鏉′竴椤佃姹傚埌3椤电粨鏉熶粖鏃ユ柊鍝�
- }
-
- // 鏍规嵁鏍囩id 鏌ヨ鏁版嵁
- List<QualityFactory> listQuery = qualityGoodsService.listQueryEverydayRob((page - 1) * pageSize, pageSize, null,
- labId, sortField, startCouponAmount, endCouponAmount);
-
- // 鍙彇鍓�50鏉℃暟
- long count = 50;
-
- // long count = qualityGoodsService.countQueryEverydayRob(null, labId,
- // startCouponAmount, endCouponAmount);
-
- if (listQuery == null || listQuery.size() == 0) {
- return null;
- }
-
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
- /* 閬嶅巻鍒楄〃鏁版嵁 */
- for (QualityFactory selectionGoods : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
-
- data.put("count", count);
- data.put("result_list", array);
-
- return data;
- }
-
- /**
- * 鍝佺墝璐� 锛堝畼鏂规帹鑽愩�愬搧鐗屽埜銆戞帴鍙o級
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getBrandsGoods")
- public void getBrandsGoods(String callback, Integer page, String subName, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "鍝佺墝鍒�");
-
- if (list == null || list.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial taobaoMeterial = list.get(0);
- Integer materialId = taobaoMeterial.getMaterialId();
- if (materialId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = taoKeGoodsService.getBrandsGoods(materialId, page, pageSize);
-
- if (jsonObject == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 鍝佺墝璐� 锛堝畼鏂规帹鑽愩�愬搧鐗屽埜銆戞帴鍙o級
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getBrandsShops")
- public void getBrandsShops(String callback, Integer page, PrintWriter out) {
-
- try {
- String subName = "缁煎悎";
- List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "鍝佺墝鍒�");
-
- if (list == null || list.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial taobaoMeterial = list.get(0);
- Integer materialId = taobaoMeterial.getMaterialId();
- if (materialId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = taoKeGoodsService.getBrandsShops(materialId, page, pageSize);
-
- if (jsonObject == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 澶ч鍒� 锛堝畼鏂规帹鑽愪腑鐨勩�愮壒鎯犮�戯級
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getPreferential", method = RequestMethod.POST)
- public void getPreferential(int page, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null, "鐗规儬");
-
- if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
- out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial meterial = taobaoMeterials.get(0);
- Integer materialId = meterial.getMaterialId();
- if (materialId == null) {
- out.print(JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page < 1)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
-
- if (jsonObject == null) {
- out.print(JsonUtil.loadFalseResult(2, "鏆傛棤鏇村鏁版嵁"));
- }
- out.print(JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
-
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 瓒呴珮濂栭噾(瀹樻柟鎺ㄨ崘涓殑銆愭湁濂借揣銆�)
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getSuperiors", method = RequestMethod.POST)
- public void getSuperiors(int page, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
- "鏈夊ソ璐�");
-
- if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
- out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial meterial = taobaoMeterials.get(0);
- Integer materialId = meterial.getMaterialId();
- if (materialId == null) {
- out.print(JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page < 1)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
-
- if (jsonObject == null) {
- out.print(JsonUtil.loadFalseResult(2, "鏆傛棤鏇村鏁版嵁"));
- }
- out.print(JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
-
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 浠婃棩鏂板搧銆愶紙瀹樻柟鎺ㄨ崘銆愬ソ鍒哥洿鎾�戞帴鍙o級
- *
- * @param page
- * @param subName
- * 瀛愮被鍚嶇О
- */
- @RequestMapping(value = "todayNew")
- public void todayNew(String callback, Integer page, String subName, String uid, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "濂藉埜鐩存挱");
-
- if (list == null || list.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial taobaoMeterial = list.get(0);
- Integer materialId = taobaoMeterial.getMaterialId();
- if (materialId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- List<TaoBaoGoodsBrief> listMaterial = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
-
- if (listMaterial == null || listMaterial.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion =manageService.getFanLiRate();
-
- /* 閬嶅巻鍒楄〃鏁版嵁 */
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : listMaterial) {
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄 澶у浘鏇存竻鏅�
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- pictUrl = pictUrl.replaceAll("320x320", "640x640");
- taoBaoGoodsBrief.setPictUrl(pictUrl);
-
- int collected = 0;
- // 鍒ゆ柇鏀惰棌
- if (!StringUtil.isNullOrEmpty(uid)) {
- CollectionGoodsV2 collectionGoods = collectionGoodsV2Service
- .findByUidAndAuctionId(Long.parseLong(uid), taoBaoGoodsBrief.getAuctionId());
- if (collectionGoods != null) {
- collected = 1;
- }
- }
-
- TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
- proportion.toString(), null);
- taoBaoGoodsBriefExtra.setCollected(collected);
-
- array.add(gson.toJson(taoBaoGoodsBriefExtra));
- }
-
- JSONObject data = new JSONObject();
- data.put("result_list", array);
- data.put("count", 1000);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 娼搧鐑崠锛堝畼鏂规帹鑽愪腑鐨勩�愭疆娴佽寖銆戯級
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getFashions")
- public void getFashions(String callback, Integer page, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
- "娼祦鑼�");
-
- if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial meterial = taobaoMeterials.get(0);
- Integer materialId = meterial.getMaterialId();
- if (materialId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page == null) {
- page = 1;
- }
-
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
-
- if (jsonObject == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
-
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 姣嶅┐绮鹃�夛紙瀹樻柟鎺ㄨ崘涓殑銆愭瘝濠翠富棰樸�戯級
- *
- * @param page
- * @param out
- */
- @RequestMapping(value = "getPregnantBaby")
- public void getPregnantBaby(AcceptData acceptData, String callback, Integer page, String subName, PrintWriter out) {
-
- try {
-
- List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName,
- "姣嶅┐涓婚");
-
- if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
- return;
- }
-
- TaobaoMeterial meterial = taobaoMeterials.get(0);
- Integer materialId = meterial.getMaterialId();
- if (materialId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
- return;
- }
-
- if (page == null) {
- page = 1;
- }
- int pageSize = Constant.PAGE_SIZE;
-
- JSONObject jsonObject = queryMaterialGoods(page, pageSize, materialId);
-
- if (jsonObject == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- }
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
-
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * 鎺ㄨ崘鏌ヨ鎺ュ彛瀵规帴-鍏敤鏂规硶
- *
- * @param page
- * @param pageSize
- * @param materialId
- * @return
- * @throws Exception
- */
- public JSONObject queryMaterialGoods(int page, int pageSize, Integer materialId) throws Exception {
-
- List<TaoBaoGoodsBrief> listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
-
- if (listBrands == null || listBrands.size() == 0) {
- return null;
- }
-
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
-
- /* 閬嶅巻鍒楄〃鏁版嵁 */
- for (TaoBaoGoodsBrief taoBaoGoodsBrief : listBrands) {
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
- data.put("result_list", array);
- data.put("count", 1000);
-
- return data;
-
- }
-
- /**
- * 闄愭椂鎶㈣喘
- *
- * @param callback
- * @param page
- * @param out
- */
- @RequestMapping("getFlashSale")
- public void getFlashSale(String callback, Integer page, PrintWriter out) {
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
- int type = qualityFlashSaleService.getNowType();
-
- List<QualityFactory> listQuery = qualityGoodsService.listQueryByFlashSale((page - 1) * pageSize, pageSize);
-
- // 绮鹃�夊簱鏁版嵁涓虹┖
- if (listQuery == null || listQuery.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- long count = 3000;
-
- // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
-
- // 閬嶅巻鍒楄〃鏁版嵁
- for (QualityFactory quality : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
- data.put("count", count);
- data.put("type", type);
- data.put("result_list", array);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
- }
-
- /**
- * 澶ч鍒革紙鍒搁潰鍊艰寖鍥达級
- *
- * @param callback
- * @param amount
- * @param page
- * @param out
- */
- @RequestMapping("choiceCouponAmount")
- public void choiceCouponAmount(String callback, Integer amount, Integer page, PrintWriter out) {
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- Integer startAmount = null;
- Integer endAmount = null;
-
- if (amount.equals(1)) {
- startAmount = 5;
- endAmount = 10;
- } else if (amount.equals(2)) {
- startAmount = 10;
- endAmount = 30;
- } else if (amount.equals(3)) {
- startAmount = 30;
- endAmount = 50;
- } else if (amount.equals(4)) {
- startAmount = 50;
- }
-
- Integer startPropor = 20;
-
- List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
- startAmount, endAmount, startPropor);
-
- if (listQuery == null || listQuery.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
-
- // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
- // 閬嶅巻鍒楄〃鏁版嵁
- for (QualityFactory selectionGoods : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
- data.put("count", count);
- data.put("result", array);
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
- }
-
- /**
- * 瓒呴珮濂栭噾
- *
- * @param callback
- * @param page
- * @param type
- * @param out
- */
- @RequestMapping("choiceRebate")
- public void choiceRebate(String callback, Integer page, Integer type, PrintWriter out) {
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- Integer startAmount = null;
- Integer endAmount = null;
-
- if (type.equals(1)) {
- startAmount = 1;
- endAmount = 5;
- } else if (type.equals(2)) {
- startAmount = 5;
- endAmount = 10;
- } else if (type.equals(3)) {
- startAmount = 10;
- endAmount = 15;
- } else if (type.equals(4)) {
- startAmount = 15;
- }
-
- double tkRate = 20.00;
-
- BigDecimal proportion = manageService.getFanLiRate();
- List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
- proportion.toString(), startAmount, endAmount, tkRate);
-
- if (listQuery == null || listQuery.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount, tkRate);
-
- // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- // 閬嶅巻鍒楄〃鏁版嵁
- for (QualityFactory quality : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- int biz30day = taoBaoGoodsBrief.getBiz30day();
- if (biz30day >= 10000) {
- double sales = biz30day;
- String salesCountMidea = String.format("%.1f", sales / 10000);
- taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
- } else {
- taoBaoGoodsBrief.setSalesCount(biz30day + "");
- }
-
- // 鏀瑰彉鍥剧墖灏哄
- String pictUrl = taoBaoGoodsBrief.getPictUrl();
- if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
- taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
- }
-
- array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
- }
-
- JSONObject data = new JSONObject();
- data.put("count", count);
- data.put("result_list", array);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
- }
-
- /**
- * 瓒呴珮濂栭噾
- *
- * @param callback
- * @param page
- * @param type
- * @param out
- */
- @RequestMapping("recommendToIndex")
- public void recommendToIndex(String callback, Integer page, PrintWriter out) {
-
- if (page == null)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- BigDecimal proportion = manageService.getFanLiRate();
- JSONArray array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString());
-
- if (array == null) {
- out.print(JsonUtil.loadFalseResult("娌℃湁鏇村浜�"));
- return;
- }
-
- long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
-
- JSONObject data = new JSONObject();
- data.put("count", count);
- data.put("result_list", array);
-
- out.print(JsonUtil.loadTrueResult(data));
- return;
- }
-
- /**
- * 瓒呴珮濂栭噾
- *
- * @param callback
- * @param page
- * @param type
- * @param out
- */
- @RequestMapping("freeGoods")
- public void freeGoods(String callback, Integer page, PrintWriter out) {
-
- if (page == null || page < 1)
- page = 1;
-
- int pageSize = Constant.PAGE_SIZE;
-
- double tkRate = 20;
- String lableName = "9.9";
-
- try {
- List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize, tkRate,
- lableName);
- if (listQuery == null || listQuery.size() == 0) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
- return;
- }
-
- List<Long> listGid = new ArrayList<Long>();
- for (QualityFactory qualityFactory : listQuery) {
- TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
- listGid.add(taoBaoGoodsBrief.getAuctionId());
- }
-
- // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
- List<TaoBaoGoodsBrief> listTaoKeGoods = null;
- try {
- listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
- } catch (TaoKeApiException e) {
- e.printStackTrace();
- } catch (TaobaoGoodsDownException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- JSONArray array = new JSONArray();
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
-
- BigDecimal proportion = manageService.getFanLiRate();
- /* 閬嶅巻鍒楄〃鏁版嵁 */
- for (QualityFactory selectionGoods : listQuery) {
-
- TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-
- if (taoBaoGoodsBrief == null) {
- continue;
- }
-
- if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
- boolean stateSale = false; // 榛樿鍋滃敭
- Long goodsId = taoBaoGoodsBrief.getAuctionId();
- for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
- Long auctionId = taoKeGoods.getAuctionId();
- if (goodsId == auctionId || goodsId.equals(auctionId)) {
- stateSale = true; // 鍦ㄥ敭
- break;
- }
- }
-
- if (!stateSale) {
- continue;
- }
- }
-
- BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
- if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
- continue; // 鍒稿悗浠峰ぇ浜�10
- }
-
- TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
- proportion.toString(), null);
- // 灏嗚繑鍒╂敼涓哄埜鍚庝环
- TaoBaoHongBaoInfo taoBaoHongBaoInfo = extra.getTaoBaoHongBaoInfo();
- if (taoBaoHongBaoInfo != null) {
- taoBaoHongBaoInfo.setHongbao(extra.getQuanPrice());
- taoBaoHongBaoInfo.setRate("楼" + extra.getQuanPrice());
- }
-
- array.add(gson.toJson(extra));
- }
-
- long count = qualityGoodsService.countFreeGoods(tkRate, lableName);
-
- JSONObject data = new JSONObject();
- data.put("count", count);
- data.put("result_list", array);
-
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
- e.printStackTrace();
- }
- }
-
-}
+package com.yeshi.fanli.controller.apph5;
+
+import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.yeshi.utils.JsonUtil;
+import org.yeshi.utils.taobao.TbImgUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.bus.lable.MergeClass;
+import com.yeshi.fanli.entity.bus.lable.QualityFactory;
+import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoHongBaoInfo;
+import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
+import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2;
+import com.yeshi.fanli.exception.taobao.TaoKeApiException;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
+import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
+import com.yeshi.fanli.service.inter.lable.MergeClassService;
+import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
+import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
+import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsActivityService;
+import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
+import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+@Controller
+@RequestMapping("api/apph5/v1/quality")
+public class AppH5QualityGoodsController {
+ @Resource
+ private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
+
+ @Resource
+ private TaobaoMeterialService taobaoMeterialService;
+
+ @Resource
+ private TaoKeGoodsService taoKeGoodsService;
+
+
+ @Resource
+ private HongBaoManageService manageService;
+
+ @Resource
+ private MergeClassService mergeClassService;
+
+
+ @Resource
+ private QualityGoodsService qualityGoodsService;
+
+ @Resource
+ private QualityFlashSaleService qualityFlashSaleService;
+
+ @Resource
+ private CollectionGoodsV2Service collectionGoodsV2Service;
+
+ @Resource
+ private HongBaoManageService hongBaoManageService;
+
+
+ @Resource
+ private TaoBaoGoodsActivityService taoBaoGoodsActivityService;
+
+ @Resource
+ private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
+
+
+ /**
+ * 9.9鍟嗗搧
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get9k9")
+ public void get9k9(AcceptData acceptData, String callback, Integer page, Long mcid, PrintWriter out) {
+ get9k9ClassGoods(acceptData, callback, out, page, 500, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9), mcid);
+
+ }
+
+ /**
+ * 19.9鍟嗗搧
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get19k9")
+ public void get19k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9),
+ mcid);
+
+ }
+
+
+ /**
+ * 29.9鍟嗗搧
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get29k9")
+ public void get29k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9),
+ mcid);
+
+ }
+
+ /**
+ * 49.9鍟嗗搧
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get49k9")
+ public void get49k9(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ get9k9ClassGoods(acceptData,callback, out, page, 500, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9),
+ mcid);
+ }
+
+ /**
+ * 9k9绫诲瀷鐨勫晢鍝佹煡璇�
+ *
+ * @param callback
+ * @param out
+ * @param page
+ * @param biz30day
+ * @param zkPrice
+ * @param minQuanPrice
+ * @param maxQuanPrice
+ * @param mcid
+ */
+ public void get9k9ClassGoods(AcceptData acceptData, String callback, PrintWriter out, Integer page, Integer biz30day, BigDecimal zkPrice,
+ BigDecimal minQuanPrice, BigDecimal maxQuanPrice, Long mcid) {
+ try {
+ if (page == null || page <= 0) {
+ page = 1;
+ }
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ String mergeCids = null;
+ if (mcid != null && (!mcid.equals(0) || mcid != 0)) {
+ MergeClass mergeClass = mergeClassService.selectByPrimaryKeyCache(mcid);
+ if (mergeClass != null) {
+ // 鍒嗙被id,闅斿紑
+ mergeCids = mergeClass.getMergeCids();
+ }
+ }
+
+ // 鏍规嵁鏍囩id 鏌ヨ鏁版嵁
+ List<QualityFactory> listQuery = qualityGoodsService.get9k9ClassGoods((page - 1) * pageSize, pageSize,
+ biz30day, zkPrice, minQuanPrice, maxQuanPrice, mergeCids);
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ // 鎬绘潯鏁�
+ long count = qualityGoodsService.count9k9ClassGoods(biz30day, zkPrice, minQuanPrice, maxQuanPrice,
+ mergeCids);
+
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem());
+ /* 閬嶅巻鍒楄〃鏁版嵁 */
+ for (QualityFactory selectionGoods : listQuery) {
+ TaoBaoGoodsBrief goodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+ if (goodsBrief == null) {
+ continue;
+ }
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
+ }
+
+ // 618娲诲姩
+ if (System.currentTimeMillis() < TimeUtil.convertToTimeTemp("2019-06-19", "yyyy-MM-dd")) {
+ if (mcid == null || mcid == 0) {
+ count = taoBaoGoodsActivityService.countByPrice(minQuanPrice,
+ maxQuanPrice.add(new BigDecimal("0.1")));
+ List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsActivityService.listByPrice(minQuanPrice,
+ maxQuanPrice.add(new BigDecimal("0.1")), page, pageSize);
+ if (goodsList != null) {
+ array.clear();
+ for (TaoBaoGoodsBrief goods : goodsList) {
+ array.add(gson
+ .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), null)));
+ }
+ }
+ }
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("result_list", array);
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+ /**
+ * 9.9鍟嗗搧-姣忔棩蹇呮姠
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get9k9EverydayRob")
+ public void get9k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ queryEverydayRob(acceptData,callback, out, page, new BigDecimal(209.9), new BigDecimal(0), new BigDecimal(9.9));
+
+ }
+
+ /**
+ * 19.9鍟嗗搧-姣忔棩蹇呮姠
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get19k9EverydayRob")
+ public void get19k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ queryEverydayRob(acceptData,callback, out, page, new BigDecimal(319.9), new BigDecimal(9.9), new BigDecimal(19.9));
+ }
+
+ /**
+ * 29.9鍟嗗搧-姣忔棩蹇呮姠
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get29k9EverydayRob")
+ public void get29k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ queryEverydayRob(acceptData,callback, out, page, new BigDecimal(429.9), new BigDecimal(19.9), new BigDecimal(29.9));
+
+ }
+
+
+ /**
+ * 49.9鍟嗗搧-姣忔棩蹇呮姠
+ *
+ * @param callback
+ * @param page
+ * @param mcid
+ * @param out
+ */
+ @RequestMapping(value = "get49k9EverydayRob")
+ public void get49k9EverydayRob(AcceptData acceptData,String callback, Integer page, Long mcid, PrintWriter out) {
+ queryEverydayRob(acceptData,callback, out, page, new BigDecimal(549.9), new BigDecimal(29.9), new BigDecimal(49.9));
+
+ }
+
+ /**
+ * 姣忔棩蹇呮姠
+ *
+ * @param callback
+ * @param out
+ * @param page
+ * @param zkPrice
+ * @param minQuanPrice
+ * @param maxQuanPrice
+ */
+ public void queryEverydayRob(AcceptData acceptData, String callback, PrintWriter out, Integer page, BigDecimal zkPrice,
+ BigDecimal minQuanPrice, BigDecimal maxQuanPrice) {
+
+ if (page == null)
+ page = 1;
+
+ // 20 鏉′竴椤佃姹傚埌3椤电粨鏉熶粖鏃ユ柊鍝�
+ if (page > 3) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ try {
+ int pageSize = Constant.PAGE_SIZE;
+ List<QualityFactory> listQuery = qualityGoodsService.listQueryEverydayRob((page - 1) * pageSize, pageSize,
+ zkPrice, minQuanPrice, maxQuanPrice);
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ for (QualityFactory selectionGoods : listQuery) {
+ TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+ array.add(gson
+ .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ long count = qualityGoodsService.countQueryEverydayRob(zkPrice, minQuanPrice, maxQuanPrice);
+ if (count < 50) {
+ count = listQuery.size();
+ } else {
+ count = 50;
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("result_list", array);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+ /**
+ * 鍝佺墝璐� 锛堝畼鏂规帹鑽愩�愬搧鐗屽埜銆戞帴鍙o級
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getBrandsGoods")
+ public void getBrandsGoods(AcceptData acceptData, String callback, Integer page, String subName, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "鍝佺墝鍒�");
+
+ if (list == null || list.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial taobaoMeterial = list.get(0);
+ Integer materialId = taobaoMeterial.getMaterialId();
+ if (materialId == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = taoKeGoodsService.getBrandsGoods(materialId, page, pageSize,acceptData.getSystem());
+
+ if (jsonObject == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 鍝佺墝璐� 锛堝畼鏂规帹鑽愩�愬搧鐗屽埜銆戞帴鍙o級
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getBrandsShops")
+ public void getBrandsShops(String callback, Integer page, PrintWriter out) {
+
+ try {
+ String subName = "缁煎悎";
+ List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "鍝佺墝鍒�");
+
+ if (list == null || list.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial taobaoMeterial = list.get(0);
+ Integer materialId = taobaoMeterial.getMaterialId();
+ if (materialId == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = taoKeGoodsService.getBrandsShops(materialId, page, pageSize);
+
+ if (jsonObject == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 澶ч鍒� 锛堝畼鏂规帹鑽愪腑鐨勩�愮壒鎯犮�戯級
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getPreferential", method = RequestMethod.POST)
+ public void getPreferential(AcceptData acceptData,int page, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null, "鐗规儬");
+
+ if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+ out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial meterial = taobaoMeterials.get(0);
+ Integer materialId = meterial.getMaterialId();
+ if (materialId == null) {
+ out.print(JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page < 1)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = queryMaterialGoods(acceptData,page, pageSize, materialId);
+
+ if (jsonObject == null) {
+ out.print(JsonUtil.loadFalseResult(2, "鏆傛棤鏇村鏁版嵁"));
+ }
+ out.print(JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 瓒呴珮濂栭噾(瀹樻柟鎺ㄨ崘涓殑銆愭湁濂借揣銆�)
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getSuperiors", method = RequestMethod.POST)
+ public void getSuperiors(AcceptData acceptData, int page, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
+ "鏈夊ソ璐�");
+
+ if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+ out.print(JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial meterial = taobaoMeterials.get(0);
+ Integer materialId = meterial.getMaterialId();
+ if (materialId == null) {
+ out.print(JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page < 1)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
+
+ if (jsonObject == null) {
+ out.print(JsonUtil.loadFalseResult(2, "鏆傛棤鏇村鏁版嵁"));
+ }
+ out.print(JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 浠婃棩鏂板搧銆愶紙瀹樻柟鎺ㄨ崘銆愬ソ鍒哥洿鎾�戞帴鍙o級
+ *
+ * @param page
+ * @param subName 瀛愮被鍚嶇О
+ */
+ @RequestMapping(value = "todayNew")
+ public void todayNew(AcceptData acceptData, String callback, Integer page, String subName, String uid, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> list = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName, "濂藉埜鐩存挱");
+
+ if (list == null || list.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial taobaoMeterial = list.get(0);
+ Integer materialId = taobaoMeterial.getMaterialId();
+ if (materialId == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ List<TaoBaoGoodsBrief> listMaterial = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
+
+ if (listMaterial == null || listMaterial.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+
+ /* 閬嶅巻鍒楄〃鏁版嵁 */
+ for (TaoBaoGoodsBrief taoBaoGoodsBrief : listMaterial) {
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鏀瑰彉鍥剧墖灏哄 澶у浘鏇存竻鏅�
+ String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ pictUrl = pictUrl.replaceAll("320x320", "640x640");
+ taoBaoGoodsBrief.setPictUrl(pictUrl);
+
+ int collected = 0;
+ // 鍒ゆ柇鏀惰棌
+ if (!StringUtil.isNullOrEmpty(uid)) {
+ CollectionGoodsV2 collectionGoods = collectionGoodsV2Service
+ .findByUidAndAuctionId(Long.parseLong(uid), taoBaoGoodsBrief.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO);
+ if (collectionGoods != null) {
+ collected = 1;
+ }
+ }
+
+ TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
+ proportion.toString(), null);
+ taoBaoGoodsBriefExtra.setCollected(collected);
+
+ array.add(gson.toJson(taoBaoGoodsBriefExtra));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("result_list", array);
+ data.put("count", 1000);
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 娼搧鐑崠锛堝畼鏂规帹鑽愪腑鐨勩�愭疆娴佽寖銆戯級
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getFashions")
+ public void getFashions(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(null,
+ "娼祦鑼�");
+
+ if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial meterial = taobaoMeterials.get(0);
+ Integer materialId = meterial.getMaterialId();
+ if (materialId == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page == null) {
+ page = 1;
+ }
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
+
+ if (jsonObject == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 姣嶅┐绮鹃�夛紙瀹樻柟鎺ㄨ崘涓殑銆愭瘝濠翠富棰樸�戯級
+ *
+ * @param page
+ * @param out
+ */
+ @RequestMapping(value = "getPregnantBaby")
+ public void getPregnantBaby(AcceptData acceptData, String callback, Integer page, String subName, PrintWriter out) {
+
+ try {
+
+ List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache(subName,
+ "姣嶅┐涓婚");
+
+ if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+ return;
+ }
+
+ TaobaoMeterial meterial = taobaoMeterials.get(0);
+ Integer materialId = meterial.getMaterialId();
+ if (materialId == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈绱㈠埌鏁版嵁"));
+ return;
+ }
+
+ if (page == null) {
+ page = 1;
+ }
+ int pageSize = Constant.PAGE_SIZE;
+
+ JSONObject jsonObject = queryMaterialGoods(acceptData, page, pageSize, materialId);
+
+ if (jsonObject == null) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ }
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(jsonObject));
+
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触"));
+
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 鎺ㄨ崘鏌ヨ鎺ュ彛瀵规帴-鍏敤鏂规硶
+ *
+ * @param page
+ * @param pageSize
+ * @param materialId
+ * @return
+ * @throws Exception
+ */
+ public JSONObject queryMaterialGoods(AcceptData acceptData, int page, int pageSize, Integer materialId) throws Exception {
+
+ List<TaoBaoGoodsBrief> listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
+
+ if (listBrands == null || listBrands.size() == 0) {
+ return null;
+ }
+
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+
+ /* 閬嶅巻鍒楄〃鏁版嵁 */
+ for (TaoBaoGoodsBrief taoBaoGoodsBrief : listBrands) {
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鏀瑰彉鍥剧墖灏哄
+ String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
+ taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
+ }
+
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("result_list", array);
+ data.put("count", 1000);
+
+ return data;
+
+ }
+
+ /**
+ * 闄愭椂鎶㈣喘
+ *
+ * @param callback
+ * @param page
+ * @param out
+ */
+ @RequestMapping("getFlashSale")
+ public void getFlashSale(AcceptData acceptData, String callback, Integer page, Long auctionId, PrintWriter out) {
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+ int type = qualityFlashSaleService.getNowType();
+
+ TaoBaoGoodsBrief goodsBrief = null;
+ if (page == 1 && auctionId != null) {
+ List<TaoBaoGoodsBrief> list = taoBaoGoodsBriefService.queryByAuctionId(auctionId);
+ if (list != null && list.size() > 0) {
+ goodsBrief = list.get(0);
+ }
+ }
+
+ if (goodsBrief != null) {
+ pageSize = pageSize - 1;
+ }
+
+ List<QualityFactory> listQuery = qualityGoodsService.listQueryByFlashSale((page - 1) * pageSize, pageSize);
+
+ // 绮鹃�夊簱鏁版嵁涓虹┖
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ long count = 3000;
+
+ // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+
+ if (goodsBrief != null) {
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null)));
+ }
+
+ // 閬嶅巻鍒楄〃鏁版嵁
+ for (QualityFactory quality : listQuery) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+
+ if (goodsBrief != null && auctionId.equals(taoBaoGoodsBrief.getAuctionId())) {
+ continue;
+ }
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鏀瑰彉鍥剧墖灏哄
+ String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
+ taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
+ }
+
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("type", type);
+ data.put("result_list", array);
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ }
+
+ @RequestMapping("getFlashSaleNew")
+ public void getFlashSaleNew(AcceptData acceptData, String callback, Integer page, Long auctionId, String time, PrintWriter out) {
+ List<DaTaoKeDetailV2> detailList0 = daTaoKeGoodsDetailV2Service.getDingDongQiangData(time);
+ if (detailList0 == null)
+ detailList0 = new ArrayList<>();
+ List<DaTaoKeDetailV2> detailList = new ArrayList<>();
+ detailList.addAll(detailList0);
+ JSONArray array = new JSONArray();
+ if (page == 1) {
+ if (auctionId != null && detailList != null)
+ for (int i = 0; i < detailList.size(); i++) {
+ if (detailList.get(i).getGoodsId().longValue() == auctionId) {
+ DaTaoKeDetailV2 goods = detailList.get(i);
+ detailList.remove(i);
+ detailList.add(0, goods);
+ break;
+ }
+ }
+
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+ if (detailList != null)
+ for (DaTaoKeDetailV2 detail : detailList) {
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(detail),
+ hongBaoManageService.getFanLiRate(acceptData.getSystem()) + "", null)));
+ }
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", detailList.size());
+ data.put("result_list", array);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ }
+
+ /**
+ * 澶ч鍒革紙鍒搁潰鍊艰寖鍥达級
+ *
+ * @param callback
+ * @param amount
+ * @param page
+ * @param out
+ */
+ @RequestMapping("choiceCouponAmount")
+ public void choiceCouponAmount(AcceptData acceptData, String callback, Integer amount, Integer page, PrintWriter out) {
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ Integer startAmount = null;
+ Integer endAmount = null;
+
+ if (amount.equals(1)) {
+ startAmount = 5;
+ endAmount = 10;
+ } else if (amount.equals(2)) {
+ startAmount = 10;
+ endAmount = 30;
+ } else if (amount.equals(3)) {
+ startAmount = 30;
+ endAmount = 50;
+ } else if (amount.equals(4)) {
+ startAmount = 50;
+ }
+
+ Integer startPropor = 20;
+
+ List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize,
+ startAmount, endAmount, startPropor);
+
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor);
+
+ // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ // 閬嶅巻鍒楄〃鏁版嵁
+ for (QualityFactory selectionGoods : listQuery) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鏀瑰彉鍥剧墖灏哄
+ String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
+ taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
+ }
+
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("result", array);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ }
+
+ /**
+ * 瓒呴珮濂栭噾
+ *
+ * @param callback
+ * @param page
+ * @param type
+ * @param out
+ */
+ @RequestMapping("choiceRebate")
+ public void choiceRebate(AcceptData acceptData, String callback, Integer page, Integer type, PrintWriter out) {
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ Integer startAmount = null;
+ Integer endAmount = null;
+
+ if (type.equals(1)) {
+ startAmount = 1;
+ endAmount = 5;
+ } else if (type.equals(2)) {
+ startAmount = 5;
+ endAmount = 10;
+ } else if (type.equals(3)) {
+ startAmount = 10;
+ endAmount = 15;
+ } else if (type.equals(4)) {
+ startAmount = 15;
+ }
+
+ double tkRate = 20.00;
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
+ proportion.toString(), startAmount, endAmount, tkRate);
+
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount,
+ tkRate);
+
+ // 绮鹃�夊簱鏁版嵁澶勭悊杩斿洖 鍓嶇
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ // 閬嶅巻鍒楄〃鏁版嵁
+ for (QualityFactory quality : listQuery) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief();
+
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+
+ int biz30day = taoBaoGoodsBrief.getBiz30day();
+ if (biz30day >= 10000) {
+ double sales = biz30day;
+ String salesCountMidea = String.format("%.1f", sales / 10000);
+ taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�");
+ } else {
+ taoBaoGoodsBrief.setSalesCount(biz30day + "");
+ }
+
+ // 鏀瑰彉鍥剧墖灏哄
+ String pictUrl = taoBaoGoodsBrief.getPictUrl();
+ if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
+ taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
+ }
+
+ array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("result_list", array);
+
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ }
+
+ /**
+ * 瓒呴珮濂栭噾
+ *
+ * @param callback
+ * @param page
+ * @param out
+ */
+ @RequestMapping("recommendToIndex")
+ public void recommendToIndex(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
+
+ if (page == null)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ JSONArray array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize,
+ proportion.toString());
+
+ if (array == null) {
+ out.print(JsonUtil.loadFalseResult("娌℃湁鏇村浜�"));
+ return;
+ }
+
+ long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
+
+ JSONObject data = new JSONObject();
+ data.put("count", count);
+ data.put("result_list", array);
+
+ out.print(JsonUtil.loadTrueResult(data));
+ return;
+ }
+
+ /**
+ * 瓒呴珮濂栭噾
+ *
+ * @param callback
+ * @param page
+ * @param out
+ */
+ @RequestMapping("freeGoods")
+ public void freeGoods(AcceptData acceptData, String callback, Integer page, PrintWriter out) {
+ try {
+ if (page == null || page < 1)
+ page = 1;
+
+ int pageSize = Constant.PAGE_SIZE;
+
+ List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+ if (listQuery == null || listQuery.size() == 0) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+ return;
+ }
+
+ List<Long> listGid = new ArrayList<Long>();
+ for (QualityFactory qualityFactory : listQuery) {
+ TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
+
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+ listGid.add(taoBaoGoodsBrief.getAuctionId());
+ }
+
+ // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+ List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+ try {
+ listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+ } catch (TaoKeApiException e) {
+ e.printStackTrace();
+ } catch (TaobaoGoodsDownException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ JSONArray array = new JSONArray();
+ Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+
+ BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem());
+ /* 閬嶅巻鍒楄〃鏁版嵁 */
+ for (QualityFactory selectionGoods : listQuery) {
+
+ TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+
+ if (taoBaoGoodsBrief == null) {
+ continue;
+ }
+
+ if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
+ boolean stateSale = false; // 榛樿鍋滃敭
+ Long goodsId = taoBaoGoodsBrief.getAuctionId();
+ for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+ Long auctionId = taoKeGoods.getAuctionId();
+ if (goodsId == auctionId || goodsId.equals(auctionId)) {
+ stateSale = true; // 鍦ㄥ敭
+ break;
+ }
+ }
+
+ if (!stateSale) {
+ continue;
+ }
+ }
+
+ BigDecimal couplePrice = TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief);
+ if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
+ continue; // 鍒稿悗浠峰ぇ浜�10
+ }
+
+ TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
+ proportion.toString(), null);
+ // 灏嗚繑鍒╂敼涓哄埜鍚庝环
+ TaoBaoHongBaoInfo taoBaoHongBaoInfo = extra.getTaoBaoHongBaoInfo();
+ if (taoBaoHongBaoInfo != null) {
+ taoBaoHongBaoInfo.setHongbao(extra.getQuanPrice());
+ taoBaoHongBaoInfo.setRate("楼" + extra.getQuanPrice());
+ }
+
+ array.add(gson.toJson(extra));
+ }
+
+ long count = qualityGoodsService.countFreeGoods();
+
+ JSONObject data = new JSONObject();
+ if (page == 1) {
+ // 鎶藉瑙勫垯
+ data.put("ruleLink", "");
+ }
+
+ data.put("count", count);
+ data.put("result_list", array);
+ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏁版嵁鏆傛湭鎻愪緵"));
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+}
--
Gitblit v1.8.0