| | |
| | | TaoBaoWeiQuanOrder weiQuanOrder = taoBaoWeiQuanOrderService.listByorderItemId(order.getTradeId());
|
| | | if (weiQuanOrder != null)// 有维权
|
| | | {
|
| | | order.setWeiQuanState(weiQuanOrder.getState());
|
| | | order.setState(CommonOrder.STATE_WQ);
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService
|
| | | .selectByOrderItemId(weiQuanOrder.getOrderItemId());
|
| | | if (drawBack != null) {// 已经退款
|
| | | order.setWeiQuanState(weiQuanOrder.getState());
|
| | | |
| | | // 计算退款资金
|
| | | UserMoneyDetail detail = null;
|
| | | switch (order.getHongBaoType()) {
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | |
| | | TaoBaoGoodsBrief tb = null;
|
| | | String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
|
| | |
|
| | | |
| | | Pattern p = Pattern.compile(URL_REGEX);
|
| | | Matcher matcher = p.matcher(url);
|
| | | if (!matcher.find()) {// 不包含链接
|
| | |
| | | // 商品详情
|
| | | // 发现
|
| | | // 没有链接,标题过长也不处理
|
| | | if (text.length() > 50) {
|
| | | if (text.startsWith("【") && text.contains("】")) {
|
| | | int end = text.indexOf("】");
|
| | | if (end > 2)
|
| | | text = text.substring(1, end);
|
| | | }
|
| | |
|
| | | LogHelper.test("根据粘贴板推荐:"+text);
|
| | |
|
| | | if (text.length() > 80) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | |
| | | // 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
|
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | if (countRecord == 0) {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId);
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId, null);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | LogHelper.errorDetailInfo(e, "uid:" + uid, null);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {//
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid);
|
| | | if (isNewUser) {
|
| | | // 判定为老用户:
|
| | | // 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
|
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | if (countRecord == 0) {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | }
|
| | |
|
| | | data.put("native", true);
|
| | | } else {
|
| | | if (pidType == PidUser.TYPE_FANLI_ANDROID)
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
|
| | | isNative = false;
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "购买淘宝商品转链出错"));
|
| | |
| | | int totalHongBaoCount = 2000 + (int) (Math.random() * 8000);
|
| | | int leftHongBaoCount = 200 + (int) (Math.random() * 2000);
|
| | | tljBuyGoodsService.addTLJBuyGoods(
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount));
|
| | | new TLJBuyGoods(null, day, new Date(), goods, totalHongBaoCount, leftHongBaoCount),
|
| | | TaoBaoConstant.ownBuyApp);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | List<TLJBuyGoods> listGoods = tljBuyGoodsService.listByDay(day, 30);
|
| | | JSONArray array = new JSONArray();
|
| | | for (TLJBuyGoods sh : listGoods) {
|
| | | TaoBaoGoodsBriefExtra item = TaoBaoUtil.getTaoBaoGoodsBriefExtra(sh.getGoods(), TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null);
|
| | | TaoBaoGoodsBriefExtra item = TaoBaoUtil.getTaoBaoGoodsBriefExtra(sh.getGoods(),
|
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null);
|
| | | if (!StringUtil.isNullOrEmpty(item.getPictUrlWhite()))
|
| | | item.setPictUrl(item.getPictUrlWhite());
|
| | | item.setAuctionUrl(sh.getId());
|
| | |
| | | @Id
|
| | | private String id;
|
| | | @Field
|
| | | private String appKey;
|
| | | @Field
|
| | | private String day;
|
| | | @Field
|
| | | private Date updateTime;
|
| | |
| | | @Field
|
| | | private Integer leftHongBaoCount;// 剩余红包个数
|
| | |
|
| | | public String getAppKey() {
|
| | | return appKey;
|
| | | }
|
| | |
|
| | | public void setAppKey(String appKey) {
|
| | | this.appKey = appKey;
|
| | | }
|
| | |
|
| | | public Integer getTotalHongBaoCount() {
|
| | | return totalHongBaoCount;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId) throws ShareGoodsException {
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId, String pid)
|
| | | throws ShareGoodsException {
|
| | | if (uid == null || uid <= 0) {
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | | }
|
| | |
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | | if (pid == null)
|
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | | else
|
| | | app.setPid(pid);
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
|
| | | if (goods == null) {
|
| | | throw new ShareGoodsException(1, "");
|
| | |
| | |
|
| | | boolean canBuy = userTLJBuyHistoryService.canBuy(uid, auctionId);
|
| | | if (!canBuy) {
|
| | | throw new ShareGoodsException(3, "同一商品每日只能领取三次");
|
| | | throw new ShareGoodsException(3, "立减红包已抢光,请稍后再试");
|
| | | }
|
| | |
|
| | | long currentTime = System.currentTimeMillis();
|
| | |
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "自购立减", perface, 1, new Date(currentTime), sendEndTime,
|
| | | new Date(currentTime), sendEndTime, app);
|
| | | } catch (TaoKeApiException e) {
|
| | | LogHelper.errorDetailInfo(e, e.getMessage(), null);
|
| | | throw new ShareGoodsException(5, "生成推广链接失败");
|
| | | }
|
| | | if (taoLiJinDTO == null)
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyCanCreateTLJ(Long auctionId,TaoKeAppInfo info) {
|
| | | public boolean verifyCanCreateTLJ(Long auctionId, TaoKeAppInfo info) {
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "淘礼金验证", new BigDecimal("1.00"), 1, new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6),
|
| | | info);
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), info);
|
| | | } catch (TaoKeApiException e) {
|
| | | if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) {
|
| | | // 该商品不支持创建淘礼金红包
|
| | |
| | | shareHotGoods.getGoods().setCouponStartFee(goods.getCouponStartFee());
|
| | | shareHotGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount());
|
| | | shareHotGoods.getGoods().setBiz30day(goods.getBiz30day());
|
| | | shareHotGoods.getGoods().setTkRate(goods.getTkRate());
|
| | | shareHotGoodsDao.save(shareHotGoods);
|
| | | }
|
| | | }
|
| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Override
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods) {
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods, TaoKeAppInfo taoKeAppInfo) {
|
| | | if (goods == null || StringUtil.isNullOrEmpty(goods.getDay()) || goods.getGoods() == null)
|
| | | return;
|
| | | goods.setId(StringUtil.Md5(goods.getDay() + "#" + goods.getGoods().getAuctionId()));
|
| | | if (goods.getUpdateTime() == null)
|
| | | goods.setUpdateTime(new Date());
|
| | | if (taoKeAppInfo != null)
|
| | | goods.setAppKey(taoKeAppInfo.getAppKey());
|
| | | tljBuyGoodsDao.save(goods);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public void updateGoods(TaoBaoGoodsBrief goods) {
|
| | | if (goods == null)
|
| | | return;
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByAuctionId(goods.getAuctionId());
|
| | | // 查询自购立减是否小于1元
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | // if (money.compareTo(new BigDecimal(1)) < 0) {// 删除商品
|
| | | // if (list != null)
|
| | | // for (TLJBuyGoods tljGoods : list) {
|
| | | // tljBuyGoodsDao.delete(tljGoods.getId());
|
| | | // }
|
| | | // }
|
| | |
|
| | | if (list != null)
|
| | | for (TLJBuyGoods TLJBuyGoods : list) {
|
| | |
|
| | | if (goods.getCouponInfo() == null)
|
| | | goods.setCouponInfo("");
|
| | | if (goods.getCouponAmount() == null)
|
| | | goods.setCouponAmount(new BigDecimal(0));
|
| | |
|
| | | // 判断 券信息 价格信息 返利比例信息是否改变
|
| | | boolean change = false;
|
| | | if (goods.getZkPrice().compareTo(TLJBuyGoods.getGoods().getZkPrice()) != 0)
|
| | | change = true;
|
| | | if (goods.getCouponAmount().compareTo(TLJBuyGoods.getGoods().getCouponAmount()) != 0)
|
| | | change = true;
|
| | | if (!goods.getCouponInfo().equalsIgnoreCase(TLJBuyGoods.getGoods().getCouponInfo()))
|
| | | change = true;
|
| | | if (goods.getTkRate().compareTo(TLJBuyGoods.getGoods().getTkRate()) != 0)
|
| | | change = true;
|
| | |
|
| | | if (change) {
|
| | | // 清除列表缓存
|
| | | ehCacheCacheManager.getCache("commonContentCache").evict(
|
| | | "tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | }
|
| | |
|
| | | // 更新券信息 ,价格信息,销量信息
|
| | | TLJBuyGoods.getGoods().setZkPrice(goods.getZkPrice());
|
| | | TLJBuyGoods.getGoods().setCouponAmount(goods.getCouponAmount());
|
| | |
| | | TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee());
|
| | | TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount());
|
| | | TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day());
|
| | | TLJBuyGoods.getGoods().setTkRate(goods.getTkRate());
|
| | | tljBuyGoodsDao.save(TLJBuyGoods);
|
| | | }
|
| | | }
|
| | |
| | | public List<DaTaoKeDetailV2> listPreShareHotGoods(int page) {
|
| | | Map<Long, DaTaoKeDetailV2> map = new HashMap<>();
|
| | | List<DaTaoKeDetailV2> list = daTaoKeGoodsDetailV2Dao.listPreShareHotGoods((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, "updateTime");
|
| | | Constant.PAGE_SIZE, "monthSales");
|
| | | System.out.println(list);
|
| | | for (DaTaoKeDetailV2 v2 : list) {
|
| | | map.put(v2.getId(), v2);
|
| | |
| | | * @return
|
| | | * @throws ShareGoodsException
|
| | | */
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId) throws ShareGoodsException;
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId,String pid) throws ShareGoodsException;
|
| | |
|
| | | /**
|
| | | * 淘礼金 链接
|
| | |
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | |
|
| | | /**
|
| | | * 自购立减
|
| | |
| | | *
|
| | | * @param goods
|
| | | */
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods);
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods,TaoKeAppInfo taoKeAppInfo);
|
| | |
|
| | | /**
|
| | | * 根据日期查找
|
| | |
| | | dto.setRightsId(modelJson.optString("rights_id"));
|
| | | dto.setSendUrl(modelJson.optString("send_url"));
|
| | | return dto;
|
| | | }else{
|
| | | LogHelper.error(json);
|
| | | }
|
| | |
|
| | | // 接口返回异常
|
| | |
| | | case "FAIL_BIZ_ITEM_FORBIDDEN":
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_FORBIDDEN, "该商品不支持创建淘礼金红包");
|
| | | case "FAIL_BIZ_ACCOUNT_UN_PAID":
|
| | | case "2":
|
| | | case "PRE_FREEZE_ASSET_ACCOUNT_ERROR":
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足");
|
| | | default:
|
| | | return null;
|