| | |
| | |
|
| | | 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.hongbao.HongBaoManageService;
|
| | | 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;
|
| | |
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | 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) {
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion(), UserLevelEnum.daRen);
|
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory selectionGoods : listQuery) {
|
| | |
|
| | |
| | | if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
|
| | | continue; // 券后价大于10
|
| | | }
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate);
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO);
|
| | | array.add(gson.toJson(detailVO));
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | return;
|
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.count
|
| | | 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));
|
| | | }
|
| | |
|
| | | } |