| | |
| | | package com.yeshi.fanli.service.impl.activity;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityImgMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityInviteInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityTaoBaoGoodsMapper;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityShareResult;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityImg;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.activity.ActivityUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | | public class ActivityServiceImpl implements ActivityService {
|
| | |
|
| | | @Resource
|
| | | private RecommendActivityMapper recommendActivityMapper;
|
| | |
|
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private ActivityUserMapper activityUserMapper;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private RecommendActivityTaoBaoGoodsMapper recommendActivityTaoBaoGoodsMapper;
|
| | |
|
| | | @Resource
|
| | | private RecommendActivityImgMapper recommendActivityImgMapper;
|
| | |
|
| | | @Resource
|
| | | private RecommendActivityInviteInfoMapper recommendActivityInviteInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private UserAccountService userAccountService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Override
|
| | | public List<RecommendActivity> getRecommendActivityList(int page, int pageSize) {
|
| | | return recommendActivityMapper.getRecommendActivityList((page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<RecommendActivity> queryRecommendActivityList(String title, int page, int pageSize) {
|
| | | return recommendActivityMapper.queryRecommendActivityList(title, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long getRecommendActivityCount() {
|
| | | return recommendActivityMapper.getRecommendActivityCount();
|
| | | }
|
| | |
|
| | | @Override
|
| | | 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()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | |
|
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
|
| | | Long.parseLong(goodsActivity.getAuctionId()), CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | |
|
| | | try {
|
| | | 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);
|
| | | imgList.add((FileUploadResult) map.get("loadResult"));
|
| | | result.setImgList(imgList);
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | @Override
|
| | | 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()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | |
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | |
|
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
|
| | | Long.parseLong(goodsActivity.getAuctionId()), CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | |
|
| | | try {
|
| | | 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) {
|
| | | String[] split = totalGetMoney.split(":");
|
| | | if (split != null) {
|
| | | 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);
|
| | |
|
| | | data.put("title", title);
|
| | | data.put("revenue", array);
|
| | | data.put("shareId", map.get("shareId"));
|
| | | data.put("shareImg", map.get("loadResult"));
|
| | | data.put("notifyDesc", configService.get("goods_share_multiple_notify"));
|
| | |
|
| | | return data;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ActivityShareResult shareInviteImg(Long uid, Long activityId) throws ActivityException {
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | if (activity == null)
|
| | | throw new ActivityException(2, "动态不存在");
|
| | | if (activity.getType() != RecommendActivity.TYPE_INVITE)
|
| | | throw new ActivityException(3, "不属于邀请动态");
|
| | | if (activity.getImageList() == null || activity.getImageList().size() < 1)
|
| | | throw new ActivityException(4, "无背景图");
|
| | |
|
| | | ActivityShareResult result = new ActivityShareResult();
|
| | | result.setTitle(activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", ""));
|
| | | List<FileUploadResult> imgList = new ArrayList<>();
|
| | |
|
| | | RecommendActivityInviteInfo inviteInfo = recommendActivityInviteInfoMapper.selectByActivityId(activityId);
|
| | |
|
| | | String img = spreadUserImgService.getUserSpreadImg(uid, activity.getImageList().get(0), inviteInfo.getPx(),
|
| | | inviteInfo.getPy(), inviteInfo.getSize());
|
| | | if (!StringUtil.isNullOrEmpty(img))
|
| | | imgList.add(new FileUploadResult(img, ""));
|
| | | result.setImgList(imgList);
|
| | | return result;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ActivityUser> getActivityUserList() {
|
| | | return activityUserMapper.selectList();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity addShareGoodsRecommendActivity(Long activityUid, String title, List<Long> goodsList,
|
| | | boolean top, int shareCount) throws ActivityException {
|
| | |
|
| | | if (goodsList == null || goodsList.size() == 0 || goodsList.size() > 9)
|
| | | throw new ActivityException(1, "商品数量错误:10>商品数量>0");
|
| | |
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setCreateTime(new Date());
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | 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;
|
| | | try {
|
| | | tb = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (tb == null)
|
| | | continue;
|
| | | RecommendActivityTaoBaoGoods goods = new RecommendActivityTaoBaoGoods();
|
| | | goods.setAuctionId(tb.getAuctionId() + "");
|
| | | goods.setCreateTime(new Date());
|
| | | goods.setDesc(ActivityUtil.getGoodsShowPrice(tb));
|
| | | goods.setOrderBy(0);
|
| | | goods.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tb.getPictUrl()));
|
| | | goods.setTaoBaoGoodsBrief(tb);
|
| | | goods.setRecommendActivity(activity);
|
| | | goods.setCouponAmount(tb.getCouponAmount());
|
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
|
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | taotaoMoney = taotaoMoney.add(money);
|
| | |
|
| | | // 转换简版商品信息
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(tb);
|
| | | listCommonGoods.add(commonGoods);
|
| | | }
|
| | |
|
| | | try {
|
| | | // 更新简版信息
|
| | | commonGoodsService.addBatchCommonGoods(listCommonGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | | updateActivity.setId(activity.getId());
|
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString());
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity);
|
| | |
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity addInviteImgRecommendActivity(Long activityUid, String title, String url, boolean top,
|
| | | int shareCount, int px, int py, int erCodeSize) throws ActivityException {
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setCreateTime(new Date());
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_INVITE);
|
| | | recommendActivityMapper.insertSelective(activity);
|
| | | RecommendActivityImg img = new RecommendActivityImg();
|
| | | img.setImg(url);
|
| | | img.setOrderBy(0);
|
| | | img.setRecommendActivity(activity);
|
| | | try {
|
| | | int[] hw = ImageUtil.getImgWidthAndHeight(url);
|
| | | img.setImgHeight(hw[1]);
|
| | | img.setImgWidth(hw[0]);
|
| | | } catch (Exception e) {
|
| | | throw new ActivityException(2, "图片尺寸获取失败");
|
| | | }
|
| | |
|
| | | // 插入二维码位置信息
|
| | | RecommendActivityInviteInfo recommendActivityInviteInfo = new RecommendActivityInviteInfo();
|
| | | recommendActivityInviteInfo.setPx(px);
|
| | | recommendActivityInviteInfo.setPy(py);
|
| | | recommendActivityInviteInfo.setRecommendActivity(activity);
|
| | | recommendActivityInviteInfo.setSize(erCodeSize);
|
| | | recommendActivityInviteInfoMapper.insertSelective(recommendActivityInviteInfo);
|
| | |
|
| | | recommendActivityImgMapper.insertSelective(img);
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity addTextAndImgRecommendActivity(Long activityUid, String title, List<String> imgList,
|
| | | boolean top, int shareCount) throws ActivityException {
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setCreateTime(new Date());
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_TEXTIMG);
|
| | | recommendActivityMapper.insertSelective(activity);
|
| | | for (String imgUrl : imgList) {
|
| | | RecommendActivityImg img = new RecommendActivityImg();
|
| | | img.setImg(imgUrl);
|
| | | img.setOrderBy(0);
|
| | | img.setRecommendActivity(activity);
|
| | | try {
|
| | | int[] hw = ImageUtil.getImgWidthAndHeight(imgUrl);
|
| | | img.setImgHeight(hw[1]);
|
| | | img.setImgWidth(hw[0]);
|
| | | } catch (Exception e) {
|
| | | throw new ActivityException(2, "图片尺寸获取失败");
|
| | | }
|
| | | recommendActivityImgMapper.insertSelective(img);
|
| | | }
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteRecommendActivity(long[] ids) {
|
| | | recommendActivityMapper.batchDeleteByPrimaryKey(ids);
|
| | | recommendActivityImgMapper.batchDeleteByActivityid(ids);
|
| | | recommendActivityTaoBaoGoodsMapper.batchDeleteByActivityid(ids);
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity getRecommendActivityById(Long id) {
|
| | | return recommendActivityMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity updateShareGoodsRecommendActivity(Long id, Long activityUid, String title,
|
| | | List<Long> goodsList, boolean top, int shareCount) throws ActivityException {
|
| | | if (goodsList == null || goodsList.size() == 0 || goodsList.size() > 9)
|
| | | throw new ActivityException(1, "商品数量错误:10>商品数量>0");
|
| | | // 删除之前的商品
|
| | | recommendActivityTaoBaoGoodsMapper.batchDeleteByActivityid(new long[] { id });
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setId(id);
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | activity.setTop(top);
|
| | |
|
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS);
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity);
|
| | |
|
| | | BigDecimal taotaoMoney = new BigDecimal(0);
|
| | | for (long auctionId : goodsList) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | |
|
| | | try {
|
| | | tb = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (tb == null)
|
| | | continue;
|
| | | RecommendActivityTaoBaoGoods goods = new RecommendActivityTaoBaoGoods();
|
| | | goods.setAuctionId(tb.getAuctionId() + "");
|
| | | goods.setCreateTime(new Date());
|
| | | goods.setDesc(ActivityUtil.getGoodsShowPrice(tb));
|
| | | goods.setOrderBy(0);
|
| | | goods.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tb.getPictUrl()));
|
| | | goods.setTaoBaoGoodsBrief(tb);
|
| | | goods.setRecommendActivity(activity);
|
| | | goods.setTitle(tb.getTitle());
|
| | | goods.setCouponAmount(tb.getCouponAmount());
|
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
|
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | taotaoMoney = taotaoMoney.add(money);
|
| | | }
|
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | | updateActivity.setId(activity.getId());
|
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString());
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity);
|
| | |
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity updateInviteImgRecommendActivity(Long id, Long activityUid, String title, String url,
|
| | | boolean top, int shareCount, int px, int py, int erCodeSize) throws ActivityException {
|
| | | recommendActivityImgMapper.batchDeleteByActivityid(new long[] { id });
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setId(id);
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_INVITE);
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity);
|
| | | RecommendActivityImg img = new RecommendActivityImg();
|
| | | img.setImg(url);
|
| | | img.setOrderBy(0);
|
| | | img.setRecommendActivity(activity);
|
| | | try {
|
| | | int[] hw = ImageUtil.getImgWidthAndHeight(url);
|
| | | img.setImgHeight(hw[1]);
|
| | | img.setImgWidth(hw[0]);
|
| | | } catch (Exception e) {
|
| | | throw new ActivityException(2, "图片尺寸获取失败");
|
| | | }
|
| | | recommendActivityImgMapper.insertSelective(img);
|
| | |
|
| | | RecommendActivityInviteInfo inviteInfo = recommendActivityInviteInfoMapper.selectByActivityId(activity.getId());
|
| | | if (inviteInfo != null)
|
| | | recommendActivityInviteInfoMapper.deleteByPrimaryKey(inviteInfo.getId());
|
| | |
|
| | | // 插入二维码位置信息
|
| | | RecommendActivityInviteInfo recommendActivityInviteInfo = new RecommendActivityInviteInfo();
|
| | | recommendActivityInviteInfo.setPx(px);
|
| | | recommendActivityInviteInfo.setPy(py);
|
| | | recommendActivityInviteInfo.setRecommendActivity(activity);
|
| | | recommendActivityInviteInfo.setSize(erCodeSize);
|
| | | recommendActivityInviteInfoMapper.insertSelective(recommendActivityInviteInfo);
|
| | |
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity updateTextAndImgRecommendActivity(Long id, Long activityUid, String title,
|
| | | List<String> imgList, boolean top, int shareCount) throws ActivityException {
|
| | | recommendActivityImgMapper.batchDeleteByActivityid(new long[] { id });
|
| | | RecommendActivity activity = new RecommendActivity();
|
| | | activity.setId(id);
|
| | | activity.setActivityUser(new ActivityUser(activityUid));
|
| | | activity.setGoodsList(null);
|
| | | activity.setOrderBy(0);
|
| | | activity.setShareCount(shareCount);
|
| | | activity.setTitle(title);
|
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_TEXTIMG);
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity);
|
| | | for (String imgUrl : imgList) {
|
| | | RecommendActivityImg img = new RecommendActivityImg();
|
| | | img.setImg(imgUrl);
|
| | | img.setOrderBy(0);
|
| | | img.setRecommendActivity(activity);
|
| | | try {
|
| | | int[] hw = ImageUtil.getImgWidthAndHeight(imgUrl);
|
| | | img.setImgHeight(hw[1]);
|
| | | img.setImgWidth(hw[0]);
|
| | | } catch (Exception e) {
|
| | | throw new ActivityException(2, "图片尺寸获取失败");
|
| | | }
|
| | | recommendActivityImgMapper.insertSelective(img);
|
| | | }
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addShareCount(Long activityId, int count) {
|
| | | recommendActivityMapper.addShareCount(activityId, count);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "activityCache", key = "'getRecommendActivityList-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | | public List<RecommendActivity> getRecommendActivityListCache(int page, int pageSize) {
|
| | | List<RecommendActivity> activityList = getRecommendActivityList(page, pageSize);
|
| | | if (activityList != null)
|
| | | for (RecommendActivity activity : activityList) {
|
| | | if (activity != null && activity.getGoodsList() != null)
|
| | | for (RecommendActivityTaoBaoGoods goods : activity.getGoodsList()) {
|
| | | goods.setQuanPrice(goods.getDesc().replace("券后价:¥", ""));
|
| | | }
|
| | | }
|
| | | return activityList;
|
| | | }
|
| | |
|
| | | @Cacheable(value = "activityCache", key = "'getRecommendActivityCount'")
|
| | | @Override
|
| | | public long getRecommendActivityCountCache() {
|
| | | return getRecommendActivityCount();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void upgradeShareGoodsRecommendActivity(Long id) throws ActivityException {
|
| | | // 获取商品
|
| | | List<RecommendActivityTaoBaoGoods> list = recommendActivityTaoBaoGoodsMapper.selectByActivityId(id);
|
| | | if (list != null)
|
| | | for (RecommendActivityTaoBaoGoods goods : list) {
|
| | | // 下架商品不必更新
|
| | | if (goods.getState() == RecommendActivityTaoBaoGoods.STATE_UNSHELVE)
|
| | | continue;
|
| | | try {
|
| | | TaoBaoGoodsBrief tbGoods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(goods.getAuctionId()));
|
| | | if (tbGoods != null) {
|
| | | RecommendActivityTaoBaoGoods update = new RecommendActivityTaoBaoGoods();
|
| | | update.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tbGoods.getPictUrl()));
|
| | | update.setId(goods.getId());
|
| | | update.setDesc(ActivityUtil.getGoodsShowPrice(tbGoods));
|
| | | update.setCouponAmount(tbGoods.getCouponAmount());
|
| | | // 当没有券的时候商品无效
|
| | | if (StringUtil.isNullOrEmpty(tbGoods.getCouponActivityId())
|
| | | || tbGoods.getCouponLeftCount() == null || tbGoods.getCouponLeftCount() == 0)
|
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE);
|
| | | else
|
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_NORMAL);
|
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(update);
|
| | | try {
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(tbGoods);
|
| | | } catch (TaobaoGoodsUpdateException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | RecommendActivityTaoBaoGoods update = new RecommendActivityTaoBaoGoods();
|
| | | update.setId(goods.getId());
|
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE);
|
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(update);
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(goods.getAuctionId()));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<RecommendActivity> getRecommendActivityList(int type, int page, int pageSize) {
|
| | | return recommendActivityMapper.getRecommendActivityListByType(type, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long getRecommendActivityCount(int type) {
|
| | | return recommendActivityMapper.getRecommendActivityCountByType(type);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivityInviteInfo getRecommendActivityInviteInfoByActivityId(Long activityId) {
|
| | | return recommendActivityInviteInfoMapper.selectByActivityId(activityId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void downTaoBaoGoods(Long auctionId) {
|
| | | recommendActivityTaoBaoGoodsMapper.updateStateByAuctionId(auctionId,
|
| | | RecommendActivityTaoBaoGoods.STATE_UNSHELVE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity getRecommendActivityDetail(Long activityId) {
|
| | |
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | if (activity != null && activity.getGoodsList() != null) {
|
| | | for (RecommendActivityTaoBaoGoods goods : activity.getGoodsList()) {
|
| | | goods.setQuanPrice(goods.getDesc().replace("券后价:¥", ""));
|
| | | goods.setPictUrl(goods.getPictUrl().replace("_.webp", ""));
|
| | | }
|
| | | }
|
| | |
|
| | | return activity;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insert(RecommendActivity record) {
|
| | | return recommendActivityMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(RecommendActivity record) {
|
| | | return recommendActivityMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public RecommendActivity selectByPrimaryKey(Long id) {
|
| | | return recommendActivityMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(RecommendActivity record) {
|
| | | return recommendActivityMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(RecommendActivity record) {
|
| | | return recommendActivityMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ActivityUser selectActivityUserByPrimaryKey(Long id) {
|
| | | return activityUserMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.activity; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.service.inter.user.*; |
| | | import org.jsoup.Jsoup; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.NumberUtil; |
| | | import org.yeshi.utils.entity.FileUploadResult; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper; |
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityImgMapper; |
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityInviteInfoMapper; |
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityMapper; |
| | | import com.yeshi.fanli.dao.mybatis.activity.RecommendActivityTaoBaoGoodsMapper; |
| | | import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityShareResult; |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser; |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity; |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityImg; |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo; |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.exception.ActivityException; |
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.activity.ActivityService; |
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; |
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService; |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.util.ImageUtil; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.activity.ActivityUtil; |
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Service |
| | | public class ActivityServiceImpl implements ActivityService { |
| | | |
| | | @Resource |
| | | private RecommendActivityMapper recommendActivityMapper; |
| | | |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | |
| | | @Resource |
| | | private ActivityUserMapper activityUserMapper; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private RecommendActivityTaoBaoGoodsMapper recommendActivityTaoBaoGoodsMapper; |
| | | |
| | | @Resource |
| | | private RecommendActivityImgMapper recommendActivityImgMapper; |
| | | |
| | | @Resource |
| | | private RecommendActivityInviteInfoMapper recommendActivityInviteInfoMapper; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | @Resource |
| | | private DynamicInfoService dynamicInfoService; |
| | | |
| | | @Resource |
| | | private ActivityUserService activityUserService; |
| | | |
| | | |
| | | @Override |
| | | public List<RecommendActivity> getRecommendActivityList(int page, int pageSize) { |
| | | return recommendActivityMapper.getRecommendActivityList((page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public List<RecommendActivity> queryRecommendActivityList(String title, int page, int pageSize) { |
| | | return recommendActivityMapper.queryRecommendActivityList(title, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long getRecommendActivityCount(String title) { |
| | | return recommendActivityMapper.getRecommendActivityCount(title); |
| | | } |
| | | |
| | | @Override |
| | | 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(goodsActivity.getAuctionId()); |
| | | listGoodsBrief.add(goodsBrief); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType( |
| | | goodsActivity.getAuctionId(), CommonGoods.GOODS_TYPE_TB); |
| | | if (commonGoods != null) { |
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); |
| | | goodsBrief.setState(1); |
| | | listGoodsBrief.add(goodsBrief); |
| | | } |
| | | |
| | | try { |
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--"); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (listGoodsBrief.size() < 1) { |
| | | throw new ActivityException(1, "商品下架"); |
| | | } |
| | | |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordActivity(uid, listGoodsBrief); |
| | | FileUploadResult loadResult = new FileUploadResult(); |
| | | loadResult.setUrl(shareRecord.getSharePictureUrl()); |
| | | |
| | | imgList.add(loadResult); |
| | | result.setImgList(imgList); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | 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(goodsActivity.getAuctionId()); |
| | | listGoodsBrief.add(goodsBrief); |
| | | |
| | | } catch (TaobaoGoodsDownException e) { |
| | | |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType( |
| | | goodsActivity.getAuctionId(), CommonGoods.GOODS_TYPE_TB); |
| | | if (commonGoods != null) { |
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); |
| | | goodsBrief.setState(1); |
| | | listGoodsBrief.add(goodsBrief); |
| | | } |
| | | |
| | | try { |
| | | 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 shareMoney = "0"; |
| | | String revenue = "¥0"; |
| | | String totalGetMoney = activity.getTotalGetMoney(); |
| | | if (totalGetMoney != null && totalGetMoney.trim().length() > 0) { |
| | | String[] split = totalGetMoney.split(":"); |
| | | if (split != null) { |
| | | revenue = split[1]; |
| | | } |
| | | |
| | | String[] splitMoney = totalGetMoney.split("¥"); |
| | | if (splitMoney != null) { |
| | | shareMoney = splitMoney[1]; |
| | | } |
| | | } |
| | | |
| | | JSONObject contentJson2 = new JSONObject(); |
| | | contentJson2.put("color", fontColor2); |
| | | contentJson2.put("content", revenue); |
| | | |
| | | array.add(contentJson1); |
| | | array.add(contentJson2); |
| | | |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordActivity(uid, listGoodsBrief); |
| | | FileUploadResult loadResult = new FileUploadResult(); |
| | | loadResult.setUrl(shareRecord.getSharePictureUrl()); |
| | | |
| | | SystemEnum system = userInfoService.getUserSystem(uid); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("title", title); |
| | | data.put("revenue", array); |
| | | data.put("fanMoney", shareMoney); |
| | | data.put("shareId", shareRecord.getRedisKey()); |
| | | data.put("shareImg", loadResult); |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareMultipleNotify.getKey(),system)); |
| | | |
| | | return data; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ActivityShareResult shareInviteImg(Long uid, Long activityId) throws ActivityException { |
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId); |
| | | if (activity == null) |
| | | throw new ActivityException(2, "动态不存在"); |
| | | if (activity.getType() != RecommendActivity.TYPE_INVITE) |
| | | throw new ActivityException(3, "不属于邀请动态"); |
| | | if (activity.getImageList() == null || activity.getImageList().size() < 1) |
| | | throw new ActivityException(4, "无背景图"); |
| | | |
| | | ActivityShareResult result = new ActivityShareResult(); |
| | | result.setTitle(activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", "")); |
| | | List<FileUploadResult> imgList = new ArrayList<>(); |
| | | |
| | | RecommendActivityInviteInfo inviteInfo = recommendActivityInviteInfoMapper.selectByActivityId(activityId); |
| | | |
| | | String img = spreadUserImgService.getUserSpreadImg(uid, activity.getImageList().get(0), inviteInfo.getPx(), |
| | | inviteInfo.getPy(), inviteInfo.getSize()); |
| | | if (!StringUtil.isNullOrEmpty(img)) |
| | | imgList.add(new FileUploadResult(img, "")); |
| | | result.setImgList(imgList); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ActivityUser> getActivityUserList() { |
| | | return activityUserMapper.selectList(); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity addShareGoodsRecommendActivity(Long activityUid, List<String> goodsList, |
| | | RecommendActivity activity) throws ActivityException, Exception { |
| | | |
| | | if (goodsList == null || goodsList.size() == 0 || goodsList.size() > 9) |
| | | throw new ActivityException(1, "商品数量错误:10>商品数量>0"); |
| | | |
| | | if (StringUtil.isNullOrEmpty(activity.getTitle())) { |
| | | throw new ActivityException(1, "标题不能为空"); |
| | | } |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setCreateTime(new Date()); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS); |
| | | recommendActivityMapper.insertSelective(activity); |
| | | |
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>(); |
| | | |
| | | BigDecimal taotaoMoney = new BigDecimal(0); |
| | | for (String auctionId : goodsList) { |
| | | TaoBaoGoodsBrief tb = null; |
| | | try { |
| | | tb = redisManager.getTaoBaoGoodsBrief(auctionId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (tb == null) |
| | | continue; |
| | | RecommendActivityTaoBaoGoods goods = new RecommendActivityTaoBaoGoods(); |
| | | goods.setAuctionId(tb.getAuctionId() + ""); |
| | | goods.setCreateTime(new Date()); |
| | | goods.setDesc(ActivityUtil.getGoodsShowPrice(tb)); |
| | | goods.setOrderBy(0); |
| | | goods.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tb.getPictUrl())); |
| | | goods.setTaoBaoGoodsBrief(tb); |
| | | goods.setRecommendActivity(activity); |
| | | goods.setCouponAmount(tb.getCouponAmount()); |
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods); |
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,SystemEnum.blks); |
| | | taotaoMoney = taotaoMoney.add(money); |
| | | |
| | | // 转换简版商品信息 |
| | | CommonGoods commonGoods = CommonGoodsFactory.create(tb); |
| | | listCommonGoods.add(commonGoods); |
| | | } |
| | | |
| | | try { |
| | | // 更新简版信息 |
| | | commonGoodsService.addBatchCommonGoods(listCommonGoods); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | RecommendActivity updateActivity = new RecommendActivity(); |
| | | updateActivity.setId(activity.getId()); |
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString()); |
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity); |
| | | |
| | | return activity; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity addInviteImgRecommendActivity(Long activityUid, RecommendActivity activity, String url, |
| | | int px, int py, int erCodeSize) throws ActivityException, Exception { |
| | | if (StringUtil.isNullOrEmpty(url)) |
| | | throw new ActivityException(1, "图片为空"); |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setCreateTime(new Date()); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | activity.setType(RecommendActivity.TYPE_INVITE); |
| | | recommendActivityMapper.insertSelective(activity); |
| | | RecommendActivityImg img = new RecommendActivityImg(); |
| | | img.setImg(url); |
| | | img.setOrderBy(0); |
| | | img.setRecommendActivity(activity); |
| | | try { |
| | | int[] hw = ImageUtil.getImgWidthAndHeight(url); |
| | | img.setImgHeight(hw[1]); |
| | | img.setImgWidth(hw[0]); |
| | | } catch (Exception e) { |
| | | throw new ActivityException(2, "图片尺寸获取失败"); |
| | | } |
| | | |
| | | // 插入二维码位置信息 |
| | | RecommendActivityInviteInfo recommendActivityInviteInfo = new RecommendActivityInviteInfo(); |
| | | recommendActivityInviteInfo.setPx(px); |
| | | recommendActivityInviteInfo.setPy(py); |
| | | recommendActivityInviteInfo.setRecommendActivity(activity); |
| | | recommendActivityInviteInfo.setSize(erCodeSize); |
| | | recommendActivityInviteInfoMapper.insertSelective(recommendActivityInviteInfo); |
| | | recommendActivityImgMapper.insertSelective(img); |
| | | return activity; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity addTextAndImgRecommendActivity(Long activityUid, List<String> imgList, |
| | | RecommendActivity activity) throws ActivityException, Exception { |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setCreateTime(new Date()); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | activity.setType(RecommendActivity.TYPE_TEXTIMG); |
| | | recommendActivityMapper.insertSelective(activity); |
| | | for (String imgUrl : imgList) { |
| | | RecommendActivityImg img = new RecommendActivityImg(); |
| | | img.setImg(imgUrl); |
| | | img.setOrderBy(0); |
| | | img.setRecommendActivity(activity); |
| | | try { |
| | | int[] hw = ImageUtil.getImgWidthAndHeight(imgUrl); |
| | | img.setImgHeight(hw[1]); |
| | | img.setImgWidth(hw[0]); |
| | | } catch (Exception e) { |
| | | throw new ActivityException(2, "图片尺寸获取失败"); |
| | | } |
| | | recommendActivityImgMapper.insertSelective(img); |
| | | } |
| | | return activity; |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void deleteRecommendActivity(long[] ids) { |
| | | recommendActivityMapper.batchDeleteByPrimaryKey(ids); |
| | | recommendActivityImgMapper.batchDeleteByActivityid(ids); |
| | | recommendActivityTaoBaoGoodsMapper.batchDeleteByActivityid(ids); |
| | | |
| | | try { |
| | | for (Long id : ids) { |
| | | dynamicInfoService.deleteActivity(id); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public RecommendActivity getRecommendActivityById(Long id) { |
| | | return recommendActivityMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity updateShareGoodsRecommendActivity(Long activityUid, |
| | | List<String> goodsList, RecommendActivity activity) throws ActivityException, Exception { |
| | | |
| | | if (goodsList == null || goodsList.size() == 0 || goodsList.size() > 9) |
| | | throw new ActivityException(1, "商品数量错误:10>商品数量>0"); |
| | | |
| | | // 删除之前的商品 |
| | | recommendActivityTaoBaoGoodsMapper.batchDeleteByActivityid(new long[]{activity.getId()}); |
| | | |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS); |
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity); |
| | | |
| | | List<RecommendActivityTaoBaoGoods> listgoods = new ArrayList<RecommendActivityTaoBaoGoods>(); |
| | | BigDecimal taotaoMoney = new BigDecimal(0); |
| | | for (String auctionId : goodsList) { |
| | | TaoBaoGoodsBrief tb = null; |
| | | |
| | | try { |
| | | tb = redisManager.getTaoBaoGoodsBrief(auctionId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (tb == null) |
| | | continue; |
| | | RecommendActivityTaoBaoGoods goods = new RecommendActivityTaoBaoGoods(); |
| | | goods.setAuctionId(tb.getAuctionId() + ""); |
| | | goods.setCreateTime(new Date()); |
| | | goods.setDesc(ActivityUtil.getGoodsShowPrice(tb)); |
| | | goods.setOrderBy(0); |
| | | goods.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tb.getPictUrl())); |
| | | goods.setTaoBaoGoodsBrief(tb); |
| | | goods.setRecommendActivity(activity); |
| | | goods.setTitle(tb.getTitle()); |
| | | goods.setCouponAmount(tb.getCouponAmount()); |
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods); |
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,SystemEnum.blks); |
| | | taotaoMoney = taotaoMoney.add(money); |
| | | |
| | | listgoods.add(goods); |
| | | } |
| | | |
| | | RecommendActivity updateActivity = new RecommendActivity(); |
| | | updateActivity.setId(activity.getId()); |
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString()); |
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity); |
| | | |
| | | // 1.5.4 动态信息更新 |
| | | RecommendActivity exist = recommendActivityMapper.selectByPrimaryKey(activity.getId()); |
| | | if (exist.getState() != null && exist.getState() == 1) { |
| | | try { |
| | | ActivityUser activityUser = activityUserService.selectByPrimaryKey(activityUid); |
| | | exist.setActivityUser(activityUser); |
| | | exist.setGoodsList(listgoods); |
| | | dynamicInfoService.insertActivityRecommend(exist); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return activity; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity updateInviteImgRecommendActivity(Long activityUid, RecommendActivity activity, String url, |
| | | int px, int py, int erCodeSize) throws ActivityException, Exception { |
| | | recommendActivityImgMapper.batchDeleteByActivityid(new long[]{activity.getId()}); |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | activity.setType(RecommendActivity.TYPE_INVITE); |
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity); |
| | | RecommendActivityImg img = new RecommendActivityImg(); |
| | | img.setImg(url); |
| | | img.setOrderBy(0); |
| | | img.setRecommendActivity(activity); |
| | | try { |
| | | int[] hw = ImageUtil.getImgWidthAndHeight(url); |
| | | img.setImgHeight(hw[1]); |
| | | img.setImgWidth(hw[0]); |
| | | } catch (Exception e) { |
| | | throw new ActivityException(2, "图片尺寸获取失败"); |
| | | } |
| | | recommendActivityImgMapper.insertSelective(img); |
| | | |
| | | RecommendActivityInviteInfo inviteInfo = recommendActivityInviteInfoMapper.selectByActivityId(activity.getId()); |
| | | if (inviteInfo != null) |
| | | recommendActivityInviteInfoMapper.deleteByPrimaryKey(inviteInfo.getId()); |
| | | |
| | | // 插入二维码位置信息 |
| | | RecommendActivityInviteInfo recommendActivityInviteInfo = new RecommendActivityInviteInfo(); |
| | | recommendActivityInviteInfo.setPx(px); |
| | | recommendActivityInviteInfo.setPy(py); |
| | | recommendActivityInviteInfo.setRecommendActivity(activity); |
| | | recommendActivityInviteInfo.setSize(erCodeSize); |
| | | recommendActivityInviteInfoMapper.insertSelective(recommendActivityInviteInfo); |
| | | |
| | | |
| | | RecommendActivity exist = recommendActivityMapper.selectByPrimaryKey(activity.getId()); |
| | | if (exist.getState() != null && exist.getState() == 1) { |
| | | try { |
| | | ActivityUser activityUser = activityUserService.selectByPrimaryKey(activityUid); |
| | | activity.setActivityUser(activityUser); |
| | | activity.setInviteInfo(recommendActivityInviteInfo); |
| | | List<String> imageList = new ArrayList<String>(); |
| | | imageList.add(url); |
| | | activity.setImageList(imageList); |
| | | dynamicInfoService.insertInviteActivity(activity); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return activity; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public RecommendActivity updateTextAndImgRecommendActivity(Long activityUid, List<String> imgList, |
| | | RecommendActivity activity) throws ActivityException, Exception { |
| | | recommendActivityImgMapper.batchDeleteByActivityid(new long[]{activity.getId()}); |
| | | |
| | | Integer shareCount = activity.getShareCount(); |
| | | if (shareCount == null) { |
| | | activity.setShareCount(0); |
| | | } |
| | | |
| | | Boolean top = activity.getTop(); |
| | | if (top == null) { |
| | | activity.setTop(false); |
| | | } |
| | | // 时间转换 |
| | | conversionTime(activity); |
| | | |
| | | activity.setActivityUser(new ActivityUser(activityUid)); |
| | | activity.setGoodsList(null); |
| | | activity.setOrderBy(0); |
| | | activity.setType(RecommendActivity.TYPE_TEXTIMG); |
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity); |
| | | for (String imgUrl : imgList) { |
| | | RecommendActivityImg img = new RecommendActivityImg(); |
| | | img.setImg(imgUrl); |
| | | img.setOrderBy(0); |
| | | img.setRecommendActivity(activity); |
| | | try { |
| | | int[] hw = ImageUtil.getImgWidthAndHeight(imgUrl); |
| | | img.setImgHeight(hw[1]); |
| | | img.setImgWidth(hw[0]); |
| | | } catch (Exception e) { |
| | | throw new ActivityException(2, "图片尺寸获取失败"); |
| | | } |
| | | recommendActivityImgMapper.insertSelective(img); |
| | | } |
| | | return activity; |
| | | } |
| | | |
| | | @Override |
| | | public void addShareCount(Long activityId, int count) { |
| | | recommendActivityMapper.addShareCount(activityId, count); |
| | | } |
| | | |
| | | @Cacheable(value = "activityCache", key = "'getRecommendActivityList-'+#page+'-'+#pageSize") |
| | | @Override |
| | | public List<RecommendActivity> getRecommendActivityListCache(int page, int pageSize) { |
| | | List<RecommendActivity> activityList = getRecommendActivityList(page, pageSize); |
| | | if (activityList != null) { |
| | | for (int i = 0; i < activityList.size(); i++) { |
| | | |
| | | RecommendActivity activity = activityList.get(i); |
| | | |
| | | // 筛选出不足9个的商品 |
| | | if (RecommendActivity.TYPE_SHARE_GOODS == activity.getType() |
| | | && (activity.getGoodsList() == null || activity.getGoodsList().size() < 9)) { |
| | | activityList.remove(activity); |
| | | i--; |
| | | continue; |
| | | } |
| | | |
| | | |
| | | if (activity != null && activity.getGoodsList() != null) { |
| | | for (RecommendActivityTaoBaoGoods goods : activity.getGoodsList()) { |
| | | goods.setQuanPrice(goods.getDesc().replace("券后价:¥", "")); |
| | | } |
| | | } |
| | | |
| | | // 过滤一遍 |
| | | if (!StringUtil.isNullOrEmpty(activity.getTitle())) { |
| | | activity.setTitle(Jsoup.parse(activity.getTitle()).text()); |
| | | if (activity.getShareCount() >= 10000) { |
| | | activity.setShareCountShow(NumberUtil.get1PointNumber(activity.getShareCount() / 10000.0) + "万"); |
| | | } else { |
| | | activity.setShareCountShow(activity.getShareCount() + ""); |
| | | } |
| | | } |
| | | |
| | | Date startTime = activity.getStartTime(); |
| | | if (startTime != null) { |
| | | activity.setCreateTime(startTime); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | return activityList; |
| | | } |
| | | |
| | | @Cacheable(value = "activityCache", key = "'getRecommendActivityCount'") |
| | | @Override |
| | | public long getRecommendActivityCountCache() { |
| | | return recommendActivityMapper.getRecommendActivityEffectiveCount(); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void upgradeShareGoodsRecommendActivity(Long id) throws ActivityException { |
| | | // 获取商品 |
| | | List<RecommendActivityTaoBaoGoods> list = recommendActivityTaoBaoGoodsMapper.selectByActivityId(id); |
| | | if (list != null) |
| | | for (RecommendActivityTaoBaoGoods goods : list) { |
| | | // 下架商品不必更新 |
| | | if (goods.getState() == RecommendActivityTaoBaoGoods.STATE_UNSHELVE) |
| | | continue; |
| | | try { |
| | | TaoBaoGoodsBrief tbGoods = TaoKeApiUtil.searchGoodsDetail((goods.getAuctionId())); |
| | | if (tbGoods != null) { |
| | | RecommendActivityTaoBaoGoods update = new RecommendActivityTaoBaoGoods(); |
| | | update.setPictUrl(TbImgUtil.getTBSize220ImgWebp(tbGoods.getPictUrl())); |
| | | update.setId(goods.getId()); |
| | | update.setDesc(ActivityUtil.getGoodsShowPrice(tbGoods)); |
| | | update.setCouponAmount(tbGoods.getCouponAmount()); |
| | | // 当没有券的时候商品无效 |
| | | if (StringUtil.isNullOrEmpty(tbGoods.getCouponActivityId()) |
| | | || tbGoods.getCouponLeftCount() == null || tbGoods.getCouponLeftCount() == 0) |
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE); |
| | | else |
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_NORMAL); |
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(update); |
| | | try { |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(tbGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (TaobaoGoodsDownException e) { |
| | | RecommendActivityTaoBaoGoods update = new RecommendActivityTaoBaoGoods(); |
| | | update.setId(goods.getId()); |
| | | update.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE); |
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(update); |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods((goods.getAuctionId())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<RecommendActivity> getRecommendActivityList(int type, int page, int pageSize) { |
| | | return recommendActivityMapper.getRecommendActivityListByType(type, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long getRecommendActivityCount(int type) { |
| | | return recommendActivityMapper.getRecommendActivityCountByType(type); |
| | | } |
| | | |
| | | @Override |
| | | public RecommendActivityInviteInfo getRecommendActivityInviteInfoByActivityId(Long activityId) { |
| | | return recommendActivityInviteInfoMapper.selectByActivityId(activityId); |
| | | } |
| | | |
| | | @Override |
| | | public void downTaoBaoGoods(String auctionId) { |
| | | recommendActivityTaoBaoGoodsMapper.updateStateByAuctionId(auctionId, |
| | | RecommendActivityTaoBaoGoods.STATE_UNSHELVE); |
| | | } |
| | | |
| | | @Override |
| | | public RecommendActivity getRecommendActivityDetail(Long activityId) { |
| | | |
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId); |
| | | if (activity != null && activity.getGoodsList() != null) { |
| | | for (RecommendActivityTaoBaoGoods goods : activity.getGoodsList()) { |
| | | goods.setQuanPrice(goods.getDesc().replace("券后价:¥", "")); |
| | | goods.setPictUrl(goods.getPictUrl().replace("_.webp", "")); |
| | | } |
| | | } |
| | | |
| | | return activity; |
| | | } |
| | | |
| | | @Override |
| | | public int insert(RecommendActivity record) { |
| | | return recommendActivityMapper.insert(record); |
| | | } |
| | | |
| | | @Override |
| | | public int insertSelective(RecommendActivity record) { |
| | | return recommendActivityMapper.insertSelective(record); |
| | | } |
| | | |
| | | @Override |
| | | public RecommendActivity selectByPrimaryKey(Long id) { |
| | | return recommendActivityMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public int updateByPrimaryKeySelective(RecommendActivity record) { |
| | | return recommendActivityMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | |
| | | @Override |
| | | public int updateByPrimaryKey(RecommendActivity record) { |
| | | return recommendActivityMapper.updateByPrimaryKey(record); |
| | | } |
| | | |
| | | @Override |
| | | public ActivityUser selectActivityUserByPrimaryKey(Long id) { |
| | | return activityUserMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void updateRecommendActivityGoods(TaoBaoGoodsBrief goods) { |
| | | List<RecommendActivityTaoBaoGoods> list = recommendActivityTaoBaoGoodsMapper |
| | | .selectByAuctionId(goods.getAuctionId()); |
| | | |
| | | BigDecimal d = TaoBaoUtil.getCouponPrice(goods); |
| | | |
| | | RecommendActivityTaoBaoGoods updateGoods = new RecommendActivityTaoBaoGoods(); |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && !"无".equalsIgnoreCase(goods.getCouponInfo())) { |
| | | updateGoods.setDesc("券后价:¥" + d); |
| | | updateGoods.setState(RecommendActivityTaoBaoGoods.STATE_NORMAL); |
| | | } else { |
| | | updateGoods.setState(RecommendActivityTaoBaoGoods.STATE_UNSHELVE); |
| | | } |
| | | |
| | | if (list != null) |
| | | for (RecommendActivityTaoBaoGoods tbGoods : list) { |
| | | updateGoods.setId(tbGoods.getId()); |
| | | recommendActivityTaoBaoGoodsMapper.updateByPrimaryKeySelective(updateGoods); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * web段时间转换 |
| | | * |
| | | * @param record |
| | | */ |
| | | public void conversionTime(RecommendActivity record) throws ActivityException, Exception { |
| | | // 是否时间控制 |
| | | if (!record.isTimeTask()) { |
| | | record.setStartTime(null); |
| | | record.setEndTime(null); |
| | | } else { |
| | | String startTime_str = record.getStartTime_str(); |
| | | String endTime_str = record.getEndTime_str(); |
| | | |
| | | if ((startTime_str == null || startTime_str.trim().length() == 0) |
| | | && (endTime_str == null || endTime_str.trim().length() == 0)) { |
| | | throw new ActivityException(1, "请输入控制时间"); |
| | | } else { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | if (startTime_str != null && startTime_str.trim().length() > 0) { |
| | | startTime_str = startTime_str.replaceAll("T", " "); |
| | | record.setStartTime(format.parse(startTime_str)); |
| | | } |
| | | |
| | | if (endTime_str != null && endTime_str.trim().length() > 0) { |
| | | endTime_str = endTime_str.replaceAll("T", " "); |
| | | record.setEndTime(format.parse(endTime_str)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getImgByActivityId(Long activityId) { |
| | | return recommendActivityImgMapper.getImgByActivityId(activityId); |
| | | } |
| | | |
| | | @Override |
| | | public List<RecommendActivity> getNeedPublish() { |
| | | return recommendActivityMapper.getNeedPublish(); |
| | | } |
| | | } |