| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.fanli.facade.goods.entity.usergoods.UserGoodsStorage;
|
| | | import org.fanli.facade.goods.entity.usergoods.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import org.fanli.facade.goods.exception.taobao.CommonGoodsException;
|
| | | import org.fanli.facade.goods.exception.taobao.TaobaoGoodsDownException;
|
| | | import org.fanli.facade.goods.exception.taoke.TaoKeApiException;
|
| | | import org.fanli.facade.goods.exception.usergoods.UserGoodsStorageException;
|
| | | import org.fanli.facade.goods.exception.usergoods.UserShareGoodsRecordException;
|
| | | import org.fanli.facade.goods.service.taobao.CommonGoodsService;
|
| | | import org.fanli.facade.goods.service.usergoods.UserGoodsStorageService;
|
| | | import org.fanli.facade.goods.service.usergoods.UserShareGoodsRecordService;
|
| | | import org.fanli.facade.goods.utils.RedisGoodsManager;
|
| | | import org.fanli.facade.goods.utils.dataoke.TaoKeApiUtil;
|
| | | import org.fanli.facade.goods.utils.factory.CommonGoodsFactory;
|
| | | import org.fanli.facade.goods.utils.taobao.TaoBaoUtil;
|
| | | import org.fanli.facade.order.service.hongbao.HongBaoManageService;
|
| | | import org.fanli.facade.goods.utils.taobao.TaoKeGoodsApiUtil;
|
| | | import org.fanli.facade.system.exception.TaoKeApiException;
|
| | | import org.fanli.facade.system.service.common.ConfigService;
|
| | | import org.fanli.facade.system.service.hongbao.HongBaoManageService;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import com.alibaba.dubbo.config.annotation.Service;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.MoneyBigDecimalUtil;
|
| | |
|
| | | import com.alibaba.dubbo.config.annotation.Service;
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.base.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.base.entity.goods.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.goods.dao.usergoods.UserGoodsStorageMapper;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service(version = "1.0.0")
|
| | | public class UserGoodsStorageServiceImpl implements UserGoodsStorageService {
|
| | |
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService manageService;
|
| | |
|
| | | @Resource
|
| | | private UserGoodsStorageMapper userGoodsStorageMapper;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
| | |
|
| | | /**
|
| | | * 根据主键 、uid 批量删除
|
| | | * |
| | | * @param list
|
| | | * @return
|
| | | */
|
| | |
| | | userGoodsStorageMapper.updateByPrimaryKeySelective(goodsStorage);
|
| | | } else {
|
| | | goodsStorage = new UserGoodsStorage();
|
| | | goodsStorage.setUid(uid);;
|
| | | goodsStorage.setUid(uid);
|
| | | ;
|
| | | goodsStorage.setState(UserGoodsStorage.STATE_NORMAL);
|
| | | goodsStorage.setCommonGoods(commonGoods);
|
| | | goodsStorage.setCreateTime(new Date());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public JSONArray getMyStorage(int page, int pageSize, Long uid) throws UserGoodsStorageException {
|
| | |
|
| | |
| | | if (listStorage == null || listStorage.size() == 0) {
|
| | | return array;
|
| | | }
|
| | | |
| | |
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (UserGoodsStorage userGoodsStorage : listStorage) {
|
| | |
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | listTaoKeGoods = TaoKeGoodsApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | BigDecimal rate = manageService.getFanLiRate();
|
| | | BigDecimal rate = hongBaoManageService.getFanLiRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | |
| | | return array;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public boolean isExistStorage(Long uid, Long auctionId) {
|
| | | boolean state = false;
|
| | |
| | | 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>();
|
| | |
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal rate = hongBaoManageService.getFanLiRate();
|
| | |
|
| | | for (UserGoodsStorage userGoodsStorage: listResult) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | |
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, new BigDecimal(rateStr));
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate);
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | }
|
| | |
|
| | | String revenue = listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney;
|
| | |
|
| | | Map<String,Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, |
| | | null, listGoodsBrief);
|
| | | Map<String, Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, null,
|
| | | listGoodsBrief);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("revenue", revenue);
|