| | |
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.CommonGoodsUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | jdGoods = JDApiUtil.getGoodsDetail(auctionId);
|
| | | }
|
| | | if (jdGoods == null) {
|
| | | throw new UserGoodsStorageException(1, "auctionId商品已下架");
|
| | | throw new UserGoodsStorageException(1, auctionId + "商品已下架");
|
| | | }
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | |
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | // 拼多多
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(auctionId);
|
| | | if (pddGoods == null) {
|
| | | throw new UserGoodsStorageException(1, "auctionId商品已下架");
|
| | | throw new UserGoodsStorageException(1, auctionId + "商品已下架");
|
| | | }
|
| | | commonGoods = CommonGoodsFactory.create(pddGoods);
|
| | | } else {
|
| | |
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | commonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new UserGoodsStorageException(1, "auctionId商品已下架");
|
| | | throw new UserGoodsStorageException(1, auctionId + "商品已下架");
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void addCommonGoods(Long uid, Set<Long> ids) throws UserGoodsStorageException {
|
| | |
|
| | | if (uid == null) {
|
| | |
| | | }
|
| | | return state;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public JSONObject shareGoods(Long uid, List<Long> listStorageID)
|
| | | throws UserGoodsStorageException, UserShareGoodsRecordException {
|
| | |
| | | throw new UserGoodsStorageException(1, "选品库商品不存在");
|
| | | }
|
| | |
|
| | | |
| | | List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
|
| | | // 还原顺序 用于制图
|
| | | for (Long sid: listStorageID) {
|
| | |
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | Integer goodsType = null;
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | for (UserGoodsStorage userGoodsStorage: listResult) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | listCommonGoods.add(commonGoods);
|
| | |
|
| | | if (goodsType == null) {
|
| | | goodsType = commonGoods.getGoodsType();
|
| | | }
|
| | | |
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | |
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate);
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | }
|
| | |
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listGoodsBrief, listStorageID);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods, listStorageID);
|
| | | FileUploadResult uploadResult = new FileUploadResult();
|
| | | uploadResult.setUrl(shareRecord.getSharePictureUrl());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("revenue", listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney);
|
| | | data.put("revenue", listCommonGoods.size() + "个商品预估分享奖金:¥"+totalMoney);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | data.put("shareImg", uploadResult);
|
| | |
|