New file |
| | |
| | | package com.yeshi.fanli.controller.admin.config; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/v1/pddauth") |
| | | public class PDDAuthAdminController { |
| | | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | |
| | | @RequestMapping("getAuthLink") |
| | | public void getAuthLink(AdminAcceptData acceptData, Long uid, String callback, PrintWriter out) { |
| | | if (uid == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户ID为空")); |
| | | } |
| | | |
| | | try { |
| | | String link = pddAuthService.createPDDAuthLink(uid, PinDuoDuoApiUtil.PID_FANLI); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(link)); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage())); |
| | | } |
| | | } |
| | | } |
| | |
| | |
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | import com.yeshi.fanli.entity.SystemFunction;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.*;
|
| | | import org.json.simple.JSONArray;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private PDDAuthService pddAuthService;
|
| | |
|
| | | private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) {
|
| | | UserLevelEnum level = UserLevelEnum.daRen;
|
| | |
| | | if (couponInfo != null) {
|
| | | // 券链接处理
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),null,
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null,
|
| | | JDApiUtil.POSITION_COUPON + "", null);
|
| | | couponInfo.setLink(url);
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id,PinDuoDuoApiUtil.PID_FANLI,uid+"");
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, PinDuoDuoApiUtil.PID_FANLI, pddAuthService.getFanliCustomParams(uid));
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | |
| | |
|
| | | if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息
|
| | | }
|
| | |
|
| | | if (extraVO.getListCouponUser() == null) {
|
| | | extraVO.setListCouponUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | if (extraVO.getListShareUser() == null) {
|
| | | extraVO.setListShareUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | // 免单商品
|
| | |
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | if (extraVO.getListShareUser() == null) {
|
| | | extraVO.setListShareUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | if (extraVO.getListCouponUser() == null) {
|
| | | extraVO.setListCouponUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | // 云发单文案信息
|
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO);
|
| | |
|
| | |
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | if (extraVO.getListShareUser() == null) {
|
| | | extraVO.setListShareUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | if (extraVO.getListCouponUser() == null) {
|
| | | extraVO.setListCouponUser(new ArrayList<>());
|
| | | }
|
| | |
|
| | | // 云发单文案信息
|
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO);
|
| | |
| | | Long[] strings = new Long[goodsIdList.size()];
|
| | | pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter,Constant.PDD_SEARCH_CUSTOMER_PARAMS);
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
|
| | | if (result != null) {
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | |
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | if (jumpLink == null) {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | }
|
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_COUPON + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_COUPON + "",
|
| | | "");
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | |
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (jumpLink == null) {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | }
|
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "",
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | |
| | | String jumpLink = null;
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | |
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_FANLI + "", null);
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_FANLI + "", null);
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | jumpLink = couponUrl;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | //TODO 是否需要返回绑定链接
|
| | | boolean auth = PinDuoDuoApiUtil.isAuth(pid, uid + "");
|
| | | PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, pid + "", uid + "", !auth);
|
| | | String customParams = pddAuthService.getFanliCustomParams(uid);
|
| | | boolean auth = PinDuoDuoApiUtil.isAuth(pid, customParams);
|
| | | PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, pid + "", customParams, !auth);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | | data.put("jumpLink", convertUrl.getUrl());
|
| | | data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
|
| | | LogHelper.test(String.format("拼多多转链:uid:%s data:%s",uid+"",data.toString()));
|
| | | LogHelper.test(String.format("拼多多转链:uid:%s data:%s", uid + "", data.toString()));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 获得金币
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(link, null, null,JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | | link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, JDApiUtil.POSITION_FANLI + "", uid + "");
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("link", link);
|
| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private PDDAuthService pddAuthService;
|
| | |
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | /*-------- 拼多多商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
|
| | | searchPDDGoods(acceptData,uid, searchkey, page, filter, order, ap, out);
|
| | | searchPDDGoods(acceptData, uid, searchkey, page, filter, order, ap, out);
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | * @param ap
|
| | | * @param out
|
| | | */
|
| | | private void searchPDDGoods(AcceptData acceptData,Long uid, String key, Integer page, String filter, Integer order,
|
| | | private void searchPDDGoods(AcceptData acceptData, Long uid, String key, Integer page, String filter, Integer order,
|
| | | AppPageNotification ap, PrintWriter out) {
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setKw(SearchFilterUtil.filterSearchContent(key));
|
| | |
| | | int count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | String customParams = Constant.PDD_SEARCH_CUSTOMER_PARAMS;
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter,Constant.PDD_SEARCH_CUSTOMER_PARAMS);
|
| | | if (uid != null) {
|
| | | String cp = pddAuthService.getFanliCustomParams(uid);
|
| | | if (PinDuoDuoApiUtil.isAuth(PinDuoDuoApiUtil.PID_FANLI, cp)) {
|
| | | customParams = cp;
|
| | | }
|
| | | }
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter, customParams);
|
| | | if (result != null) {
|
| | | count = result.getTotalCount();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | |
| | | package com.yeshi.fanli.controller.h5;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | |
| | | @RequestMapping("api/h5/v1/pddgoods")
|
| | | public class H5PDDGoodsController {
|
| | |
|
| | | @Resource
|
| | | private PDDGoodsService pddGoodsService;
|
| | | @Resource
|
| | | private PDDGoodsService pddGoodsService;
|
| | |
|
| | | /**
|
| | | * 获取拼多多的图文详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getImageList", method = RequestMethod.GET)
|
| | | public void getCouponList(AcceptData acceptData, String callback, Long id, PrintWriter out) {
|
| | | if (id == null || id == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请上传商品ID")));
|
| | | return;
|
| | | }
|
| | | List<String> list = pddGoodsService.getDetailImageList(id);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(list)));
|
| | | }
|
| | | /**
|
| | | * 获取拼多多的图文详情
|
| | | *
|
| | | * @param acceptData
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getImageList", method = RequestMethod.GET)
|
| | | public void getCouponList(AcceptData acceptData, String callback, Long id, PrintWriter out) {
|
| | | if (id == null || id == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请上传商品ID")));
|
| | | return;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, PinDuoDuoApiUtil.PID_FANLI, Constant.PDD_SEARCH_CUSTOMER_PARAMS);
|
| | | if (pddGoods != null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(Arrays.asList(pddGoods.getGoodsGalleryUrls()))));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.pdd; |
| | | |
| | | import com.yeshi.common.MongodbBaseDao; |
| | | import com.yeshi.fanli.entity.pdd.UserPDDAuthRecord; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class UserPDDAuthRecordDao extends MongodbBaseDao<UserPDDAuthRecord> { |
| | | |
| | | private Criteria[] getWheres(DaoQuery daoQuery) { |
| | | List<Criteria> whereList = new ArrayList<>(); |
| | | if (daoQuery.success != null) { |
| | | whereList.add(Criteria.where("success").is(daoQuery.success)); |
| | | } |
| | | if (daoQuery.minCreateTime != null) { |
| | | whereList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime)); |
| | | } |
| | | |
| | | if (daoQuery.uid != null) { |
| | | whereList.add(Criteria.where("uid").is(daoQuery.uid)); |
| | | } |
| | | Criteria[] wheres = new Criteria[whereList.size()]; |
| | | whereList.toArray(wheres); |
| | | return wheres; |
| | | } |
| | | |
| | | public List<UserPDDAuthRecord> list(DaoQuery daoQuery) { |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().andOperator(getWheres(daoQuery))); |
| | | query.skip(daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) |
| | | query.with(new Sort(daoQuery.sortList)); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().andOperator(getWheres(daoQuery))); |
| | | return count(query); |
| | | } |
| | | |
| | | public void updateSelectiveByPrimaryKey(UserPDDAuthRecord record) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("id").is(record.getId())); |
| | | Update update = new Update(); |
| | | if (record.getSuccess() != null) { |
| | | update.set("success", record.getSuccess()); |
| | | } |
| | | |
| | | if (record.getCustomParams() != null) { |
| | | update.set("customParams", record.getCustomParams()); |
| | | } |
| | | |
| | | if (record.getPid() != null) { |
| | | update.set("pid", record.getPid()); |
| | | } |
| | | |
| | | if (record.getSuccessTime() != null) { |
| | | update.set("successTime", record.getSuccessTime()); |
| | | } |
| | | |
| | | if (record.getUid() != null) { |
| | | update.set("uid", record.getUid()); |
| | | } |
| | | |
| | | update(query, update); |
| | | } |
| | | |
| | | public UserPDDAuthRecord selectByPidAndCustomParams(String pid, String customParams) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("pid").is(pid).and("customParams").is(customParams)); |
| | | return findOne(query); |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public Boolean success; |
| | | public Date minCreateTime; |
| | | public int start; |
| | | public int count; |
| | | public Long uid; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | if (config.getPddFanliCustomerParams() != null) { |
| | | update.set("pddFanliCustomerParams", config.getPddFanliCustomerParams()); |
| | | } |
| | | if (config.getPddFanliPid() != null) { |
| | | update.set("pddFanliPid", config.getPddFanliPid()); |
| | | } |
| | | config.setUpdateTime(new Date()); |
| | | update(query, update); |
| | | } |
| | |
| | | //拼多多自购的CustomerParams |
| | | private String pddFanliCustomerParams; |
| | | |
| | | //拼多多返利PID |
| | | private String pddFanliPid; |
| | | |
| | | private Date createTime; |
| | | |
| | | private Date updateTime; |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getPddFanliPid() { |
| | | return pddFanliPid; |
| | | } |
| | | |
| | | public void setPddFanliPid(String pddFanliPid) { |
| | | this.pddFanliPid = pddFanliPid; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.pdd; |
| | | |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Document(collection = "userPDDAuthRecord") |
| | | public class UserPDDAuthRecord { |
| | | |
| | | private String id; |
| | | |
| | | private Long uid; |
| | | |
| | | private String pid; |
| | | |
| | | private String customParams; |
| | | |
| | | //是否成功 |
| | | private Boolean success; |
| | | |
| | | //成功时间 |
| | | private Date successTime; |
| | | |
| | | //创建时间 |
| | | private Date createTime; |
| | | //更新时间 |
| | | private Date updateTime; |
| | | |
| | | |
| | | public static String createId(String pid, String customParams) { |
| | | return pid + "#" + customParams; |
| | | } |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public Long getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(Long uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public String getPid() { |
| | | return pid; |
| | | } |
| | | |
| | | public void setPid(String pid) { |
| | | this.pid = pid; |
| | | } |
| | | |
| | | public String getCustomParams() { |
| | | return customParams; |
| | | } |
| | | |
| | | public void setCustomParams(String customParams) { |
| | | this.customParams = customParams; |
| | | } |
| | | |
| | | public Boolean getSuccess() { |
| | | return success; |
| | | } |
| | | |
| | | public void setSuccess(Boolean success) { |
| | | this.success = success; |
| | | } |
| | | |
| | | public Date getSuccessTime() { |
| | | return successTime; |
| | | } |
| | | |
| | | public void setSuccessTime(Date successTime) { |
| | | this.successTime = successTime; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.job; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.yeshi.fanli.entity.AppVersionInfo; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.common.Config; |
| | | import com.yeshi.fanli.entity.pdd.UserPDDAuthRecord; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.service.inter.config.AppVersionService; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.AppMarketUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 拼多多授权验证 |
| | | */ |
| | | @Component |
| | | public class PDDAuthValidJob { |
| | | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @XxlJob("pdd-validAuthResult") |
| | | public ReturnT<String> validAuthResult(String param) throws Exception { |
| | | |
| | | Date minCreateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60L * 24); |
| | | Long uid = null; |
| | | if (!StringUtil.isNullOrEmpty(param)) { |
| | | uid = Long.parseLong(param); |
| | | } |
| | | |
| | | if (uid != null) { |
| | | UserPDDAuthRecord record = pddAuthService.getLatestRecordByUid(uid); |
| | | if (record != null && !record.getSuccess()) { |
| | | boolean auth = PinDuoDuoApiUtil.isAuth(record.getPid(), record.getCustomParams()); |
| | | if (auth) { |
| | | pddAuthService.authSuccess(record.getId()); |
| | | } |
| | | } |
| | | } else { |
| | | List<UserPDDAuthRecord> list = pddAuthService.listNeedValidRecord(minCreateTime, 1, 100); |
| | | if (list != null) { |
| | | for (UserPDDAuthRecord record : list) { |
| | | boolean auth = PinDuoDuoApiUtil.isAuth(record.getPid(), record.getCustomParams()); |
| | | if (auth) { |
| | | pddAuthService.authSuccess(record.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
|
| | | if (oldHongBao == null)
|
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | // 已经失效,已经领取,领取中,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU|| oldHongBao.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | return false;
|
| | |
|
| | | SystemEnum system = userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
|
| | |
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null && children.size() > 0)
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU||child.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | continue;
|
| | |
|
| | | HongBaoV2 childUpdate = new HongBaoV2(child.getId());
|
| | |
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null)
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU||child.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | continue;
|
| | |
|
| | | HongBaoV2 childUpdate = new HongBaoV2(child.getId());
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.pdd; |
| | | |
| | | import com.yeshi.fanli.dao.pdd.UserPDDAuthRecordDao; |
| | | import com.yeshi.fanli.dao.user.UserGoodsChannelConfigDao; |
| | | import com.yeshi.fanli.entity.goods.UserGoodsChannelConfig; |
| | | import com.yeshi.fanli.entity.pdd.UserPDDAuthRecord; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class PDDAuthServiceImpl implements PDDAuthService { |
| | | |
| | | @Resource |
| | | private UserPDDAuthRecordDao userPDDAuthRecordDao; |
| | | |
| | | @Resource |
| | | private UserGoodsChannelConfigDao userGoodsChannelConfigDao; |
| | | |
| | | |
| | | @Override |
| | | public String createPDDAuthLink(Long uid, String pid) throws Exception { |
| | | String customParams = PinDuoDuoUtil.getCustomParams(uid); |
| | | String link = PinDuoDuoApiUtil.getAuthLink(pid, customParams); |
| | | if (StringUtil.isNullOrEmpty(link)) { |
| | | throw new Exception("生成授权链接失败"); |
| | | } |
| | | UserPDDAuthRecord record = new UserPDDAuthRecord(); |
| | | record.setUid(uid); |
| | | record.setCreateTime(new Date()); |
| | | record.setPid(pid); |
| | | record.setCustomParams(customParams); |
| | | record.setId(UserPDDAuthRecord.createId(pid, customParams)); |
| | | record.setSuccess(false); |
| | | |
| | | if (userPDDAuthRecordDao.get(record.getId()) == null) { |
| | | userPDDAuthRecordDao.save(record); |
| | | } |
| | | return link; |
| | | } |
| | | |
| | | @Override |
| | | public UserPDDAuthRecord selectByPidAndCustomParams(String pid, String customParams) { |
| | | return userPDDAuthRecordDao.selectByPidAndCustomParams(pid, customParams); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserPDDAuthRecord> listNeedValidRecord(Date minCreateTime, int page, int pageSize) { |
| | | UserPDDAuthRecordDao.DaoQuery query = new UserPDDAuthRecordDao.DaoQuery(); |
| | | query.success = false; |
| | | query.minCreateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60L * 24 * 1); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | return userPDDAuthRecordDao.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countNeedValidRecord(Date minCreateTime) { |
| | | UserPDDAuthRecordDao.DaoQuery query = new UserPDDAuthRecordDao.DaoQuery(); |
| | | query.success = false; |
| | | query.minCreateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60L * 24 * 1); |
| | | return userPDDAuthRecordDao.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public void authSuccess(String id) { |
| | | UserPDDAuthRecord record = userPDDAuthRecordDao.get(id); |
| | | if (record == null) { |
| | | return; |
| | | } |
| | | UserPDDAuthRecord update = new UserPDDAuthRecord(); |
| | | update.setId(record.getId()); |
| | | update.setSuccess(true); |
| | | update.setSuccessTime(new Date()); |
| | | userPDDAuthRecordDao.updateSelectiveByPrimaryKey(update); |
| | | |
| | | UserGoodsChannelConfig config = userGoodsChannelConfigDao.get(record.getUid()); |
| | | if (config == null) { |
| | | config = new UserGoodsChannelConfig(); |
| | | config.setUid(record.getUid()); |
| | | config.setPddFanliCustomerParams(record.getCustomParams()); |
| | | config.setPddFanliPid(record.getPid()); |
| | | config.setCreateTime(new Date()); |
| | | userGoodsChannelConfigDao.save(config); |
| | | } else { |
| | | UserGoodsChannelConfig updateConfig = new UserGoodsChannelConfig(); |
| | | updateConfig.setUid(record.getUid()); |
| | | updateConfig.setPddFanliCustomerParams(record.getCustomParams()); |
| | | updateConfig.setPddFanliPid(record.getPid()); |
| | | userGoodsChannelConfigDao.updateSelective(updateConfig); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String getFanliCustomParams(Long uid) { |
| | | UserGoodsChannelConfig config = userGoodsChannelConfigDao.get(uid); |
| | | if (config == null || StringUtil.isNullOrEmpty(config.getPddFanliCustomerParams())) { |
| | | return uid + ""; |
| | | } |
| | | return config.getPddFanliCustomerParams(); |
| | | } |
| | | |
| | | @Override |
| | | public UserPDDAuthRecord getLatestRecordByUid(Long uid) { |
| | | UserPDDAuthRecordDao.DaoQuery query = new UserPDDAuthRecordDao.DaoQuery(); |
| | | query.uid = uid; |
| | | List<Sort.Order> orderList = new ArrayList<>(); |
| | | orderList.add(new Sort.Order(Sort.Direction.DESC, "createTime")); |
| | | query.sortList = orderList; |
| | | query.count = 1; |
| | | List<UserPDDAuthRecord> list = userPDDAuthRecordDao.list(query); |
| | | return list != null && list.size() > 0 ? list.get(0) : null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.service.inter.pdd; |
| | | |
| | | import com.yeshi.fanli.entity.pdd.UserPDDAuthRecord; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface PDDAuthService { |
| | | |
| | | |
| | | /** |
| | | * 生成拼多多授权链接 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public String createPDDAuthLink(Long uid, String pid) throws Exception; |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | | * @param pid |
| | | * @param customParams |
| | | * @return |
| | | */ |
| | | public UserPDDAuthRecord selectByPidAndCustomParams(String pid, String customParams); |
| | | |
| | | |
| | | /** |
| | | * 查询需要验证的记录 |
| | | * |
| | | * @param page |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<UserPDDAuthRecord> listNeedValidRecord(Date minCreateTime, int page, int pageSize); |
| | | |
| | | public long countNeedValidRecord(Date minCreateTime); |
| | | |
| | | /** |
| | | * 验证成功 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void authSuccess(String id); |
| | | |
| | | |
| | | public String getFanliCustomParams(Long uid); |
| | | |
| | | public UserPDDAuthRecord getLatestRecordByUid(Long uid); |
| | | } |
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.StringUtil;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoTokenAuctionIdMapManager taoBaoTokenAuctionIdMapManager;
|
| | |
|
| | | @Resource
|
| | | private PDDAuthService pddAuthService;
|
| | |
|
| | | /**
|
| | | * @Title: convertJDLinkFromText @Description:转链文本中的京东短链 @param text @param
|
| | |
| | | List<String> pddShortLink = PinDuoDuoUtil.getPDDShortLinksFromText(text);
|
| | | Set<String> linkSet = new HashSet<>();
|
| | | Map<String, String> linkMap = new HashMap<>();
|
| | |
|
| | | if (pddShortLink != null && pddShortLink.size() > 0) {
|
| | | linkSet.addAll(pddShortLink);
|
| | | for (String shortLink : linkSet) {
|
| | | String goodsId = PinDuoDuoUtil.getPDDGoodsId(shortLink);
|
| | | if (!StringUtil.isNullOrEmpty(goodsId)) {
|
| | | PDDPromotionUrl pddUrl = PinDuoDuoApiUtil.convert(Long.parseLong(goodsId),
|
| | | share ? PinDuoDuoApiUtil.PID_SHARE : PinDuoDuoApiUtil.PID_FANLI, uid + "", false);
|
| | | share ? PinDuoDuoApiUtil.PID_SHARE : PinDuoDuoApiUtil.PID_FANLI, pddAuthService.getFanliCustomParams(uid), false);
|
| | | if (pddUrl != null) {
|
| | | linkMap.put(shortLink, pddUrl.getShortUrl());
|
| | | }
|
| | |
| | | throw new HongBaoException(201, "用户等级为空");
|
| | |
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU|| oldHongBao.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | return false;
|
| | |
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | |
| | | List<UserTeamLevel> bossList = getBossList(children);
|
| | |
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU||child.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | continue;
|
| | |
|
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) {
|
| | |
| | | if (children != null && children.size() > 0) {
|
| | | List<UserTeamLevel> bossList = getBossList(children);
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU||child.getState() == HongBaoV2.STATE_LINGQUING)
|
| | | continue;
|
| | |
|
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | |
| | | JSONArray array = json.optJSONObject("store").optJSONObject("initDataObj")
|
| | | .optJSONObject("goods").optJSONArray("detailGallery");
|
| | | for (int j = 0; j < array.size(); j++) {
|
| | | imgList.add("http:" + array.optJSONObject(j).optString("url"));
|
| | | String u = array.optJSONObject(j).optString("url");
|
| | | if (!u.startsWith("http"))
|
| | | imgList.add("http:" + u);
|
| | | else
|
| | | imgList.add(u);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
| | | return urlList;
|
| | | }
|
| | |
|
| | | public static String getCustomParams(String uid) {
|
| | | return uid + "_" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHH");
|
| | | public static String getCustomParams(Long uid) {
|
| | | return uid + "_" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd");
|
| | | }
|
| | |
|
| | | public static String getUidFromCustomParams(String params) {
|
| | |
| | | ###
|
| | | log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
| | | log4j.appender.stdout.Target = System.out
|
| | | log4j.appender.stdout.Threshold = DEBUG
|
| | | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
| | | log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
| | |
|