袁野 4 days ago
parent 686c24790f
commit ef0080286d
  1. BIN
      bweb/lib/pop-sdk-1.18.23-all.jar
  2. BIN
      bweb/lib/taobao-sdk-java-elm.jar
  3. BIN
      bweb/lib/taobao-sdk.jar
  4. 29
      bweb/pom.xml
  5. BIN
      cweb/lib/taobao-sdk.jar
  6. 40
      cweb/src/main/java/com/hfkj/controller/GoodsController.java
  7. 23
      cweb/src/main/java/com/hfkj/controller/TestController.java
  8. BIN
      service/lib/taobao-sdk.jar
  9. 14
      service/src/main/java/com/hfkj/service/elm/ElmService.java
  10. 64
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java
  11. 25
      service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -18,6 +18,27 @@
<artifactId>service</artifactId> <artifactId>service</artifactId>
<version>PACKT-SNAPSHOT</version> <version>PACKT-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>taobao.skd</groupId>
<artifactId>taobao-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk.jar</systemPath>
</dependency>
<dependency>
<groupId>taobao-elm.skd</groupId>
<artifactId>taobao-open-elm-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk-java-elm.jar</systemPath>
</dependency>
<dependency>
<groupId>pop.skd</groupId>
<artifactId>pop-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/pop-sdk-1.18.23-all.jar</systemPath>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -26,7 +47,15 @@
<directory>src/main/resources/${env}</directory> <directory>src/main/resources/${env}</directory>
<filtering>false</filtering> <filtering>false</filtering>
</resource> </resource>
<resource>
<directory>${basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

Binary file not shown.

@ -55,10 +55,19 @@ public class GoodsController {
try { try {
List<GoodsModel> goodsList; List<GoodsModel> goodsList;
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
BsUser bsUser = bsUserService.getUser(userSession.getUser().getId());
// 1:淘宝 2:拼多多 // 1:淘宝 2:拼多多
if (type == 1) { if (type == 1) {
JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize);
if (bsUser.getSpecialId() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户未授权!");
}
JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize , bsUser.getSpecialId());
if (!jsonObject.getBoolean("success")) { if (!jsonObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
@ -66,8 +75,6 @@ public class GoodsController {
goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject); goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject);
} else if (type == 2) { } else if (type == 2) {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
Map<String , Object> mapUser = new JSONObject(); Map<String , Object> mapUser = new JSONObject();
mapUser.put("uid", userSession.getUser().getId()); mapUser.put("uid", userSession.getUser().getId());
JSONObject object = PddService.authority(mapUser.toString()); JSONObject object = PddService.authority(mapUser.toString());
@ -139,12 +146,19 @@ public class GoodsController {
JSONObject tokenResult = JSONObject.parseObject(token); JSONObject tokenResult = JSONObject.parseObject(token);
JSONObject jsonObject = TaoBaoService.publisher(tokenResult.getString("access_token")); // 用户备案
JSONObject jsonObject = TaoBaoService.publisher(tokenResult.getString("access_token") , "5FM9A9");
String body = jsonObject.getString("body"); String body = jsonObject.getString("body");
JSONObject result = JSONObject.parseObject(body); JSONObject result = JSONObject.parseObject(body);
// 渠道备案
JSONObject relationObject = TaoBaoService.publisher(tokenResult.getString("access_token") , "JIIIVF");
String relation = relationObject.getString("body");
JSONObject relationBody = JSONObject.parseObject(relation);
BsUser user = bsUserService.getUser(userSession.getUser().getId()); BsUser user = bsUserService.getUser(userSession.getUser().getId());
user.setSpecialId(result.getJSONObject("data").getString("relation_id")); user.setSpecialId(result.getJSONObject("data").getString("special_id"));
user.setRelationId(relationBody.getJSONObject("data").getString("relation_id"));
bsUserService.updateInfo(user); bsUserService.updateInfo(user);
return ResponseMsgUtil.success("绑定成功"); return ResponseMsgUtil.success("绑定成功");
@ -155,21 +169,5 @@ public class GoodsController {
} }
} }
@RequestMapping(value="/getToken",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取Access Token")
public ResponseData getToken(@RequestParam(value = "code" , required = false) String code
) {
try {
JSONObject jsonObject = TaoBaoService.getToken(code);
String token = jsonObject.getString("token_result");
JSONObject tokenResult = JSONObject.parseObject(token);
return ResponseMsgUtil.success(tokenResult);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -41,29 +41,6 @@ import java.util.Map;
public class TestController { public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class); private static Logger log = LoggerFactory.getLogger(TestController.class);
@RequestMapping(value="/material",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "淘宝客-推广者-物料id列表查询 ")
public ResponseData material(@RequestParam(value = "title" , required = false) String title,
@RequestParam(value = "pageNo" , required = false) Long pageNo,
@RequestParam(value = "pageSize" , required = false) Long pageSize
) {
try {
JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize);
if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getJSONArray("result_list"));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}

Binary file not shown.

@ -2,9 +2,7 @@ package com.hfkj.service.elm;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.TaoBaoUtil;
import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.taobao.TaoBaoService;
import com.taobao.api.DefaultTaobaoClient; import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient; import com.taobao.api.TaobaoClient;
@ -12,18 +10,10 @@ import com.taobao.api.request.AlibabaAlscUnionElemePromotionOfficialactivityGetR
import com.taobao.api.request.AlibabaAlscUnionMediaZoneAddRequest; import com.taobao.api.request.AlibabaAlscUnionMediaZoneAddRequest;
import com.taobao.api.response.AlibabaAlscUnionElemePromotionOfficialactivityGetResponse; import com.taobao.api.response.AlibabaAlscUnionElemePromotionOfficialactivityGetResponse;
import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse; import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse;
import com.taobao.top.DefaultTopApiClient;
import com.taobao.top.TopApiClient;
import com.taobao.top.ability375.Ability375;
import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest;
import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class ElmService { public class ElmService {

@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -203,8 +204,6 @@ public class BsOrderServiceImpl implements BsOrderService {
} }
return orderModels; return orderModels;
} }
return null; return null;
} }
@ -264,13 +263,15 @@ public class BsOrderServiceImpl implements BsOrderService {
// 根据订单号获取BsOrder对象 // 根据订单号获取BsOrder对象
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null); BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null);
// 根据uid获取BsUser对象 // 根据uid获取BsUser对象
BsUser user = userService.getUser(uid); BsUser user = userService.getUser(Long.valueOf(uid));
if (bsOrder == null) { if (bsOrder == null) {
// 如果BsOrder对象为空,则创建新的BsOrder对象 // 如果BsOrder对象为空,则创建新的BsOrder对象
bsOrder = new BsOrder(); bsOrder = new BsOrder();
bsOrder.setOrderNo(orderListItem.getOrderSn()); bsOrder.setOrderNo(orderListItem.getOrderSn());
bsOrder.setUserId(Long.valueOf(uid)); bsOrder.setUserId(Long.valueOf(uid));
bsOrder.setUserPhone(user.getPhone()); if (user != null) {
bsOrder.setUserPhone(user.getPhone() == null ? "" : user.getPhone());
}
bsOrder.setCreateTime(new Date()); bsOrder.setCreateTime(new Date());
bsOrder.setUpdateTime(new Date()); bsOrder.setUpdateTime(new Date());
bsOrder.setStatus(orderListItem.getOrderStatus()); bsOrder.setStatus(orderListItem.getOrderStatus());
@ -279,13 +280,26 @@ public class BsOrderServiceImpl implements BsOrderService {
bsOrder.setGoodsName(orderListItem.getGoodsName()); bsOrder.setGoodsName(orderListItem.getGoodsName());
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity()));
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); bsOrder.setCustomparameters(orderListItem.getCustomParameters());
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); if (orderListItem.getOrderPayTime() != null) {
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000));
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); }
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); if (orderListItem.getOrderCreateTime() != null) {
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()*1000));
}
if (orderListItem.getOrderSettleTime() != null) {
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000));
}
if (orderListItem.getOrderModifyAt() != null) {
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000));
}
if (orderListItem.getOrderModifyAt() != null) {
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000));
}
create(bsOrder); create(bsOrder);
}else { }else {
// 如果BsOrder对象不为空,则更新BsOrder对象 // 如果BsOrder对象不为空,则更新BsOrder对象
@ -296,13 +310,27 @@ public class BsOrderServiceImpl implements BsOrderService {
bsOrder.setGoodsName(orderListItem.getGoodsName()); bsOrder.setGoodsName(orderListItem.getGoodsName());
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity()));
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); bsOrder.setCustomparameters(orderListItem.getCustomParameters());
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP));
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP));
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); if (orderListItem.getOrderPayTime() != null) {
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000));
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); }
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); if (orderListItem.getOrderCreateTime() != null) {
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()*1000));
}
if (orderListItem.getOrderSettleTime() != null) {
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000));
}
if (orderListItem.getOrderModifyAt() != null) {
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000));
}
if (orderListItem.getOrderModifyAt() != null) {
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000));
}
// 如果订单状态为5,则调用orderRebate方法 // 如果订单状态为5,则调用orderRebate方法
if (bsOrder.getStatus() == 5){ if (bsOrder.getStatus() == 5){
orderRebate(bsOrder); orderRebate(bsOrder);

@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.entity.BsUser;
import com.hfkj.service.user.BsUserService;
import com.taobao.top.DefaultTopApiClient; import com.taobao.top.DefaultTopApiClient;
import com.taobao.top.TopApiClient; import com.taobao.top.TopApiClient;
import com.taobao.top.ability304.Ability304; import com.taobao.top.ability304.Ability304;
@ -14,18 +16,26 @@ import com.taobao.top.ability375.Ability375;
import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest; import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest;
import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse; import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse;
import com.taobao.top.ability425.Ability425; import com.taobao.top.ability425.Ability425;
import com.taobao.top.ability425.request.TaobaoTbkScInvitecodeGetRequest;
import com.taobao.top.ability425.request.TaobaoTbkScPublisherInfoGetRequest;
import com.taobao.top.ability425.request.TaobaoTbkScPublisherInfoSaveRequest; import com.taobao.top.ability425.request.TaobaoTbkScPublisherInfoSaveRequest;
import com.taobao.top.ability425.response.TaobaoTbkScInvitecodeGetResponse;
import com.taobao.top.ability425.response.TaobaoTbkScPublisherInfoGetResponse;
import com.taobao.top.ability425.response.TaobaoTbkScPublisherInfoSaveResponse; import com.taobao.top.ability425.response.TaobaoTbkScPublisherInfoSaveResponse;
import com.taobao.top.defaultability.Defaultability; import com.taobao.top.defaultability.Defaultability;
import com.taobao.top.defaultability.domain.TaobaoTbkOptimusTouMaterialIdsGetMaterialQuery; import com.taobao.top.defaultability.domain.*;
import com.taobao.top.defaultability.request.TaobaoTbkDgGeneralLinkConvertRequest;
import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialOptionalUpgradeRequest; import com.taobao.top.defaultability.request.TaobaoTbkDgMaterialOptionalUpgradeRequest;
import com.taobao.top.defaultability.response.TaobaoTbkDgGeneralLinkConvertResponse;
import com.taobao.top.defaultability.response.TaobaoTbkDgMaterialOptionalUpgradeResponse; import com.taobao.top.defaultability.response.TaobaoTbkDgMaterialOptionalUpgradeResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
public class TaoBaoService { public class TaoBaoService {
@ -37,6 +47,9 @@ public class TaoBaoService {
private static String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; private static String appsecret = "f04baedca9cd794665dfa04a2fcbfd86";
private static String url = "https://eco.taobao.com/router/rest"; private static String url = "https://eco.taobao.com/router/rest";
@Resource
private BsUserService userService;
/** /**
* @MethodName material * @MethodName material
* @Description:淘宝客-推广者-物料id列表查询 * @Description:淘宝客-推广者-物料id列表查询
@ -47,10 +60,11 @@ public class TaoBaoService {
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/9/10 下午1:52 * @Date: 2024/9/10 下午1:52
*/ */
public static JSONObject material(String title , Long pageNo , Long pageSize) throws Exception { public static JSONObject material(String title , Long pageNo , Long pageSize , String specialId) throws Exception {
if (StringUtils.isBlank(title)) { if (StringUtils.isBlank(title)) {
title = "百货"; title = "百货";
} }
log.info("============ 淘宝客-推广者-物料id列表查询-START ============="); log.info("============ 淘宝客-推广者-物料id列表查询-START =============");
TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url);
Defaultability apiPackage = new Defaultability(client); Defaultability apiPackage = new Defaultability(client);
@ -62,6 +76,7 @@ public class TaoBaoService {
TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest();
request.setQ(title); request.setQ(title);
request.setPageNo(pageNo); request.setPageNo(pageNo);
request.setRelationId(specialId);
request.setHasCoupon(true); request.setHasCoupon(true);
request.setPageSize(pageSize); request.setPageSize(pageSize);
request.setAdzoneId(115764450446L); request.setAdzoneId(115764450446L);
@ -120,7 +135,7 @@ public class TaoBaoService {
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/9/23 上午11:40 * @Date: 2024/9/23 上午11:40
*/ */
public static JSONObject publisher(String token) throws Exception { public static JSONObject publisher(String token , String code) throws Exception {
log.info("============ 淘宝客-公用-私域用户备案-START ============="); log.info("============ 淘宝客-公用-私域用户备案-START =============");
TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url);
@ -129,7 +144,7 @@ public class TaoBaoService {
// create request // create request
TaobaoTbkScPublisherInfoSaveRequest request = new TaobaoTbkScPublisherInfoSaveRequest(); TaobaoTbkScPublisherInfoSaveRequest request = new TaobaoTbkScPublisherInfoSaveRequest();
request.setInviterCode("JIIIVF"); request.setInviterCode(code);
request.setInfoType(1L); request.setInfoType(1L);
request.setNote("元气"); request.setNote("元气");
@ -145,6 +160,7 @@ public class TaoBaoService {
return JSONObject.parseObject(JSON.toJSONString(response)); return JSONObject.parseObject(JSON.toJSONString(response));
} }
/** /**
* @MethodName getToken * @MethodName getToken
* @Description:获取Access Token * @Description:获取Access Token
@ -177,5 +193,4 @@ public class TaoBaoService {
} }
} }

Loading…
Cancel
Save