Compare commits

..

No commits in common. 'e61f43889b94ed2cceb82b8a523f6d772b8972bb' and '02373d1178f3d96f119f9652c168a1d595f700c7' have entirely different histories.

  1. 23
      cweb/src/main/java/com/hfkj/controller/ElmController.java
  2. 32
      cweb/src/main/java/com/hfkj/controller/GoodsController.java
  3. 16
      schedule/src/main/java/com/hfkj/schedule/OrderSchedule.java
  4. 32
      service/src/main/java/com/hfkj/service/elm/ElmService.java
  5. 106
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java

@ -2,12 +2,9 @@ package com.hfkj.controller;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUser;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject; import com.hfkj.model.UserSessionObject;
import com.hfkj.service.elm.ElmService; import com.hfkj.service.elm.ElmService;
import com.hfkj.service.user.BsUserService;
import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -18,8 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller @Controller
@RequestMapping(value="/elm") @RequestMapping(value="/elm")
@Api(value="饿了么") @Api(value="饿了么")
@ -30,9 +25,6 @@ public class ElmController {
@Autowired @Autowired
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private BsUserService bsUserService;
@RequestMapping(value="/officialactivity",method = RequestMethod.GET) @RequestMapping(value="/officialactivity",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "本地联盟饿了么推广官方活动查询") @ApiOperation(value = "本地联盟饿了么推广官方活动查询")
@ -42,20 +34,7 @@ public class ElmController {
// 用户session // 用户session
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
BsUser user = bsUserService.getUser(session.getUser().getId()); return ResponseMsgUtil.success(ElmService.officialactivity(session.getUser().getId() , "10144"));
String pid = "alsc_28560886_9016007_22442020";
if(user != null){
if (user.getElmPid() == null) {
AlibabaAlscUnionMediaZoneAddResponse mediaZone = ElmService.mediaZone(user.getPhone());
pid = mediaZone.getResult().getPid();
user.setElmPid(pid);
bsUserService.editData(user);
} else {
pid = user.getElmPid();
}
}
return ResponseMsgUtil.success(ElmService.officialactivity(session.getUser().getId() , "10144" , pid));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);

@ -16,7 +16,6 @@ import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.pdd.PddService; import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.taobao.TaoBaoService;
import com.hfkj.service.user.BsUserService; import com.hfkj.service.user.BsUserService;
import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -26,6 +25,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@ -43,10 +44,6 @@ public class GoodsController {
@Resource @Resource
private BsUserService bsUserService; private BsUserService bsUserService;
@Resource
private BsOrderService orderService;
@RequestMapping(value="/goodsList",method = RequestMethod.GET) @RequestMapping(value="/goodsList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询商品列表") @ApiOperation(value = "查询商品列表")
@ -167,25 +164,6 @@ public class GoodsController {
} }
} }
@RequestMapping(value="/mediaZone",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "饿了么创建推广位")
public ResponseData mediaZone() {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
AlibabaAlscUnionMediaZoneAddResponse object = ElmService.mediaZone( userSession.getUser().getPhone());
return ResponseMsgUtil.success(object.getResult().getPid());
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getPublisherInfo",method = RequestMethod.GET) @RequestMapping(value="/getPublisherInfo",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "淘宝客-公用-私域用户备案信息查询") @ApiOperation(value = "淘宝客-公用-私域用户备案信息查询")
@ -216,11 +194,11 @@ public class GoodsController {
@RequestMapping(value="/getOrderList",method = RequestMethod.GET) @RequestMapping(value="/getOrderList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询订单") @ApiOperation(value = "查询订单")
public ResponseData getOrderList() { public ResponseData getOrderList(@RequestParam(value = "code" , required = false) String code
) {
try { try {
orderService.getOrderElmList("2024-10-20 09:34:00" , "2024-11-08 12:34:00"); return ResponseMsgUtil.success(ElmService.elmOrderList("2024-10-20 09:34:00" , "2024-11-04 12:34:00").getJSONArray("result"));
return ResponseMsgUtil.success("nu");
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);

@ -66,21 +66,5 @@ public class OrderSchedule {
} }
} }
@Scheduled(cron = "0 0/15 * * * ?") // 每十五分钟 执行一次
public void getOrderElmList() {
try {
// 昨日时间
// create domain
LocalDateTime now = LocalDateTime.now();
LocalDateTime twentyMinutesBefore = now.minus(Duration.ofMinutes(19));
// 昨日时间
orderService.getOrderElmList(twentyMinutesBefore.format(DateTimeFormatter.ofPattern(DateUtil.Y_M_D_HMS)) , DateUtil.format(new Date(),DateUtil.Y_M_D_HMS));
} catch (Exception e) {
System.out.println("查询失败!!!");
}
}
} }

@ -25,9 +25,10 @@ public class ElmService {
private static String appKey = "34818013"; private static String appKey = "34818013";
private static String appsecret = "822a2df4166dbab7e0acfc42ba0aab75"; private static String appsecret = "822a2df4166dbab7e0acfc42ba0aab75";
private static String url = "https://gw.api.taobao.com/router/rest"; private static String url = "https://gw.api.taobao.com/router/rest";
private static String pid = "alsc_28560886_9016007_22442020";
// 本地联盟饿了么推广官方活动查询 // 本地联盟饿了么推广官方活动查询
public static JSONObject officialactivity(Long userId , String activityId , String pid) throws Exception { public static JSONObject officialactivity(Long userId , String activityId) throws Exception {
// 打印日志,开始本地联盟饿了么推广官方活动查询 // 打印日志,开始本地联盟饿了么推广官方活动查询
log.info("============ 本地联盟饿了么推广官方活动查询-START ============="); log.info("============ 本地联盟饿了么推广官方活动查询-START =============");
@ -63,7 +64,7 @@ public class ElmService {
} }
public static AlibabaAlscUnionKbcpxPositiveOrderGetResponse elmOrderList(String startTime , String endTime) throws Exception { public static JSONObject elmOrderList(String startTime , String endTime) throws Exception {
// 打印日志, 本地生活媒体推广位创建 // 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建-START ============="); log.info("============ 本地生活媒体推广位创建-START =============");
@ -77,6 +78,7 @@ public class ElmService {
req.setPageSize(50L); req.setPageSize(50L);
req.setPageNumber(1L); req.setPageNumber(1L);
req.setStartDate(startTime); req.setStartDate(startTime);
req.setPid(pid);
req.setIncludeUsedStoreId(false); req.setIncludeUsedStoreId(false);
AlibabaAlscUnionKbcpxPositiveOrderGetResponse rsp = client.execute(req); AlibabaAlscUnionKbcpxPositiveOrderGetResponse rsp = client.execute(req);
@ -89,31 +91,7 @@ public class ElmService {
// 打印日志, 本地生活媒体推广位创建 // 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建--END =============="); log.info("============ 本地生活媒体推广位创建--END ==============");
// 返回响应参数 // 返回响应参数
return rsp; return JSONObject.parseObject(JSON.toJSONString(rsp));
}
public static AlibabaAlscUnionMediaZoneAddResponse mediaZone(String phone) throws Exception {
// 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建-START =============");
// 创建淘宝客户端
TaobaoClient client = new DefaultTaobaoClient(url, appKey, appsecret);
AlibabaAlscUnionMediaZoneAddRequest req = new AlibabaAlscUnionMediaZoneAddRequest();
req.setZoneName(phone);
AlibabaAlscUnionMediaZoneAddResponse rsp = client.execute(req);
// 打印日志,请求接口
log.info("请求接口:" + "officialactivity");
// 打印日志,请求参数
log.info("请求参数:" + JSONObject.toJSONString(req));
// 打印日志,响应参数
log.info("响应参数:" + rsp);
// 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建--END ==============");
// 返回响应参数
return rsp;
} }
} }

@ -16,7 +16,6 @@ import com.hfkj.entity.BsOrderExample;
import com.hfkj.entity.BsUser; import com.hfkj.entity.BsUser;
import com.hfkj.model.BsOrderModel; import com.hfkj.model.BsOrderModel;
import com.hfkj.model.UserTeamModel; import com.hfkj.model.UserTeamModel;
import com.hfkj.service.elm.ElmService;
import com.hfkj.service.meituan.MeiTuanService; import com.hfkj.service.meituan.MeiTuanService;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderBusinessService; import com.hfkj.service.order.OrderBusinessService;
@ -30,7 +29,6 @@ import com.hfkj.service.user.BsUserService;
import com.hfkj.sysenum.partner.PartnerEnum; import com.hfkj.sysenum.partner.PartnerEnum;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse; import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse;
import com.taobao.api.response.AlibabaAlscUnionKbcpxPositiveOrderGetResponse;
import com.taobao.top.ability414.domain.TaobaoTbkOrderDetailsGetPublisherOrderDto; import com.taobao.top.ability414.domain.TaobaoTbkOrderDetailsGetPublisherOrderDto;
import com.taobao.top.ability414.response.TaobaoTbkOrderDetailsGetResponse; import com.taobao.top.ability414.response.TaobaoTbkOrderDetailsGetResponse;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -186,7 +184,7 @@ public class BsOrderServiceImpl implements BsOrderService {
@Override @Override
public void getOrderElmList(String startTime, String endTime) { public void getOrderElmList(String startTime, String endTime) {
try { try {
elmOrder(startTime , endTime); meiTuanOrder(startTime , endTime);
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
@ -597,106 +595,18 @@ public class BsOrderServiceImpl implements BsOrderService {
} else { } else {
// 否则,调用editData方法,更新订单信息 // 否则,调用editData方法,更新订单信息
editData(bsOrder); editData(bsOrder);
}
}
}
}
}
}
private void elmOrder(String startTime , String endTime) throws Exception {
AlibabaAlscUnionKbcpxPositiveOrderGetResponse elmOrderList = ElmService.elmOrderList(startTime ,endTime);
List<AlibabaAlscUnionKbcpxPositiveOrderGetResponse.OrderDetailReportDTO> elmOrderListResult = elmOrderList.getResult();
List<BsOrder> list = getOrderList(new HashMap<>());
List<BsUser> userList = userService.getList(new HashMap<>());
userList = userList.stream().filter(s->s.getElmPid() != null).collect(Collectors.toList());
if (elmOrderListResult != null && !elmOrderListResult.isEmpty()) {
for (AlibabaAlscUnionKbcpxPositiveOrderGetResponse.OrderDetailReportDTO elmOrder : elmOrderListResult) {
// 根据订单号,从本地订单列表中查找订单
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(elmOrder.getBizOrderId().toString())).findFirst().orElse(null);
// 根据relationId,从用户列表中查找用户
BsUser bsUser = userList.stream().filter(s->s.getElmPid().equals(elmOrder.getPid())).findFirst().orElse(null);
// 如果本地订单列表中没有该订单,则创建一个新的订单
if (bsOrder == null) {
bsOrder = new BsOrder();
bsOrder.setOrderNo(elmOrder.getBizOrderId().toString());
if (bsUser != null) {
bsOrder.setUserId(bsUser.getId());
bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone());
}
bsOrder.setCreateTime(new Date());
bsOrder.setUpdateTime(new Date());
bsOrder.setStatus(elmStatus(elmOrder.getOrderState()));
bsOrder.setType(4);
bsOrder.setGoodsName(elmOrder.getTitle());
bsOrder.setGoodsCount(1);
bsOrder.setTotalPrice(new BigDecimal(elmOrder.getPayAmount()));
bsOrder.setPromotionAmount(new BigDecimal(elmOrder.getSettleAmount()));
if (elmOrder.getTkCreateTime() != null) {
bsOrder.setCreateTime(DateUtil.format(elmOrder.getTkCreateTime() , DateUtil.Y_M_D_HMS));
}
if (elmOrder.getPayTime() != null) {
bsOrder.setPayTime(DateUtil.format(elmOrder.getPayTime() , DateUtil.Y_M_D_HMS));
}
if (elmOrder.getSettleTime() != null) {
bsOrder.setFinishTime(DateUtil.format(elmOrder.getSettleTime() , DateUtil.Y_M_D_HMS));
} }
// 调用create方法,将新订单保存到本地订单列表中
create(bsOrder);
} else {
// 如果本地订单列表中已有该订单,则更新订单信息
if (bsOrder.getStatus() == 2) {
bsOrder.setOrderNo(elmOrder.getBizOrderId().toString());
if (bsUser != null) {
bsOrder.setUserId(bsUser.getId());
bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone());
} }
bsOrder.setCreateTime(new Date());
bsOrder.setUpdateTime(new Date());
bsOrder.setStatus(elmStatus(elmOrder.getOrderState()));
bsOrder.setType(4);
bsOrder.setGoodsName(elmOrder.getTitle());
bsOrder.setGoodsCount(1);
bsOrder.setTotalPrice(new BigDecimal(elmOrder.getPayAmount()));
bsOrder.setPromotionAmount(new BigDecimal(elmOrder.getSettleAmount()));
if (elmOrder.getTkCreateTime() != null) {
bsOrder.setCreateTime(DateUtil.format(elmOrder.getTkCreateTime() , DateUtil.Y_M_D_HMS));
} }
if (elmOrder.getPayTime() != null) {
bsOrder.setPayTime(DateUtil.format(elmOrder.getPayTime() , DateUtil.Y_M_D_HMS));
}
if (elmOrder.getSettleTime() != null) {
bsOrder.setFinishTime(DateUtil.format(elmOrder.getSettleTime() , DateUtil.Y_M_D_HMS));
}
// 如果订单状态为5,则调用orderRebate方法
if (bsOrder.getStatus() == 2 && elmOrder.getOrderState() == 4){
orderRebate(bsOrder);
} else {
// 否则,调用editData方法,更新订单信息
editData(bsOrder);
} }
} }
}
}
} }
}
private Integer pddStatus(Long status) { private Integer pddStatus(Long status) {
int result = 4; int result = 4;
if (status == 0) { if (status == 0) {
@ -742,18 +652,4 @@ public class BsOrderServiceImpl implements BsOrderService {
} }
return result; return result;
} }
private Integer elmStatus(Long status) {
int result = 4;
if (status == 1) {
result = 1;
} else if (status == 0) {
result = 4;
} else if (status == 2) {
result = 2;
} else if (status == 4) {
result = 2;
}
return result;
}
} }

Loading…
Cancel
Save