| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | 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 com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.common.CommonContentNav;
|
| | | import com.yeshi.fanli.dto.common.CommonContentResult;
|
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 通用模板
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v1/commoncontent")
|
| | | public class CommonContentController {
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private CommonTemplateContentService commonTemplateContentService;
|
| | |
|
| | | /**
|
| | | * 通用模板导航
|
| | | * |
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNavList", method = RequestMethod.POST)
|
| | | public void getNavList(AcceptData acceptData, String key, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
|
| | | return;
|
| | | }
|
| | | List<CommonContentNav> list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key));
|
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(list)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取内容
|
| | | * |
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param page-页码
|
| | | * @param navId-导航ID
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST)
|
| | | public void getNavContent(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入正确的page"));
|
| | | return;
|
| | | }
|
| | |
|
| | | CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key),
|
| | | cid, page, 10);
|
| | |
|
| | | // 保留暂时不开启,待后续开启
|
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | if (page == 1)
|
| | | root.put("bannerList", new Gson().toJson(bannerList));
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | BigDecimal pro = hongBaoManageService.getFanLiRate();
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, pro.toString(), "")));
|
| | | }
|
| | | root.put("goodsList", array);
|
| | | root.put("goodsCount", result.getCount());
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v1; |
| | | |
| | | 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 com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.common.CommonContentNav; |
| | | import com.yeshi.fanli.dto.common.CommonContentResult; |
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService; |
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | /** |
| | | * 通用模板 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Controller |
| | | @RequestMapping("api/v1/commoncontent") |
| | | public class CommonContentController { |
| | | |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private CommonTemplateContentService commonTemplateContentService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | /** |
| | | * 通用模板导航 |
| | | * |
| | | * @param acceptData |
| | | * @param key |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getNavList", method = RequestMethod.POST) |
| | | public void getNavList(AcceptData acceptData, String key, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key")); |
| | | return; |
| | | } |
| | | List<CommonContentNav> list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key),acceptData.getSystem()); |
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(list))); |
| | | } |
| | | |
| | | /** |
| | | * 获取内容 |
| | | * |
| | | * @param acceptData |
| | | * @param key |
| | | * @param page-页码 |
| | | * @param navId-导航ID |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST) |
| | | public void getNavContent(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key")); |
| | | return; |
| | | } |
| | | |
| | | if (page == null || page < 1) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入正确的page")); |
| | | return; |
| | | } |
| | | |
| | | CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key), |
| | | cid, page, 10,acceptData.getSystem()); |
| | | |
| | | // 保留暂时不开启,待后续开启 |
| | | List<SwiperPicture> bannerList = new ArrayList<>(); |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | if (page == 1) |
| | | root.put("bannerList", new Gson().toJson(bannerList)); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | BigDecimal pro = hongBaoManageService.getFanLiRate(acceptData.getSystem()); |
| | | if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 |
| | | pro = new BigDecimal(100); |
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList(); |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) { |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, pro.toString(), ""); |
| | | if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 |
| | | { |
| | | extra.getTaoBaoHongBaoInfo().setRate("¥" + TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); |
| | | extra.getTaoBaoHongBaoInfo().setHongbao(TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); |
| | | } |
| | | array.add(gson.toJson(extra)); |
| | | } |
| | | root.put("goodsList", array); |
| | | root.put("goodsCount", result.getCount()); |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | |
| | | // 更新前5页数据 |
| | | if (page <= 5) |
| | | try { |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | } |