| | |
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | // String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | // Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | // goodsId + "");
|
| | |
|
| | | // 券短连接
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | String couponUrl = null;
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid+ "");
|
| | | |
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setRule(configService.get("share_rule_link_jd"));
|
| | | shareInfo.setPictUrl(jdGoods.getPicUrl());
|
| | |
|
| | | String shareText = "";
|
| | | boolean hasCoupon = false;
|
| | | |
| | | // 分享模板
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
|
| | | if (couponInfo == null) { // 无券模板
|
| | | if (textTemplate != null)
|
| | |
| | | if (StringUtil.isNullOrEmpty(shareText))
|
| | | shareText = configService.get("goods_share_text_coupon_jd");
|
| | | }
|
| | | shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, shortLink, hasCoupon);
|
| | | shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, hasCoupon);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | // String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | // Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | // goodsId + "");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | String jumpLink = PinDuoDuoApiUtil.convert(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
|
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setRule(configService.get("share_rule_link_pdd"));
|
| | | shareInfo.setPictUrl(goods.getGoodsImageUrl());
|
| | |
|
| | |
| | | String token = PinDuoDuoApiUtil.createGenerate(goodsId);
|
| | |
|
| | | // 生成分享内容
|
| | | String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
|
| | | String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
|
| | | hasCoupon, token);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | |
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | |
|
| | | public class ShareGoodsRecordDTO {
|
| | |
|
| | |
| | | private ShareSourceTypeEnum source;
|
| | | private Long auctionId;
|
| | | private Integer goodsType;
|
| | | private List<TaoBaoGoodsBrief> listGoodsBrief;
|
| | | private List<CommonGoods> listGoods;
|
| | | private List<Long> listId;
|
| | |
|
| | | public Long getUid() {
|
| | |
| | |
|
| | | public void setShareId(Long shareId) {
|
| | | this.shareId = shareId;
|
| | | }
|
| | |
|
| | | public List<TaoBaoGoodsBrief> getListGoodsBrief() {
|
| | | return listGoodsBrief;
|
| | | }
|
| | |
|
| | | public void setListGoodsBrief(List<TaoBaoGoodsBrief> listGoodsBrief) {
|
| | | this.listGoodsBrief = listGoodsBrief;
|
| | | }
|
| | |
|
| | | public String getRedisKey() {
|
| | |
| | | this.goodsType = goodsType;
|
| | | }
|
| | |
|
| | | public List<CommonGoods> getListGoods() {
|
| | | return listGoods;
|
| | | }
|
| | |
|
| | | public void setListGoods(List<CommonGoods> listGoods) {
|
| | | this.listGoods = listGoods;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" /> |
| | | <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" /> |
| | | <result column="nick_name" property="nickName" jdbcType="VARCHAR" /> |
| | | <result column="tbName" property="tbName" jdbcType="VARCHAR" /> |
| | | <result column="uiet_taobao_nick_name" property="tbName" jdbcType="VARCHAR" />
|
| | | <result column="tbPic" property="tbPic" jdbcType="VARCHAR" /> |
| | | <result column="wxName" property="wxName" jdbcType="VARCHAR" /> |
| | | <result column="wxPic" property="wxPic" jdbcType="VARCHAR" /> |
| | |
| | | <result column="totalOrder" property="totalOrder" jdbcType="BIGINT" /> |
| | | <result column="monthOrder" property="monthOrder" jdbcType="BIGINT" /> |
| | | |
| | | <result column="taoBaoUid" property="taoBaoUid" jdbcType="VARCHAR" /> |
| | | <result column="uiet_special_id" property="tbSpecialId" jdbcType="VARCHAR" />
|
| | | <result column="uiet_relation_id" property="tbRelationId" jdbcType="VARCHAR" />
|
| | | <result column="uiet_taobao_uid" property="taoBaoUid" jdbcType="VARCHAR" />
|
| | | |
| | | <result column="wxUnionIdInvalid" property="wxUnionIdInvalid" jdbcType="VARCHAR" /> |
| | | <result column="taobaoUidInvalid" property="taobaoUidInvalid" jdbcType="VARCHAR" /> |
| | |
| | | // 实付款
|
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
|
| | |
|
| | | listOrderGoods.add(commonGoodsVO);
|
| | |
|
| | | Integer orderType = order.getOrderType();
|
| | | if (orderType == null) {
|
| | | String shopType = commonGoodsVO.getShopType();
|
| | |
| | | } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
|
| | | order.setOrderType(2);
|
| | | }
|
| | | |
| | | if (Constant.SOURCE_TYPE_JD == sourceType2) {
|
| | | order.setOrderType(3);
|
| | | } else if (Constant.SOURCE_TYPE_PDD == sourceType2) {
|
| | | order.setOrderType(4);
|
| | | }
|
| | | }
|
| | |
|
| | | listOrderGoods.add(commonGoodsVO);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | order.setReceiveTime("收货时间:" + format.format(settleTime));
|
| | | }
|
| | |
|
| | | Integer sourceType2 = order.getSourceType();
|
| | | if (sourceType2 == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | Integer orderType = order.getOrderType();
|
| | | if (orderType == null) {
|
| | | order.setOrderType(1);
|
| | | } |
| | | } else if (sourceType2 == Constant.SOURCE_TYPE_JD) {
|
| | | order.setOrderType(3);
|
| | | } else if (sourceType2 == Constant.SOURCE_TYPE_PDD) {
|
| | | order.setOrderType(4);
|
| | | }
|
| | |
|
| | | /* 订单状态 转换处理 */
|
| | | String orderStateContent = "";
|
| | | Map<String, String> orderStateMap = new HashMap<String, String>();
|
| | |
| | | @Override
|
| | | @Cacheable(value = "pddSpecialCache", key = "'getIndexPDDGoods-'+#page")
|
| | | public PDDGoodsResult getIndexPDDGoods(int page) {
|
| | | return PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page-1, Constant.PAGE_SIZE, 1);
|
| | | return PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page, Constant.PAGE_SIZE, 1);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.CommonGoodsUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | throw new UserGoodsStorageException(1, "选品库商品不存在");
|
| | | }
|
| | |
|
| | | |
| | | List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
|
| | | // 还原顺序 用于制图
|
| | | for (Long sid: listStorageID) {
|
| | |
| | | }
|
| | |
|
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | Integer goodsType = null;
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | for (UserGoodsStorage userGoodsStorage: listResult) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | |
| | | if (goodsType == null) {
|
| | | goodsType = commonGoods.getGoodsType();
|
| | | }
|
| | | |
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | |
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate);
|
| | | BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | |
| | | listCommonGoods.add(commonGoods);
|
| | | }
|
| | |
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listGoodsBrief, listStorageID);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods, listStorageID);
|
| | | FileUploadResult uploadResult = new FileUploadResult();
|
| | | uploadResult.setUrl(shareRecord.getSharePictureUrl());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("revenue", listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney);
|
| | | data.put("revenue", listCommonGoods.size() + "个商品预估分享奖金:¥"+totalMoney);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | data.put("shareImg", uploadResult);
|
| | |
|
| | |
| | | userInfoVO.setLastLoginTime(null);
|
| | | }
|
| | |
|
| | | /*
|
| | | * 显示用户微信 淘宝 老版本存在 String wxUnionId = userInfoVO.getWxUnionId(); if
|
| | | * (wxUnionId == null || wxUnionId.trim().length() == 0) {
|
| | | * userInfoVO.setWxName(null); }
|
| | | * |
| | | * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null
|
| | | * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
|
| | | */
|
| | | |
| | | //显示用户微信 淘宝 老版本存在 |
| | | String wxUnionId = userInfoVO.getWxUnionId(); |
| | | if (wxUnionId == null || wxUnionId.trim().length() == 0) {
|
| | | userInfoVO.setWxName(null); |
| | | }
|
| | | |
| | | // 是否绑定支付宝(购买 + 分享权限)
|
| | | String taoBaoUid = userInfoVO.getTaoBaoUid(); |
| | | String tbSpecialId = userInfoVO.getTbSpecialId();
|
| | | String tbRelationId = userInfoVO.getTbRelationId();
|
| | | if (StringUtil.isNullOrEmpty(taoBaoUid) || StringUtil.isNullOrEmpty(tbSpecialId) || StringUtil.isNullOrEmpty(tbRelationId)) { |
| | | userInfoVO.setTbName(null); |
| | | userInfoVO.setTaoBaoUid(null); |
| | | }
|
| | |
|
| | | Long uid = userInfoVO.getId();
|
| | |
|
| | | /* 绑定收款账号信息 */
|
| | | List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
|
| | | if (account != null && account.size() > 0) {
|
| | |
| | | * @param listGoods
|
| | | */
|
| | | @Transactional
|
| | | public void multipleGoodsShareRecord(Long shareId, List<TaoBaoGoodsBrief> listGoods)
|
| | | public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
|
| | | throws UserShareGoodsRecordException {
|
| | | // 分享记录
|
| | | Date date = new Date();
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
|
| | | commonGoods.setState(taoBaoGoodsBrief.getState());
|
| | | for (CommonGoods commonGoods : listGoods) {
|
| | | try {
|
| | | CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
|
| | |
|
| | |
| | | record.setCreateTime(new Date());
|
| | | userShareGoodsRecordMapper.insertSelective(record);
|
| | |
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | | for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
|
| | | listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
|
| | | }
|
| | | |
| | | |
| | | Long id = record.getId();
|
| | | // 分享链接
|
| | | String shareUrl = getShareUrl(record);
|
| | | // 分享二维码链接
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
|
| | |
|
| | | ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
|
| | | recordDTO.setUid(uid);
|
| | | recordDTO.setShareId(id);
|
| | | recordDTO.setShareUrl(shareUrl);
|
| | | recordDTO.setListId(listStorageID);
|
| | | recordDTO.setListGoodsBrief(listGoodsBrief);
|
| | | recordDTO.setListGoods(listCommonGoods);
|
| | | recordDTO.setSharePictureUrl(uploadResult.getUrl());
|
| | | recordDTO.setSource(ShareSourceTypeEnum.storage);
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, List<Long> listStorageID)
|
| | | public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID)
|
| | | throws UserShareGoodsRecordException {
|
| | | if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
|
| | | if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) {
|
| | | throw new UserShareGoodsRecordException(1, "传递参数不正确");
|
| | | }
|
| | | // 插入记录
|
| | |
| | | record.setUid(uid);
|
| | | record.setShareState(0); // 初始未分享
|
| | | record.setSource(ShareSourceTypeEnum.storage);
|
| | | record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
|
| | | record.setPicture(listGoods.get(0).getPicture()); // 取一个商品图片作为主图
|
| | | record.setCreateTime(new Date());
|
| | | userShareGoodsRecordMapper.insertSelective(record);
|
| | |
|
| | |
| | | // 分享链接
|
| | | String shareUrl = getShareUrlV2(record);
|
| | | // 分享二维码链接
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods);
|
| | |
|
| | | ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
|
| | | recordDTO.setUid(uid);
|
| | | recordDTO.setShareId(id);
|
| | | recordDTO.setShareUrl(shareUrl);
|
| | | recordDTO.setListId(listStorageID);
|
| | | recordDTO.setListGoodsBrief(listGoodsBrief);
|
| | | recordDTO.setListGoods(listGoods);
|
| | | recordDTO.setSharePictureUrl(uploadResult.getUrl());
|
| | | recordDTO.setSource(ShareSourceTypeEnum.storage);
|
| | |
|
| | |
| | | record.setCreateTime(new Date());
|
| | | userShareGoodsRecordMapper.insertSelective(record);
|
| | |
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | | for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
|
| | | listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
|
| | | }
|
| | | |
| | | Long id = record.getId();
|
| | | // 分享链接
|
| | | String shareUrl = getShareUrl(record);
|
| | | // 分享二维码链接
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
|
| | | FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
|
| | |
|
| | | ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
|
| | | recordDTO.setUid(uid);
|
| | | recordDTO.setShareId(id);
|
| | | recordDTO.setListGoodsBrief(listGoodsBrief);
|
| | | recordDTO.setListGoods(listCommonGoods);
|
| | | recordDTO.setShareUrl(shareUrl);
|
| | | recordDTO.setSharePictureUrl(uploadResult.getUrl());
|
| | | recordDTO.setSource(ShareSourceTypeEnum.activity);
|
| | |
| | | record.setCreateTime(new Date());
|
| | | userShareGoodsRecordMapper.insertSelective(record);
|
| | |
|
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | | for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
|
| | | listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
|
| | | }
|
| | | |
| | | Long id = record.getId();
|
| | | // 分享链接
|
| | | String shareUrl = getShareUrl(record);
|
| | |
| | | recordDTO.setUid(uid);
|
| | | recordDTO.setShareId(id);
|
| | | recordDTO.setShareUrl(shareUrl);
|
| | | recordDTO.setListGoodsBrief(listGoodsBrief);
|
| | | recordDTO.setListGoods(listCommonGoods);
|
| | | recordDTO.setSource(ShareSourceTypeEnum.activity);
|
| | |
|
| | | // 缓存分享商品信息
|
| | |
| | | updateByPrimaryKeySelective(shareRecord);
|
| | |
|
| | | // 保存商品信息
|
| | | multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
|
| | | multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
|
| | |
|
| | | } else if (ShareSourceTypeEnum.storage.equals(source)) {
|
| | | // 分享库分享
|
| | |
| | | updateByPrimaryKeySelective(shareRecord);
|
| | |
|
| | | // 保存商品信息
|
| | | multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
|
| | | multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
|
| | |
|
| | | // 更新选品库商品状态 为已分享
|
| | | List<Long> listId = recordDTO.getListId();
|
| | |
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<TaoBaoGoodsBrief> listGoods)
|
| | | public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<CommonGoods> listGoods)
|
| | | throws UserShareGoodsRecordException {
|
| | |
|
| | | InputStream erCodeInputStream = null;
|
| | |
| | | import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | |
|
| | |
| | |
|
| | | public List<UserShareGoodsGroup> listByRecordId(Long shareId);
|
| | |
|
| | | public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief,
|
| | | public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listCommonGoods,
|
| | | List<Long> listStorageID) throws UserShareGoodsRecordException;
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | return BigDecimalUtil.getWithNoZera(money);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | | * |
| | | * @param goodsBrief
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getAfterUseCouplePrice(CommonGoods goods) {
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo()) || "无".equals(goods.getCouponInfo())) {
|
| | | return goods.getPrice();
|
| | | } else {
|
| | | List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goods.getCouponInfo());
|
| | | BigDecimal startFee = list.get(0);
|
| | | BigDecimal couponAccount = list.get(1);
|
| | | if (startFee.compareTo(goods.getPrice()) <= 0
|
| | | && goods.getPrice().compareTo(couponAccount) > 0) {
|
| | | BigDecimal finalPrice = goods.getPrice().subtract(couponAccount);
|
| | | return finalPrice;
|
| | | } else {// 不能用券
|
| | | return goods.getPrice();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import org.yeshi.utils.entity.DateInfo;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | | * @return
|
| | | */
|
| | | public static InputStream drawGoodsSharePicture(InputStream qrcodeStream, InputStream portrait,
|
| | | List<TaoBaoGoodsBrief> goodsList) {
|
| | | List<CommonGoods> goodsList) {
|
| | |
|
| | | String fontPath = "/usr/share/fonts/PingFang_Medium.ttf";
|
| | | String os = System.getProperty("os.name");
|
| | |
| | | try {
|
| | | // 画第一张
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = goodsList.get(i);
|
| | | BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | CommonGoods goods = goodsList.get(i);
|
| | | BigDecimal couplePrice = CommonGoodsUtil.getAfterUseCouplePrice(goods);
|
| | | // 第一张图需要有价格信息
|
| | | if (i == 0) {
|
| | | int topX = 50;
|
| | |
| | | // 画大图 起始点坐标为(50,50)
|
| | | int widht = 650;
|
| | | int height = 650;
|
| | | InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPictUrl().replace("_.webp", "").replace("_220x220", ""));
|
| | | InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPicture().replace("_.webp", "").replace("_220x220", ""));
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = ImageUtil.zoomInImage(picImage, widht, height);
|
| | | g2d.drawImage(picImage, topX, topX, null);
|
| | |
| | |
|
| | | // 画大图
|
| | | InputStream goodsPicture = TaoBaoHttpUtil
|
| | | .getAsInputStream(goods.getPictUrl().replace("_.webp", ""));
|
| | | .getAsInputStream(goods.getPicture().replace("_.webp", ""));
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = ImageUtil.zoomInImage(picImage, 315, 315);
|
| | | g2d.drawImage(picImage, topX, topY, null);
|
| | |
| | |
|
| | | private static JDGoods parseJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | |
| | | // 佣金信息
|
| | | Object commission = json.get("commissionInfo");
|
| | | JSONObject commissionJson = JSONObject.fromObject(commission);
|
| | | BigDecimal commissionShare = new BigDecimal(commissionJson.optString("commissionShare"));
|
| | | if (commissionShare.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
|
| | | commissionInfo.setCommissionShare(commissionShare);
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | |
| | | goods.setComments(json.optLong("comments"));
|
| | | goods.setBrandCode(json.optString("brandCode"));
|
| | | goods.setBrandName(json.optString("brandName"));
|
| | |
| | | categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | |
|
| | | |
| | | // 佣金信息
|
| | | Object commission = json.get("commissionInfo");
|
| | | JSONObject commissionJson = JSONObject.fromObject(commission);
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
|
| | | commissionInfo.setCommissionShare(new BigDecimal(commissionJson.optString("commissionShare")));
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | |
|
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | |
| | | if (resultJson.optInt("code") == 0) {
|
| | | result = resultJson.optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | System.out.println(resultJson);
|
| | | JSONArray array = resultJson.optJSONArray("data");
|
| | | if (array != null)
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | |
| | |
|
| | | private static JDGoods parseSimpleJDGoods(JSONObject json) {
|
| | | JDGoods goods = new JDGoods();
|
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | |
|
| | | |
| | | BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
|
| | | if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
|
| | | commissionInfo.setCommission(MoneyBigDecimalUtil
|
| | | .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | |
|
| | | JDCategoryInfo categoryInfo = new JDCategoryInfo();
|
| | | categoryInfo.setCid1(json.optLong("cid1"));
|
| | |
| | |
|
| | | goods.setCategoryInfo(categoryInfo);
|
| | | goods.setComments(null);
|
| | | goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
|
| | | ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
|
| | |
|
| | | JDCommissionInfo commissionInfo = new JDCommissionInfo();
|
| | | commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
|
| | | commissionInfo.setCommission(MoneyBigDecimalUtil
|
| | | .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
|
| | |
|
| | | String isFreeShipping = json.optString("isFreeShipping");
|
| | | if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
|
| | | goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
|
| | | }
|
| | |
|
| | | |
| | | goods.setCommissionInfo(commissionInfo);
|
| | | goods.setCouponInfo(null);
|
| | | goods.setGoodCommentsShare(null);
|
| | | List<String> imageList = new ArrayList<>();
|
| | |
| | | JSONArray array = json.optJSONObject("data").optJSONArray("unionGoods");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | goodsList.add(parseGoods(array.optJSONArray(i).optJSONObject(0).toString()));
|
| | | JDGoods parseGoods = parseGoods(array.optJSONArray(i).optJSONObject(0).toString());
|
| | | if (parseGoods != null) {
|
| | | goodsList.add(parseGoods);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | JSONArray array = json.optJSONObject("data").optJSONArray("unionRecommendGoods");
|
| | | if (array != null) {
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | goodsList.add(parseGoods(array.optJSONArray(i).optJSONObject(0).toString()));
|
| | | JDGoods parseGoods = parseGoods(array.optJSONArray(i).optJSONObject(0).toString());
|
| | | if (parseGoods != null) {
|
| | | goodsList.add(parseGoods);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private static JDGoods parseGoods(String data) {
|
| | | JDGoods goods = new JDGoods();
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | |
| | | BigDecimal wlCommissionRatio = new BigDecimal(json.optString("wlCommissionRatio"));
|
| | | if (wlCommissionRatio.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commission = new JDCommissionInfo();
|
| | | commission.setCommission(new BigDecimal(json.optString("wlCommission")));
|
| | | commission.setCommissionShare(wlCommissionRatio);
|
| | | goods.setCommissionInfo(commission);
|
| | | } else {
|
| | | return null; // 过滤无返利商品
|
| | | }
|
| | | |
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("skuName"));
|
| | | |
| | |
|
| | | JDShopInfo shopInfo = new JDShopInfo();
|
| | | shopInfo.setShopId(json.optInt("shopId"));
|
| | |
| | |
|
| | | goods.setMaterialUrl("https://item.jd.com/"+ json.optLong("skuId") +".html");
|
| | | goods.setPicUrl("http://img14.360buyimg.com/n1/" + json.optString("materialUrl"));
|
| | | JDCommissionInfo commission = new JDCommissionInfo();
|
| | | commission.setCommission(new BigDecimal(json.optString("wlCommission")));
|
| | | commission.setCommissionShare(new BigDecimal(json.optString("wlCommissionRatio")));
|
| | | goods.setCommissionInfo(commission);
|
| | | |
| | | goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
|
| | |
|
| | | // 团购信息
|
| | |
| | | }
|
| | |
|
| | |
|
| | | String finalPrice = json.optString("finalPrice");
|
| | | if (!StringUtil.isNullOrEmpty(finalPrice)) {
|
| | | // 券信息
|
| | | BigDecimal finalPrice = new BigDecimal(json.optString("finalPrice"));
|
| | | if (finalPrice != null && json.optString("hasCoupon") != null && json.optInt("hasCoupon") == 1
|
| | | BigDecimal finalPriceDecimal = new BigDecimal(json.optString("finalPrice"));
|
| | | if (finalPriceDecimal != null && json.optString("hasCoupon") != null && json.optInt("hasCoupon") == 1
|
| | | && json.optInt("couponRemainCnt") > 0) {
|
| | | JDCouponInfo coupon = new JDCouponInfo();
|
| | | coupon.setDiscount(new BigDecimal(json.optString("couponDiscount")));
|
| | |
| | | coupon.setLink("https:" + json.optString("couponLink"));
|
| | | goods.setCouponInfo(coupon);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | return goods;
|
| | | }
|
| | |
| | | public static PDDGoodsResult getTopList(String pid, Integer page, Integer pageSize, Integer sortType) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("type", "pdd.ddk.top.goods.list.query");
|
| | | map.put("offset", (page == null? 0: page) +"");
|
| | | map.put("offset", (page == null? 0: (page-1) * Constant.PAGE_SIZE) +"");
|
| | | map.put("limit", (pageSize == null? Constant.PAGE_SIZE : pageSize) +"");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(pid))
|
| | |
| | |
|
| | | Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
| | | List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
|
| | | int totalCount = root.optInt("total");
|
| | | //int totalCount = root.optInt("total");
|
| | | int totalCount = 400; // 默认设置成400
|
| | | return new PDDGoodsResult(totalCount, goodsList);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | private String alipayAccountInvalid; // 支付宝账号
|
| | |
|
| | | |
| | | private String tbSpecialId;
|
| | | private String tbRelationId;
|
| | | |
| | |
|
| | | public String getRankId() {
|
| | | return rankId;
|
| | | }
|
| | |
| | | this.alipayAccountInvalid = alipayAccountInvalid;
|
| | | }
|
| | |
|
| | | public String getTbSpecialId() {
|
| | | return tbSpecialId;
|
| | | }
|
| | |
|
| | | public void setTbSpecialId(String tbSpecialId) {
|
| | | this.tbSpecialId = tbSpecialId;
|
| | | }
|
| | |
|
| | | public String getTbRelationId() {
|
| | | return tbRelationId;
|
| | | }
|
| | |
|
| | | public void setTbRelationId(String tbRelationId) {
|
| | | this.tbRelationId = tbRelationId;
|
| | | }
|
| | | |
| | | }
|