| | |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoAuthException;
|
| | | import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.log.LogManager;
|
| | | import com.yeshi.fanli.log.LogType;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | |
| | |
|
| | | @RequestMapping(value = "tb")
|
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
|
| | | LogHelper.test("淘宝授权回调:" + code + ":" + state);
|
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调:" + code + ":" + state);
|
| | | if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) {
|
| | | LogHelper.error("淘宝授权回调出错");
|
| | | try {
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html?code=1");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html?code=1");
|
| | | } catch (IOException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | source = json.optString("s");
|
| | | }
|
| | |
|
| | | LogHelper.userErrorInfo("淘宝授权回调state:" + state);
|
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调state:" + state);
|
| | |
|
| | | LogHelper.userErrorInfo("淘宝授权回调解密:" + stateStr);
|
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调解密:" + stateStr);
|
| | |
|
| | | int errCode = 0;
|
| | | if (StringUtil.isNullOrEmpty(stateStr)) {
|
| | |
| | | } catch (Exception e) {
|
| | | }
|
| | | final String name = nickName;
|
| | | LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken);
|
| | | LogManager.getLogger(LogType.taobaoAuth).info("uid:" + uid + "\n accessToken:" + accessToken);
|
| | |
|
| | | // 获取渠道ID与会员ID
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | |
| | | relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
|
| | | } catch (TaoBaoAuthException e) {
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "渠道备案失败:" + e.getMessage());
|
| | | if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
|
| | | userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名");
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | LogHelper.test(uid + "渠道备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, nickName, true);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | |
| | |
|
| | | final String relationId2 = relationId;
|
| | | // 异步申请会员ID
|
| | | final Long fuid=uid;
|
| | | final Long fuid = uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | |
| | | specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | } catch (TaoBaoAuthException e1) {
|
| | |
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(fuid + "会员备案失败:" + e1.getMessage());
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(specialId))
|
| | | LogHelper.test(fuid + "会员备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addSpecialId(fuid, specialId, taoBaoUid, name, true);
|
| | |
|
| | |
| | | } catch (TaoBaoAuthException e) {
|
| | | if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
|
| | | userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名");
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败:" + e.getMessage());
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(specialId))
|
| | | LogHelper.test(uid + "会员备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, nickName, true);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | | LogHelper.test(e.getMsg());
|
| | | errCode = 5;
|
| | | }
|
| | | final Long fuid=uid;
|
| | | final Long fuid = uid;
|
| | |
|
| | | final String specialId2 = specialId;
|
| | | // 异步申请渠道ID
|
| | |
| | | relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | } catch (TaoBaoAuthException e1) {
|
| | | } // 渠道ID
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | LogHelper.test(fuid + "渠道备案失败");
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(fuid + "渠道备案失败:" + e1.getMessage());
|
| | | }
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addRelationId(fuid, relationId, taoBaoUid, name, true);
|
| | |
|
| | |
| | | relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
|
| | | } catch (TaoBaoAuthException e) {
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "渠道备案失败");
|
| | | tbErrorCode = e.getCode();
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId)) {
|
| | | LogHelper.test(uid + "渠道备案失败");
|
| | | bindInfo = false;
|
| | | }
|
| | |
|
| | |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | } catch (TaoBaoAuthException e) {
|
| | | tbErrorCode = e.getCode();
|
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败");
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(specialId)) {
|
| | | LogHelper.test(uid + "会员备案失败");
|
| | | bindInfo = false;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
|
| | | else {
|
| | | String script = String.format(
|
| | | "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"恭喜你,淘宝绑定成功\");yestv.finishPage();}</script>",
|
| | |
| | | } else {// 失败
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
|
| | | else {
|
| | | String script = String.format(
|
| | | "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"抱歉,淘宝绑定失败\");yestv.finishPage();}</script>",
|
| | |
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void closeWebPage(PrintWriter out) {
|
| | |
| | | desc.append("维权订单数:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#");
|
| | | desc.append("维权订单佣金:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#");
|
| | | if (record.getExtraInfo().getOrderCount50More() > 0
|
| | | || record.getExtraInfo().getWeiQuanOrderCount() > 1
|
| | | || record.getExtraInfo().getWeiQuanOrderCount() > 0
|
| | | || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(10)) >= 0)
|
| | | warnLevel = 2;
|
| | | } else {
|
| | |
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsSetsPay;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopOrderException;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
|
| | |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.email.MailSenderUtil;
|
| | | import com.yeshi.fanli.util.factory.shop.BanLiShopOrderGoodsVOFactory;
|
| | | import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil;
|
| | | import com.yeshi.fanli.vo.shop.BanLiShopOrderVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | /**
|
| | | * 商品列表
|
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | else
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | long[] targetUids = new long[] { 3L, 4L };
|
| | | Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey());
|
| | | String[] sts = config.getValue().split(",");
|
| | | String account = sts[0];
|
| | | String pwd = sts[1];
|
| | | for (long adminId : targetUids) {
|
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
|
| | | String msg = "红包商城有新的订单,请前往审核";
|
| | | boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "红包商城新订单提醒", msg);
|
| | | }
|
| | | }
|
| | | });
|
| | | |
| | | }
|
| | |
|
| | | } catch (BanLiShopOrderException e) {
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | | * @return
|
| | | */
|
| | | private boolean analysisTaoToken(String text, PrintWriter out) {
|
| | | String token = StringUtil.picUpTaoToken(text);
|
| | | if (!StringUtil.isNullOrEmpty(token)) {
|
| | | Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | List<String> tokenList = TaoBaoUtil.getTokenListFromText(text);
|
| | | if (tokenList != null && tokenList.size() > 0) {
|
| | | String token = tokenList.get(0);
|
| | | Long auctionId = null;
|
| | | try {
|
| | | auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | } catch (TaoBaoTokenParseException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | if (auctionId != null) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | try {
|
| | |
| | | if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) {
|
| | | long startTime = java.lang.System.currentTimeMillis();
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa,"");
|
| | |
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | | // 筛选
|
| | |
| | | data.put("shareUrl", shareUrl);
|
| | | data.put("shareUsers", listShareUser);
|
| | | data.put("couponUsers", listCouponUser);
|
| | | data.put("detailWebUrl", "http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
|
| | | data.put("detailWebUrl", "http://apph5.banliapp.com/apppage/goods_img.html?id=" + id);
|
| | |
|
| | | String noRebateHelpLink = null;
|
| | |
|
| | |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | |
|
| | | data.put("rule",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | |
| | |
|
| | | // 帮助链接
|
| | | data.put("helpLink",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | |
|
| | | if (cid == 2) { // 2 推荐好货
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
|
| | |
| | |
|
| | | } catch (UserAccountException e) {
|
| | | try {
|
| | | LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | } catch (UserAccountException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | try {
|
| | | LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | maxDate = new Date(
|
| | | TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy-MM"), "yyyy-MM"));
|
| | |
|
| | | // 本月未到账,以app端我的页面上月收益为准
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 2, null);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 3, null);
|
| | |
|
| | | |
| | | BigDecimal monthUnRecievedMoney = selfMoney.setScale(2, BigDecimal.ROUND_DOWN)
|
| | | .add(shareMoney.setScale(2, BigDecimal.ROUND_DOWN)).add(inviteMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | // 本月未到账
|
| | | BigDecimal monthUnRecievedMoney = hongBaoV2Service.getUnRecievedMoneyWithPreGetTime(uid, minDate, maxDate);
|
| | | vo.setMonthUnRecievedMoney(monthUnRecievedMoney);
|
| | |
|
| | | // 全部未到账
|
| | |
| | | }
|
| | |
|
| | | private void addRecommendGoods(Long uid, String device, String imei, String idfa) {
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa,"");
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | | for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
|
| | | if (result.getTaoBaoGoodsBriefs().get(i).getCouponAmount() == null
|
New file |
| | |
| | | package com.yeshi.fanli.controller.client.v1.h5;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/apph5/v1/coupon")
|
| | | public class AppH5CouponController {
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @RequestMapping("getMianDanGoodsList")
|
| | | public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
|
| | | List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
|
| | | if (listQuery == null || listQuery.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (QualityFactory qualityFactory : listQuery) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(taoBaoGoodsBrief.getAuctionId());
|
| | | }
|
| | |
|
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | ConfigParamsDTO configParamsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory selectionGoods : listQuery) {
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
|
| | |
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
|
| | | boolean stateSale = false; // 默认停售
|
| | | Long goodsId = taoBaoGoodsBrief.getAuctionId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | stateSale = true; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!stateSale) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
|
| | | if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
|
| | | continue; // 券后价大于10
|
| | | }
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO);
|
| | | array.add(gson.toJson(detailVO));
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goodsList", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("getMianDanInfo")
|
| | | public void getMianDanInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.countUsableFreeCouponForBuy(uid);
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | | userJson.put("id", user.getId());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("couponCount", couponCount);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取返利奖励券信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | * @param uid
|
| | | * @param callback
|
| | | */
|
| | | @RequestMapping("getRewardCouponInfo")
|
| | | public void getRewardCouponInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | // 获取免单券数量
|
| | | long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
|
| | | UserInfoExtra extraInfo = userInfoExtraService.getUserInfoExtra(uid);
|
| | | long integralCount = extraInfo != null ? extraInfo.getGoldCoin() : 0L;
|
| | | JSONObject userJson = new JSONObject();
|
| | | userJson.put("nickName", user.getNickName());
|
| | | userJson.put("portrait", user.getPortrait());
|
| | | userJson.put("id", user.getId());
|
| | | userJson.put("vip", userVIPInfoService.isVIP(user.getId()));
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", userJson);
|
| | | data.put("couponCount", couponCount);
|
| | | data.put("integralCount", integralCount);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | } |
| | |
| | | // 猜你喜欢
|
| | | String idfa = acceptData.getIdfa();
|
| | | String imei = acceptData.getImei();
|
| | | result = guessLikeDeviceTB(idfa, imei, page);
|
| | | result = guessLikeDeviceTB(idfa, imei, acceptData.getUtdid(), page);
|
| | | } else {
|
| | | // 大淘客页码只能为10,50,100,200
|
| | | result = commonTemplateContentService.getContentList(type, cid, page, 10);
|
| | |
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (result != null)
|
| | | goodsList = result.getGoodsList();
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
| | | }
|
| | |
|
| | | root.put("list", array);
|
| | | root.put("count", result.getCount());
|
| | | root.put("count", result != null ? result.getCount() : 0);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | |
| | |
|
| | | for (JDGoods goods : goodsList) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO)));
|
| | | }
|
| | |
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> bannerList = null;
|
| | | if (Constant.IS_TEST) {
|
| | | bannerList = swiperPictureService.getByBannerCardAndVersion("index_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | bannerList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(),
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | }
|
| | |
|
| | | if (bannerList == null) {
|
| | |
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | |
| | |
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)));
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page")
|
| | | private CommonContentResult guessLikeDeviceTB(String idfa, String imei, Integer page) {
|
| | | TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa);
|
| | | private CommonContentResult guessLikeDeviceTB(String idfa, String imei, String utdid, Integer page) {
|
| | | TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa, utdid);
|
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
|
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | CommonContentResult result = new CommonContentResult();
|
New file |
| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserConvertLinkTemplate;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserConvertLinkTemplateService;
|
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 文案转链
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller("convertLinkControllerV2")
|
| | | @RequestMapping("api/v2/convertlink")
|
| | | public class ConvertLinkController {
|
| | |
|
| | | @Resource
|
| | | private UserConvertLinkTemplateService userConvertLinkTemplateService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ConvertLinkManager convertLinkManager;
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: getCommonTextList
|
| | | * @Description: 获取模板
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param callback
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "getCommonTextList")
|
| | | public void getCommonTextList(AcceptData acceptData, Long uid, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | List<UserConvertLinkTemplate> list = userConvertLinkTemplateService.listByUid(uid);
|
| | | if (list == null)
|
| | | list = new ArrayList<>();
|
| | |
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | data.put("list", gson.toJson(list));
|
| | | data.put("tip", configService.get(ConfigKeyEnum.convertDocTip.getKey()));
|
| | | data.put("helpLink", configService.get(ConfigKeyEnum.convertDocHelpLink.getKey()));
|
| | |
|
| | | String text = redisManager.getCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid);
|
| | | if (text != null) {
|
| | | data.put("lastText", text);
|
| | | redisManager.removeCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid);
|
| | | }
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: setConvertLinkDoc
|
| | | * @Description: 暂存文案
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param text
|
| | | * @param callback
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "setConvertLinkDoc")
|
| | | public void setConvertLinkDoc(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(text)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("文案为空")));
|
| | | return;
|
| | | }
|
| | | redisManager.cacheCommonString(RedisKeyEnum.convertLinkDocTemp.getKey() + uid, text);
|
| | | |
| | | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: addCommonText
|
| | | * @Description: 添加模板
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param template
|
| | | * @param callback
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | |
|
| | | @RequestMapping(value = "addCommonText")
|
| | | public void addCommonText(AcceptData acceptData, Long uid, String template, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("文案为空")));
|
| | | return;
|
| | | }
|
| | | UserConvertLinkTemplate bean = new UserConvertLinkTemplate();
|
| | | bean.setUid(uid);
|
| | | bean.setTemplate(template);
|
| | |
|
| | | try {
|
| | | userConvertLinkTemplateService.addConvertLinkTemplate(bean);
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: deleteCommonText
|
| | | * @Description: 删除模板
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param callback
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "deleteCommonText")
|
| | | public void deleteCommonText(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("模板ID为空")));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | userConvertLinkTemplateService.deleteConvertLinkTemplate(id, uid);
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "updateCommonText")
|
| | | public void updateCommonText(AcceptData acceptData, Long uid, String id, String template, String callback,
|
| | | PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("模板ID为空")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("模板内容为空")));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserConvertLinkTemplate bean = new UserConvertLinkTemplate();
|
| | | bean.setUid(uid);
|
| | | bean.setTemplate(template);
|
| | | bean.setId(id);
|
| | |
|
| | | try {
|
| | | userConvertLinkTemplateService.updateTemplate(bean);
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: convert
|
| | | * @Description: 文案转链
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param text
|
| | | * @param callback
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "convert")
|
| | | public void convert(AcceptData acceptData, Long uid, String text, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(text)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("文案为空")));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | String key = RedisKeyEnum.convertLinkDocResultTemp.getKey() + uid + "-"
|
| | | + StringUtil.Md5(UUID.randomUUID().toString());
|
| | | String result = convertLinkManager.convertLinkFromText(text, uid, true);
|
| | | redisManager.cacheCommonString(key, result, 60);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("id", key);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMessage())));
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getConvertResult")
|
| | | public void getConvertResult(AcceptData acceptData, Long uid, String id, String callback, PrintWriter out) {
|
| | | if (uid == null || uid == 0L) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("用户未登录")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("文案ID为空")));
|
| | | return;
|
| | | }
|
| | |
|
| | | String key =id;
|
| | | String result = redisManager.getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(result)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("获取转链结果出错")));
|
| | | } else {
|
| | | redisManager.removeCommonString(key);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("data", result);
|
| | | data.put("tip", "1.转好的链接/口令有效期,请在有效期内推广分享;\r\n" + "2.已经转好的链接/口令请不要修改,以免无法追踪到订单;\r\n"
|
| | | + "3.请确保转换链接合法合规,一切违法的链/口令产生的法律后果自行承担与本App无关。");
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | |
|
| | | /**
|
| | | * 淘宝商品详情
|
| | |
| | | "¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods, hongBaoManageService.getVIPShareRate()));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo().setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | if (TaoBaoUtil.isYUShou(goods)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) {
|
| | |
| | | }
|
| | |
|
| | | extraVO.setTbPidInfo(clientTBPid);
|
| | | extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
|
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + id);
|
| | |
|
| | | // 分享赚人提示
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | |
| | | } else
|
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | rewardCoupon.setParams(params1.toString());
|
| | |
|
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | |
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | | }
|
| | | extraVO.setFanliValid(fanliValid);
|
| | |
| | | .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate()));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo().setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | // 附加信息
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | |
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | }
|
| | | rewardCoupon.setParams(params1.toString());
|
| | | |
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | | |
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | |
| | | "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate()));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo().setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | // 附加信息
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | |
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | rewardCoupon.setParams(params1.toString());
|
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | |
| | | }
|
| | |
|
| | | // 图文详情
|
| | | extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id=" + id);
|
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
|
| | |
|
| | | String salesTip = pddGoods.getSalesTip();
|
| | | if (!StringUtil.isNullOrEmpty(salesTip)) {
|
| | |
| | | if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) {
|
| | | long startTime = java.lang.System.currentTimeMillis();
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa,"");
|
| | |
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | | // 筛选
|
| | |
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.UserInviteUtil;
|
| | | import com.yeshi.fanli.util.email.MailSenderUtil;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackGiveVO;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackWinInviteVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | /**
|
| | | * 统计
|
| | | *
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "getGiveList", method = RequestMethod.POST)
|
| | | public void getGiveList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (page == null || page <= 0) |
| | |
|
| | | if (page == null || page <= 0)
|
| | | page = 1;
|
| | | |
| | |
|
| | | try {
|
| | | List<RedPackGiveVO> list = redPackGiveRecordService.getGiveList(page, Constant.PAGE_SIZE, uid);
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy.MM.dd HH:mm").create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", gson.toJson(list));
|
| | | data.put("count", redPackGiveRecordService.countGiveList(uid));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 转换红包为真实金钱
|
| | | *
|
| | |
| | | try {
|
| | | redPackExchangeService.exchangeCash(uid, amount);
|
| | | out.print(JsonUtil.loadTrueResult("提现申请成功"));
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("timeStamp", java.lang.System.currentTimeMillis());
|
| | | json.put("adminId", 4L);
|
| | | String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY);
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("%s?from=emailh5&sign=%s",
|
| | | Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | long[] targetUids = new long[] { 3L, 4L };
|
| | | Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey());
|
| | | String[] sts = config.getValue().split(",");
|
| | | String account = sts[0];
|
| | | String pwd = sts[1];
|
| | | for (long adminId : targetUids) {
|
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
|
| | | String msg = "有用户采用红包兑换现金";
|
| | | boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "红包兑换现金提醒", msg);
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | } catch (RedPackExchangeException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | |
| | | data.put("redPackLock", redPackForbidService.verifyForbid(uid));
|
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if ( !StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | data.put("inviteCode", inviteCode);
|
| | | } else {
|
| | | data.put("inviteCode", "");
|
| | | }
|
| | | |
| | |
|
| | | // 赠送免单券
|
| | | long freeCouponCount = userSystemCouponService.countGiveFreeCoupon(uid);
|
| | | // 奖励券
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 该用户邀请奖金榜
|
| | | *
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getInviteReward")
|
| | | public void getInviteReward(AcceptData acceptData,Integer page, Long uid, String callback, PrintWriter out) {
|
| | | public void getInviteReward(AcceptData acceptData, Integer page, Long uid, String callback, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (page == null || page < 1)
|
| | | page = 1;
|
| | | |
| | |
|
| | | List<RedPackWinProgressVO> listVO = new ArrayList<RedPackWinProgressVO>();
|
| | | List<RedPackWinInvite> list = redPackWinInviteService.getWinTopListByBossId(page, Constant.PAGE_SIZE, uid);
|
| | | if (list != null) {
|
| | | for (RedPackWinInvite win: list) {
|
| | | for (RedPackWinInvite win : list) {
|
| | | ThreeSale threeSale = threeSaleSerivce.getNearRelationByBossIdAndWorkerId(uid, win.getTeamUid());
|
| | | if (threeSale == null)
|
| | | continue;
|
| | | |
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(win.getTeamUid());
|
| | | if (userInfo == null)
|
| | | continue;
|
| | | |
| | |
|
| | | RedPackWinProgressVO progressVO = new RedPackWinProgressVO();
|
| | | progressVO.setUid(userInfo.getId());
|
| | | progressVO.setName(userInfo.getNickName());
|
| | |
| | | listVO.add(progressVO);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", listVO);
|
| | | data.put("count", redPackWinInviteService.countWinTopListByBossId(uid));
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 该用户邀请进度
|
| | | *
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "传递参数缺失"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", redPackWinInviteService.getInviteProgressByWorkerId(uid, tid));
|
| | | data.put("num", redPackWinInviteService.countTeamNumByTid(uid, tid));
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.user.TokenRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandInfoService;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SuperHotSearchService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.HistorySearchService;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.manger.ClipboardAnalysisManager;
|
| | | import com.yeshi.fanli.service.manger.IClipboardAnalysisResult;
|
| | | import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.brand.BrandInfoVO;
|
| | | import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
|
| | | import com.yeshi.fanli.vo.common.JumpDetailContentVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.msg.TokenVO;
|
| | | import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | @Resource
|
| | | private JDGoodsLinkParseManager jdGoodsLinkParseManager;
|
| | |
|
| | | @Resource
|
| | | private ClipboardAnalysisManager clipboardAnalysisManager;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | /**
|
| | | * 粘贴板信息推荐
|
| | | *
|
| | |
| | | text = text.trim();
|
| | | String originalText = text;
|
| | |
|
| | | try {
|
| | | TokenVO tokenVO = tokenRecordService.discernToken(text, uid, acceptData);
|
| | | out.print(JsonUtil.loadTrueResult(tokenVO));
|
| | | return;
|
| | | } catch (TokenRecordException e) {
|
| | | if (e.getCode() == 1001) { // 需要用户登录
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | 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\\&%_\\./-~-]*)?";
|
| | | clipboardAnalysisManager.parse(acceptData.getPlatform(), acceptData.getVersion(), originalText, uid,
|
| | | new IClipboardAnalysisResult() {
|
| | |
|
| | | Pattern p = Pattern.compile(URL_REGEX);
|
| | | Matcher matcher = p.matcher(text);
|
| | | if (!matcher.find()) {// 不包含链接
|
| | | if (text.length() > 256) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | | String pattern = "^[A-Za-z0-9-]+$";
|
| | | if (Pattern.matches(pattern, text.replace(" ", ""))) {// 删除空格
|
| | | out.println(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | | @Override
|
| | | public void onResult(GoodsDocParseResultVO result) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("无推荐"));
|
| | | return;
|
| | | }
|
| | |
|
| | | LogHelper.test("根据粘贴板推荐:" + text);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 20);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("text", originalText);
|
| | | //
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | | JumpDetailContentVO convert = new JumpDetailContentVO();
|
| | | convert.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", platformCode, version));
|
| | | JSONObject convertParams = new JSONObject();
|
| | | convertParams.put("url", configService.get(ConfigKeyEnum.convertDocWebLink.getKey()));
|
| | | convertParams.put("clipboard", false);
|
| | | convert.setParams(convertParams);
|
| | |
|
| | | if (text.length() > 80) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | | JumpDetailContentVO view = null;
|
| | | JumpDetailContentVO guessLike = null;
|
| | |
|
| | | if (analysisTaoToken(acceptData, text, out)) {
|
| | | return;
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(TaoBaoUtil.parseSystemTaoToken(text))) {
|
| | | out.print(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", text);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | data.put("title", "智能搜索");
|
| | | |
| | | |
| | |
|
| | | int type = 3;
|
| | | CommonGoods commonGoods = null;
|
| | | text = matcher.group();
|
| | | int state = 0;
|
| | | if (result.getFirstGoods() != null && result.getFirstGoods().getGoodsId() != null) {
|
| | | state = 2;
|
| | | data.put("stateDesc", "选择搜券或转链");
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("id", result.getFirstGoods().getGoodsId()+"");
|
| | | params.put("from", "转链");
|
| | | if (result.getFirstGoods().getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | view = new JumpDetailContentVO();
|
| | | view.setJumpDetail(
|
| | | jumpDetailV2Service.getByTypeCache("goodsdetail", platformCode, version));
|
| | | view.setParams(params);
|
| | | } else if (result.getFirstGoods().getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | view = new JumpDetailContentVO();
|
| | | view.setJumpDetail(
|
| | | jumpDetailV2Service.getByTypeCache("goodsdetail_jd", platformCode, version));
|
| | | view.setParams(params);
|
| | | } else if (result.getFirstGoods().getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | view = new JumpDetailContentVO();
|
| | | view.setJumpDetail(
|
| | | jumpDetailV2Service.getByTypeCache("goodsdetail_pdd", platformCode, version));
|
| | | view.setParams(params);
|
| | | }
|
| | |
|
| | | if (text.startsWith("https://a.m.taobao.com/i"))// 淘宝账号未登录状态
|
| | | {
|
| | | text = text.substring("https://a.m.taobao.com/i".length(), text.indexOf(".htm"));
|
| | | if (NumberUtil.isNumeric(text)) {
|
| | | tb = TaoBaoUtil.isAlimama(text);
|
| | | }
|
| | | } else if (text.contains("ju.taobao.com") || text.contains(".juhuasuan.com")) {// 聚划算
|
| | | int index = text.indexOf("item_id");
|
| | | if (index < 0) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | | text = text.substring(index);
|
| | | int last = text.indexOf("&");
|
| | | String id = "";
|
| | | if (last > 0)
|
| | | id = text.substring(text.indexOf("=") + 1, text.indexOf("&"));
|
| | | else {
|
| | | id = text.substring(text.indexOf("=" + 1));
|
| | | }
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | type = 4;
|
| | | tb = getTaoBaoGoodsBriefFromGoodsId(id, originalText);
|
| | | }
|
| | | } else if (text.contains("http://zmnxbc.com")) { // 手机端天猫APP分享
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTM(text);
|
| | | } else if (text.contains("h5.m.taobao") || text.contains("detail.m.tmall") || text.contains("item.taobao")
|
| | | || text.contains("detail.tmall")) { // 手机页面和电脑页面
|
| | | Map<String, String> map = Utils.parseURL(text);
|
| | | String id = "";
|
| | | id = map.get("id").replace("}", "");
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | type = 4;
|
| | | tb = getTaoBaoGoodsBriefFromGoodsId(id, originalText);
|
| | | }
|
| | | } else if (text.contains("v.douyin.com")) { // 抖音
|
| | | analysisDouYin(acceptData, text, out);
|
| | | return;
|
| | | } else {
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTB(text);
|
| | |
|
| | | if (tb == null) {
|
| | | String goodsId = TaoBaoUtil.getGoodsIdByPhoneShareUrl(text);
|
| | | if (!StringUtil.isNullOrEmpty(goodsId)) {
|
| | | tb = getTaoBaoGoodsBriefFromGoodsId(goodsId, originalText);
|
| | | if (tb != null)
|
| | | type = 4;
|
| | | }
|
| | | }
|
| | |
|
| | | if (tb == null)// 淘宝是空值
|
| | | {
|
| | | String jdId = JDUtil.getJDGoodsId(text);
|
| | |
|
| | | // 微信链接
|
| | | if (StringUtil.isNullOrEmpty(jdId)) {
|
| | | jdId = JDUtil.getJDGoodsIdByWeiXin(text);
|
| | | }
|
| | |
|
| | | // 领券短连接
|
| | | if (StringUtil.isNullOrEmpty(jdId) && text.contains("u.jd.com")) {
|
| | | jdId = jdGoodsLinkParseManager.parseGoodsIdByJDShortUrl(text);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null) {
|
| | | // 高级接口 -- 信息更完整
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
|
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else if (!StringUtil.isNullOrEmpty(result.getFirstLink())) {
|
| | | state = 2;
|
| | | data.put("stateDesc", "选择搜券或转链");
|
| | | view = new JumpDetailContentVO();
|
| | | view.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", platformCode, version));
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", result.getFirstLink());
|
| | | view.setParams(params);
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | data.put("stateDesc", "去试试转链");
|
| | | state = 1;
|
| | | }
|
| | | } else {
|
| | | type = 4;
|
| | | goods = JDUtil.getSimpleGoodsInfo(jdId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getSkuName());
|
| | | commonGoods.setPicture(goods.getPicUrl());
|
| | | }
|
| | | data.put("state", state);
|
| | | if (convert != null)
|
| | | data.put("convert", gson.toJson(convert));
|
| | | if (view != null)
|
| | | data.put("view", gson.toJson(view));
|
| | |
|
| | | if (guessLike != null)
|
| | | data.put("guessLike", gson.toJson(guessLike));
|
| | |
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | | } else {
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(text);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | type = 4;
|
| | | goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getGoodsName());
|
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | |
|
| | | @Override
|
| | | public void onResult(String result) {
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", result);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onResult(CommonGoods goods) {
|
| | | if (goods.getGoodsId() != null) {
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {// 1.6.5版本后返回商品详情
|
| | | if (goods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = TaoKeApiUtil.searchGoodsDetail(goods.getGoodsId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (goodsBrief != null) {
|
| | | goods = CommonGoodsFactory.create(goodsBrief);
|
| | | Gson gson = JsonUtil
|
| | | .getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd")
|
| | | .create();
|
| | | data.put("type", 3);
|
| | | data.put("goods",
|
| | | gson.toJson(
|
| | | GoodsDetailVOFactory.convertCommonGoods(goods,
|
| | | hongBaoManageService.getShowComputeRate(
|
| | | acceptData.getPlatform(),
|
| | | acceptData.getVersion()))));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | } else {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd")
|
| | | .create();
|
| | | data.put("type", 3);
|
| | | data.put("goods",
|
| | | gson.toJson(
|
| | | GoodsDetailVOFactory.convertCommonGoods(goods,
|
| | | hongBaoManageService.getShowComputeRate(
|
| | | acceptData.getPlatform(),
|
| | | acceptData.getVersion()))));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | } else {
|
| | | // 低于1.6.5版本
|
| | | JSONObject taoBaoGoodsJSON = new JSONObject();
|
| | | taoBaoGoodsJSON.put("title", goods.getTitle());
|
| | | taoBaoGoodsJSON.put("zkPrice", goods.getPrice() + "");
|
| | | taoBaoGoodsJSON.put("id", goods.getGoodsId());
|
| | | taoBaoGoodsJSON.put("goodsType", goods.getGoodsType());
|
| | | if (goods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | taoBaoGoodsJSON.put("url",
|
| | | "http://item.taobao.com/item.htm?id=" + goods.getGoodsId());
|
| | | } else if (goods.getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | taoBaoGoodsJSON.put("url",
|
| | | String.format("https://item.jd.com/%s.html", goods.getGoodsId() + ""));
|
| | | } else if (goods.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | taoBaoGoodsJSON.put("url",
|
| | | "http://yangkeduo.com/goods.html?goods_id=" + goods.getGoodsId());
|
| | | }
|
| | | data.put("goods", taoBaoGoodsJSON);
|
| | | List<String> picList = new ArrayList<>();
|
| | | picList.add(goods.getPicture());
|
| | | data.put("imgs", picList);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 1);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (tb == null && commonGoods == null) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", goods.getTitle());
|
| | | goodsJSON.put("pictUrl", goods.getPicture());
|
| | |
|
| | | if (type == 4) {
|
| | | if (!VersionUtil.greaterThan_2_0_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if (tb != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(tb.getTitle());
|
| | | commonGoods.setPicture(tb.getPictUrl());
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(commonGoods.getTitle())
|
| | | || StringUtil.isNullOrEmpty(commonGoods.getPicture())) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", commonGoods.getTitle());
|
| | | goodsJSON.put("pictUrl", commonGoods.getPicture());
|
| | |
|
| | | data.put("type", type);
|
| | | data.put("desc", "该商品无推广信息");
|
| | | data.put("goods", goodsJSON);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (tb != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = TaoKeApiUtil.searchGoodsDetail(tb.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goodsBrief == null) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | | commonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | }
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | data.put("type", type);
|
| | | data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods,
|
| | | hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (tb != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setPrice(tb.getZkPrice());
|
| | | commonGoods.setTitle(tb.getTitle());
|
| | | commonGoods.setGoodsId(tb.getAuctionId());
|
| | | commonGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | commonGoods.setPicture(tb.getPictUrl());
|
| | | }
|
| | |
|
| | | JSONObject taoBaoGoodsJSON = new JSONObject();
|
| | | taoBaoGoodsJSON.put("title", commonGoods.getTitle());
|
| | | taoBaoGoodsJSON.put("zkPrice", commonGoods.getPrice() + "");
|
| | | taoBaoGoodsJSON.put("id", commonGoods.getGoodsId());
|
| | | taoBaoGoodsJSON.put("goodsType", commonGoods.getGoodsType());
|
| | | if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + commonGoods.getGoodsId());
|
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | taoBaoGoodsJSON.put("url", String.format("https://item.jd.com/%s.html", commonGoods.getGoodsId() + ""));
|
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | taoBaoGoodsJSON.put("url", "http://yangkeduo.com/goods.html?goods_id=" + commonGoods.getGoodsId());
|
| | | }
|
| | | data.put("goods", taoBaoGoodsJSON);
|
| | | List<String> picList = new ArrayList<>();
|
| | | picList.add(commonGoods.getPicture());
|
| | | data.put("imgs", picList);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 1);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | private TaoBaoGoodsBrief getTaoBaoGoodsBriefFromGoodsId(String goodsId, String text) {
|
| | | TaoBaoGoodsBrief tb = TaoBaoUtil.getTmallGoodsInfo(goodsId);
|
| | | if (tb == null && NumberUtil.isNumeric(goodsId)) {// 是数字
|
| | | // tb = TaoBaoUtil.getSimpleGoodsBrief(Long.parseLong(goodsId));
|
| | | // if (tb != null) {
|
| | | // tb.setPictUrl(TbImgUtil.getTBSize220Img(tb.getPictUrl()));
|
| | | // }
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief();
|
| | | if (text.trim().indexOf("【") == 0 && text.trim().indexOf("】") > 0) {
|
| | | // 截取标题
|
| | | String title = text.trim().substring(1, text.trim().lastIndexOf("】"));
|
| | | tb.setAuctionId(Long.parseLong(goodsId));
|
| | | tb.setTitle(title);
|
| | | tb.setPictUrl("http://");
|
| | | }
|
| | | }
|
| | | }
|
| | | return tb;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 解析抖音链接
|
| | | * |
| | | * @param acceptData
|
| | | * @param text
|
| | | * @param out
|
| | | * @return
|
| | | */
|
| | | private void analysisDouYin(AcceptData acceptData, String text, PrintWriter out) {
|
| | | String location = HttpUtil.getLocation(text);
|
| | | if (!StringUtil.isNullOrEmpty(location)) {
|
| | | if (location.contains("taobao.com")) { // 淘宝商品
|
| | | String realUrl = TaoBaoUtil.getRealUrl(location);
|
| | | if (!StringUtil.isNullOrEmpty(realUrl)) {
|
| | | getRecommendInfo(acceptData, realUrl, null, out);
|
| | | return;
|
| | | }
|
| | | } else if (location.contains("haohuo.jinritemai.com")) { // 抖音商品
|
| | | DouYinGoods goods = DouYinUtil.getGoodsInfo(location);
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", goods.getName());
|
| | | goodsJSON.put("pictUrl", goods.getImg());
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("type", 4);
|
| | | data.put("desc", "该商品无推广信息");
|
| | | data.put("goods", goodsJSON);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | }
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 解析淘口令
|
| | | * |
| | | * @param acceptData
|
| | | * @param text
|
| | | * @param out
|
| | | * @return
|
| | | */
|
| | | private boolean analysisTaoToken(AcceptData acceptData, String text, PrintWriter out) {
|
| | | String token = StringUtil.picUpTaoToken(text);
|
| | | if (!StringUtil.isNullOrEmpty(token)) {
|
| | | Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | if (auctionId != null) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | try {
|
| | | tb = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (tb != null) {
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = TaoKeApiUtil.searchGoodsDetail(tb.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (goodsBrief == null) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return false;
|
| | | }
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("type", 3);
|
| | | data.put("goods",
|
| | | gson.toJson(GoodsDetailVOFactory.convertTaoBao(goodsBrief, hongBaoManageService
|
| | | .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))));
|
| | | data.put("type", 4);
|
| | | data.put("desc", "该商品无推广信息");
|
| | | data.put("goods", goodsJSON);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return true;
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONObject taoBaoGoodsJSON = new JSONObject();
|
| | | taoBaoGoodsJSON.put("title", tb.getTitle());
|
| | | taoBaoGoodsJSON.put("zkPrice", tb.getZkPrice());
|
| | | taoBaoGoodsJSON.put("id", tb.getAuctionId());
|
| | | taoBaoGoodsJSON.put("goodsType", Constant.SOURCE_TYPE_TAOBAO);
|
| | | taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId());
|
| | | data.put("goods", taoBaoGoodsJSON);
|
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) {
|
| | | if (tb.getImgList() == null)
|
| | | tb.setImgList(new ArrayList<>());
|
| | | tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl()));
|
| | | @Override
|
| | | public void onResult(TokenVO tokenVO) {
|
| | | out.print(JsonUtil.loadTrueResult(tokenVO));
|
| | | return;
|
| | | }
|
| | | data.put("imgs", tb.getImgList());
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 1);
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | |
|
| | | @Override
|
| | | public void none() {
|
| | | out.print(JsonUtil.loadFalseResult("无推荐"));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void needLogin(String msg) {
|
| | | out.print(JsonUtil.loadFalseResult(1001, msg));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | 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.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo;
|
| | | import com.yeshi.fanli.vo.goods.ShareInfoVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
|
| | | BigDecimal fanliMoney) {
|
| | | List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(token))
|
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "淘口令", token, true, false));
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_LINK, "链接",link, true, false));
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_INVITE_CODE, "邀请码", inviteCode, false,
|
| | | true));
|
| | | }
|
| | |
|
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_DOWNLOAD_LINK, "下载链接", "http://www.baidu.com", false,
|
| | | true));
|
| | |
|
| | | list.add(
|
| | | new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_FANLI_MONEY, "返利金额", "¥ "+fanliMoney, false, true));
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | }
|
| | |
|
| | | // 淘礼金创建分享
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | if (source != null && "taolijin".equals(source)) {// 淘礼金分享创建
|
| | | createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | |
|
| | | // 测试
|
| | |
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
|
| | |
|
| | | if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
|
| | | ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
|
| | | shareInfo.setGoodsInfo(goodsInfo);
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
|
| | | List<String> commentTexts = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) {
|
| | | JSONArray array = JSONArray.fromObject(commentTextStr);
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | if (array.optString(i).contains("[邀请码]")) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(inviteCode))
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[淘口令]", shareInfo.getToken()));
|
| | | else
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", shareInfo.getToken()));
|
| | | }
|
| | | }
|
| | | shareInfo.setCommentTexts(commentTexts);
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
|
| | | : TaoBaoConstant.SHARE_PRICE_TM;
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
|
| | |
|
| | | 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("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | |
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n")) {
|
| | | descText = descText.substring(0);
|
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | | // 测试
|
| | | // 2.0.2之前
|
| | | if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | shareInfo.setClickUrl(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()),
|
| | | taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), taoBaoLink.getGoods(),
|
| | | shareInfo.getToken()));
|
| | |
|
| | | // 提示图文内容
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
|
| | |
|
| | | // 分享金额
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | |
|
| | | // 分享id
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, false);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(
|
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | | // 异步操作
|
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl());
|
| | | history.setShareImg(taobaoLink.getClickUrl());
|
| | | List<String> imgList = taobaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | } else {// 普通分享创建
|
| | | createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid,
|
| | | needGoods, relationId, out);
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + " goodsId:" + goodsId, "");
|
| | | // 分享出错报警
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid,
|
| | | boolean needGoods, String relationId, PrintWriter out) {
|
| | | try {
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | |
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
|
| | |
|
| | | if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
|
| | | ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(platform, version);
|
| | | GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
|
| | | shareInfo.setGoodsInfo(goodsInfo);
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
|
| | | List<String> commentTexts = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) {
|
| | | JSONArray array = JSONArray.fromObject(commentTextStr);
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | if (array.optString(i).contains("[邀请码]")) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(inviteCode))
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[淘口令]", shareInfo.getToken()));
|
| | | else
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", shareInfo.getToken()));
|
| | | }
|
| | | }
|
| | | shareInfo.setCommentTexts(commentTexts);
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
|
| | | : TaoBaoConstant.SHARE_PRICE_TM;
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
|
| | |
|
| | | 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("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | |
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n")) {
|
| | | descText = descText.substring(0);
|
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | | // 测试
|
| | | // 2.0.2之前
|
| | | if (!VersionUtil.greaterThan_2_0_2(platform, version))
|
| | | shareInfo.setClickUrl(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()),
|
| | | taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()),
|
| | | taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | // 提示图文内容
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
|
| | |
|
| | | // 分享金额
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | |
|
| | | // 分享id
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, false);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getToken(), null, inviteCode,
|
| | | TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate())));
|
| | |
|
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(
|
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | | // 异步操作
|
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl());
|
| | | List<String> imgList = taobaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + " goodsId:" + goodsId, "");
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东创建分享
|
| | | *
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
|
| | | JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate())));
|
| | | |
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(
|
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
|
| | |
|
| | |
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | | history.setShareImg(jumpLink);
|
| | | |
| | |
|
| | | List<String> imgList = goods.getImageList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
|
| | | PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate())));
|
| | | |
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(
|
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
|
| | |
|
| | |
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | try {
|
| | | LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.log.LogManager;
|
| | | import com.yeshi.fanli.log.LogType;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(uid))
|
| | | uid = uid.replace(" ", "+");
|
| | |
|
| | | LogHelper.shareGoods("分享出去的H5访问: uid:" + uid + " id:" + id);
|
| | | LogManager.getLogger(LogType.taobaoTrade)
|
| | | .info(String.format("淘宝分享商品H5访问:\n 商品ID:%s \n 原始用户ID:%s \n", id, uid));
|
| | | |
| | | long begin = java.lang.System.currentTimeMillis();
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | |
| | | boolean hasCoupon = false;
|
| | | String couponUrl = null;
|
| | | BigDecimal discount = new BigDecimal(0);
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo( jdGoods) ;
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
|
| | | if (couponInfo != null) {
|
| | | hasCoupon = true;
|
| | | discount = couponInfo.getDiscount();
|
| | |
| | | }
|
| | |
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid);
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | uid);
|
| | |
|
| | | int priceType = 1;
|
| | | BigDecimal price = jdGoods.getPrice();
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogManager;
|
| | | import com.yeshi.fanli.log.LogType;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | |
| | | @RequestMapping(value = "getRecommenBanner", method = RequestMethod.GET)
|
| | | public void getRecommendBanner(AcceptData acceptData, String callback, PrintWriter out) {
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem("WEB", Constant.systemCommonConfig.getH5PackageName());
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem("WEB",
|
| | | Constant.systemCommonConfig.getH5PackageName());
|
| | | JSONObject json = new JSONObject();
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM));
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | *
|
| | | * 方法说明: 获取商品详情
|
| | |
| | | */
|
| | |
|
| | | @RequestMapping(value = "getGoodsDetail", method = RequestMethod.GET)
|
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, Integer goodsType, |
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, Integer goodsType,
|
| | | String callback, PrintWriter out) {
|
| | | |
| | | long begin = java.lang.System.currentTimeMillis();
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id"));
|
| | | return;
|
| | | }
|
| | | BusinessSystem system = webControllerUtil.getSystem(acceptData);
|
| | | // 淘特价
|
| | | if (system.getId() == 7) {
|
| | | system = businessSystemService.getBusinessSystem("ANDROID", Constant.systemCommonConfig.getAndroidPackageName());
|
| | | }
|
| | |
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, WebControllerUtil.NOSYSTEM));
|
| | |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb) + "元");
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | |
|
| | | final TaoBaoGoodsBrief tbb=tb;
|
| | | final TaoBaoGoodsBrief tbb = tb;
|
| | |
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | |
| | | }
|
| | |
|
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id=" + id);
|
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
|
| | |
|
| | | String salesTip = pddGoods.getSalesTip();
|
| | | if (!StringUtil.isNullOrEmpty(salesTip)) {
|
| | |
| | |
|
| | | // TODO 跳转地址
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", "http://apph5.yeshitv.com/special/1.0.9/jingXuanN_9.html?type=9_9");
|
| | | params.put("url", "http://apph5.banliapp.com/special/1.0.9/jingXuanN_9.html?type=9_9");
|
| | | JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | userSystemMsgVO.setJumpDetail(wxmpJumDetail);
|
| | |
|
| | |
| | | public List<T> findList(Query query) {
|
| | | return mongoTemplate.find(query, this.getEntityClass());
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 统计数量
|
| | | * |
| | | * @param query
|
| | | * @return
|
| | | */
|
| | | public long count(Query query) {
|
| | | return mongoTemplate.count(query, this.getEntityClass());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 主键查询
|
New file |
| | |
| | | package com.yeshi.fanli.dao.user;
|
| | |
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.yeshi.fanli.dao.MongodbBaseDao;
|
| | | import com.yeshi.fanli.entity.bus.user.UserConvertLinkTemplate;
|
| | |
|
| | | @Repository
|
| | | public class UserConvertLinkTemplateDao extends MongodbBaseDao<UserConvertLinkTemplate> {
|
| | | |
| | | |
| | |
|
| | | }
|
| | |
| | | private String network;
|
| | | private String imei;
|
| | | private String idfa;
|
| | | private String utdid;
|
| | |
|
| | | public String getUtdid() {
|
| | | return utdid;
|
| | | }
|
| | |
|
| | | public void setUtdid(String utdid) {
|
| | | this.utdid = utdid;
|
| | | }
|
| | |
|
| | | public String getIdfa() {
|
| | | return idfa;
|
| | |
| | | package com.yeshi.fanli.entity.bus.help;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | |
| | | */
|
| | |
|
| | | @Table("yeshi_ec_help_class")
|
| | | public class HelpClass {
|
| | | public class HelpClass implements Serializable{
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Expose
|
| | | @Column(name = "hc_id")
|
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import org.springframework.data.annotation.Id;
|
| | | import org.springframework.data.mongodb.core.index.Indexed;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | /**
|
| | | * 文案转链模板
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Document(collection = "convertLinkTemplate")
|
| | | public class UserConvertLinkTemplate{
|
| | | @Expose
|
| | | @Id
|
| | | private String id;
|
| | | @Indexed
|
| | | @Field
|
| | | private Long uid;
|
| | | @Expose
|
| | | @Field
|
| | | private String template;
|
| | | @Field
|
| | | private Date createTime;
|
| | | @Field
|
| | | private Date updateTime;
|
| | |
|
| | | @Expose
|
| | | private String content;// 模板用户填充后的内容
|
| | |
|
| | | public String getContent() {
|
| | | return content;
|
| | | }
|
| | |
|
| | | public void setContent(String content) {
|
| | | this.content = content;
|
| | | }
|
| | |
|
| | | public String getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(String id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getTemplate() {
|
| | | return template;
|
| | | }
|
| | |
|
| | | public void setTemplate(String template) {
|
| | | this.template = template;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | fanli("返利到账", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", ""),
|
| | | fanliWeiQuan("返利扣除",
|
| | | "http://img.flqapp.com/resource/money_detail/icon_fanli.png",
|
| | | "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | "http://apph5.banliapp.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | inviteWeiQuan("邀请奖金扣除",
|
| | | "http://img.flqapp.com/resource/money_detail/icon_invite.png",
|
| | | "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | "http://apph5.banliapp.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | shareWeiQuan("分享奖金扣除",
|
| | | "http://img.flqapp.com/resource/money_detail/icon_share.png",
|
| | | "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | "http://apph5.banliapp.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | weiQuan("售后订单扣款",
|
| | | "http://img.flqapp.com/resource/money_detail/icon_fanli.png",
|
| | | "http://apph5.yeshitv.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | "http://apph5.banliapp.com/AppPage/1.8.0/all_help_content.html?id=214"),
|
| | | systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""),
|
| | | scoreConvert("金币兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""),
|
| | | hongbao("官方红包", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png", ""),
|
| | |
| | | articleHotWords("article_hot_words", "动态-学院文章热搜词"),
|
| | | vipLink("vip_link", "超级会员升级链接"), // 转移至VIPConfig 已废弃
|
| | | helpLinkVipInfo("help_link_vip_info", "超级会员详情页帮助链接"), // 已废弃
|
| | | //文案转链
|
| | | convertDocWebLink("convert_doc_web_link","文案转链网页"),
|
| | | convertDocHelpLink("convert_doc_help_link","文案转链帮助网页"),
|
| | | convertDocTip("convert_doc_tip","文案转链温馨提示")
|
| | | ;
|
| | |
|
| | | private final String key;
|
| | |
| | | @Column(name = "value")
|
| | | private String value;
|
| | |
|
| | | @Expose
|
| | | // @Expose
|
| | | @Column(name = "name")
|
| | | private String name;
|
| | |
|
| | | @Expose
|
| | | // @Expose
|
| | | @Column(name = "updatetime")
|
| | | private Long updatetime;
|
| | |
|
| | |
| | | @Expose
|
| | | private String title;// 商品标题
|
| | |
|
| | | |
| | |
|
| | | @Field
|
| | | @Indexed
|
| | | @org.yeshi.utils.mybatis.Column(name = "auctionId")
|
| | |
| | | @Transient
|
| | | private Integer materialLibType;//物料库类型
|
| | |
|
| | | private String description;//推荐语
|
| | | |
| | |
|
| | |
|
| | | /* 新增字段 2018-7-16 ; 由于数据未从淘宝获取成功,暂不启用 */
|
| | |
|
| | |
|
| | |
|
| | | public Integer getMaterialLibType() {
|
| | | return materialLibType;
|
| | | }
|
| | |
| | | this.pictUrlWhite = pictUrlWhite;
|
| | | }
|
| | |
|
| | | public String getDescription() {
|
| | | return description;
|
| | | }
|
| | |
|
| | | public void setDescription(String description) {
|
| | | this.description = description;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.taobao;
|
| | |
|
| | | import com.yeshi.fanli.exception.BaseException;
|
| | |
|
| | | public class TaoBaoTokenParseException extends BaseException {
|
| | |
|
| | | // 商品已下架
|
| | | public static int CODE_GOODS_OFFLINE = 10000;
|
| | | // 解析结果为空
|
| | | public static int CODE_NULL = 20011;
|
| | |
|
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public TaoBaoTokenParseException(int code, String msg) {
|
| | | super(code, msg);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | |
| | | if (order.getValidCode() == 15)// 过滤掉待付款
|
| | | continue;
|
| | |
|
| | | //防止多个商品拆单问题,爬取
|
| | | // 防止多个商品拆单问题,爬取
|
| | | if (order.getOrderItemList().size() > 1
|
| | | && order.getOrderTime() > System.currentTimeMillis() - 1000 * 60 * 2L) {
|
| | | && order.getOrderTime() > System.currentTimeMillis() - 1000 * 60 * 3L) {
|
| | | continue;
|
| | | }
|
| | |
|
| | |
| | | /**
|
| | | * 做频率限制
|
| | | */
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.JDOrder, order.getOrderId() + "" );
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.JDOrder, order.getOrderId() + "");
|
| | | String result = redisManager.getCommonString(key);
|
| | | // 判断
|
| | |
|
| | | JDOrderCMQManager.getInstance().addJDOrder(order.getOrderId() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | if (StringUtil.isNullOrEmpty(result)) {
|
| | | JDOrderCMQManager.getInstance().addJDOrder(order.getOrderId() + "");
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新
|
| | | }
|
| | | } catch (JDOrderException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | |
|
| | | private static Logger userOrderLogger = Logger.getLogger("userOrderLog");
|
| | |
|
| | | private static Logger cookieLogger = Logger.getLogger("cookieLog");
|
| | |
|
| | | private static Logger testLogger = Logger.getLogger("testLog");
|
| | |
|
| | | private static Logger errorLogger = Logger.getLogger("errorLog");
|
| | |
| | |
|
| | | public static void orderErrorInfo(Object obj) {
|
| | | orderLogger.error(obj);
|
| | | }
|
| | |
|
| | | public static void cookieLog(Object obj) {
|
| | | cookieLogger.info(obj);
|
| | | }
|
| | |
|
| | | public static void userOrder(Object obj) {
|
New file |
| | |
| | | package com.yeshi.fanli.log;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | public class LogManager {
|
| | | private static Map<LogType, org.apache.logging.log4j.Logger> logMap = new HashMap<>();
|
| | |
|
| | | public static org.apache.logging.log4j.Logger getLogger(LogType logType) {
|
| | | if (logMap.get(logType) == null)
|
| | | logMap.put(logType, org.apache.logging.log4j.LogManager.getLogger(logType.name()));
|
| | | return logMap.get(logType);
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.log;
|
| | |
|
| | | //日志类型
|
| | | public enum LogType {
|
| | | mqSend("消息发送"),
|
| | | mqConsume("消息消费"),
|
| | | taobaoTaoke("淘客api"),
|
| | | taobaoTrade("淘宝交易(分享/自购)"),
|
| | | taobaoAuth("淘宝授权"),
|
| | | userLogin("用户登录");
|
| | |
|
| | | private String desc;
|
| | |
|
| | | private LogType(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import org.yeshi.utils.exception.HttpException;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.PidUserMapper;
|
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinNewbiesException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.log.LogManager;
|
| | | import com.yeshi.fanli.log.LogType;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.UserTLJBuyHistoryService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | |
| | | @Service
|
| | | public class ShareGoodsServiceImpl implements ShareGoodsService {
|
| | |
|
| | | @Resource
|
| | | private PidUserMapper pidUserMapper;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
| | | @Resource
|
| | | private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageMapper hongBaoManageMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userinfoMapper;
|
| | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserTLJBuyHistoryService userTLJBuyHistoryService;
|
| | |
| | | @Resource
|
| | | private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
|
| | |
|
| | | @Resource
|
| | | private ConvertLinkManager convertLinkManager;
|
| | |
|
| | | @Override
|
| | | public void addShareGoodsHistory(UserShareGoodsHistory history) {
|
| | | UserShareGoodsHistory userShareGoodsHistory = userShareGoodsHistoryMapper
|
| | |
| | | }
|
| | |
|
| | | FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_"
|
| | | + System.currentTimeMillis() + ".png");
|
| | |
|
| | | if (shareImgResult == null || StringUtil.isNullOrEmpty(shareImgResult.getUrl())) {
|
| | | throw new ShareGoodsException(6, "分享图片保存失败");
|
| | |
| | | }
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | // 测试
|
| | | // info.setAdzoneId("123");
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId, info);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(4, "商品已下架");
|
| | |
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponLink()) && !goods.getAuctionUrl().contains("s.click.taobao.com")) {
|
| | | TaoBaoUnionConfig taoBaoUnionConfig = taoBaoUnionConfigService
|
| | | .getConfigByAppIdCache(info.getPid().split("_")[2]);
|
| | | TaoBaoGoodsBrief taoBaoLink = TaoKeApiUtil.specialConvertCoupon(auctionId, info);
|
| | | if (taoBaoLink == null) {
|
| | | throw new ShareGoodsException(201, "商品转链失败");
|
| | |
| | | tbLink.setCouponLink(goods.getCouponLink());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tbLink.getCouponLink())) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid, goods.getPictUrl(), goods.getTitle(), tbLink.getCouponLink());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | | } else if (!StringUtil.isNullOrEmpty(tbLink.getClickUrl())) {
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
|
| | | String quanToken = convertLinkManager.createTaoBaoToken(uid,goods.getPictUrl(), goods.getTitle(), tbLink.getClickUrl());
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | tbLink.setTaoToken(quanToken);
|
| | | }
|
| | |
| | | // 存储分享商品的信息,用于加快分享网页接口请求速度
|
| | | if (Constant.IS_OUTNET)
|
| | | redisManager.saveTaoBaoGoodsBriefTemp(goods);
|
| | |
|
| | | LogManager.getLogger(LogType.taobaoTrade)
|
| | | .info(String.format("淘宝商品分享\n UID:%s \n 商品ID:%s \n 券链接%s \n商品链接:%s \n 口令:%s ", uid, auctionId,
|
| | | tbLink.getCouponLink(), tbLink.getClickUrl(), tbLink.getTaoToken()));
|
| | |
|
| | | return tbLink;
|
| | | }
|
| | |
| | | @Override
|
| | | public TaoBaoLink getTaoLiJinLinkForBuy(Long uid, String specialId, Long auctionId, String pid)
|
| | | throws ShareGoodsException {
|
| | | if (uid == null || uid <= 0) |
| | | if (uid == null || uid <= 0)
|
| | | throw new ShareGoodsException(1, "用户ID不能为空");
|
| | |
|
| | | if (auctionId == null || auctionId <= 0) |
| | | if (auctionId == null || auctionId <= 0)
|
| | | throw new ShareGoodsException(1, "商品ID不能为空");
|
| | | |
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new ShareGoodsException(1, "该商品已下架");
|
| | | }
|
| | | |
| | | if (goods == null) |
| | |
|
| | | if (goods == null)
|
| | | throw new ShareGoodsException(1, "该商品已下架");
|
| | | |
| | |
|
| | | String taoLiJinLink = null;
|
| | | try {
|
| | | goods.setAuctionId(auctionId);
|
| | |
| | | if (fList != null && fList.size() > 0)
|
| | | return fList;
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(1, 50, imei, idfa,"");
|
| | | List<TaoBaoGoodsBrief> finalList = new ArrayList<>();
|
| | |
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) {
|
| | |
| | | .selectByOrderIdAndOrderItemId(order.getOrderId(), order.getOrderItemId());
|
| | | if (taoBaoWeiQuanOrder != null) {
|
| | | // 已经是最新的状态了
|
| | | if (taoBaoWeiQuanOrder.getState() != null && (taoBaoWeiQuanOrder.getState().contains("维权成功")
|
| | | || taoBaoWeiQuanOrder.getState().contains("维权失败")))
|
| | | if (taoBaoWeiQuanOrder.getState() != null && (taoBaoWeiQuanOrder.getState().contains("维权成功")))
|
| | | return;
|
| | | // 更新金额,状态与时间
|
| | | TaoBaoWeiQuanOrder update = new TaoBaoWeiQuanOrder();
|
| | |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private RedPackExchangeMapper redPackExchangeMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private RedPackConfigService redPackConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state){
|
| | | public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state) {
|
| | | return redPackExchangeMapper.query(start, count, key, state);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Long count(String key, Integer state){
|
| | | public Long count(String key, Integer state) {
|
| | | return redPackExchangeMapper.count(key, state);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public Long countByUidAndState(long uid, Integer state) {
|
| | | return redPackExchangeMapper.countByUidAndState(uid, state);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public BigDecimal countMoneyByUidAndState(Long uid, Integer state){
|
| | | public BigDecimal countMoneyByUidAndState(Long uid, Integer state) {
|
| | | return redPackExchangeMapper.countMoneyByUidAndState(uid, state);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public RedPackExchange selectByPrimaryKey(long id){
|
| | | public RedPackExchange selectByPrimaryKey(long id) {
|
| | | return redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException {
|
| | | if (uid == null || amount == null)
|
| | | throw new RedPackExchangeException(1, "参数不正确");
|
| | | |
| | | if(redPackForbidService.verifyForbid(uid))
|
| | |
|
| | | if (redPackForbidService.verifyForbid(uid))
|
| | | throw new RedPackExchangeException(1, "红包功能已被封禁");
|
| | | |
| | |
|
| | | String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
|
| | | |
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | |
|
| | | BigDecimal balance = redPackBalanceService.getBalance(uid);
|
| | | if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
|
| | | throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
|
| | | |
| | |
|
| | | if (balance.compareTo(amount) < 0)
|
| | | throw new RedPackExchangeException(1, "提现余额不足");
|
| | | |
| | |
|
| | | String moneyMin = redPackConfigService.getValueByKey("extract_money_min");
|
| | | String moneyMax = redPackConfigService.getValueByKey("extract_money_max");
|
| | | if (amount.compareTo(new BigDecimal(moneyMin)) < 0 || amount.compareTo(new BigDecimal(moneyMax)) > 0)
|
| | | throw new RedPackExchangeException(1, "提现金额至少" + moneyMin + "元至多" + moneyMax + "元");
|
| | | |
| | | |
| | |
|
| | | long countToday = redPackExchangeMapper.countTodayByUid(uid);
|
| | | String extractDayMax = redPackConfigService.getValueByKey("extract_day_max");
|
| | | if (!StringUtil.isNullOrEmpty(extractDayMax) && countToday >= Long.parseLong(extractDayMax)) |
| | | if (!StringUtil.isNullOrEmpty(extractDayMax) && countToday >= Long.parseLong(extractDayMax))
|
| | | throw new RedPackExchangeException(1, "今日红包提现次数超限");
|
| | | |
| | | |
| | |
|
| | | Date nowDate = new Date();
|
| | | // 提现申请
|
| | | RedPackExchange exchange = new RedPackExchange();
|
| | |
| | | exchange.setState(RedPackExchange.STATE_INIT);
|
| | | exchange.setCreateTime(nowDate);
|
| | | redPackExchangeMapper.insertSelective(exchange);
|
| | | |
| | |
|
| | | // 减少红包
|
| | | try {
|
| | | redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createExchange(exchange));
|
| | |
| | | throw new RedPackExchangeException(1, "红包信息异常");
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void passExchange(final long id, AdminUser admin) throws RedPackExchangeException {
|
| | | RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | if (record == null) |
| | | throw new RedPackExchangeException(1,"申请记录已不存在");
|
| | | if (record == null)
|
| | | throw new RedPackExchangeException(1, "申请记录已不存在");
|
| | |
|
| | | if (RedPackExchange.STATE_INIT != record.getState())
|
| | | throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
|
| | | throw new RedPackExchangeException(1, "该申请已被处理,请刷新");
|
| | |
|
| | | if(redPackForbidService.verifyForbid(record.getUid()))
|
| | | if (redPackForbidService.verifyForbid(record.getUid()))
|
| | | throw new RedPackExchangeException(1, "红包功能已被封禁");
|
| | | |
| | |
|
| | | Date nowDate = new Date();
|
| | | record.setAuditId(admin.getId());
|
| | | record.setAuditTime(nowDate);
|
| | | record.setState(RedPackExchange.STATE_SUCCESS);
|
| | | redPackExchangeMapper.updateByPrimaryKeySelective(record);
|
| | | |
| | |
|
| | | // 资金明细-添加资金
|
| | | UserMoneyDetail detail = new UserMoneyDetail();
|
| | | detail.setCreateTime(new Date());
|
| | |
| | | detail.setMoney(record.getMoney());
|
| | | detail.setType(UserMoneyDetailTypeEnum.redPackExchange);
|
| | | detail.setTitle(UserMoneyDetailTypeEnum.redPackExchange.getDesc());
|
| | | detail.setDescInfo("于"+ TimeUtil.formatDate(record.getCreateTime()) +"提现");
|
| | | detail.setDescInfo("于" + TimeUtil.formatDate(record.getCreateTime()) + "提现");
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setUserInfo(new UserInfo(record.getUid()));
|
| | | |
| | |
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
|
| | | |
| | |
|
| | | // 更新红包提现明细
|
| | | try {
|
| | | String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.redExchange.name() + ":" + record.getId());
|
| | |
| | | redPackDetailService.updateByPrimaryKeySelective(updateDetail);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new RedPackExchangeException(1,"更新提现明细出错");
|
| | | throw new RedPackExchangeException(1, "更新提现明细出错");
|
| | | }
|
| | | |
| | | |
| | | //消息
|
| | |
|
| | | // 消息
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | String beizu = "红包提现成功后请到“我的-账户余额”中查看";
|
| | | MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
|
| | | dto.setTitle("红包提现");
|
| | | dto.setTime(sd.format(record.getCreateTime()));
|
| | | dto.setHandle("人工审核" + sd.format(new Date())); |
| | | dto.setMoney("¥" + record.getMoney().setScale(2)); |
| | | dto.setHandle("人工审核" + sd.format(new Date()));
|
| | | dto.setMoney("¥" + record.getMoney().setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(record.getUid()));
|
| | | userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
|
| | | |
| | | userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass,
|
| | | new Gson().toJson(dto), beizu);
|
| | |
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void rejectExchange(long id, String reason, AdminUser admin) throws RedPackExchangeException {
|
| | | RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
|
| | | if (record == null) |
| | | throw new RedPackExchangeException(1,"申请记录已不存在");
|
| | | if (record == null)
|
| | | throw new RedPackExchangeException(1, "申请记录已不存在");
|
| | |
|
| | | if (RedPackExchange.STATE_INIT != record.getState())
|
| | | throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
|
| | | |
| | | throw new RedPackExchangeException(1, "该申请已被处理,请刷新");
|
| | |
|
| | | record.setReason(reason);
|
| | | record.setAuditTime(new Date());
|
| | | record.setAuditId(admin.getId());
|
| | | record.setState(RedPackExchange.STATE_REJECT);
|
| | | redPackExchangeMapper.updateByPrimaryKeySelective(record);
|
| | | |
| | |
|
| | | // 退回红包
|
| | | try {
|
| | | redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchangeReject(record));
|
| | | redPackBalanceService.addRedPack(record.getUid(), record.getMoney(),
|
| | | RedPackDetailFactory.createExchangeReject(record));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new RedPackExchangeException(1, "红包退回时出错");
|
| | | }
|
| | | |
| | | //消息
|
| | |
|
| | | // 消息
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
|
| | | dto.setTitle("红包提现");
|
| | | dto.setReason(reason);
|
| | | dto.setHandle(""); // TODO 处理方式待定
|
| | | dto.setTime(sd.format(record.getCreateTime()));
|
| | | userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangeReject, new Gson().toJson(dto), null);
|
| | | userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangeReject,
|
| | | new Gson().toJson(dto), null);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackUseContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsClass;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.shop.ChargeTypeEnum;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackDetailException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopOrderException;
|
| | | import com.yeshi.fanli.exception.shop.FuLuChargeException;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.charge.FuLuChargeApiUtil;
|
| | | import com.yeshi.fanli.util.email.MailSenderUtil;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
| | | * 支付成功
|
| | | */
|
| | | private void paySuccess(BanLiShopOrder order) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | | |
| | | @Override
|
| | | public void run() {
|
| | | long[] targetUids = new long[] { 3L, 4L };
|
| | | Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey());
|
| | | String[] sts = config.getValue().split(",");
|
| | | String account = sts[0];
|
| | | String pwd = sts[1];
|
| | | for (long adminId : targetUids) {
|
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
|
| | | String msg = "有新的红包商城订单";
|
| | | boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的红包商城订单", msg);
|
| | | }
|
| | | }
|
| | | });
|
| | | |
| | | |
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | | |
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | | |
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | @Resource
|
| | | private SystemCouponService systemCouponService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteMsgNotificationService userInviteMsgNotificationService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private RedPackGiveRecordService redPackGiveRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | |
|
| | | @Override
|
| | | public void insertSelective(TokenRecord record) {
|
| | |
| | | tokenRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(TokenRecord record) {
|
| | | tokenRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public TokenRecord getNearByTypeAndIdentify(String type, String identify) {
|
| | | return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public TokenRecord getByTypeAndIdentify(String type, String identify) {
|
| | | return tokenRecordMapper.getByTypeAndIdentify(type, identify);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TokenVO discernToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
|
| | | public TokenVO discernToken(String token, Long uid, String platform, String version) throws TokenRecordException {
|
| | | // 解析口令
|
| | | String parseToken = TokenUtil.parseToken(token);
|
| | | if (StringUtil.isNullOrEmpty(parseToken)) |
| | | if (StringUtil.isNullOrEmpty(parseToken))
|
| | | throw new TokenRecordException(1, "未发现口令");
|
| | | |
| | |
|
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(parseToken);
|
| | | if (rokenRecord == null)
|
| | | throw new TokenRecordException(1, "口令不存在");
|
| | |
| | | Long uidToken = rokenRecord.getUid();
|
| | | if (uid != null && uidToken != null && uid.longValue() == uidToken.longValue())
|
| | | throw new TokenRecordException(1, "不能自己赠送给自己");
|
| | | |
| | |
|
| | | Date now = new Date();
|
| | | Date endTimeToken = rokenRecord.getEndTime();
|
| | | Integer stateTtoken = rokenRecord.getState();
|
| | | if (endTimeToken != null && endTimeToken.getTime() < now.getTime()
|
| | | || (stateTtoken != null && stateTtoken == 1) || StringUtil.isNullOrEmpty(rokenRecord.getIdentify())) |
| | | if (endTimeToken != null && endTimeToken.getTime() < now.getTime() || (stateTtoken != null && stateTtoken == 1)
|
| | | || StringUtil.isNullOrEmpty(rokenRecord.getIdentify()))
|
| | | throw new TokenRecordException(1, "口令已失效");
|
| | |
|
| | | |
| | | Integer num = 0;
|
| | | Integer type = 0;
|
| | | String money = null;
|
| | | boolean state = false;
|
| | | List<String> tips = new ArrayList<String>();
|
| | | String identify = rokenRecord.getIdentify();
|
| | | |
| | |
|
| | | TokenTypeEnum tokenType = rokenRecord.getType();
|
| | | if (tokenType == TokenTypeEnum.freeCoupon) {
|
| | | type = 10;
|
| | |
| | | .selectByPrimaryKey(Long.parseLong(identify));
|
| | | if (giveRecord == null)
|
| | | throw new TokenRecordException(1, "赠送记录不存在");
|
| | | |
| | |
|
| | | Date endTime = giveRecord.getEndTime();
|
| | | // 用户券信息
|
| | | UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId());
|
| | | if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive())
|
| | | throw new TokenRecordException(1, "券不存在或非赠送状态");
|
| | | |
| | | if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE || (endTime != null && endTime.getTime() < now.getTime())) {
|
| | |
|
| | | if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE
|
| | | || (endTime != null && endTime.getTime() < now.getTime())) {
|
| | | tips.add("哎呀,这张免单券已失效了!");
|
| | | } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
|
| | | tips.add("哎呀,这张免单券已被领取了!");
|
| | | } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
|
| | | if (uid == null || uid <= 0)
|
| | | throw new TokenRecordException(1001, "温馨提示,[免单券]需要登录后领取");
|
| | | |
| | |
|
| | | state = true;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | |
| | | .selectByPrimaryKey(Long.parseLong(identify));
|
| | | if (giveRecord == null)
|
| | | throw new TokenRecordException(1, "赠送记录不存在");
|
| | | |
| | |
|
| | | Date endTime = giveRecord.getEndTime();
|
| | | UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(giveRecord.getCouponId());
|
| | | if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive())
|
| | | throw new TokenRecordException(1, "券不存在或非赠送状态");
|
| | | |
| | | |
| | | if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE|| (endTime != null && endTime.getTime() < now.getTime())) {
|
| | |
|
| | | if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE
|
| | | || (endTime != null && endTime.getTime() < now.getTime())) {
|
| | | tips.add("哎呀,这张返利奖励券已失效了!");
|
| | | } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
|
| | | tips.add("哎呀,这张返利奖励券已被领取了!");
|
| | |
| | | throw new TokenRecordException(1, "口令已失效");
|
| | | }
|
| | | } else if (tokenType == TokenTypeEnum.redPack) {
|
| | | if(!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | if (!VersionUtil.greaterThan_2_0_5(platform, version))
|
| | | throw new TokenRecordException(1, "请升级到最新版");
|
| | | |
| | | |
| | |
|
| | | type = 13;
|
| | | RedPackGiveRecord giveRecord = redPackGiveRecordService.selectByPrimaryKey(Long.parseLong(identify));
|
| | | if (giveRecord == null)
|
| | | throw new TokenRecordException(1, "口令已失效");
|
| | | |
| | |
|
| | | Date endTime = giveRecord.getEndTime();
|
| | | // 赠送面额
|
| | | money = giveRecord.getAmount().setScale(2).toString();
|
| | |
|
| | | if(giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE |
| | | if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE
|
| | | || (endTime != null && endTime.getTime() < now.getTime())) {
|
| | | tips.add("哎呀,这个红包已失效了!");
|
| | | } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) {
|
| | |
| | | if (nickName.length() > 6) {
|
| | | nickName = nickName.substring(0, 6) + "...";
|
| | | }
|
| | | |
| | |
|
| | | TokenVO tokenVO = new TokenVO();
|
| | | tokenVO.setAmount(num);
|
| | | tokenVO.setMoney(money);
|
| | |
| | | tokenVO.setType(type);
|
| | | return tokenVO;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public String receiveToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
|
| | |
| | | TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
|
| | | if (rokenRecord == null)
|
| | | throw new TokenRecordException(1, "口令已失效");
|
| | | |
| | |
|
| | | Long uidToken = rokenRecord.getUid();
|
| | | if (uidToken != null && uid.longValue() == uidToken.longValue())
|
| | | throw new TokenRecordException(1, "不能自己赠送给自己");
|
| | | |
| | |
|
| | | Date now = new Date();
|
| | | Date endTimeToken = rokenRecord.getEndTime();
|
| | | if (endTimeToken != null && endTimeToken.getTime() < now.getTime())
|
| | |
| | | if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive()
|
| | | || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE)
|
| | | throw new TokenRecordException(1, "该券不存在或非赠送");
|
| | | |
| | | UserSystemCoupon userSystemCoupon= null;
|
| | |
|
| | | UserSystemCoupon userSystemCoupon = null;
|
| | | try {
|
| | | userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_GIVE, null,true);
|
| | | UserSystemCoupon.SOURCE_GIVE, null, true);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | |
| | | userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
|
| | |
|
| | | integralGetService.addGiveFreeCoupon(giveUid);
|
| | | |
| | |
|
| | | msg = "领取成功[免单券]成功,请到[我的-福利中心]中查看";
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | |
| | | msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
|
| | | msgOther.setReceiveTime(sd.format(new Date()));
|
| | | userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
|
| | | |
| | |
|
| | | // 激活邀请信息
|
| | | if (addTeam)
|
| | | addInviteMsg(uid, giveUid, "免单券");
|
| | | addInviteMsg(uid, giveUid, "免单券");
|
| | | }
|
| | | });
|
| | | } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) {
|
| | |
| | | SystemCoupon systemCoupon = userCoupon.getSystemCoupon();
|
| | | if (systemCoupon == null)
|
| | | throw new TokenRecordException(1, "该券不存在");
|
| | | |
| | |
|
| | | systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
|
| | | if (systemCoupon == null)
|
| | | throw new TokenRecordException(1, "该券不存在");
|
| | | |
| | | UserSystemCoupon userSystemCoupon= null;
|
| | |
|
| | | UserSystemCoupon userSystemCoupon = null;
|
| | | try {
|
| | | userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
|
| | | UserSystemCoupon.SOURCE_GIVE, systemCoupon.getPercent(),true);
|
| | | userSystemCoupon = userSystemCouponService.insertUserCoupon(uid,
|
| | | CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE,
|
| | | systemCoupon.getPercent(), true);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | throw new TokenRecordException(1, "领取失败");
|
| | |
| | | userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
|
| | |
|
| | | integralGetService.addGiveRebateCoupon(giveUid);
|
| | | |
| | |
|
| | | msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看";
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | |
| | | msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
|
| | | msgOther.setReceiveTime(sd.format(new Date()));
|
| | | userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
|
| | | |
| | |
|
| | | // 激活邀请信息
|
| | | if (addTeam)
|
| | | addInviteMsg(uid, giveUid, "返利奖励券");
|
| | | addInviteMsg(uid, giveUid, "返利奖励券");
|
| | | }
|
| | | });
|
| | | } else if (tokenType == TokenTypeEnum.redPack) {
|
| | | if(!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | throw new TokenRecordException(1, "请升级到最新版");
|
| | | |
| | |
|
| | | try {
|
| | | msg = "领取红包成功,请到[我的-红包]中查看";
|
| | | // 领取红包、更新记录
|
| | | RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid, Long.parseLong(identify));
|
| | | RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid,
|
| | | Long.parseLong(identify));
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
|
| | | |
| | |
|
| | | String beiZhu = "无";
|
| | | String giveBeiZhu = "无";
|
| | | if (addTeam) {
|
| | |
| | | // 激活邀请信息
|
| | | addInviteMsg(uid, giveUid, giveRecord.getAmount().setScale(2) + "元红包");
|
| | | }
|
| | | |
| | |
|
| | | // 领取人消息
|
| | | String giveUserName = "无";
|
| | | UserInfo giveuser = userInfoService.selectByPKey(giveUid);
|
| | |
| | | dto.setUserInfo("昵称:" + giveUserName + " ID:" + giveUid);
|
| | | dto.setTime(sd.format(giveRecord.getGiveTime()));
|
| | | dto.setMoney("¥" + giveRecord.getAmount().setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
|
| | | |
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff,
|
| | | new Gson().toJson(dto), beiZhu);
|
| | |
|
| | | // 赠送人消息
|
| | | String userName = "无";
|
| | | UserInfo user = userInfoService.selectByPKey(uid);
|
| | |
| | | givedto.setUserInfo("昵称:" + userName + " ID:" + uid);
|
| | | givedto.setTime(sd.format(new Date()));
|
| | | givedto.setMoney("¥" + giveRecord.getAmount().setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackGiveOff, new Gson().toJson(givedto), giveBeiZhu);
|
| | | userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackGiveOff,
|
| | | new Gson().toJson(givedto), giveBeiZhu);
|
| | | }
|
| | | });
|
| | | } catch (RedPackGiveRecordException e) {
|
| | |
| | | }
|
| | | return invite;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | private void addInviteMsg(Long uid, Long giveUid, String giftName) {
|
| | | try {
|
| | | UserInfo user = userInfoService.selectByPKey(giveUid);
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | |
| | |
|
| | | String inviteCode = null;
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) {
|
| | | inviteCode = userInfoExtra.getInviteCodeVip();
|
| | | } else {
|
| | | inviteCode = userInfoExtra.getInviteCode();
|
| | | }
|
| | | |
| | |
|
| | | MsgInviteContentDTO msgInvite = new MsgInviteContentDTO();
|
| | | msgInvite.setTitle("邀请消息");
|
| | | msgInvite.setState("成功激活邀请");
|
| | | msgInvite.setCode("你的邀请码:" + inviteCode);
|
| | | msgInvite.setInviter("昵称:"+user.getNickName());
|
| | | msgInvite.setInviter("昵称:" + user.getNickName());
|
| | | msgInvite.setMode("成功领取邀请人的" + giftName);
|
| | | userInviteMsgNotificationService.receiveGift(uid, "邀请关系一旦确立无法更改 ", msgInvite);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<TokenRecord> overdueList(int count) {
|
| | | return tokenRecordMapper.overdueList(count);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void overdue(List<TokenRecord> list) {
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | Date date = new Date();
|
| | | for (TokenRecord tokenRecord: list) {
|
| | | for (TokenRecord tokenRecord : list) {
|
| | | tokenRecord.setState(1);
|
| | | tokenRecord.setUpdateTime(date);
|
| | | tokenRecordMapper.updateByPrimaryKeySelective(tokenRecord);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void invalidByRedPack(Long id) {
|
| | | if (id == null)
|
| | | return;
|
| | | |
| | |
|
| | | List<String> list = new ArrayList<String>();
|
| | | list.add(TokenTypeEnum.redPack.name());
|
| | | tokenRecordMapper.invalidByTypeAndIdentify(list, id.toString());
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void invalidByCoupon(Long id) {
|
| | | if (id == null)
|
| | | return;
|
| | | |
| | |
|
| | | List<String> list = new ArrayList<String>();
|
| | | list.add(TokenTypeEnum.freeCoupon.name());
|
| | | list.add(TokenTypeEnum.rebatePercentCoupon.name());
|
| | |
| | | import com.google.gson.Gson;
|
| | | import com.qcloud.cos.model.COSObjectSummary;
|
| | | import com.qcloud.cos.model.ObjectListing;
|
| | | import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | |
| | | private BindingAccountService bindingAccountService;
|
| | |
|
| | | @Resource
|
| | | private UserConnectHistoryMapper userConnectHistoryMapper;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageMapper accountMessageMapper;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.UserConvertLinkTemplateDao;
|
| | | import com.yeshi.fanli.entity.bus.user.UserConvertLinkTemplate;
|
| | | import com.yeshi.fanli.service.inter.user.UserConvertLinkTemplateService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class UserConvertLinkTemplateServiceImpl implements UserConvertLinkTemplateService {
|
| | |
|
| | | @Resource
|
| | | private UserConvertLinkTemplateDao userConvertLinkTemplateDao;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: countByUid
|
| | | * @Description: 根据用户ID统计数量
|
| | | * @param uid
|
| | | * @return |
| | | * long 返回类型
|
| | | * @throws
|
| | | */
|
| | | private long countByUid(Long uid) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("uid").is(uid));
|
| | | return userConvertLinkTemplateDao.count(query);
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: verifyTemplate
|
| | | * @Description: 验证模板内容是否正确
|
| | | * @param template
|
| | | * @param uid
|
| | | * @throws Exception |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | private void verifyTemplate(String template, Long uid) throws Exception {
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | throw new Exception("模板内容不能为空");
|
| | | if (template.length() > 140) {
|
| | | throw new Exception("最长为140个字");
|
| | | }
|
| | |
|
| | | if (template.contains("[邀请码]")) {
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | throw new Exception("用户未激活,模板本不能出现[邀请码]");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserConvertLinkTemplate> listByUid(Long uid) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("uid").is(uid).and("createTime").lte(new Date(System.currentTimeMillis()+1000*60*60*24L)));
|
| | | List<UserConvertLinkTemplate> templateList = userConvertLinkTemplateDao.findList(query);
|
| | | if (templateList != null) {
|
| | | String inviteCode = null;
|
| | | for (UserConvertLinkTemplate userConvertLinkTemplate : templateList) {
|
| | | // 替换邀请码
|
| | | if (userConvertLinkTemplate.getTemplate().contains("[邀请码]")) {
|
| | | if (inviteCode == null)
|
| | | inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | userConvertLinkTemplate
|
| | | .setContent(userConvertLinkTemplate.getTemplate().replace("[邀请码]", inviteCode));
|
| | | }
|
| | | }
|
| | | }
|
| | | return templateList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateTemplate(UserConvertLinkTemplate template) throws Exception {
|
| | |
|
| | | if (template.getId() == null || StringUtil.isNullOrEmpty(template.getTemplate()))
|
| | | throw new Exception("参数不完整");
|
| | |
|
| | | UserConvertLinkTemplate oldTemplate = userConvertLinkTemplateDao.get(template.getId());
|
| | | if (oldTemplate == null)
|
| | | throw new Exception("模板不存在");
|
| | |
|
| | | verifyTemplate(template.getTemplate(), oldTemplate.getUid());
|
| | |
|
| | | oldTemplate.setTemplate(template.getTemplate());
|
| | | oldTemplate.setUpdateTime(new Date());
|
| | | userConvertLinkTemplateDao.save(oldTemplate);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteConvertLinkTemplate(String id, Long uid) throws Exception {
|
| | | UserConvertLinkTemplate template = userConvertLinkTemplateDao.get(id);
|
| | | if (template != null && template.getUid().longValue() != uid)
|
| | | throw new Exception("只能删除属于自己的");
|
| | | userConvertLinkTemplateDao.delete(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addConvertLinkTemplate(UserConvertLinkTemplate template) throws Exception {
|
| | | if (template.getUid() == null || StringUtil.isNullOrEmpty(template.getTemplate()))
|
| | | throw new Exception("参数不完整");
|
| | |
|
| | | int maxCount = 5;
|
| | |
|
| | | // 判断数量
|
| | | long count = countByUid(template.getUid());
|
| | | if (count >= maxCount) {
|
| | | throw new Exception("数量超限");
|
| | | }
|
| | |
|
| | | verifyTemplate(template.getTemplate(), template.getUid());
|
| | |
|
| | | // 添加模板
|
| | | if (template.getCreateTime() == null)
|
| | | template.setCreateTime(new Date());
|
| | |
|
| | | template.setId(template.getUid() + "-"
|
| | | + StringUtil.Md5(UUID.randomUUID().toString() + "#" + System.currentTimeMillis()));
|
| | |
|
| | | userConvertLinkTemplateDao.save(template);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.exception.user.ThreeSaleException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.tb.TaoBaoUnionAuthRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | |
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | @Resource
|
| | | private UserRankService userRankService;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | @Resource
|
| | | private BindingAccountService bindingAccountService;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | |
| | | * @return
|
| | | * @throws TokenRecordException
|
| | | */
|
| | | public TokenVO discernToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException;
|
| | | public TokenVO discernToken(String token, Long uid, String platform,String version) throws TokenRecordException;
|
| | |
|
| | |
|
| | | /**
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserConvertLinkTemplate;
|
| | |
|
| | | /**
|
| | | * 用户文案转链模板服务
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface UserConvertLinkTemplateService {
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: listByUid
|
| | | * @Description: 根据用户ID检索
|
| | | * @param uid
|
| | | * @return |
| | | * List<UserConvertLinkTemplate> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public List<UserConvertLinkTemplate> listByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: updateTemplate
|
| | | * @Description: 更新模板
|
| | | * @param template |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void updateTemplate(UserConvertLinkTemplate template) throws Exception;
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: deleteConvertLinkTemplate
|
| | | * @Description: 删除模板
|
| | | * @param id
|
| | | * @param uid
|
| | | * @throws Exception |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void deleteConvertLinkTemplate(String id, Long uid) throws Exception;
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: addConvertLinkTemplate
|
| | | * @Description: 添加模板
|
| | | * @param template
|
| | | * @throws Exception |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void addConvertLinkTemplate(UserConvertLinkTemplate template) throws Exception;
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger;
|
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.douyin.DouYinGoods;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.user.TokenRecordException;
|
| | | import com.yeshi.fanli.service.inter.user.TokenRecordService;
|
| | | import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager;
|
| | | import com.yeshi.fanli.util.DouYinUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TokenUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | 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;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.msg.TokenVO;
|
| | | import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 粘贴板解析
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Component
|
| | | public class ClipboardAnalysisManager {
|
| | |
|
| | | @Resource
|
| | | private JDGoodsLinkParseManager jdGoodsLinkParseManager;
|
| | |
|
| | | @Resource
|
| | | private TokenRecordService tokenRecordService;
|
| | |
|
| | | /**
|
| | | * @Title: parseContentType
|
| | | * @Description: 解析文本的类型
|
| | | * @param text
|
| | | * @return |
| | | * Set<ClipboardContentType> 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static Set<ClipboardContentType> parseContentType(String originText) {
|
| | | Set<ClipboardContentType> typeSet = new HashSet<>();
|
| | | StringBuffer textBuffer = new StringBuffer(originText);
|
| | | String text = textBuffer.toString();
|
| | | // 自有口令
|
| | | String parseToken = TokenUtil.parseToken(text);
|
| | | if (!StringUtil.isNullOrEmpty(parseToken)) {
|
| | | typeSet.add(ClipboardContentType.systemToken);
|
| | | text = text.replace(parseToken, "");
|
| | | }
|
| | |
|
| | | // 链接
|
| | | 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(text);
|
| | | while (matcher.find()) {
|
| | | String url = matcher.group();
|
| | | if (!StringUtil.isNullOrEmpty(url)) {
|
| | | typeSet.add(ClipboardContentType.link);
|
| | | text = text.replace(url, "");
|
| | | }
|
| | | }
|
| | |
|
| | | // 淘口令
|
| | | List<String> taoBaoTokenList = TaoBaoUtil.getTokenListFromText(text);
|
| | | if (taoBaoTokenList != null && taoBaoTokenList.size() > 0) {
|
| | | typeSet.add(ClipboardContentType.taoBaoToken);
|
| | | for (String token : taoBaoTokenList) {
|
| | | text = text.replace(token, "");
|
| | | }
|
| | | }
|
| | |
|
| | | // 文本
|
| | | if (text != null && text.trim().length() > 0) {
|
| | | typeSet.add(ClipboardContentType.text);
|
| | | }
|
| | |
|
| | | return typeSet;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: parse
|
| | | * @Description: 解析
|
| | | * @param text
|
| | | * @param typeSet |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | public void parse(String platform, String version, String text, Long uid, IClipboardAnalysisResult resultListener) {
|
| | | if (text == null)
|
| | | return;
|
| | | text = text.trim();
|
| | |
|
| | | Set<ClipboardContentType> typeSet = parseContentType(text);
|
| | |
|
| | | // 系统口令
|
| | | if (typeSet.contains(ClipboardContentType.systemToken)) {
|
| | | try {
|
| | | TokenVO tokenVO = tokenRecordService.discernToken(text, uid, platform, version);
|
| | | resultListener.onResult(tokenVO);
|
| | | } catch (TokenRecordException e) {
|
| | | if (e.getCode() == 1001) { // 需要用户登录
|
| | | resultListener.needLogin(e.getMsg());
|
| | | } else {
|
| | | resultListener.none();
|
| | | }
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | // 只有链接 淘宝链接/京东链接/拼多多链接
|
| | | if (typeSet.size() == 1) {
|
| | | if (typeSet.contains(ClipboardContentType.link)) {// 纯链接
|
| | | // 解析商品
|
| | | CommonGoods goods = parseLink(text);
|
| | | if (goods == null) {
|
| | | resultListener.none();
|
| | | } else {
|
| | | resultListener.onResult(goods);
|
| | | }
|
| | |
|
| | | } else if (typeSet.contains(ClipboardContentType.taoBaoToken)) {// 纯淘口令
|
| | |
|
| | | try {
|
| | | CommonGoods commonGoods = parseTaoBaoToken(text);
|
| | | if (commonGoods != null)
|
| | | resultListener.onResult(commonGoods);
|
| | | else
|
| | | resultListener.onResult(text);
|
| | |
|
| | | } catch (TaoBaoTokenParseException e1) {
|
| | | resultListener.onResult(text);
|
| | | }
|
| | |
|
| | | } else {// 纯文本
|
| | | // 文本推荐
|
| | | if (text.length() > 256)
|
| | | resultListener.none();
|
| | | else
|
| | | resultListener.onResult(text);
|
| | | }
|
| | | } else if (typeSet.size() == 2) {
|
| | | List<String> urlList = HttpUtil.getUrlListFromText(text);
|
| | | List<String> tokenList = TaoBaoUtil.getTokenListFromText(text);
|
| | |
|
| | | String link = null;
|
| | | String token = null;
|
| | |
|
| | | if (typeSet.contains(ClipboardContentType.link) && typeSet.contains(ClipboardContentType.taoBaoToken)) {// 链接+口令
|
| | | if (text.indexOf(urlList.get(0)) < text.indexOf(tokenList.get(0)))// 第一个链接在第一个口令前面
|
| | | link = urlList.get(0);
|
| | | else// 第一个口令在第一个链接前面
|
| | | token = tokenList.get(0);
|
| | |
|
| | | } else if (typeSet.contains(ClipboardContentType.link) && typeSet.contains(ClipboardContentType.text)) {// 链接+文本
|
| | | link = urlList.get(0);
|
| | |
|
| | | } else {// 口令+文本
|
| | | token = tokenList.get(0);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | CommonGoods goods = parseLink(urlList.get(0));
|
| | | if (goods == null || goods.getGoodsId() == null) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
|
| | | } else {
|
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | } else {
|
| | | resultListener.onResult(goods);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | CommonGoods goods = null;
|
| | | try {
|
| | | goods = parseTaoBaoToken(token);
|
| | | } catch (TaoBaoTokenParseException e) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text));
|
| | | return;
|
| | | }
|
| | | if (goods != null && goods.getGoodsId() != null) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | } else {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | } else if (typeSet.size() == 3) {// 口令+链接+文本
|
| | | List<String> tokenList = TaoBaoUtil.getTokenListFromText(text);
|
| | | List<String> urlList = HttpUtil.getUrlListFromText(text);
|
| | | if (text.startsWith("【") && tokenList != null && tokenList.size() == 1 && urlList != null
|
| | | && urlList.size() == 1) {// Android淘宝链接复制
|
| | | CommonGoods goods = null;
|
| | | try {
|
| | | goods = parseTaoBaoToken(tokenList.get(0));
|
| | | } catch (TaoBaoTokenParseException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | if (goods == null) {
|
| | | if (text.trim().indexOf("【") == 0 && text.trim().indexOf("】") > 0) {
|
| | | // 截取标题
|
| | | String title = text.trim().substring(1, text.trim().lastIndexOf("】"));
|
| | | goods = new CommonGoods();
|
| | | goods.setTitle(title);
|
| | | goods.setPicture("http://");
|
| | | }
|
| | | }
|
| | |
|
| | | if (goods != null) {
|
| | | resultListener.onResult(goods);
|
| | | }
|
| | |
|
| | | } else {// 文案
|
| | |
|
| | | String link = null;
|
| | | String token = null;
|
| | |
|
| | | if (text.indexOf(urlList.get(0)) < text.indexOf(tokenList.get(0)))// 第一个链接在第一个口令前面
|
| | | link = urlList.get(0);
|
| | | else// 第一个口令在第一个链接前面
|
| | | token = tokenList.get(0);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(link)) {
|
| | | CommonGoods goods = parseLink(urlList.get(0));
|
| | | if (goods == null || goods.getGoodsId() == null) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, urlList.get(0)));
|
| | | } else {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | }
|
| | | } else {
|
| | | CommonGoods goods = null;
|
| | | try {
|
| | | goods = parseTaoBaoToken(token);
|
| | | if (goods != null && goods.getGoodsId() != null) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text, goods));
|
| | | } else {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text));
|
| | | }
|
| | | } catch (TaoBaoTokenParseException e) {
|
| | | resultListener.onResult(new GoodsDocParseResultVO(text));
|
| | | }
|
| | | }
|
| | | }
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: parseLink
|
| | | * @Description: 解析单链接
|
| | | * @param link
|
| | | * @return |
| | | * CommonGoods 返回类型
|
| | | * @throws
|
| | | */
|
| | | public CommonGoods parseLink(String link) {
|
| | |
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | if (link.startsWith("https://a.m.taobao.com/i"))// 淘宝账号未登录状态
|
| | | {
|
| | | link = link.substring("https://a.m.taobao.com/i".length(), link.indexOf(".htm"));
|
| | | if (NumberUtil.isNumeric(link)) {
|
| | | tb = TaoBaoUtil.isAlimama(link);
|
| | | }
|
| | | } else if (link.contains("ju.taobao.com") || link.contains(".juhuasuan.com")) {// 聚划算
|
| | | int index = link.indexOf("item_id");
|
| | | if (index >= 0) {
|
| | | link = link.substring(index);
|
| | | int last = link.indexOf("&");
|
| | | String id = "";
|
| | | if (last > 0)
|
| | | id = link.substring(link.indexOf("=") + 1, link.indexOf("&"));
|
| | | else {
|
| | | id = link.substring(link.indexOf("=" + 1));
|
| | | }
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(id));
|
| | | }
|
| | | }
|
| | | } else if (link.contains("http://zmnxbc.com")) { // 手机端天猫APP分享
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTM(link);
|
| | | } else if (link.contains("h5.m.taobao") || link.contains("detail.m.tmall") || link.contains("item.taobao")
|
| | | || link.contains("detail.tmall")) { // 手机页面和电脑页面
|
| | | Map<String, String> map = Utils.parseURL(link);
|
| | | String id = "";
|
| | | id = map.get("id").replace("}", "");
|
| | | tb = TaoBaoUtil.isAlimama(id);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(id));
|
| | | }
|
| | | } else if (link.contains("v.douyin.com")) { // 抖音
|
| | | tb = analysisDouYin(link);
|
| | | if (tb != null) {
|
| | | if (!StringUtil.isNullOrEmpty(tb.getAuctionUrl())) {// 抖音解析到淘宝商品链接
|
| | | return parseLink(tb.getAuctionUrl());
|
| | | }
|
| | | }
|
| | | } else {
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTB(link);
|
| | | }
|
| | |
|
| | | // 没解析到淘宝相关商品
|
| | | if (tb == null) {
|
| | | String goodsId = TaoBaoUtil.getGoodsIdByPhoneShareUrl(link);
|
| | | if (!StringUtil.isNullOrEmpty(goodsId)) {
|
| | | tb = TaoBaoUtil.isAlimama(goodsId);
|
| | | if (tb == null) {
|
| | | tb = new TaoBaoGoodsBrief(Long.parseLong(goodsId));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | CommonGoods commonGoods = null;
|
| | |
|
| | | // 淘宝商品解析结束
|
| | | if (tb != null) {
|
| | | if (StringUtil.isNullOrEmpty(tb.getTitle())) {
|
| | | tb = TaoBaoUtil.getTaoBaoGoodsBriefNotInPub(tb.getId());
|
| | | if (tb != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setPicture(tb.getPictUrl());
|
| | | commonGoods.setTitle(tb.getTitle());
|
| | | }
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(tb);
|
| | | }
|
| | | } else {
|
| | | // 解析其他商品
|
| | | String jdId = JDUtil.getJDGoodsId(link);
|
| | |
|
| | | // 微信链接
|
| | | if (StringUtil.isNullOrEmpty(jdId)) {
|
| | | jdId = JDUtil.getJDGoodsIdByWeiXin(link);
|
| | | }
|
| | |
|
| | | // 领券短连接
|
| | | if (StringUtil.isNullOrEmpty(jdId) && link.contains("u.jd.com")) {
|
| | | jdId = jdGoodsLinkParseManager.parseGoodsIdByJDShortUrl(link);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null) {
|
| | | // 高级接口 -- 信息更完整
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
|
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | } else {
|
| | | goods = JDUtil.getSimpleGoodsInfo(jdId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getSkuName());
|
| | | commonGoods.setPicture(goods.getPicUrl());
|
| | | }
|
| | | }
|
| | | } else {
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(link);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getGoodsName());
|
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return commonGoods;
|
| | | }
|
| | |
|
| | | private CommonGoods parseTaoBaoToken(String token) throws TaoBaoTokenParseException {
|
| | |
|
| | | Long auctionId = TaoKeApiUtil.tokenConvertAuctionId(token);
|
| | | if (auctionId != null) {//
|
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.isAlimama(auctionId + "");
|
| | | if (goods == null) {
|
| | | goods = TaoBaoUtil.getTaoBaoGoodsBriefNotInPub(auctionId);
|
| | | }
|
| | | if (goods != null) {
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(goods);
|
| | | return commonGoods;
|
| | | } else
|
| | | return null;
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @Title: analysisDouYin
|
| | | * @Description: 抖音解析
|
| | | * @param link
|
| | | * @return |
| | | * CommonGoods 返回类型
|
| | | * @throws
|
| | | */
|
| | | private TaoBaoGoodsBrief analysisDouYin(String link) {
|
| | | String location = HttpUtil.getLocation(link);
|
| | | if (!StringUtil.isNullOrEmpty(location)) {
|
| | | if (location.contains("taobao.com")) { // 淘宝商品
|
| | | String realUrl = TaoBaoUtil.getRealUrl(location);
|
| | | if (!StringUtil.isNullOrEmpty(realUrl)) {
|
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
|
| | | goods.setAuctionUrl(realUrl);
|
| | | return goods;
|
| | | }
|
| | | } else if (location.contains("haohuo.jinritemai.com")) { // 抖音商品
|
| | | DouYinGoods goods = DouYinUtil.getGoodsInfo(location);
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", goods.getName());
|
| | | goodsJSON.put("pictUrl", goods.getImg());
|
| | |
|
| | | TaoBaoGoodsBrief commonGoods = new TaoBaoGoodsBrief();
|
| | | commonGoods.setPictUrl(goods.getImg());
|
| | | commonGoods.setTitle(goods.getName());
|
| | | return commonGoods;
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 粘贴板解析结果
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger;
|
| | |
|
| | | /**
|
| | | * 粘贴板的内容类型
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public enum ClipboardContentType {
|
| | |
|
| | | systemToken("自有口令"), text("文本"), link("链接"), taoBaoToken("淘口令");
|
| | |
|
| | | private String desc;
|
| | |
|
| | | private ClipboardContentType(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.manger;
|
| | |
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.vo.msg.TokenVO;
|
| | | import com.yeshi.fanli.vo.search.GoodsDocParseResultVO;
|
| | |
|
| | | /**
|
| | | * 粘贴板解析接口
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface IClipboardAnalysisResult {
|
| | | // 系统口令解析结果
|
| | | public void onResult(TokenVO tokenVO);
|
| | |
|
| | | // 商品解析结果
|
| | | public void onResult(CommonGoods goods);
|
| | |
|
| | | // 标题解析结果
|
| | | public void onResult(String result);
|
| | |
|
| | | // 文案解析结果
|
| | | public void onResult(GoodsDocParseResultVO result);
|
| | |
|
| | | // 需要登录
|
| | | public void needLogin(String msg);
|
| | |
|
| | | // 无结果
|
| | | public void none();
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | return newText;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建口令
|
| | | * @Title: createTaoBaoToken
|
| | | * @Description: |
| | | * @param uid 用户ID
|
| | | * @param picturl |
| | | * @param title
|
| | | * @param link
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public String createTaoBaoToken(Long uid, String picturl, String title, String link) {
|
| | |
|
| | | String token = TaoKeApiUtil.getTKToken(picturl, title, link);
|
| | | if (!StringUtil.isNullOrEmpty(token)) {
|
| | | // 缓存30分钟
|
| | | redisManager.cacheCommonString(
|
| | | RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoUserTKToken, uid + "-" + StringUtil.Md5(token)), "1",
|
| | | 60 * 30);
|
| | | }
|
| | | return token;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.DeviceSexDao;
|
| | |
|
| | | public enum RedisKeyEnum {
|
| | | emptyKey("", "空值-key外部空值"),
|
| | | SMS("sms-", "短信"),
|
| | |
| | | taobaoTokenCommon("taobao-common-token-", "淘宝口令"),
|
| | | taobaoTokenTLJ("taobao-tlj-token-", "淘礼金的口令"),
|
| | | taobaoCoupleXCX("taobao-couple-xcx-", "淘宝券"),
|
| | | taobaoUserTKToken("taobao-user-token-","用户的淘口令"),
|
| | | taobaoCachecoupon("cachecoupon-", "淘宝券商品列表"),
|
| | | taobaolinkParse("linkParse-", "获取淘宝推广链接"),
|
| | | taobaoUpdate("tb-u-", "淘宝商品更新"),
|
| | |
| | | PDDOrder("pdd-order-", "拼多多订单"),
|
| | | hongBaoFanLi("hongbao-fanli-", "红包返利"),
|
| | |
|
| | | deviceSex(" device_sex-", "设备性别版本");
|
| | | deviceSex("device_sex-", "设备性别版本"),
|
| | | |
| | | convertLinkDocTemp("convert-link-doc-temp-","转链文本暂存"),
|
| | | convertLinkDocResultTemp("convert-link-doc-result-temp-","转链文本结果暂存")
|
| | | |
| | | ;
|
| | |
|
| | | private final String key;
|
| | | private final String desc;
|
| | |
| | | return str;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 淘口令提取
|
| | | * |
| | | * @param str
|
| | | * @return
|
| | | */
|
| | | public static String picUpTaoToken(String str) {
|
| | | String pattern = "(₳{1}[A-Za-z0-9]+₳{1})|(¥{1}[A-Za-z0-9]+¥{1})|(¥{1}[A-Za-z0-9]+¥{1})";
|
| | | Pattern r = Pattern.compile(pattern);
|
| | | Matcher m = r.matcher(str);
|
| | | while (m.find()) {
|
| | | String group = m.group(0);
|
| | | if (!StringUtil.isNullOrEmpty(group))
|
| | | return group;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
| | | else
|
| | | return false;
|
| | | }
|
| | | |
| | | public static boolean greaterThan_2_0_7(String platform, String versionCode) {
|
| | | if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 55))
|
| | | || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 77)))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | | public static boolean smallerThan_1_5_1(String platform, String versionCode) {
|
| | | if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) < 36))
|
| | |
| | | goodsInfo.setState(goods.getState() == null ? 0 : goods.getState());
|
| | | goodsInfo.setSalesCount(goods.getSalesCount());
|
| | | goodsInfo.setPicUrl(goods.getPictUrl());
|
| | | goodsInfo.setDescription(goods.getDescription());
|
| | |
|
| | | Integer shopType = goods.getUserType();
|
| | | if (shopType != null && shopType == 1) {
|
| | |
| | | goodsInfo.setTitle(goods.getTitle());
|
| | | goodsInfo.setSalesType(1); // 默认月销量
|
| | | goodsInfo.setZkPrice(goods.getZkPrice());
|
| | | goodsInfo.setDescription(goods.getDescription());
|
| | |
|
| | | String provcity = goods.getProvcity();
|
| | | if (!StringUtil.isNullOrEmpty(provcity)) {
|
| | |
| | | String as = gm.getResponseBodyAsString();
|
| | | JSONObject root = JSONObject.fromObject(as);
|
| | | if (root.optInt("code") == 0) {// 上报成功
|
| | | LogHelper.cookieLog("上报成功!");
|
| | | LogHelper.error("上报成功!");
|
| | | return;
|
| | | }
|
| | | LogHelper.cookieLog("上报失败!");
|
| | | LogHelper.error("上报失败!");
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.cookieLog("上报失败!");
|
| | | LogHelper.error("上报失败!");
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | public static List<TaoBaoOrder> getOrderList(int day, TaoBaoUnionConfig config) {
|
| | | String cookie1 = getTaoBaoCookie(config.getAccount());
|
| | |
|
| | | LogHelper.cookieLog("账号为:" + config.getAccount() + ",cookie为:" + cookie1);
|
| | | LogHelper.error("账号为:" + config.getAccount() + ",cookie为:" + cookie1);
|
| | |
|
| | | String[] cookies = new String[] { cookie1 };
|
| | | List<TaoBaoOrder> list = new ArrayList<TaoBaoOrder>();
|
| | |
| | | private static List<TaoBaoOrder> downLoadOrderFromTaoBao(String url, TaoBaoUnionConfig config)
|
| | | throws TaoBaoOrderException {
|
| | | String cookie1 = getTaoBaoCookie(config.getAccount());
|
| | | LogHelper.cookieLog("账号为:" + config.getAccount() + ",cookie为:" + cookie1);
|
| | | LogHelper.error("账号为:" + config.getAccount() + ",cookie为:" + cookie1);
|
| | | String[] cookies = new String[] { cookie1 };
|
| | | List<TaoBaoOrder> list = new ArrayList<TaoBaoOrder>();
|
| | | int i = 0;
|
| | |
| | | import java.net.URLDecoder;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
| | | import org.apache.commons.httpclient.methods.GetMethod;
|
| | | import org.apache.commons.httpclient.params.HttpMethodParams;
|
| | | import org.hibernate.cache.spi.NaturalIdCacheKey;
|
| | | import org.jsoup.Connection;
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | |
| | | return tg;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief getTaoBaoGoodsBrief(String id) {
|
| | | Map<String, String> params = new HashMap<String, String>();
|
| | | params.put("q", String.format("http://item.taobao.com/item.htm?id=%s", id));
|
| | | params.put("_t", System.currentTimeMillis() + "");
|
| | | params.put("auctionTag", "");
|
| | | params.put("perPageSize", 40 + "");
|
| | | params.put("t", System.currentTimeMillis() + "");
|
| | | String result = TaoBaoHttpUtil.get(SEARCH_URL, params);
|
| | | result = result.replace("</span>", "").replace("<span class=H>", "");
|
| | | TaoBaoSearchResult presult = parseTaoBao(result);
|
| | | if (presult != null && presult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | // TaoBaoGoodsBrief taoBaoGoodsBrief =
|
| | | // presult.getTaoBaoGoodsBriefs().get(0);
|
| | |
|
| | | return presult.getTaoBaoGoodsBriefs().get(0);
|
| | | } else
|
| | | return null;
|
| | | /**
|
| | | * 获取未参与推广的淘宝商品详情
|
| | | * @Title: getTaoBaoGoodsBrief
|
| | | * @Description: |
| | | * @param id
|
| | | * @return |
| | | * TaoBaoGoodsBrief 包含(标题与图片)
|
| | | * @throws
|
| | | */
|
| | | public static TaoBaoGoodsBrief getTaoBaoGoodsBriefNotInPub(Long id) {
|
| | | TaoBaoGoodsBrief tb = TaoBaoUtil.getTmallGoodsInfo(id+"");
|
| | | return tb;
|
| | | }
|
| | |
|
| | | public static List<String> getSuguestSearch(String key) {
|
| | |
| | | * @throws
|
| | | */
|
| | | public static List<String> getTokenListFromText(String str) {
|
| | | String pattern = "(₳{1}[A-Za-z0-9]+₳{1})|(¥{1}[A-Za-z0-9]+¥{1})|(¥{1}[A-Za-z0-9]+¥{1})|(€{1}[A-Za-z0-9]+€{1})";
|
| | | String[] marks = new String[] { "₳", "¥", "¥", "€", "\\$", "₴", "¢", "₤" };
|
| | |
|
| | | return getTokenListFromText(str, Arrays.asList(marks));
|
| | | }
|
| | |
|
| | | public static List<String> getTokenListFromText(String str, List<String> markList) {
|
| | | List<String> expressList = new ArrayList<>();
|
| | | for (String st : markList) {
|
| | | expressList.add(String.format("(%s{1}[A-Za-z0-9]{11,13}+%s{1})", st, st));
|
| | | }
|
| | | String pattern = StringUtil.concat(expressList, "|");
|
| | | Pattern r = Pattern.compile(pattern);
|
| | | Matcher m = r.matcher(str);
|
| | | List<String> urlList = new ArrayList<>();
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoAuthException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(item.optString("reserve_price")))
|
| | | goods.setReservePrice(new BigDecimal(item.optString("reserve_price")));
|
| | | goods.setTotalFee(new BigDecimal("0"));
|
| | | // 推荐语
|
| | | goods.setDescription(item.optString("item_description"));
|
| | |
|
| | | goods = loadYuShouInfo(goods, item);
|
| | | return goods;
|
| | | }
|
| | |
| | | * @param idfa
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoSearchResult guessDeviceLike(int page, int pageSize, String imei, String idfa) {
|
| | | public static TaoBaoSearchResult guessDeviceLike(int page, int pageSize, String imei, String idfa, String utdid) {
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.optimus.material");
|
| | | map.put("page_no", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | map.put("material_id", "6708");
|
| | | if (StringUtil.isNullOrEmpty(imei) && StringUtil.isNullOrEmpty(idfa))
|
| | | if (StringUtil.isNullOrEmpty(imei) && StringUtil.isNullOrEmpty(idfa) && StringUtil.isNullOrEmpty(utdid))
|
| | | return null;
|
| | | map.put("device_encrypt", "MD5");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(imei)) {
|
| | | map.put("device_encrypt", "MD5");
|
| | | map.put("device_value", StringUtil.Md5(imei));
|
| | | map.put("device_type", "IMEI");
|
| | | } else {
|
| | | } else if (!StringUtil.isNullOrEmpty(idfa)) {
|
| | | map.put("device_encrypt", "MD5");
|
| | | map.put("device_value", StringUtil.Md5(idfa));
|
| | | map.put("device_type", "IDFA");
|
| | | } else if (!StringUtil.isNullOrEmpty(utdid)) {
|
| | | map.put("device_value", utdid);
|
| | | map.put("device_type", "UTDID");
|
| | | }
|
| | |
|
| | | JSONObject resultJSON = null;
|
| | |
| | | * @param token
|
| | | * @return
|
| | | */
|
| | | public static Long tokenConvertAuctionId(String token) {
|
| | | public static Long tokenConvertAuctionId(String token) throws TaoBaoTokenParseException {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.tpwd.convert");
|
| | | map.put("password_content", token);
|
| | |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | |
|
| | | try {
|
| | | return json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data").optLong("num_iid");
|
| | | } catch (Exception e) {
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | JSONObject msg = null;
|
| | | try {
|
| | | msg = JSONObject.fromObject(e.getMsg());
|
| | | } catch (Exception e2) {
|
| | | }
|
| | | if (msg != null && msg.optJSONObject("error_response") != null) {
|
| | | throw new TaoBaoTokenParseException(msg.optJSONObject("error_response").optInt("sub_code"),
|
| | | msg.optJSONObject("error_response").optString("sub_msg"));
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId,int count) {
|
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId, int count) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.optimus.material");
|
| | | map.put("item_id", auctionId + "");
|
New file |
| | |
| | | package com.yeshi.fanli.vo.common;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class JumpDetailContentVO {
|
| | |
|
| | | @Expose
|
| | | private JumpDetailV2 jumpDetail;
|
| | | @Expose
|
| | | private JSONObject params;
|
| | |
|
| | | public JumpDetailV2 getJumpDetail() {
|
| | | return jumpDetail;
|
| | | }
|
| | |
|
| | | public void setJumpDetail(JumpDetailV2 jumpDetail) {
|
| | | this.jumpDetail = jumpDetail;
|
| | | }
|
| | |
|
| | | public JSONObject getParams() {
|
| | | return params;
|
| | | }
|
| | |
|
| | | public void setParams(JSONObject params) {
|
| | | this.params = params;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | private boolean baoyou; // 是否包邮
|
| | | @Expose
|
| | | private String provcity; // 商品所在地
|
| | | @Expose
|
| | | private String description;//推荐语
|
| | |
|
| | | public String getDescription() {
|
| | | return description;
|
| | | }
|
| | |
|
| | | public void setDescription(String description) {
|
| | | this.description = description;
|
| | | }
|
| | |
|
| | | public Long getGoodsId() {
|
| | | return goodsId;
|
New file |
| | |
| | | package com.yeshi.fanli.vo.goods;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | /**
|
| | | * 分享商品的评论文本选择信息
|
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class ShareGoodsCommentChoiceInfo {
|
| | |
|
| | | public final static int TYPE_TOKEN = 1;// 口令
|
| | | public final static int TYPE_LINK = 2;// 购买链接
|
| | | public final static int TYPE_INVITE_CODE = 3;// 邀请码
|
| | | public final static int TYPE_DOWNLOAD_LINK = 4;// 下载链接
|
| | | public final static int TYPE_FANLI_MONEY = 5;// 返利金额
|
| | |
|
| | | @Expose
|
| | | private int type;// 类型
|
| | | @Expose
|
| | | private String name;// 名称
|
| | | @Expose
|
| | | private String content;// 内容
|
| | | @Expose
|
| | | private boolean selected;// 是否选中
|
| | | @Expose
|
| | | private boolean canCancel;// 是否可取消
|
| | |
|
| | | public boolean isCanCancel() {
|
| | | return canCancel;
|
| | | }
|
| | |
|
| | | public void setCanCancel(boolean canCancel) {
|
| | | this.canCancel = canCancel;
|
| | | }
|
| | |
|
| | | public ShareGoodsCommentChoiceInfo() {
|
| | |
|
| | | }
|
| | |
|
| | | public ShareGoodsCommentChoiceInfo(int type, String name, String content, boolean selected, boolean canCancel) {
|
| | | this.type = type;
|
| | | this.name = name;
|
| | | this.content = content;
|
| | | this.selected = selected;
|
| | | this.canCancel = canCancel;
|
| | | }
|
| | |
|
| | | public boolean isSelected() {
|
| | | return selected;
|
| | | }
|
| | |
|
| | | public void setSelected(boolean selected) {
|
| | | this.selected = selected;
|
| | | }
|
| | |
|
| | | public int getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(int type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getName() {
|
| | | return name;
|
| | | }
|
| | |
|
| | | public void setName(String name) {
|
| | | this.name = name;
|
| | | }
|
| | |
|
| | | public String getContent() {
|
| | | return content;
|
| | | }
|
| | |
|
| | | public void setContent(String content) {
|
| | | this.content = content;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Expose
|
| | | private String wxErCode;// 微信二维码内容
|
| | | |
| | |
|
| | | @Expose
|
| | | private GoodsDetailVO goodsInfo;
|
| | |
|
| | | // 评论文本
|
| | | @Expose
|
| | | private String commentText;
|
| | | // 评论文本选择项
|
| | | @Expose
|
| | | private List<ShareGoodsCommentChoiceInfo> commentTextChoiceList;
|
| | |
|
| | | // 推荐语
|
| | | @Expose
|
| | | private String recommendText;
|
| | |
|
| | | public List<ShareGoodsCommentChoiceInfo> getCommentTextChoiceList() {
|
| | | return commentTextChoiceList;
|
| | | }
|
| | |
|
| | | public void setCommentTextChoiceList(List<ShareGoodsCommentChoiceInfo> commentTextChoiceList) {
|
| | | this.commentTextChoiceList = commentTextChoiceList;
|
| | | }
|
| | |
|
| | | public String getCommentText() {
|
| | | return commentText;
|
| | | }
|
| | |
|
| | | public void setCommentText(String commentText) {
|
| | | this.commentText = commentText;
|
| | | }
|
| | |
|
| | | public String getRecommendText() {
|
| | | return recommendText;
|
| | | }
|
| | |
|
| | | public void setRecommendText(String recommendText) {
|
| | | this.recommendText = recommendText;
|
| | | }
|
| | |
|
| | | public GoodsDetailVO getGoodsInfo() {
|
| | | return goodsInfo;
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.search;
|
| | |
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | |
|
| | | //商品文案解析结果
|
| | | public class GoodsDocParseResultVO {
|
| | | private String sourceDoc;// 原始文案
|
| | | private CommonGoods firstGoods;// 第一个商品
|
| | | private String firstLink;// 第一个链接
|
| | |
|
| | | public GoodsDocParseResultVO(String sourceDoc, CommonGoods firstGoods) {
|
| | | this.sourceDoc = sourceDoc;
|
| | | this.firstGoods = firstGoods;
|
| | | }
|
| | |
|
| | | public GoodsDocParseResultVO(String sourceDoc, String firstLink) {
|
| | | this.sourceDoc = sourceDoc;
|
| | | this.firstLink = firstLink;
|
| | | }
|
| | |
|
| | | public GoodsDocParseResultVO(String sourceDoc) {
|
| | | }
|
| | |
|
| | | public String getSourceDoc() {
|
| | | return sourceDoc;
|
| | | }
|
| | |
|
| | | public void setSourceDoc(String sourceDoc) {
|
| | | this.sourceDoc = sourceDoc;
|
| | | }
|
| | |
|
| | | public CommonGoods getFirstGoods() {
|
| | | return firstGoods;
|
| | | }
|
| | |
|
| | | public void setFirstGoods(CommonGoods firstGoods) {
|
| | | this.firstGoods = firstGoods;
|
| | | }
|
| | |
|
| | | public String getFirstLink() {
|
| | | return firstLink;
|
| | | }
|
| | |
|
| | | public void setFirstLink(String firstLink) {
|
| | | this.firstLink = firstLink;
|
| | | }
|
| | | }
|
| | |
| | | import java.net.URL;
|
| | | import java.net.URLEncoder;
|
| | | import java.security.KeyStore;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | import javax.net.ssl.SSLContext;
|
| | |
|
| | |
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class HttpUtil {
|
| | |
|
| | | public static List<String> getUrlListFromText(String text) {
|
| | | List<String> urlList = new ArrayList<String>();
|
| | | // 链接
|
| | | 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(text);
|
| | | while (matcher.find()) {
|
| | | String url = matcher.group();
|
| | | if (!StringUtil.isNullOrEmpty(url)) {
|
| | | urlList.add(url);
|
| | | }
|
| | | }
|
| | | return urlList;
|
| | | }
|
| | |
|
| | | public static String getHost(String host) {
|
| | | try {
|
| | |
| | | }
|
| | | return "";
|
| | | }
|
| | | |
| | |
|
| | | @SuppressWarnings("deprecation")
|
| | | public static String post(String url, String entity,String charset) {
|
| | | public static String post(String url, String entity, String charset) {
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod method = new PostMethod(url);
|
| | | method.addRequestHeader("Content-Type", "text/html;charset="+charset);
|
| | | method.setRequestHeader("Content-Type", "text/html;charset="+charset);
|
| | | method.addRequestHeader("Content-Type", "text/html;charset=" + charset);
|
| | | method.setRequestHeader("Content-Type", "text/html;charset=" + charset);
|
| | | method.setRequestBody(entity);
|
| | | try {
|
| | | client.executeMethod(method);
|
| | |
| | |
|
| | | return result;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取post返回location
|
| | | * @param url
|
| | |
| | | PostMethod method = new PostMethod(url);
|
| | | try {
|
| | | client.executeMethod(method);
|
| | | return method.getResponseHeader("location").getValue();
|
| | | return method.getResponseHeader("location").getValue();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | |
| | | }
|
| | |
|
| | | public static String loadJSONP(String callback, String data) {
|
| | | return callback + "(" + data + ")";
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | return data;
|
| | | else
|
| | | return callback + "(" + data + ")";
|
| | | }
|
| | |
|
| | | public static String loadFalseResult(int code, String error) {
|