| | |
| | | package com.yeshi.fanli.controller.apph5;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | 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.goods.CollectionGoodsV2;
|
| | | 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.config.ConfigService;
|
| | | 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.goods.TaoBaoGoodsBriefService;
|
| | | 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.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;
|
| | |
| | |
|
| | | @Resource
|
| | | private QualityFactoryService selectionGoodsService;
|
| | | |
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private TaobaoMeterialService taobaoMeterialService;
|
| | |
| | | private TaoBaoClassService taoBaoClassService;
|
| | |
|
| | | @Resource
|
| | | private SystemService systemService;
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | /**
|
| | | * 9.9商品
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory selectionGoods : listQuery) {
|
| | |
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory selectionGoods : listQuery) {
|
| | |
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal proportion =manageService.getFanLiRate();
|
| | |
|
| | | /* 遍历列表数据 */
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listMaterial) {
|
| | |
| | | }
|
| | |
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
|
| | | proportion, fcRate, null);
|
| | | proportion.toString(), null);
|
| | | taoBaoGoodsBriefExtra.setCollected(collected);
|
| | |
|
| | | array.add(gson.toJson(taoBaoGoodsBriefExtra));
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | |
|
| | | /* 遍历列表数据 */
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listBrands) {
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getFlashSale")
|
| | | public void getFlashSale(String callback, Integer page, PrintWriter out) {
|
| | | public void getFlashSale(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);
|
| | |
|
| | | // 精选库数据为空
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | // 遍历列表数据
|
| | | for (QualityFactory selectionGoods : listQuery) {
|
| | |
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | |
|
| | | double tkRate = 20.00;
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize,
|
| | | proportion, startAmount, endAmount, tkRate);
|
| | | proportion.toString(), startAmount, endAmount, tkRate);
|
| | |
|
| | | if (listQuery == null || listQuery.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = qualityGoodsService.countQueryByRebateAmount(proportion, startAmount, endAmount, tkRate);
|
| | | long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount, tkRate);
|
| | |
|
| | | // 精选库数据处理返回 前端
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion, fcRate, null)));
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | JSONArray array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion, fcRate);
|
| | | 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);
|
| | | long count = qualityGoodsService.countRecommendToIndex(proportion.toString());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | |
| | | 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();
|
| | | if (page == 1) {
|
| | | // 抽奖规则
|
| | | String rules = configService.get("free_goods_rule");
|
| | | data.put("ruleLink", rules);
|
| | | }
|
| | | |
| | | 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();
|
| | | }
|
| | | }
|
| | | |
| | | }
|