diff --git a/bweb/lib/pop-sdk-1.18.23-all.jar b/bweb/lib/pop-sdk-1.18.23-all.jar new file mode 100644 index 0000000..ee4b58a Binary files /dev/null and b/bweb/lib/pop-sdk-1.18.23-all.jar differ diff --git a/bweb/lib/taobao-sdk-java-elm.jar b/bweb/lib/taobao-sdk-java-elm.jar new file mode 100644 index 0000000..15bf43d Binary files /dev/null and b/bweb/lib/taobao-sdk-java-elm.jar differ diff --git a/bweb/lib/taobao-sdk.jar b/bweb/lib/taobao-sdk.jar new file mode 100644 index 0000000..531b630 Binary files /dev/null and b/bweb/lib/taobao-sdk.jar differ diff --git a/bweb/pom.xml b/bweb/pom.xml index de755cd..bff4593 100644 --- a/bweb/pom.xml +++ b/bweb/pom.xml @@ -18,6 +18,27 @@ service PACKT-SNAPSHOT + + taobao.skd + taobao-open-sdk + system + 1.0.1 + ${basedir}/lib/taobao-sdk.jar + + + taobao-elm.skd + taobao-open-elm-sdk + system + 1.0.1 + ${basedir}/lib/taobao-sdk-java-elm.jar + + + pop.skd + pop-open-sdk + system + 1.0.1 + ${basedir}/lib/pop-sdk-1.18.23-all.jar + @@ -26,7 +47,15 @@ src/main/resources/${env} false + + ${basedir}/lib + BOOT-INF/lib/ + + **/*.jar + + + org.apache.maven.plugins diff --git a/cweb/lib/taobao-sdk.jar b/cweb/lib/taobao-sdk.jar index 28a9c92..531b630 100644 Binary files a/cweb/lib/taobao-sdk.jar and b/cweb/lib/taobao-sdk.jar differ diff --git a/cweb/src/main/java/com/hfkj/controller/GoodsController.java b/cweb/src/main/java/com/hfkj/controller/GoodsController.java index e3f7f93..596cfa3 100644 --- a/cweb/src/main/java/com/hfkj/controller/GoodsController.java +++ b/cweb/src/main/java/com/hfkj/controller/GoodsController.java @@ -55,10 +55,19 @@ public class GoodsController { try { List goodsList; + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + + BsUser bsUser = bsUserService.getUser(userSession.getUser().getId()); // 1:淘宝 2:拼多多 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")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); @@ -66,8 +75,6 @@ public class GoodsController { goodsList = goodsDataService.goodsModelTaoBaoList(jsonObject); } else if (type == 2) { - // 用户session - UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); Map mapUser = new JSONObject(); mapUser.put("uid", userSession.getUser().getId()); JSONObject object = PddService.authority(mapUser.toString()); @@ -139,12 +146,19 @@ public class GoodsController { 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"); 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()); - 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); 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); - } - } } diff --git a/cweb/src/main/java/com/hfkj/controller/TestController.java b/cweb/src/main/java/com/hfkj/controller/TestController.java index f4277b8..092b861 100644 --- a/cweb/src/main/java/com/hfkj/controller/TestController.java +++ b/cweb/src/main/java/com/hfkj/controller/TestController.java @@ -41,29 +41,6 @@ import java.util.Map; public class TestController { 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); - } - } - diff --git a/service/lib/taobao-sdk.jar b/service/lib/taobao-sdk.jar index 28a9c92..531b630 100644 Binary files a/service/lib/taobao-sdk.jar and b/service/lib/taobao-sdk.jar differ diff --git a/service/src/main/java/com/hfkj/service/elm/ElmService.java b/service/src/main/java/com/hfkj/service/elm/ElmService.java index 84ad5df..cb98193 100644 --- a/service/src/main/java/com/hfkj/service/elm/ElmService.java +++ b/service/src/main/java/com/hfkj/service/elm/ElmService.java @@ -2,9 +2,7 @@ package com.hfkj.service.elm; import com.alibaba.fastjson.JSON; 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.taobao.api.DefaultTaobaoClient; 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.response.AlibabaAlscUnionElemePromotionOfficialactivityGetResponse; 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.LoggerFactory; -import java.net.URLEncoder; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; public class ElmService { diff --git a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java index 252345e..6e865f8 100644 --- a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java @@ -35,6 +35,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -203,8 +204,6 @@ public class BsOrderServiceImpl implements BsOrderService { } return orderModels; } - - return null; } @@ -264,13 +263,15 @@ public class BsOrderServiceImpl implements BsOrderService { // 根据订单号获取BsOrder对象 BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null); // 根据uid获取BsUser对象 - BsUser user = userService.getUser(uid); + BsUser user = userService.getUser(Long.valueOf(uid)); if (bsOrder == null) { // 如果BsOrder对象为空,则创建新的BsOrder对象 bsOrder = new BsOrder(); bsOrder.setOrderNo(orderListItem.getOrderSn()); bsOrder.setUserId(Long.valueOf(uid)); - bsOrder.setUserPhone(user.getPhone()); + if (user != null) { + bsOrder.setUserPhone(user.getPhone() == null ? "" : user.getPhone()); + } bsOrder.setCreateTime(new Date()); bsOrder.setUpdateTime(new Date()); bsOrder.setStatus(orderListItem.getOrderStatus()); @@ -279,13 +280,26 @@ public class BsOrderServiceImpl implements BsOrderService { bsOrder.setGoodsName(orderListItem.getGoodsName()); bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); bsOrder.setCustomparameters(orderListItem.getCustomParameters()); - bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); - bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); - bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); - bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); - bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); - bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); - bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); + bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); + bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); + if (orderListItem.getOrderPayTime() != null) { + bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000)); + } + + 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); }else { // 如果BsOrder对象不为空,则更新BsOrder对象 @@ -296,13 +310,27 @@ public class BsOrderServiceImpl implements BsOrderService { bsOrder.setGoodsName(orderListItem.getGoodsName()); bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); bsOrder.setCustomparameters(orderListItem.getCustomParameters()); - bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); - bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); - bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); - bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); - bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); - bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); - bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); + bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP)); + bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP)); + if (orderListItem.getOrderPayTime() != null) { + bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000)); + } + + 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方法 if (bsOrder.getStatus() == 5){ orderRebate(bsOrder); diff --git a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java index cb4f99f..93f4a61 100644 --- a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java +++ b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; 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.TopApiClient; 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.response.TaobaoTbkTpwdCreateResponse; 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.response.TaobaoTbkScInvitecodeGetResponse; +import com.taobao.top.ability425.response.TaobaoTbkScPublisherInfoGetResponse; import com.taobao.top.ability425.response.TaobaoTbkScPublisherInfoSaveResponse; 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.response.TaobaoTbkDgGeneralLinkConvertResponse; import com.taobao.top.defaultability.response.TaobaoTbkDgMaterialOptionalUpgradeResponse; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Resource; import java.util.ArrayList; +import java.util.List; public class TaoBaoService { @@ -37,6 +47,9 @@ public class TaoBaoService { private static String appsecret = "f04baedca9cd794665dfa04a2fcbfd86"; private static String url = "https://eco.taobao.com/router/rest"; + @Resource + private BsUserService userService; + /** * @MethodName material * @Description:淘宝客-推广者-物料id列表查询 @@ -47,10 +60,11 @@ public class TaoBaoService { * @Author: Sum1Dream * @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)) { title = "百货"; } + log.info("============ 淘宝客-推广者-物料id列表查询-START ============="); TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); Defaultability apiPackage = new Defaultability(client); @@ -62,6 +76,7 @@ public class TaoBaoService { TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); request.setQ(title); request.setPageNo(pageNo); + request.setRelationId(specialId); request.setHasCoupon(true); request.setPageSize(pageSize); request.setAdzoneId(115764450446L); @@ -120,7 +135,7 @@ public class TaoBaoService { * @Author: Sum1Dream * @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 ============="); TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); @@ -129,7 +144,7 @@ public class TaoBaoService { // create request TaobaoTbkScPublisherInfoSaveRequest request = new TaobaoTbkScPublisherInfoSaveRequest(); - request.setInviterCode("JIIIVF"); + request.setInviterCode(code); request.setInfoType(1L); request.setNote("元气"); @@ -145,6 +160,7 @@ public class TaoBaoService { return JSONObject.parseObject(JSON.toJSONString(response)); } + /** * @MethodName getToken * @Description:获取Access Token @@ -177,5 +193,4 @@ public class TaoBaoService { } - }