| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | 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;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserGoodsStorageMapper;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.goods.CommonGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.user.UserGoodsStorageException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | 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.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | |
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private UserGoodsStorageMapper userGoodsStorageMapper;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) {
|
| | |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = manageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | BigDecimal rate = manageService.getFanLiRate();
|
| | |
|
| | |
|
| | | for (UserGoodsStorage userGoodsStorage : listStorage) {
|
| | |
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate, null));
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null));
|
| | |
|
| | | dataObject.put("storageId", userGoodsStorage.getId());
|
| | | dataObject.put("goods", json);
|
| | |
| | | }
|
| | | return state;
|
| | | }
|
| | | |
| | | @Override
|
| | | public JSONObject shareGoods(Long uid, List<Long> listStorageID) |
| | | throws UserGoodsStorageException, UserShareGoodsRecordException {
|
| | | |
| | | List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
|
| | | if (listStorage == null || listStorage.size() == 0) {
|
| | | throw new UserGoodsStorageException(1, "选品库商品不存在");
|
| | | }
|
| | | |
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | for (UserGoodsStorage userGoodsStorage: listStorage) {
|
| | | 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);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | data.put("revenue", revenue);
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | return data;
|
| | | |
| | | }
|
| | | }
|