| | |
| | | package com.yeshi.fanli.controller.client.v1.h5;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/apph5/v1/tlj")
|
| | | public class AppH5TaoLiJinController {
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | |
|
| | | @RequestMapping("getTLJBuyGoods")
|
| | | public void getTLJBuyGoods(AcceptData acceptData, PrintWriter out, String callback) {
|
| | | //
|
| | | List<TLJBuyGoods> goodsList = tljBuyGoodsService
|
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | int count = goodsList.size();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray goodsArray = new JSONArray();
|
| | | goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList;
|
| | | BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE;
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (TLJBuyGoods goods : goodsList) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = goods.getGoods();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | // 计算推广红包
|
| | | BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion);
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, proportion, proportion);
|
| | |
|
| | | // 大于1.6.5的才会显示福利价
|
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
|
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney));
|
| | | else
|
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney));
|
| | | }
|
| | | goodsArray.add(gson.toJson(detailVO));
|
| | | }
|
| | | data.put("goodsList", goodsArray);
|
| | | data.put("count", count);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享爆款商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | * @param callback
|
| | | */
|
| | | @RequestMapping("getShareHotGoods")
|
| | | public void getShareHotGoods(AcceptData acceptData, PrintWriter out, String callback) {
|
| | | List<ShareHotGoods> goodsList = shareHotGoodsService
|
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | int count = goodsList.size();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray goodsArray = new JSONArray();
|
| | | goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList;
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | BigDecimal fanLiRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
|
| | | BigDecimal shareRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
|
| | | for (ShareHotGoods hotGoods : goodsList) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief);
|
| | |
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate);
|
| | |
|
| | | // 大于1.6.5的才会显示福利价
|
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
|
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney));
|
| | | else
|
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney));
|
| | | }
|
| | | // 去掉标签
|
| | | detailVO.setLabels(null);
|
| | | goodsArray.add(gson.toJson(detailVO));
|
| | | }
|
| | |
|
| | | data.put("goodsList", goodsArray);
|
| | | data.put("count", count);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v1.h5; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.util.SystemInfoUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods; |
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; |
| | | import com.yeshi.fanli.util.TaoBaoConstant; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/apph5/v1/tlj") |
| | | public class AppH5TaoLiJinController { |
| | | |
| | | @Resource |
| | | private TLJBuyGoodsService tljBuyGoodsService; |
| | | |
| | | @Resource |
| | | private ShareHotGoodsService shareHotGoodsService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | |
| | | @RequestMapping("getTLJBuyGoods") |
| | | public void getTLJBuyGoods(AcceptData acceptData, PrintWriter out, String callback) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | // |
| | | List<TLJBuyGoods> goodsList = tljBuyGoodsService |
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | int count = goodsList.size(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | JSONArray goodsArray = new JSONArray(); |
| | | goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList; |
| | | BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | GoodsMoneyConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(),null); |
| | | for (TLJBuyGoods goods : goodsList) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = goods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | // 计算推广红包 |
| | | BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion,false); |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO); |
| | | |
| | | // 大于1.6.5的才会显示福利价 |
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) |
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); |
| | | else |
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); |
| | | } |
| | | goodsArray.add(gson.toJson(detailVO)); |
| | | } |
| | | data.put("goodsList", goodsArray); |
| | | data.put("count", count); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 分享爆款商品 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | * @param callback |
| | | */ |
| | | @RequestMapping("getShareHotGoods") |
| | | public void getShareHotGoods(AcceptData acceptData, PrintWriter out, String callback) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | List<ShareHotGoods> goodsList = shareHotGoodsService |
| | | .listByDay(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | int count = goodsList.size(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | JSONArray goodsArray = new JSONArray(); |
| | | goodsList = goodsList.size() > 10 ? goodsList.subList(0, 10) : goodsList; |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | GoodsMoneyConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(),null); |
| | | for (ShareHotGoods hotGoods : goodsList) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO); |
| | | |
| | | // 大于1.6.5的才会显示福利价 |
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) |
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); |
| | | else |
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); |
| | | } |
| | | // 去掉标签 |
| | | detailVO.setLabels(null); |
| | | goodsArray.add(gson.toJson(detailVO)); |
| | | } |
| | | |
| | | data.put("goodsList", goodsArray); |
| | | data.put("count", count); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | } |