| | |
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/share")
|
| | | public class ShareControllerV2 {
|
| | |
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取分享记录中的商品 分享信息
|
| | | * 获取淘宝的分享链接
|
| | | *
|
| | | * @param acceptData
|
| | | * @param recordId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareGoods")
|
| | | public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
|
| | |
|
| | | if (recordId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | JSONArray array = new JSONArray();
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
|
| | | if (list == null || list.size() == 0) {
|
| | | data.put("title", "分享商品");
|
| | | data.put("count", 0);
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | if (commonGoods == null || commonGoods.getGoodsType() != Constant.SOURCE_TYPE_TAOBAO) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(commonGoods.getGoodsId());
|
| | | }
|
| | | |
| | | if (listGid.size() > 0) {
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0
|
| | | && commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | |
|
| | | int state = 1; // 默认停售
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | state = 0; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | | commonGoods.setState(state);
|
| | | }
|
| | |
|
| | | // 今日浏览记录处理
|
| | | Date date = new Date();
|
| | | Date browseTime = goodsGroup.getBrowseTime();
|
| | | if (!DateUtil.isSameDay(browseTime, date)) {
|
| | | goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0
|
| | | }
|
| | |
|
| | | JSONObject dataObject = new JSONObject();
|
| | | dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
|
| | | dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
|
| | | dataObject.put("totalOrder", goodsGroup.getTotalOrder());
|
| | | dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate,
|
| | | shareRate);
|
| | | detailVO.setId(commonGoods.getId());
|
| | | dataObject.put("goods", gson.toJson(detailVO));
|
| | | array.add(dataObject);
|
| | | }
|
| | |
|
| | | String title = "";
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId);
|
| | | if (userShareGoodsRecord != null) {
|
| | | title = userShareGoodsRecord.getTitle();
|
| | | }
|
| | |
|
| | | data.put("title", title);
|
| | | data.put("count", list.size());
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 创建分享
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param source
|
| | | * @param totalNum
|
| | | * @param goodsType
|
| | | * @param request
|
| | | * @param uid -用户ID
|
| | | * @param auctionId-商品ID
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "createShareInfo")
|
| | | public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum,
|
| | | Integer goodsType, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (goodsId == null || goodsId <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null) {
|
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | if (goodsId == null || goodsId <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 淘宝
|
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, request, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 京东
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | // 京东 |
| | | createJDShare(acceptData, uid, goodsId, source, out);
|
| | | return;
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | // 拼多多 |
| | | }
|
| | |
|
| | | // 拼多多
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | createPDDShare(acceptData, uid, goodsId, source, out);
|
| | | return;
|
| | | }
|
| | | |
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 创建淘宝分享信息
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | | * @param totalNum
|
| | | * @param source
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | String relationId = null;
|
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
|
| | | && extraInfo.getRelationValid() == true)
|
| | | relationId = extraInfo.getRelationId();
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId)) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | |
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | |
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | data.put("rule", configService.get("share_rule_link_tb"));
|
| | | data.put("rule", configService.get("share_single_goods_rule"));
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | |
|
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | |
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_coupon");
|
| | | |
| | |
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
|
| | | .replace("{优惠券面额}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
|
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
|
| | | }
|
| | | |
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | |
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | });
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:"+uid+"auctionId:"+goodsId, "");
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + " goodsId:" + goodsId, "");
|
| | | // 分享出错报警
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 淘礼金创建分享
|
| | | * |
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param totalNum
|
| | |
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, PrintWriter out) {
|
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
|
| | | |
| | |
|
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
|
| | | |
| | |
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value");
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
|
| | | |
| | |
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("spreadMoney", " ¥" + spreadMoney.toString());
|
| | | |
| | |
|
| | | String taoLiJinLink = null;
|
| | | Long tljId = null;
|
| | | try {
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | auctionId + "",AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
|
| | | auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | data.put("clickUrl", url);
|
| | | |
| | | |
| | |
|
| | | // 创建淘口令
|
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
|
| | |
| | | taoBaoLink.setTaoToken(quanToken);
|
| | | }
|
| | | } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) {
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoBaoLink.getClickUrl());
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
|
| | | taoBaoLink.getClickUrl());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | taoBaoLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | data.put("rule", configService.get("share_rule_link_tb"));
|
| | |
|
| | | data.put("rule",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | | String shareText = "";
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | |
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configTaoLiJinService.getValueByKey("goods_share_text");
|
| | | |
| | |
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
|
| | | .replace("{优惠券面额}",
|
| | |
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
|
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
|
| | | }
|
| | | |
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | |
| | | if (descText.startsWith("\\r\\n"))
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | |
| | |
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | |
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | });
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:"+uid+"auctionId:"+auctionId, "");
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, "");
|
| | | // 分享出错报警
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | |
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 京东创建分享
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | |
| | | * @param out
|
| | | */
|
| | | public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | |
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDApiUtil.getGoodsDetail(goodsId);
|
| | |
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDApiUtil.getGoodsDetail(goodsId);
|
| | | }
|
| | |
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "", Constant.SOURCE_TYPE_JD);
|
| | |
|
| | | // 券短连接
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("rule", configService.get("share_rule_link_jd"));
|
| | | data.put("pictUrl", jdGoods.getPicUrl());
|
| | |
|
| | | String shareText = "";
|
| | |
|
| | | String shopType = "京东价";
|
| | |
|
| | | // 分享模板
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text)) {
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | }
|
| | | |
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
|
| | | return;
|
| | | }
|
| | | |
| | | shareText = text.replace("{标题}", jdGoods.getSkuName()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_coupon");
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "", Constant.SOURCE_TYPE_JD);
|
| | | |
| | | // 券短连接
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | shareText = text.replace("{标题}", jdGoods.getSkuName())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "")
|
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "")
|
| | | .replace("{优惠券价}", JDUtil.getQuanPrice(jdGoods) + "");
|
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("rule", configService.get("share_rule_link_jd"));
|
| | | data.put("pictUrl", jdGoods.getPicUrl());
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", null);
|
| | | data.put("shareText", shareText);
|
| | |
|
| | | String shareText = "";
|
| | | |
| | | String shopType = "京东价";
|
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify_jd"));
|
| | |
|
| | | // 分享模板
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text)) {
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | }
|
| | | shareText = text.replace("{标题}", jdGoods.getSkuName()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_coupon");
|
| | | |
| | | shareText = text.replace("{标题}", jdGoods.getSkuName())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "")
|
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "")
|
| | | .replace("{优惠券价}", JDUtil.getQuanPrice(jdGoods) + "" );
|
| | | }
|
| | | |
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", null);
|
| | | data.put("shareText", shareText);
|
| | | |
| | | |
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify_jd"));
|
| | | // 添加分享记录
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney =JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
|
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_JD);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 异步操作
|
| | | final JDGoods goods = jdGoods;
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(Constant.SOURCE_TYPE_JD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | | // 异步操作
|
| | | final JDGoods goods = jdGoods;
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(Constant.SOURCE_TYPE_JD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | |
|
| | | List<String> imgList = goods.getImageList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | List<String> imgList = goods.getImageList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | });
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 拼多多分享
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | |
| | | * @param out
|
| | | */
|
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "",Constant.SOURCE_TYPE_PDD);
|
| | | |
| | | goodsId + "", Constant.SOURCE_TYPE_PDD);
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | |
| | | data.put("pictUrl", goods.getGoodsImageUrl());
|
| | |
|
| | | String shareText = "";
|
| | | |
| | |
|
| | | String shopType = "拼多多价";
|
| | |
|
| | | // 无券
|
| | | if (goods.getHasCoupon()== null || !goods.getHasCoupon()) {
|
| | | if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | |
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_coupon");
|
| | | |
| | |
|
| | | shareText = text.replace("{标题}", goods.getGoodsName())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
|
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
|
| | | .replace("{优惠券价}", PinDuoDuoUtil.getQuanPrice(goods) + "" );
|
| | | .replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
|
| | | .replace("{优惠券面额}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
|
| | | .replace("{优惠券价}", PinDuoDuoUtil.getQuanPrice(goods) + "");
|
| | | }
|
| | | |
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", null);
|
| | | .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", null);
|
| | | data.put("shareText", shareText);
|
| | | String descText = shareText.replace(goods.getGoodsName(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | |
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | |
| | |
|
| | | data.put("notifyDesc", configService.get("goods_share_notify_pdd"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney =PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
|
| | | BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
|
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_JD);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getGoodsImageUrl());
|
| | | |
| | |
|
| | | List<String> imgList = null;
|
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
|
| | | if (goodsGalleryUrls != null) {
|
| | |
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享记录中的商品 分享信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param recordId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareGoods")
|
| | | public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
|
| | |
|
| | | if (recordId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
|
| | | if (list == null || list.size() == 0) {
|
| | | data.put("title", "分享商品");
|
| | | data.put("count", 0);
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | Integer goodsType = commonGoods.getGoodsType();
|
| | | if (commonGoods == null || goodsType == null || goodsType != Constant.SOURCE_TYPE_TAOBAO) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(commonGoods.getGoodsId());
|
| | | }
|
| | |
|
| | | if (listGid.size() > 0) {
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 验证淘宝商品是否在售
|
| | | Integer goodsType = commonGoods.getGoodsType();
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null
|
| | | && goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | int state = 1; // 默认停售
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | state = 0; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | | commonGoods.setState(state);
|
| | | }
|
| | |
|
| | | // 今日浏览记录处理
|
| | | Date date = new Date();
|
| | | Date browseTime = goodsGroup.getBrowseTime();
|
| | | if (!DateUtil.isSameDay(browseTime, date)) {
|
| | | goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0
|
| | | }
|
| | |
|
| | | JSONObject dataObject = new JSONObject();
|
| | | dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
|
| | | dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
|
| | | dataObject.put("totalOrder", goodsGroup.getTotalOrder());
|
| | | dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate);
|
| | | detailVO.setId(commonGoods.getId());
|
| | | dataObject.put("goods", gson.toJson(detailVO));
|
| | | array.add(dataObject);
|
| | | }
|
| | |
|
| | | String title = "";
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId);
|
| | | if (userShareGoodsRecord != null) {
|
| | | title = userShareGoodsRecord.getTitle();
|
| | | }
|
| | |
|
| | | data.put("title", title);
|
| | | data.put("count", list.size());
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|