| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException,UserShareGoodsRecordException {
|
| | | |
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId)
|
| | | throws ActivityException, UserShareGoodsRecordException {
|
| | |
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | |
| | |
|
| | | if (activity == null)
|
| | | throw new ActivityException(2, "动态不存在");
|
| | | |
| | |
|
| | | if (activity.getType() != RecommendActivity.TYPE_SHARE_GOODS)
|
| | | throw new ActivityException(3, "不属于分享商品动态");
|
| | | |
| | |
|
| | | ActivityShareResult result = new ActivityShareResult();
|
| | | |
| | |
|
| | | String title = activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", "");
|
| | | if (title != null && title.trim().endsWith("/n"))
|
| | | title = title.trim().substring(0, title.trim().length() - 2);
|
| | | result.setTitle(title);
|
| | | List<FileUploadResult> imgList = new ArrayList<>();
|
| | | |
| | |
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | |
|
| | | if (activity.getGoodsList() != null) {
|
| | | |
| | |
|
| | | activity.getGoodsList().stream().parallel().forEach(goodsActivity -> {
|
| | | |
| | |
|
| | | try {
|
| | | TaoBaoGoodsBrief goodsBrief = |
| | | redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | TaoBaoGoodsBrief goodsBrief = redisManager
|
| | | .getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | |
| | | CommonGoods commonGoods= commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goodsActivity.getAuctionId()),
|
| | | CommonGoods.GOODS_TYPE_TB);
|
| | |
|
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
|
| | | Long.parseLong(goodsActivity.getAuctionId()), CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | |
|
| | | if (listGoodsBrief.size() < 1) {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | | |
| | | Map<String,Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | |
|
| | | Map<String, Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.activity, title,
|
| | | listGoodsBrief);
|
| | | imgList.add((FileUploadResult) map.get("loadResult"));
|
| | | result.setImgList(imgList);
|
| | | |
| | |
|
| | | return result;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException,UserShareGoodsRecordException {
|
| | | |
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException, UserShareGoodsRecordException {
|
| | |
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | |
| | |
|
| | | if (activity == null)
|
| | | throw new ActivityException(2, "动态不存在");
|
| | | |
| | |
|
| | | if (activity.getType() != RecommendActivity.TYPE_SHARE_GOODS)
|
| | | throw new ActivityException(3, "不属于分享商品动态");
|
| | | |
| | |
|
| | | ActivityShareResult result = new ActivityShareResult();
|
| | | |
| | |
|
| | | String title = activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", "");
|
| | | if (title != null && title.trim().endsWith("/n"))
|
| | | title = title.trim().substring(0, title.trim().length() - 2);
|
| | | |
| | |
|
| | | result.setTitle(title);
|
| | | |
| | |
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | |
|
| | | if (activity.getGoodsList() != null) {
|
| | | activity.getGoodsList().stream().parallel().forEach(goodsActivity -> {
|
| | | try {
|
| | | TaoBaoGoodsBrief goodsBrief = |
| | | redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | TaoBaoGoodsBrief goodsBrief = redisManager
|
| | | .getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | |
| | |
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | |
| | | CommonGoods commonGoods= commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goodsActivity.getAuctionId()),
|
| | | CommonGoods.GOODS_TYPE_TB);
|
| | |
|
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
|
| | | Long.parseLong(goodsActivity.getAuctionId()), CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | |
|
| | | if (listGoodsBrief.size() < 1) {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | String fontColor1 = "#000000";
|
| | | String fontColor2 = "#E5005C";
|
| | | JSONArray array = new JSONArray();
|
| | | |
| | |
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", fontColor1);
|
| | | contentJson1.put("content", "预估分享奖金:");
|
| | | |
| | |
|
| | | String revenue = "¥0";
|
| | | String totalGetMoney = activity.getTotalGetMoney();
|
| | | if (totalGetMoney != null && totalGetMoney.trim().length() > 0) {
|
| | |
| | | revenue = split[1];
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", fontColor2);
|
| | | contentJson2.put("content", revenue);
|
| | | |
| | |
|
| | | array.add(contentJson1);
|
| | | array.add(contentJson2);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | |
| | | Map<String,Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | | |
| | |
|
| | | Map<String, Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.activity, title,
|
| | | listGoodsBrief);
|
| | |
|
| | | data.put("title", title);
|
| | | data.put("revenue", array);
|
| | | data.put("shareId", map.get("shareId"));
|
| | |
| | | data.put("notifyDesc", configService.get("goods_share_multiple_notify"));
|
| | |
|
| | | return data;
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS);
|
| | | recommendActivityMapper.insertSelective(activity);
|
| | | |
| | |
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | | |
| | |
|
| | | BigDecimal taotaoMoney = new BigDecimal(0);
|
| | | for (long auctionId : goodsList) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | |
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
|
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | taotaoMoney = taotaoMoney.add(money);
|
| | | |
| | |
|
| | | // 转换简版商品信息
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(tb);
|
| | | listCommonGoods.add(commonGoods);
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | // 更新简版信息
|
| | | commonGoodsService.addBatchCommonGoods(listCommonGoods);
|
| | |
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | | updateActivity.setId(activity.getId());
|
| | | updateActivity.setTotalGetMoney("预计分享奖金:¥" + taotaoMoney.toString());
|
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString());
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity);
|
| | |
|
| | | return activity;
|
| | |
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | | updateActivity.setId(activity.getId());
|
| | | updateActivity.setTotalGetMoney("预计分享奖金:¥" + taotaoMoney.toString());
|
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString());
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity);
|
| | |
|
| | | return activity;
|
| | |
| | | update.setId(goods.getId());
|
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE);
|
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(update);
|
| | | taoBaoGoodsUpdateService.downTaoBaoGoods(Long.parseLong(goods.getAuctionId()));
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(goods.getAuctionId()));
|
| | | }
|
| | | }
|
| | | }
|