reCreateOrders
This commit is contained in:
parent
2d2da30774
commit
5c79b1e934
|
@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.haoka.service.api.ApiDealStrategyService;
|
|||
import cn.iocoder.yudao.module.haoka.service.api.models.ApiDealResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiQueryResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.orders.OrdersService;
|
||||
import cn.iocoder.yudao.module.haoka.service.orders.UpstreamOrderStatusInfo;
|
||||
import cn.iocoder.yudao.module.haoka.service.superiorapi.SuperiorApiService;
|
||||
import cn.iocoder.yudao.module.haoka.service.superiorapilog.SuperiorApiLogService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
@ -57,7 +58,7 @@ public class HaokaUpdateOrderSchedule {
|
|||
private ApiLianTongService apiLianTongService;
|
||||
|
||||
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
@Scheduled(cron = "0 */1 * * * ?")
|
||||
public void updateOrder() {
|
||||
log.info("开始-----------更新订单开始--------------------");
|
||||
tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
|
||||
|
@ -93,7 +94,7 @@ public class HaokaUpdateOrderSchedule {
|
|||
//18 开卡失败 -460
|
||||
//19 证件不合格待重传 -200
|
||||
//20 订单终止 0
|
||||
pageReqVO.setStatus(Lists.newArrayList(460L,470L,500L,550L)); // 已经完成/取消/删除的订单,不需要再从上游同步,这里过滤掉
|
||||
// pageReqVO.setStatus(Lists.newArrayList(460L,470L,500L,550L)); // 已经完成/取消/删除的订单,不需要再从上游同步,这里过滤掉
|
||||
|
||||
while ((long) pageNo * pageSize < total) {
|
||||
pageNo += 1;
|
||||
|
@ -102,6 +103,9 @@ public class HaokaUpdateOrderSchedule {
|
|||
PageResult<OrdersDO> ordersPage = ordersService.getOrdersPage(pageReqVO);
|
||||
total = ordersPage.getTotal();
|
||||
for (OrdersDO ordersDO : ordersPage.getList()) {
|
||||
if (554892432475426816L != ordersDO.getId()) {
|
||||
continue;
|
||||
}
|
||||
// 开始从上游同步订单状态,解析,并且更新本地订单状态
|
||||
updateOrderInfo(ordersDO);
|
||||
}
|
||||
|
@ -165,32 +169,33 @@ public class HaokaUpdateOrderSchedule {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 上游对订单状态的描述
|
||||
String orderStatusDesc = data.getSupplierOrderStatusDesc();
|
||||
if (StringUtils.isNotEmpty(orderStatusDesc)) {
|
||||
ordersDO.setUpStatus(orderStatusDesc);
|
||||
}
|
||||
|
||||
// 物流信息 头都
|
||||
|
||||
Long orderId = ordersDO.getId();
|
||||
Integer upstreamOrderStatus = Integer.valueOf(orderStatusCode);
|
||||
String upstreamOrderStatusDescOrReason = data.getSupplierOrderStatusDesc();
|
||||
|
||||
UpstreamOrderStatusInfo upstreamOrderStatusInfo = new UpstreamOrderStatusInfo();
|
||||
|
||||
String trackingNumber = data.getTrackingNumber();
|
||||
if (StringUtils.isNotEmpty(trackingNumber)) {
|
||||
ordersDO.setTrackingNumber(trackingNumber);
|
||||
upstreamOrderStatusInfo.setTrackingNumber(trackingNumber);
|
||||
}
|
||||
String trackingCompany = data.getTrackingCompany();
|
||||
if (StringUtils.isNotEmpty(trackingCompany)) {
|
||||
ordersDO.setTrackingCompany(trackingCompany);
|
||||
upstreamOrderStatusInfo.setTrackingCompany(trackingCompany);
|
||||
}
|
||||
|
||||
|
||||
if (data.isNeedUpdateProducePhoneNum()) {
|
||||
ordersDO.setPlanMobileProduced(data.getSupplierPhoneNumber());
|
||||
upstreamOrderStatusInfo.setPlanMobileProduced(data.getSupplierPhoneNumber());
|
||||
}
|
||||
|
||||
|
||||
// todo 上游更新
|
||||
ordersService.updateById(ordersDO);
|
||||
ordersService.changeUpstreamOrderStatus(orderId, upstreamOrderStatus, upstreamOrderStatusDescOrReason,
|
||||
upstreamOrderStatusInfo);
|
||||
log.info("更新后--:{}", JSON.toJSONString(ordersDO));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,13 @@ import cn.iocoder.yudao.module.haoka.service.superiorproductconfig.SuperiorProdu
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.val;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component(ApiFrom.HuNanDXApiDealStrategy)
|
||||
public class HuNanDxApiDealStrategy implements ApiDealStrategy {
|
||||
|
@ -370,15 +373,12 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
|
|||
}
|
||||
|
||||
|
||||
|
||||
orderApiQueryResp.setOrderStatusCode("0");
|
||||
orderApiQueryResp.setSupplierOrderStatusDesc("busOppOrder null");
|
||||
return ApiDealResp.ok(orderApiQueryResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
JSONObject busOppOrder = data.getJSONObject("busOppOrder");
|
||||
if (busOppOrder == null) {
|
||||
// return ApiDealResp.failed("busOppOrder null");
|
||||
|
@ -390,6 +390,11 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
|
|||
|
||||
String tbBusOppOrderThState = busOppOrder.getString("tbBusOppOrderThState");
|
||||
|
||||
String stateReason = busOppOrder.getString("tbBusOppCancelReason");
|
||||
if (stateReason==null){
|
||||
stateReason = "";
|
||||
}
|
||||
|
||||
if (tbBusOppOrderThState == null) {
|
||||
// return ApiDealResp.failed("tbBusOppOrderThState null");
|
||||
|
||||
|
@ -398,17 +403,33 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
|
|||
return ApiDealResp.ok(orderApiQueryResp);
|
||||
}
|
||||
|
||||
if (!tbBusOppOrderThState.equals("1")) {
|
||||
// return ApiDealResp.failed("tbBusOppOrderThState null");
|
||||
|
||||
orderApiQueryResp.setOrderStatusCode("0");
|
||||
orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + tbBusOppOrderThState + ",状态说明:0待确认,1生产,2作废,3同步失败,4待下单,5待转业务单,8业务单挂起状态");
|
||||
Map<String, String> tbStateDescMap = new HashMap<>();
|
||||
tbStateDescMap.put("0", "0待确认");
|
||||
tbStateDescMap.put("1", "1生产");
|
||||
tbStateDescMap.put("2", "2作废");
|
||||
tbStateDescMap.put("3", "3同步失败");
|
||||
tbStateDescMap.put("4", "4待下单");
|
||||
tbStateDescMap.put("5", "5待转业务单");
|
||||
tbStateDescMap.put("8", "8业务单挂起状态");
|
||||
|
||||
|
||||
// 状态说明:0待确认,1生产,2作废,3同步失败,4待下单,5待转业务单,8业务单挂起状态
|
||||
String supplierOrderStatusDesc = tbStateDescMap.getOrDefault(tbBusOppOrderThState,"")+stateReason;
|
||||
if ("2,3,5,8".contains(tbBusOppOrderThState)) {
|
||||
orderApiQueryResp.setOrderStatusCode("-460");
|
||||
orderApiQueryResp.setSupplierOrderStatusDesc(supplierOrderStatusDesc);
|
||||
return ApiDealResp.ok(orderApiQueryResp);
|
||||
|
||||
}
|
||||
|
||||
orderApiQueryResp.setData(responseInfo);
|
||||
if (!tbBusOppOrderThState.equals("1")) {
|
||||
orderApiQueryResp.setOrderStatusCode("470");
|
||||
orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + tbBusOppOrderThState + ",状态说明:0待确认,1生产,2作废,3同步失败,4待下单,5待转业务单,8业务单挂起状态");
|
||||
} else {
|
||||
orderApiQueryResp.setData(responseInfo);
|
||||
orderApiQueryResp.setOrderStatusCode("500");
|
||||
}
|
||||
orderApiQueryResp.setSupplierOrderStatusDesc(supplierOrderStatusDesc);
|
||||
return ApiDealResp.ok(orderApiQueryResp);
|
||||
} catch (Exception e) {
|
||||
return ApiDealResp.failed(e.getMessage());
|
||||
|
|
|
@ -54,6 +54,14 @@ public interface OrdersService extends IService<OrdersDO> {
|
|||
*/
|
||||
PageResult<OrdersDO> getOrdersPage(OrdersPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* @param orderId 订单ID
|
||||
* @param upstreamOrderStatus 上游订单状态(-430 生产异常 -460 提交异常 0 开卡中470 待发货500 已发货550 已激活700)
|
||||
* @param upstreamOrderStatusDescOrReason 状态描述或者原因
|
||||
*/
|
||||
void changeUpstreamOrderStatus(Long orderId, Integer upstreamOrderStatus,
|
||||
String upstreamOrderStatusDescOrReason, UpstreamOrderStatusInfo upstreamOrderStatusInfo);
|
||||
|
||||
void auditOrdersAsync(OrdersSaveReqVO updateReqVO);
|
||||
|
||||
void auditOrders(OrdersSaveReqVO updateReqVO);
|
||||
|
@ -84,18 +92,21 @@ public interface OrdersService extends IService<OrdersDO> {
|
|||
|
||||
/**
|
||||
* 异步执行
|
||||
*
|
||||
* @param ordersDO
|
||||
*/
|
||||
void asyncSubmitAuditOrders(OrdersDO ordersDO);
|
||||
|
||||
/**
|
||||
* 异步执行
|
||||
*
|
||||
* @param ordersDO
|
||||
*/
|
||||
void asyncAuditOrders(OrdersDO ordersDO);
|
||||
|
||||
/**
|
||||
* 异步执行
|
||||
*
|
||||
* @param oldOrderDo
|
||||
* @param updateObj
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.haoka.service.api.models.ApiDealResp;
|
|||
import cn.iocoder.yudao.module.haoka.service.api.ApiDealStrategyService;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiCreateParam;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiCreateResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.api.models.OrderApiQueryResp;
|
||||
import cn.iocoder.yudao.module.haoka.service.blacklist.BlackListService;
|
||||
import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService;
|
||||
import cn.iocoder.yudao.module.haoka.service.orderCatch.DouDianOrderCatchServiceImpl;
|
||||
|
@ -30,6 +31,7 @@ import com.doudian.open.api.order_addOrderRemark.param.OrderAddOrderRemarkParam;
|
|||
import com.doudian.open.api.order_logisticsAdd.OrderLogisticsAddResponse;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -123,6 +125,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
/**
|
||||
* 在号卡系统创建订单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return
|
||||
*/
|
||||
|
@ -182,6 +185,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
/**
|
||||
* 异步判断是否自动提交审核订单
|
||||
*
|
||||
* @param ordersDO
|
||||
*/
|
||||
@Async
|
||||
|
@ -340,6 +344,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
/**
|
||||
* 异步判断是否自动审核订单
|
||||
*
|
||||
* @param ordersDO
|
||||
*/
|
||||
@Async
|
||||
|
@ -352,6 +357,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
/**
|
||||
* 判断手机号和身份证是否在黑名单中
|
||||
*
|
||||
* @param list
|
||||
* @param phoneNumber
|
||||
* @param idcard
|
||||
|
@ -575,6 +581,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
|
||||
/**
|
||||
* 强制修改订单提交状态
|
||||
*
|
||||
* @param updateReqVO
|
||||
*/
|
||||
@Override
|
||||
|
@ -706,4 +713,67 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
|||
return ordersMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
|
||||
private Long switchUpstreamOrderStatus( Integer upstreamOrderStatus){
|
||||
return switch (upstreamOrderStatus) {
|
||||
case -430 -> 0L;
|
||||
case -460 -> 2L;
|
||||
case 0 -> 3L;
|
||||
case 470 -> 4L;
|
||||
case 500 -> 5L;
|
||||
case 700 -> 6L;
|
||||
default -> {
|
||||
log.error("未知上游订单状态{}", upstreamOrderStatus);
|
||||
yield 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param orderId 订单ID
|
||||
* @param upstreamOrderStatus 上游订单状态(-430 生产异常 -460 提交异常 0 开卡中470 待发货500 已发货550 已激活700)
|
||||
* @param upstreamOrderStatusDescOrReason 状态描述或者原因
|
||||
*/
|
||||
public void changeUpstreamOrderStatus(Long orderId,
|
||||
Integer upstreamOrderStatus,
|
||||
String upstreamOrderStatusDescOrReason,
|
||||
UpstreamOrderStatusInfo upstreamOrderStatusInfo) {
|
||||
OrdersDO ordersDO = validateOrdersExists(orderId);
|
||||
if (upstreamOrderStatusDescOrReason != null) {
|
||||
String oldReason = ordersDO.getReason() == null ? "" : ordersDO.getReason();
|
||||
ordersDO.setReason(upstreamOrderStatusDescOrReason + ";\n" + oldReason);
|
||||
}
|
||||
|
||||
if (Objects.equals(upstreamOrderStatus, ordersDO.getUpstreamOrderStatus())) {
|
||||
log.debug("上游订单状态没变化,订单ID:{}", orderId);
|
||||
return;
|
||||
}
|
||||
|
||||
// (-430 生产异常 -460 提交异常 0 开卡中470 待发货500 已发货550 已激活700)
|
||||
Long orderStatus = this.switchUpstreamOrderStatus(upstreamOrderStatus);
|
||||
ordersDO.setStatus(orderStatus);
|
||||
|
||||
if (upstreamOrderStatusInfo != null) {
|
||||
// 上游产生物流信息
|
||||
String trackingNumber = upstreamOrderStatusInfo.getTrackingNumber();
|
||||
if (trackingNumber != null) {
|
||||
ordersDO.setPlanMobileProduced(trackingNumber);
|
||||
}
|
||||
String trackingCompany = upstreamOrderStatusInfo.getTrackingCompany();
|
||||
if (trackingCompany != null) {
|
||||
ordersDO.setPlanMobileProduced(trackingCompany);
|
||||
}
|
||||
// 上游生产号码
|
||||
String planMobileProduced = upstreamOrderStatusInfo.getPlanMobileProduced();
|
||||
if (planMobileProduced != null) {
|
||||
ordersDO.setPlanMobileProduced(planMobileProduced);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新订单
|
||||
this.updateOrderById(ordersDO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package cn.iocoder.yudao.module.haoka.service.orders;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpstreamOrderStatusInfo {
|
||||
|
||||
/**
|
||||
* 物流公司名称
|
||||
*/
|
||||
private String trackingCompany;
|
||||
|
||||
/**
|
||||
* 物流单号
|
||||
*/
|
||||
private String trackingNumber;
|
||||
|
||||
/**
|
||||
* 生产号码
|
||||
*/
|
||||
private String planMobileProduced;
|
||||
}
|
Loading…
Reference in New Issue