From 97ed274f6726cb5e0b60aa0d846b1b3d6c6b0238 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 4 Nov 2024 16:27:47 +0800 Subject: [PATCH] Merge branch 'master' of http://gitea.dctpay.com/hurui/youtao --- .../com/hfkj/controller/ClientController.java | 22 ++ .../com/hfkj/controller/GoodsController.java | 75 ++++++- .../com/hfkj/controller/TestController.java | 36 ++++ .../controller/order/BsOrderController.java | 14 -- .../java/com/hfkj/schedule/OrderSchedule.java | 55 +++++ .../main/java/com/hfkj/model/GoodsModel.java | 4 + .../java/com/hfkj/model/PublishInfoModel.java | 2 + .../goods/impl/GoodsDataServiceImpl.java | 2 + .../hfkj/service/order/BsOrderService.java | 5 +- .../order/Impl/BsOrderServiceImpl.java | 198 ++++++++++++++---- .../hfkj/service/taobao/TaoBaoService.java | 118 ++++++++++- .../service/user/impl/BsUserServiceImpl.java | 3 + 12 files changed, 472 insertions(+), 62 deletions(-) create mode 100644 schedule/src/main/java/com/hfkj/schedule/OrderSchedule.java diff --git a/cweb/src/main/java/com/hfkj/controller/ClientController.java b/cweb/src/main/java/com/hfkj/controller/ClientController.java index eb41c3a..52870a7 100644 --- a/cweb/src/main/java/com/hfkj/controller/ClientController.java +++ b/cweb/src/main/java/com/hfkj/controller/ClientController.java @@ -121,6 +121,28 @@ public class ClientController { } } + + + @RequestMapping(value = "/smsLogin", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "登录并注册") + public ResponseData smsLogin(@RequestParam(value = "phone" , required = true) String phone) { + try { + + + // 校验手机号格式 + if (!MemberValidateUtil.validatePhone(phone)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); + } + + + return ResponseMsgUtil.success(userService.login(phone, UserLoginType.SMS, new HashMap<>(), null)); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/loginOut",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") diff --git a/cweb/src/main/java/com/hfkj/controller/GoodsController.java b/cweb/src/main/java/com/hfkj/controller/GoodsController.java index 596cfa3..bb6d483 100644 --- a/cweb/src/main/java/com/hfkj/controller/GoodsController.java +++ b/cweb/src/main/java/com/hfkj/controller/GoodsController.java @@ -5,6 +5,7 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsUser; @@ -23,10 +24,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; @Controller @RequestMapping(value="/goods") @@ -42,6 +43,8 @@ public class GoodsController { @Resource private BsUserService bsUserService; + @Resource + private BsOrderService orderService; @RequestMapping(value="/goodsList",method = RequestMethod.GET) @@ -67,7 +70,7 @@ public class GoodsController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户未授权!"); } - JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize , bsUser.getSpecialId()); + JSONObject jsonObject = TaoBaoService.material(title , pageNo , pageSize , bsUser.getSpecialId() , bsUser.getRelationId()); if (!jsonObject.getBoolean("success")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); @@ -169,5 +172,67 @@ public class GoodsController { } } + @RequestMapping(value="/getPublisherInfo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "淘宝客-公用-私域用户备案信息查询") + public ResponseData getPublisherInfo(@RequestParam(value = "code" , required = false) String code + ) { + try { + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + + JSONObject tokenJson = TaoBaoService.getToken(code); + String token = tokenJson.getString("token_result"); + JSONObject tokenResult = JSONObject.parseObject(token); + + + BsUser user = bsUserService.getUser(userSession.getUser().getId()); + // 用户备案 + JSONObject jsonObject = TaoBaoService.getPublisherInfo(tokenResult.getString("access_token") , Long.valueOf(user.getRelationId()), user.getSpecialId()); + + return ResponseMsgUtil.success(jsonObject); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/getOrderList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单") + public ResponseData getOrderList(@RequestParam(value = "code" , required = false) String code + ) { + try { + orderService.getOrderTaoBaoList("2024-11-04 09:34:00" , "2024-11-04 12:34:00" ); + + return ResponseMsgUtil.success("1"); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/generalLink",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "淘宝客-公用-私域用户备案信息查询") + public ResponseData generalLink( + @RequestParam(value = "itemId" , required = false) String itemId, + @RequestParam(value = "url" , required = false) String url + ) { + try { + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + // 用户备案 + JSONObject jsonObject = TaoBaoService.generalLink(itemId, url, userSession.getUser().getRelationId()); + + return ResponseMsgUtil.success(jsonObject); + } 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 092b861..2dcc4ef 100644 --- a/cweb/src/main/java/com/hfkj/controller/TestController.java +++ b/cweb/src/main/java/com/hfkj/controller/TestController.java @@ -5,10 +5,13 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsUser; import com.hfkj.model.ResponseData; +import com.hfkj.model.UserSessionObject; import com.hfkj.service.elm.ElmService; import com.hfkj.service.meituan.MeiTuanService; import com.hfkj.service.pdd.PddService; @@ -16,11 +19,13 @@ import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.user.BsUserContributeService; import com.hfkj.service.user.BsUserGradeService; import com.hfkj.service.user.BsUserParentRelService; +import com.hfkj.service.user.BsUserService; import com.hfkj.sysenum.user.UserGradeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -41,6 +46,37 @@ import java.util.Map; public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); + @Autowired + private UserCenter userCenter; + + @Resource + private BsUserService bsUserService; + + @RequestMapping(value="/getPublisherInfo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "淘宝客-公用-私域用户备案") + public ResponseData getPublisherInfo(@RequestParam(value = "code" , required = false) String code + ) { + try { + // 用户session + UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); + + JSONObject tokenJson = TaoBaoService.getToken(code); + String token = tokenJson.getString("token_result"); + JSONObject tokenResult = JSONObject.parseObject(token); + + + BsUser user = bsUserService.getUser(userSession.getUser().getId()); + // 用户备案 + JSONObject jsonObject = TaoBaoService.getPublisherInfo(tokenResult.getString("access_token") , Long.valueOf(user.getRelationId()), user.getSpecialId()); + + return ResponseMsgUtil.success(jsonObject); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } diff --git a/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java b/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java index 367de94..853d3bf 100644 --- a/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java +++ b/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java @@ -93,20 +93,6 @@ public class BsOrderController { } } - @RequestMapping(value="/getPddOrderList",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "用时间段查询推广订单接口") - public ResponseData getPddOrderList() { - try { - - return ResponseMsgUtil.success(orderService.getOrderList("2024-10-01 00:00:00")); - - } catch (Exception e) { - log.error("error!",e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value="/statisticsOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "统计订单") diff --git a/schedule/src/main/java/com/hfkj/schedule/OrderSchedule.java b/schedule/src/main/java/com/hfkj/schedule/OrderSchedule.java new file mode 100644 index 0000000..07621c6 --- /dev/null +++ b/schedule/src/main/java/com/hfkj/schedule/OrderSchedule.java @@ -0,0 +1,55 @@ +package com.hfkj.schedule; + +import com.hfkj.common.utils.DateUtil; +import com.hfkj.service.order.BsOrderService; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; + + +/** + * @ClassName OrderSchedule + * @Author Sum1Dream + * @Description 订单定时任务 + * @Date 2024/11/4 下午2:48 + **/ +@Component +public class OrderSchedule { + + @Resource + private BsOrderService orderService; + + @Scheduled(cron = "0 30 1 * * ?") // 每日凌晨05:30:00 执行一次 + public void pddOrder() { + try { + // 昨日时间 + orderService.getOrderPddList("2024-10-01 00:00:00"); + + } catch (Exception e) { + System.out.println("查询失败!!!"); + } + } + + + @Scheduled(cron = "0 0/15 * * * ?") // 每十五分钟 执行一次 + public void getOrderTaoBaoList() { + try { + + // create domain + LocalDateTime now = LocalDateTime.now(); + LocalDateTime twentyMinutesBefore = now.minus(Duration.ofMinutes(19)); + // 昨日时间 + orderService.getOrderTaoBaoList(twentyMinutesBefore.format(DateTimeFormatter.ofPattern(DateUtil.Y_M_D_HMS)) , DateUtil.format(new Date(),DateUtil.Y_M_D_HMS)); + + } catch (Exception e) { + System.out.println("查询失败!!!"); + } + } + + +} diff --git a/service/src/main/java/com/hfkj/model/GoodsModel.java b/service/src/main/java/com/hfkj/model/GoodsModel.java index e941d72..d434eb7 100644 --- a/service/src/main/java/com/hfkj/model/GoodsModel.java +++ b/service/src/main/java/com/hfkj/model/GoodsModel.java @@ -24,4 +24,8 @@ public class GoodsModel { */ JSONObject pddUrl; + /** + * 淘宝商品ID + */ + String itemId; } diff --git a/service/src/main/java/com/hfkj/model/PublishInfoModel.java b/service/src/main/java/com/hfkj/model/PublishInfoModel.java index 0f9c378..0bad392 100644 --- a/service/src/main/java/com/hfkj/model/PublishInfoModel.java +++ b/service/src/main/java/com/hfkj/model/PublishInfoModel.java @@ -18,6 +18,8 @@ public class PublishInfoModel { */ String couponShareUrl; + + /** * 搜索id,建议生成推广链接时候填写,提高收 */ diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java index ff19106..72a2edf 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsDataServiceImpl.java @@ -54,6 +54,8 @@ public class GoodsDataServiceImpl implements GoodsDataService { JSONObject income_info = publish_info.getJSONObject("income_info"); JSONArray final_promotion_path_list = price_promotion_info.getJSONArray("final_promotion_path_list"); + goodsModel.setItemId(object.getString("item_id")); + // 淘客推广信息 // 商品佣金信息 incomeInfoModel = new IncomeInfoModel(); diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderService.java b/service/src/main/java/com/hfkj/service/order/BsOrderService.java index e49bd0a..ca566ea 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderService.java @@ -67,7 +67,10 @@ public interface BsOrderService { * @Author: Sum1Dream * @Date: 2024/10/23 上午10:27 */ - JSONObject getOrderList(String startTime) throws Exception; + void getOrderPddList(String startTime) throws Exception; + + + void getOrderTaoBaoList(String startTime , String endTime) throws Exception; /** * @MethodName getOrderListParent 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 6e865f8..ed2b8f7 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 @@ -20,12 +20,15 @@ import com.hfkj.service.order.OrderBusinessService; import com.hfkj.service.pdd.PddService; import com.hfkj.service.promotion.PromotionBusinessService; import com.hfkj.service.sec.SecDictionaryService; +import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.user.BsUserContributeService; import com.hfkj.service.user.BsUserParentRelService; import com.hfkj.service.user.BsUserService; import com.hfkj.sysenum.partner.PartnerEnum; import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse; +import com.taobao.top.ability414.domain.TaobaoTbkOrderDetailsGetPublisherOrderDto; +import com.taobao.top.ability414.response.TaobaoTbkOrderDetailsGetResponse; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -36,6 +39,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -146,12 +150,19 @@ public class BsOrderServiceImpl implements BsOrderService { } @Override - public JSONObject getOrderList(String startTime) throws Exception{ - + public void getOrderPddList(String startTime) throws Exception{ pddOrder(startTime); - return null; } + @Override + public void getOrderTaoBaoList(String startTime , String endTime) { + try { + taoBaoOrder(startTime , endTime); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + } @Override public List getOrderListParent(Map map) { @@ -177,6 +188,9 @@ public class BsOrderServiceImpl implements BsOrderService { orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate)); // 将订单模型添加到订单模型列表中 orderModels.add(orderModel); + // 根据订单查询淘宝订单 + getOrderTaoBaoList(DateUtil.format( new Date(new Date().getTime() - 300000) , DateUtil.Y_M_D_HMS) , DateUtil.format( new Date(new Date().getTime() + 300000) , DateUtil.Y_M_D_HMS)); + } return orderModels; } @@ -209,11 +223,6 @@ public class BsOrderServiceImpl implements BsOrderService { @Override public void orderRebate(BsOrder bsOrder) throws Exception { - // 判断订单状态是否为4或5 - if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) { - // 如果是,则抛出异常,提示订单状态不可返利 - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态不可返利"); - } Map otherParam = new HashMap<>(); otherParam.put("sourceId", bsOrder.getId()); otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); @@ -225,15 +234,13 @@ public class BsOrderServiceImpl implements BsOrderService { } - - - // 根据开始时间获取拼多多订单列表 private void pddOrder(String startTime) throws Exception{ // 调用PddService的getOrderList方法获取订单列表 PddDdkOrderListRangeGetResponse rangeGetResponse = PddService.getOrderList(startTime); // 调用getOrderList方法获取本地订单列表 List list = getOrderList(new HashMap<>()); + List userList = userService.getList(new HashMap<>()); // 判断rangeGetResponse是否为空 if (rangeGetResponse != null) { // 获取订单列表 @@ -263,7 +270,7 @@ 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(Long.valueOf(uid)); + BsUser user = userList.stream().filter(s->s.getId().equals(Long.valueOf(uid))).findFirst().orElse(null); if (bsOrder == null) { // 如果BsOrder对象为空,则创建新的BsOrder对象 bsOrder = new BsOrder(); @@ -293,44 +300,144 @@ public class BsOrderServiceImpl implements BsOrderService { bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000)); } - if (orderListItem.getOrderModifyAt() != null) { - bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); + if (bsOrder.getStatus().equals(4)) { + if (orderListItem.getOrderModifyAt() != null) { + bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); + } } - if (orderListItem.getOrderModifyAt() != null) { - bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); - } create(bsOrder); }else { - // 如果BsOrder对象不为空,则更新BsOrder对象 - bsOrder.setUpdateTime(new Date()); - bsOrder.setStatus(orderListItem.getOrderStatus()); - bsOrder.setImg(orderListItem.getGoodsThumbnailUrl()); - bsOrder.setType(2); - bsOrder.setGoodsName(orderListItem.getGoodsName()); - bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); - bsOrder.setCustomparameters(orderListItem.getCustomParameters()); - 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 (bsOrder.getStatus() != 8) { + // 如果BsOrder对象不为空,则更新BsOrder对象 + bsOrder.setUpdateTime(new Date()); + bsOrder.setStatus(orderListItem.getOrderStatus()); + bsOrder.setImg(orderListItem.getGoodsThumbnailUrl()); + bsOrder.setType(2); + bsOrder.setGoodsName(orderListItem.getGoodsName()); + bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); + bsOrder.setCustomparameters(orderListItem.getCustomParameters()); + 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); + } else { + editData(bsOrder); + + } } - if (orderListItem.getOrderCreateTime() != null) { - bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()*1000)); + } + + } + } + } + + + } + + + private void taoBaoOrder(String startTime , String endTime) throws Exception { + TaobaoTbkOrderDetailsGetResponse response = TaoBaoService.getOrderList(startTime , endTime); + List list = getOrderList(new HashMap<>()); + Map reMap = new HashMap<>(); + reMap.put("relationId" , 1); + List userList = userService.getList(reMap); + + List results = response.getData().getResults(); + if (results != null && !results.isEmpty()) { + for (TaobaoTbkOrderDetailsGetPublisherOrderDto orderListItem : results) { + + BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getTradeParentId())).findFirst().orElse(null); + BsUser bsUser = userList.stream().filter(s->s.getRelationId().equals(orderListItem.getRelationId().toString())).findFirst().orElse(null); + + if (bsOrder == null) { + bsOrder = new BsOrder(); + bsOrder.setOrderNo(orderListItem.getTradeParentId()); + if (bsUser != null) { + bsOrder.setUserId(bsUser.getId()); + bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone()); + } + + + bsOrder.setCreateTime(new Date()); + bsOrder.setUpdateTime(new Date()); + bsOrder.setStatus(taoBaoStatus(orderListItem.getTkStatus())); + bsOrder.setImg("https://" + orderListItem.getItemImg()); + bsOrder.setType(1); + bsOrder.setGoodsName(orderListItem.getItemTitle()); + bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getItemNum())); + bsOrder.setTotalPrice(new BigDecimal(orderListItem.getAlipayTotalPrice())); + if (bsOrder.getStatus().equals(5)) { + bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubShareFeeForCommission())); + } else { + bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubSharePreFeeForCommission())); + } + + if (orderListItem.getTkPaidTime() != null) { + bsOrder.setPayTime(DateUtil.format(orderListItem.getTkPaidTime() , "yyyy-MM-dd HH:mm:ss")); + } + + if (orderListItem.getTkCreateTime() != null) { + bsOrder.setCreateTime(DateUtil.format(orderListItem.getTkCreateTime() , "yyyy-MM-dd HH:mm:ss")); + } + if (orderListItem.getTkEarningTime() != null) { + bsOrder.setFinishTime(DateUtil.format(orderListItem.getTkEarningTime() , "yyyy-MM-dd HH:mm:ss")); + } + + if (orderListItem.getModifiedTime() != null) { + bsOrder.setCancelTime(DateUtil.format(orderListItem.getModifiedTime() , "yyyy-MM-dd HH:mm:ss")); + } + create(bsOrder); + } else { + if (bsOrder.getStatus() != 8) { + bsOrder.setOrderNo(orderListItem.getTradeParentId()); + bsOrder.setUpdateTime(new Date()); + bsOrder.setStatus(taoBaoStatus(orderListItem.getTkStatus())); + bsOrder.setImg("https://" + orderListItem.getItemImg()); + bsOrder.setType(1); + bsOrder.setGoodsName(orderListItem.getItemTitle()); + bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getItemNum())); + bsOrder.setTotalPrice(new BigDecimal(orderListItem.getAlipayTotalPrice())); + if (bsOrder.getStatus().equals(5)) { + bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubShareFeeForCommission())); + } else { + bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubSharePreFeeForCommission())); } - if (orderListItem.getOrderSettleTime() != null) { - bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000)); + if (orderListItem.getTkPaidTime() != null) { + bsOrder.setPayTime(DateUtil.format(orderListItem.getTkPaidTime() , "yyyy-MM-dd HH:mm:ss")); } - if (orderListItem.getOrderModifyAt() != null) { - bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); + if (orderListItem.getTkCreateTime() != null) { + bsOrder.setCreateTime(DateUtil.format(orderListItem.getTkCreateTime() , "yyyy-MM-dd HH:mm:ss")); } - - if (orderListItem.getOrderModifyAt() != null) { - bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); + if (orderListItem.getTkEarningTime() != null) { + bsOrder.setFinishTime(DateUtil.format(orderListItem.getTkEarningTime() , "yyyy-MM-dd HH:mm:ss")); } + if (orderListItem.getModifiedTime() != null) { + bsOrder.setCancelTime(DateUtil.format(orderListItem.getModifiedTime() , "yyyy-MM-dd HH:mm:ss")); + } // 如果订单状态为5,则调用orderRebate方法 if (bsOrder.getStatus() == 5){ orderRebate(bsOrder); @@ -341,10 +448,25 @@ public class BsOrderServiceImpl implements BsOrderService { } } + } } } + + private Integer taoBaoStatus(Long status) { + int result = 6; + if (status == 3) { + result = 3; + } else if (status == 12) { + result = 0; + } else if (status == 13) { + result = 4; + } else if (status == 14) { + result = 1; + } + return result; + } } 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 93f4a61..a390ade 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,7 @@ 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.common.utils.DateUtil; import com.hfkj.entity.BsUser; import com.hfkj.service.user.BsUserService; import com.taobao.top.DefaultTopApiClient; @@ -15,11 +16,12 @@ import com.taobao.top.ability304.response.TaobaoTopAuthTokenCreateResponse; import com.taobao.top.ability375.Ability375; import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest; import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse; +import com.taobao.top.ability414.Ability414; +import com.taobao.top.ability414.request.TaobaoTbkOrderDetailsGetRequest; +import com.taobao.top.ability414.response.TaobaoTbkOrderDetailsGetResponse; 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; @@ -34,7 +36,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Resource; +import javax.xml.crypto.Data; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Date; import java.util.List; @@ -60,7 +67,7 @@ public class TaoBaoService { * @Author: Sum1Dream * @Date: 2024/9/10 下午1:52 */ - public static JSONObject material(String title , Long pageNo , Long pageSize , String specialId) throws Exception { + public static JSONObject material(String title , Long pageNo , Long pageSize , String specialId , String relationId ) throws Exception { if (StringUtils.isBlank(title)) { title = "百货"; } @@ -76,7 +83,8 @@ public class TaoBaoService { TaobaoTbkDgMaterialOptionalUpgradeRequest request = new TaobaoTbkDgMaterialOptionalUpgradeRequest(); request.setQ(title); request.setPageNo(pageNo); - request.setRelationId(specialId); + request.setRelationId(relationId); + request.setSpecialId(specialId); request.setHasCoupon(true); request.setPageSize(pageSize); request.setAdzoneId(115764450446L); @@ -193,4 +201,106 @@ public class TaoBaoService { } + public static JSONObject getPublisherInfo(String token , Long relationId , String specialId) throws Exception { + + log.info("============ 淘宝客-公用-私域用户备案-START ============="); + TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); + Ability425 apiPackage = new Ability425(client); + // create domain + + // create request + TaobaoTbkScPublisherInfoGetRequest request = new TaobaoTbkScPublisherInfoGetRequest(); + request.setInfoType(1L); + request.setRelationApp("common"); + request.setRelationId(relationId); + request.setSpecialId(specialId); + request.setPageNo(0L); + request.setPageSize(10L); + + TaobaoTbkScPublisherInfoGetResponse response = apiPackage.taobaoTbkScPublisherInfoGet(request,token); + + log.info("请求接口:" + "taobaoTbkScPublisherInfoSave"); + log.info("请求参数:" + JSONObject.toJSONString(request)); + log.info("响应参数:" + response); + log.info("============ 淘宝客-公用-私域用户备案--END =============="); + if(!response.isSuccess()){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getSubMsg()); + } + return JSONObject.parseObject(JSON.toJSONString(response)); + } + + + public static TaobaoTbkOrderDetailsGetResponse getOrderList(String startTime , String endTime) throws Exception { + + log.info("============ 淘宝客-公用-私域用户备案-START ============="); + TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); + Ability414 apiPackage = new Ability414(client); + + + // create request + TaobaoTbkOrderDetailsGetRequest request = new TaobaoTbkOrderDetailsGetRequest(); + request.setQueryType(1L); + request.setPageSize(20L); + request.setStartTime(startTime); + request.setEndTime(endTime); + request.setJumpType(1L); + request.setPageNo(1L); + request.setOrderScene(2L); + + TaobaoTbkOrderDetailsGetResponse response = apiPackage.taobaoTbkOrderDetailsGet(request); + + log.info("请求接口:" + "taobaoTbkScPublisherInfoSave"); + log.info("请求参数:" + JSONObject.toJSONString(request)); + log.info("响应参数:" + response); + log.info("============ 淘宝客-公用-私域用户备案--END =============="); + if(!response.isSuccess()){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getSubMsg()); + } + return response; + } + + + public static JSONObject generalLink(String itemId , String clickUrl , String relationId) throws Exception { + + log.info("============ 淘宝客-公用-私域用户备案-START ============="); + TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url); + Defaultability apiPackage = new Defaultability(client); + // create domain + TaobaoTbkDgGeneralLinkConvertTargetItemDTO taobaoTbkDgGeneralLinkConvertTargetItemDTO = new TaobaoTbkDgGeneralLinkConvertTargetItemDTO(); + TaobaoTbkDgGeneralLinkConvertLkItemDTO taobaoTbkDgGeneralLinkConvertLkItemDTO = new TaobaoTbkDgGeneralLinkConvertLkItemDTO(); + taobaoTbkDgGeneralLinkConvertLkItemDTO.setItemId(itemId); + TaobaoTbkDgGeneralLinkConvertLkMaterialDTO taobaoTbkDgGeneralLinkConvertLkMaterialDTO = new TaobaoTbkDgGeneralLinkConvertLkMaterialDTO(); + taobaoTbkDgGeneralLinkConvertLkMaterialDTO.setMaterialUrl(clickUrl); + + // create request + TaobaoTbkDgGeneralLinkConvertRequest request = new TaobaoTbkDgGeneralLinkConvertRequest(); + request.setBizSceneId("1"); + request.setPromotionType("2"); + List materialList = new ArrayList<>(); + materialList.add(clickUrl); + request.setMaterialList(materialList); + request.setAdzoneId(115764450446L); + List itemIdList = new ArrayList<>(); + itemIdList.add(itemId); + request.setItemIdList(itemIdList); + taobaoTbkDgGeneralLinkConvertTargetItemDTO.setItemIdList(itemIdList); // xxx + request.setTargetItem(taobaoTbkDgGeneralLinkConvertTargetItemDTO); + List materialDto = new ArrayList<>(); + materialDto.add(taobaoTbkDgGeneralLinkConvertLkMaterialDTO); + request.setMaterialDto(materialDto); + request.setRelationId(relationId); + + TaobaoTbkDgGeneralLinkConvertResponse response = apiPackage.taobaoTbkDgGeneralLinkConvert(request); + + log.info("请求接口:" + "taobaoTbkScPublisherInfoSave"); + log.info("请求参数:" + JSONObject.toJSONString(request)); + log.info("响应参数:" + response); + log.info("============ 淘宝客-公用-私域用户备案--END =============="); + if(!response.isSuccess()){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getSubMsg()); + } + return JSONObject.parseObject(JSON.toJSONString(response)); + } + + } diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 539f5e6..da35d76 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -265,6 +265,9 @@ public class BsUserServiceImpl implements BsUserService { criteria.andGradeEqualTo(MapUtils.getInteger(param, "grade")); } + if (MapUtils.getInteger(param, "relationId") != null) { + criteria.andRelationIdIsNotNull(); + } if (MapUtils.getInteger(param, "status") != null) { criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); }