| | |
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | |
| | | public long countQueryByUid(Long uid) {
|
| | | return userGoodsStorageMapper.countQueryByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void updateShareState(Long shareId) {
|
| | | userGoodsStorageMapper.updateShareState(shareId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void save(Long uid, Set<Long> auctionIds) throws UserGoodsStorageException {
|
| | |
| | | long nd = 1000 * 24 * 60 * 60;
|
| | | List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | BigDecimal rate = manageService.getFanLiRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | BigDecimal rate = manageService.getFanLiRate();
|
| | | |
| | |
|
| | | for (UserGoodsStorage userGoodsStorage : listStorage) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | |
| | | if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) {
|
| | | Date updateTime = commonGoods.getUpdateTime();
|
| | | if (updateTime != null) {
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | // 计算差多少小时
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | long day = diff / nd;
|
| | | long hour = diff % nd / nh;
|
| | | if (hour > 1 ) {
|
| | | if (hour > 1 || day > 0 ) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | goodsBrief.setState(0);
|
| | | |
| | | goodsState = 0;
|
| | | goodsBrief.setState(goodsState);
|
| | | |
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | upadeteCommonGoods.setId(commonGoods.getId());
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 已下架
|
| | | goodsState = 1;
|
| | | commonGoods.setState(1);
|
| | | commonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(commonGoods);
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | } else {
|
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | | } |
| | |
|
| | | // 判断是否已分享
|
| | | Integer state = userGoodsStorage.getState();
|
| | | int shared = UserGoodsStorage.STATE_SHARED;
|
| | | if (state != null && (state == shared || state.equals(shared))) {
|
| | | if (goodsState != 1 || goodsState.equals(1)) {
|
| | | if (goodsState != 1 || !goodsState.equals(1)) {
|
| | | goodsBrief.setState(2); // 已分享状态
|
| | | }
|
| | | }
|
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | String pictUrl = goodsBrief.getPictUrl();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | goodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null));
|
| | |
|
| | |
| | | throw new UserGoodsStorageException(1, "选品库商品不存在");
|
| | | }
|
| | |
|
| | | |
| | | List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
|
| | | // 还原顺序 用于制图
|
| | | for (Long sid: listStorageID) {
|
| | | for (UserGoodsStorage torage: listStorage) {
|
| | | Long id = torage.getId();
|
| | | if (sid == id || sid.equals(id)) {
|
| | | listResult.add(torage);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
|
| | | for (UserGoodsStorage userGoodsStorage: listStorage) {
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | |
| | | for (UserGoodsStorage userGoodsStorage: listResult) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | // 已分享
|
| | | userGoodsStorage.setState(1);
|
| | | userGoodsStorage.setUpdateTime(new Date());
|
| | |
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, new BigDecimal(rateStr));
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | }
|
| | |
|
| | | String revenue = listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney;
|
| | | FileUploadResult loadResult = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, listGoodsBrief);
|
| | |
|
| | | // 更新为已分享
|
| | | userGoodsStorageMapper.updateBatchSelective(listStorage);
|
| | | |
| | | Map<String,Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, |
| | | null, listGoodsBrief);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | data.put("revenue", revenue);
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | data.put("shareId", map.get("shareId"));
|
| | | data.put("shareImg", map.get("loadResult"));
|
| | | data.put("notifyDesc", configService.get("goods_share_multiple_notify"));
|
| | |
|
| | | return data;
|
| | | |
| | | }
|
| | | }
|