| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException; |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkException; |
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudException; |
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudGoodsException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | |
| | | |
| | | @Service |
| | | public class UserCloudServiceImpl implements UserCloudService { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(UserCloudService.class); |
| | | |
| | | @Resource |
| | | private UserCloudMapper userCloudMapper; |
| | |
| | | |
| | | @Resource |
| | | private TaoBaoLinkManager taoBaoLinkManager; |
| | | |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Override |
| | | public UserCloud getValidByUid(Long uid) { |
| | |
| | | for (CommentInfo commentInfo : comments) { |
| | | String comment = null; |
| | | try { |
| | | comment = convertLinkManager.convertLinkFromText(commentInfo.getContent(), uid, true,false); |
| | | comment = convertLinkManager.convertLinkFromText(user.getSystem(), commentInfo.getContent(), uid, true, false); |
| | | hasToken = true; |
| | | } catch (ConvertLinkExceptionException e) { |
| | | if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { |
| | | } catch (ConvertLinkException e) { |
| | | if (e.getCode() != ConvertLinkException.CODE_NONE) { |
| | | throw new UserCloudException(1, e.getMsg()); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException { |
| | | public void sendCustomGoods(Long uid, String goodsId, Integer goodsType, Long sellerId) throws UserCloudException { |
| | | sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way) |
| | | private void sendCircleByGoods(Long uid, String goodsId, Integer goodsType, Long storeId, Long sellerId, int way) |
| | | throws UserCloudException { |
| | | long begainTime = java.lang.System.currentTimeMillis(); |
| | | |
| | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); |
| | | sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) { |
| | | sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); |
| | | sendVIPGoods(user, robotId, wxId, Long.parseLong(goodsId), relationId, listOpen, result.getId()); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId()); |
| | | sendSuNingGoods(user, robotId, wxId, Long.parseLong(goodsId), sellerId, relationId, listOpen, result.getId()); |
| | | } |
| | | // 更新发单记录 |
| | | if (storeId != null) { |
| | |
| | | * @param listOpen |
| | | * @throws UserCloudException |
| | | */ |
| | | private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, |
| | | private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, |
| | | List<UserCloudGroup> listOpen, String pid) throws UserCloudException { |
| | | TaoBaoLink taoBaoLink = null; |
| | | try { |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), goodsId, relationId, null); |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getSystem(), user.getId(), goodsId, relationId, null); |
| | | } catch (TaoBaoConvertLinkException e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | throw new UserCloudException(1, "该商品已下架"); |
| | |
| | | * @param listOpen |
| | | * @throws UserCloudException |
| | | */ |
| | | private void sendJDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, |
| | | private void sendJDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, |
| | | List<UserCloudGroup> listOpen, String pid) throws UserCloudException { |
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | if (jdGoods == null) |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", |
| | | user.getId() + ""); |
| | | String jumpLink = null; |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), |
| | | user.getId() + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | |
| | | boolean coupon = false; |
| | | if (couponInfo != null) { |
| | |
| | | * @param listOpen |
| | | * @throws UserCloudException |
| | | */ |
| | | private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, |
| | | private void sendPDDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId, |
| | | List<UserCloudGroup> listOpen, String pid) throws UserCloudException { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) |
| | | throw new UserCloudException(1, "该商品已下架"); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + ""); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), user.getId() + ""); |
| | | |
| | | boolean coupon = true; |
| | | if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { |
| | |
| | | |
| | | String couponLink = goods.getCouponInfo().getCouponUrl(); |
| | | String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sellerId + "", goodsId + ""), |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, user.getId() + ""); |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), user.getId() + ""); |
| | | |
| | | boolean coupon = false; |
| | | String couponAmount = ""; |