From cd637932a970e7935b17d41568fe89c92775bccc Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 06 十二月 2019 17:18:27 +0800 Subject: [PATCH] 双12活动添加,邀请码发布修改,爬单新规则添加 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java | 111 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 71 insertions(+), 40 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java index 5068d49..a59e137 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java @@ -26,6 +26,7 @@ import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; +import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord; import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum; @@ -41,11 +42,12 @@ import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; 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.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.user.UserAccountService; import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService; import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; +import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; import com.yeshi.fanli.util.AESUtil; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.ImageUtil; @@ -91,6 +93,9 @@ @Resource private UserGoodsStorageService userGoodsStorageService; + @Resource + private IntegralGetService integralGetService; + @Override public int insert(UserShareGoodsRecord record) { return userShareGoodsRecordMapper.insert(record); @@ -120,10 +125,10 @@ public long countQueryByUid(Long uid, String source) { return userShareGoodsRecordMapper.countQueryByUid(uid, source); } - + @Override public List<UserShareGoodsGroup> listByRecordId(Long shareId) { - return userShareGoodsGroupService.listByRecordId(shareId); + return userShareGoodsGroupService.listByRecordId(shareId); } @Override @@ -204,12 +209,12 @@ } } } - + String shareType = shareRecord.getShareType(); if (StringUtil.isNullOrEmpty(shareType)) { shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE); } - + BigDecimal totalMoney = shareRecord.getTotalMoney(); if (totalMoney == null) { shareRecord.setTotalMoney(new BigDecimal(0)); @@ -221,7 +226,7 @@ if (StringUtil.isNullOrEmpty(shareType)) { shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE); } - + BigDecimal totalMoney = shareRecord.getTotalMoney(); if (totalMoney == null) { shareRecord.setTotalMoney(new BigDecimal(0)); @@ -234,8 +239,7 @@ } @Override - public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType) - throws UserShareGoodsRecordException { + public void saveSingleShareRecord(Long uid, Long goodsId, Integer goodsType) throws UserShareGoodsRecordException { if (goodsId == null) { throw new UserShareGoodsRecordException(1, "鍒嗕韩鍟嗗搧涓嶈兘涓虹┖"); } @@ -419,9 +423,12 @@ /** * 鐢熸垚鍒嗕韩鍥� * - * @param uid 鐢ㄦ埛id - * @param shareId 鍒嗕韩璁板綍id - * @param source 鏉ユ簮 + * @param uid + * 鐢ㄦ埛id + * @param shareId + * 鍒嗕韩璁板綍id + * @param source + * 鏉ユ簮 * @param listGoods * @return * @throws UserShareGoodsRecordException @@ -451,7 +458,7 @@ } // 鑾峰彇鍒扮敤鎴风殑澶村儚 - UserInfo user = userInfoMapper.selectByPrimaryKey(uid); + UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid); if (user == null) { throw new UserShareGoodsRecordException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } @@ -654,7 +661,8 @@ } @Override - public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType) throws UserShareGoodsRecordException { + public ShareGoodsRecordDTO addRecordGoodsDetail(Long uid, Long auctionId, Integer goodsType, boolean isTaolijin) + throws UserShareGoodsRecordException { if (auctionId == null || uid == null || uid <= 0) { throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘"); } @@ -663,10 +671,11 @@ recordDTO.setUid(uid); recordDTO.setAuctionId(auctionId); recordDTO.setGoodsType(goodsType); + recordDTO.setTaolijin(isTaolijin); recordDTO.setSource(ShareSourceTypeEnum.goodsDetail); // 鍒嗕韩id - String key = StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#"+ goodsType); + String key = StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType); redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20); recordDTO.setRedisKey(key); @@ -674,8 +683,8 @@ } @Override - public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, List<Long> listStorageID) - throws UserShareGoodsRecordException { + public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, + List<Long> listStorageID) throws UserShareGoodsRecordException { if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) { throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘"); } @@ -689,11 +698,10 @@ userShareGoodsRecordMapper.insertSelective(record); List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>(); - for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) { + for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) { listCommonGoods.add(CommonGoodsFactory.create(goodsBrief)); } - - + Long id = record.getId(); // 鍒嗕韩閾炬帴 String shareUrl = getShareUrl(record); @@ -717,10 +725,10 @@ return recordDTO; } - + @Override - public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID) - throws UserShareGoodsRecordException { + public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID, + boolean needDrawPicture) throws UserShareGoodsRecordException { if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) { throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘"); } @@ -737,7 +745,6 @@ // 鍒嗕韩閾炬帴 String shareUrl = getShareUrlV2(record); // 鍒嗕韩浜岀淮鐮侀摼鎺� - FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods); ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO(); recordDTO.setUid(uid); @@ -745,7 +752,10 @@ recordDTO.setShareUrl(shareUrl); recordDTO.setListId(listStorageID); recordDTO.setListGoods(listGoods); - recordDTO.setSharePictureUrl(uploadResult.getUrl()); + if (needDrawPicture) { + FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods); + recordDTO.setSharePictureUrl(uploadResult.getUrl()); + } recordDTO.setSource(ShareSourceTypeEnum.storage); // 缂撳瓨鍒嗕韩鍟嗗搧淇℃伅 @@ -775,10 +785,10 @@ userShareGoodsRecordMapper.insertSelective(record); List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>(); - for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) { + for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) { listCommonGoods.add(CommonGoodsFactory.create(goodsBrief)); } - + Long id = record.getId(); // 鍒嗕韩閾炬帴 String shareUrl = getShareUrl(record); @@ -818,10 +828,10 @@ userShareGoodsRecordMapper.insertSelective(record); List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>(); - for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) { + for (TaoBaoGoodsBrief goodsBrief : listGoodsBrief) { listCommonGoods.add(CommonGoodsFactory.create(goodsBrief)); } - + Long id = record.getId(); // 鍒嗕韩閾炬帴 String shareUrl = getShareUrl(record); @@ -843,7 +853,7 @@ } @Override - public void takeEffectShareRecord(String shareKey) throws UserShareGoodsRecordException { + public void takeEffectShareRecord(AcceptData acceptData, String shareKey) throws UserShareGoodsRecordException { if (StringUtil.isNullOrEmpty(shareKey)) { throw new UserShareGoodsRecordException(1, "浼犻�掑弬鏁颁笉姝g‘"); } @@ -857,11 +867,14 @@ throw new UserShareGoodsRecordException(1, "鍒嗕韩淇℃伅涓嶅瓨鍦�"); } + Long uid = recordDTO.getUid(); + boolean taolijin = recordDTO.isTaolijin(); + boolean singleGoods = true; Long shareId = recordDTO.getShareId(); ShareSourceTypeEnum source = recordDTO.getSource(); if (ShareSourceTypeEnum.goodsDetail.equals(source)) { // 鍟嗗搧璇︽儏鍒嗕韩 - saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(),recordDTO.getGoodsType()); + saveSingleShareRecord(recordDTO.getUid(), recordDTO.getAuctionId(), recordDTO.getGoodsType()); } else if (ShareSourceTypeEnum.activity.equals(source)) { // 鍔ㄦ�佸垎浜� UserShareGoodsRecord shareRecord = new UserShareGoodsRecord(); @@ -870,11 +883,17 @@ shareRecord.setUpdateTime(new Date()); updateByPrimaryKeySelective(shareRecord); + List<CommonGoods> listGoods = recordDTO.getListGoods(); + if (listGoods != null && listGoods.size() > 1) + singleGoods = false; + // 淇濆瓨鍟嗗搧淇℃伅 multipleGoodsShareRecord(shareId, recordDTO.getListGoods()); } else if (ShareSourceTypeEnum.storage.equals(source)) { // 鍒嗕韩搴撳垎浜� + singleGoods = false; + UserShareGoodsRecord shareRecord = new UserShareGoodsRecord(); shareRecord.setId(shareId); shareRecord.setShareState(1); @@ -883,7 +902,7 @@ // 淇濆瓨鍟嗗搧淇℃伅 multipleGoodsShareRecord(shareId, recordDTO.getListGoods()); - + // 鏇存柊閫夊搧搴撳晢鍝佺姸鎬� 涓哄凡鍒嗕韩 List<Long> listId = recordDTO.getListId(); if (listId != null && listId.size() > 0) { @@ -895,9 +914,19 @@ } } } - + // 娓呯悊缂撳瓨 redisManager.removeCommonString(shareKey); + + if (singleGoods) { + if (taolijin) { + integralGetService.addShareTLJGoods(uid); + } else { + integralGetService.addShareSingleGoods(uid); + } + } else { + integralGetService.addShareMultipleGoods(uid); + } } /** @@ -920,8 +949,7 @@ } return url; } - - + /** * 鍒嗕韩閾炬帴 * @@ -932,8 +960,8 @@ Long uid = shareRecord.getUid(); Long shareId = shareRecord.getId(); - String url = String.format("http://%s/share_mushGoods_1.6.0.html?uid=%s&shareId=%s", - configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + ""); + String url = String.format("http://%s/share_mushGoods_1.6.0.html?uid=%s&shareId=%s", configService.getH5Host(), + AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + ""); String shortLink = HttpUtil.getShortLink(url); if (!StringUtil.isNullOrEmpty(shortLink)) { @@ -945,9 +973,12 @@ /** * 鐢熸垚鍒嗕韩鍥� * - * @param uid 鐢ㄦ埛id - * @param shareId 鍒嗕韩璁板綍id - * @param source 鏉ユ簮 + * @param uid + * 鐢ㄦ埛id + * @param shareId + * 鍒嗕韩璁板綍id + * @param source + * 鏉ユ簮 * @param listGoods * @return * @throws UserShareGoodsRecordException @@ -964,7 +995,7 @@ } // 鑾峰彇鍒扮敤鎴风殑澶村儚 - UserInfo user = userInfoMapper.selectByPrimaryKey(uid); + UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid); if (user == null) { throw new UserShareGoodsRecordException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } -- Gitblit v1.8.0