| | |
| | | package com.yeshi.fanli.controller.client.v1.h5;
|
| | |
|
| | | 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.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.goods.FreeGoodsCoupon;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.goods.FreeGoodsCouponService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.goods.OtherInfo;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/apph5/v1/coupon")
|
| | | public class AppH5CouponController {
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private FreeGoodsCouponService freeGoodsCouponService;
|
| | |
|
| | | @Resource
|
| | | private TearcherService tearcherService;
|
| | |
|
| | | @RequestMapping("getMianDanGoodsList")
|
| | | public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
|
| | | 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();
|
| | |
|
| | | ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion(), UserLevelEnum.daRen,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.getAfterUseCouplePrice(taoBaoGoodsBrief);
|
| | | if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
|
| | | continue; // 券后价大于10
|
| | | }
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO);
|
| | | array.add(gson.toJson(detailVO));
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goodsList", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("getMianDanInfo")
|
| | | public void getMianDanInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.countUsableFreeCouponForBuy(uid);
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | | userJson.put("id", user.getId());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("couponCount", couponCount);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取返利奖励券信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | * @param uid
|
| | | * @param callback
|
| | | */
|
| | | @RequestMapping("getRewardCouponInfo")
|
| | | public void getRewardCouponInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
|
| | | UserInfoExtra extraInfo = userInfoExtraService.getUserInfoExtra(uid);
|
| | | long integralCount = extraInfo != null ? extraInfo.getGoldCoin() : 0L;
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | | userJson.put("id", user.getId());
|
| | | userJson.put("vip", userVIPInfoService.isVIP(user.getId()));
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("couponCount", couponCount);
|
| | | data.put("integralCount", integralCount);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新版免单商品列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param callback
|
| | | * @param page
|
| | | * @param goodsType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getFreeGoodsList")
|
| | | public void getFreeGoodsList(AcceptData acceptData, String callback, Long uid, int page, int goodsType,
|
| | | PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String tearcherWX = null;
|
| | | TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
|
| | | if (tearcherInfo != null) {
|
| | | tearcherWX = tearcherInfo.getWxID();
|
| | | }
|
| | |
|
| | | // 获取免单券数量
|
| | | long couponNum = userSystemCouponService.countUsableFreeCouponForBuy(uid);
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | List<FreeGoodsCoupon> list = freeGoodsCouponService.listByType((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, goodsType);
|
| | | if (list != null && list.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | for (FreeGoodsCoupon freeGoods : list) {
|
| | | GoodsDetailVO goods = freeGoods.getGoods();
|
| | | if (goods == null)
|
| | | continue;
|
| | | |
| | | // 实付款0
|
| | | OtherInfo otherInfo = goods.getOtherInfo();
|
| | | if (otherInfo == null)
|
| | | otherInfo = new OtherInfo();
|
| | | otherInfo.setActualPay(BigDecimal.ZERO);
|
| | | |
| | | // 补齐金额
|
| | | if (goods.isHasCoupon()) {
|
| | | otherInfo.setMendMoney(goods.getCouponPrice());
|
| | | } else {
|
| | | otherInfo.setMendMoney(goods.getZkPrice());
|
| | | }
|
| | | goods.setOtherInfo(otherInfo);
|
| | | array.add(gson.toJson(goods));
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | | userJson.put("couponNum", couponNum);
|
| | | userJson.put("tearcherWX", tearcherWX);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("count", freeGoodsCouponService.countByType(goodsType));
|
| | | data.put("list", array);
|
| | | 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.ArrayList; |
| | | 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.bus.lable.QualityFactory; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra; |
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.goods.FreeGoodsCoupon; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.service.inter.goods.FreeGoodsCouponService; |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService; |
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.goods.OtherInfo; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/apph5/v1/coupon") |
| | | public class AppH5CouponController { |
| | | |
| | | @Resource |
| | | private QualityGoodsService qualityGoodsService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserSystemCouponService userSystemCouponService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private UserVIPInfoService userVIPInfoService; |
| | | |
| | | @Resource |
| | | private FreeGoodsCouponService freeGoodsCouponService; |
| | | |
| | | @Resource |
| | | private TearcherService tearcherService; |
| | | |
| | | @RequestMapping("getMianDanGoodsList") |
| | | public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | |
| | | List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize); |
| | | if (listQuery == null || listQuery.size() == 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了")); |
| | | return; |
| | | } |
| | | |
| | | List<String> listGid = new ArrayList<>(); |
| | | for (QualityFactory qualityFactory : listQuery) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | if (!"0".equalsIgnoreCase(taoBaoGoodsBrief.getAuctionId())) { |
| | | listGid.add(taoBaoGoodsBrief.getAuctionId()); |
| | | } else { |
| | | listGid.add(taoBaoGoodsBrief.getId() + ""); |
| | | } |
| | | } |
| | | |
| | | // 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(); |
| | | |
| | | GoodsMoneyConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), UserLevelEnum.daRen, acceptData.getSystem()); |
| | | /* 遍历列表数据 */ |
| | | for (QualityFactory selectionGoods : listQuery) { |
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief(); |
| | | |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) { |
| | | boolean stateSale = false; // 默认停售 |
| | | String goodsId = taoBaoGoodsBrief.getAuctionId(); |
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { |
| | | String auctionId = taoKeGoods.getAuctionId(); |
| | | if (TaoBaoUtil.isEqual(goodsId, auctionId)) { |
| | | stateSale = true; // 在售 |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!stateSale) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | BigDecimal couplePrice = TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief); |
| | | if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) { |
| | | continue; // 券后价大于10 |
| | | } |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO); |
| | | array.add(gson.toJson(detailVO)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goodsList", array); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("getMianDanInfo") |
| | | public void getMianDanInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | // 获取用户信息 |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | // 获取免单券数量 |
| | | long couponCount = userSystemCouponService.countUsableFreeCouponForBuy(uid); |
| | | JSONObject userJson = new JSONObject(); |
| | | userJson.put("nickName", user.getNickName()); |
| | | userJson.put("portrait", user.getPortrait()); |
| | | userJson.put("id", user.getId()); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", userJson); |
| | | data.put("couponCount", couponCount); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取返利奖励券信息 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | * @param uid |
| | | * @param callback |
| | | */ |
| | | @RequestMapping("getRewardCouponInfo") |
| | | public void getRewardCouponInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | // 获取用户信息 |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | // 获取免单券数量 |
| | | long couponCount = userSystemCouponService.countUsableRewardCoupon(uid); |
| | | UserInfoExtra extraInfo = userInfoExtraService.getUserInfoExtra(uid); |
| | | long integralCount = extraInfo != null ? extraInfo.getGoldCoin() : 0L; |
| | | JSONObject userJson = new JSONObject(); |
| | | userJson.put("nickName", user.getNickName()); |
| | | userJson.put("portrait", user.getPortrait()); |
| | | userJson.put("id", user.getId()); |
| | | userJson.put("vip", userVIPInfoService.isVIP(user.getId())); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", userJson); |
| | | data.put("couponCount", couponCount); |
| | | data.put("integralCount", integralCount); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 新版免单商品列表 |
| | | * |
| | | * @param acceptData |
| | | * @param callback |
| | | * @param page |
| | | * @param goodsType |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getFreeGoodsList") |
| | | public void getFreeGoodsList(AcceptData acceptData, String callback, Long uid, int page, int goodsType, |
| | | PrintWriter out) { |
| | | if (acceptData.getSystem() == null) |
| | | acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | // 获取用户信息 |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | String tearcherWX = null; |
| | | TearcherInfo tearcherInfo = tearcherService.selectByUid(uid); |
| | | if (tearcherInfo != null) { |
| | | tearcherWX = tearcherInfo.getWxID(); |
| | | } |
| | | |
| | | // 获取免单券数量 |
| | | long couponNum = userSystemCouponService.countUsableFreeCouponForBuy(uid); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | List<FreeGoodsCoupon> list = freeGoodsCouponService.listByType((page - 1) * Constant.PAGE_SIZE, |
| | | Constant.PAGE_SIZE, goodsType); |
| | | if (list != null && list.size() > 0) { |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | for (FreeGoodsCoupon freeGoods : list) { |
| | | GoodsDetailVO goods = freeGoods.getGoods(); |
| | | if (goods == null) |
| | | continue; |
| | | |
| | | // 实付款0 |
| | | OtherInfo otherInfo = goods.getOtherInfo(); |
| | | if (otherInfo == null) |
| | | otherInfo = new OtherInfo(); |
| | | otherInfo.setActualPay(BigDecimal.ZERO); |
| | | |
| | | // 补齐金额 |
| | | if (goods.isHasCoupon()) { |
| | | otherInfo.setMendMoney(goods.getCouponPrice()); |
| | | } else { |
| | | otherInfo.setMendMoney(goods.getZkPrice()); |
| | | } |
| | | goods.setOtherInfo(otherInfo); |
| | | array.add(gson.toJson(goods)); |
| | | } |
| | | } |
| | | |
| | | JSONObject userJson = new JSONObject(); |
| | | userJson.put("nickName", user.getNickName()); |
| | | userJson.put("portrait", user.getPortrait()); |
| | | userJson.put("couponNum", couponNum); |
| | | userJson.put("tearcherWX", tearcherWX); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", userJson); |
| | | data.put("count", freeGoodsCouponService.countByType(goodsType)); |
| | | data.put("list", array); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | } |