This commit is contained in:
Owen 2025-01-10 18:10:16 +08:00
parent f711ad2468
commit bfa2212148
5 changed files with 89 additions and 11 deletions

View File

@ -47,6 +47,13 @@ public class OrdersController {
return success(ordersService.createOrders(createReqVO));
}
@PostMapping("/re-create-order/{orderId}")
@Operation(summary = "订单重提")
@PreAuthorize("@ss.hasPermission('haoka:orders:create')")
public CommonResult<Long> reCreateOrders(@NotNull @PathVariable Long orderId) {
return success(ordersService.reCreateOrder(orderId));
}
@PutMapping("/update")
@Operation(summary = "更新订单")
@PreAuthorize("@ss.hasPermission('haoka:orders:update')")

View File

@ -46,17 +46,17 @@ public class HaokaLianTongUpdateOrderSchedule {
@Scheduled(cron = "0 */25 * * * ?")
public void updateOrder() {
String type = new String();
log.info("开始-----------联通--更新订单开始--------------------");
tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
TenantContextHolder.setTenantId(tenantId);
});
log.info("结束-----------联通--更新订单结束--------------------");
}
// @Scheduled(cron = "0 */25 * * * ?")
// public void updateOrder() {
// String type = new String();
//
// log.info("开始-----------联通--更新订单开始--------------------");
// tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
// TenantContextHolder.setTenantId(tenantId);
//
// });
// log.info("结束-----------联通--更新订单结束--------------------");
// }

View File

@ -11,9 +11,12 @@ import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService;
import cn.iocoder.yudao.module.haoka.service.superiorapi.SuperiorApiService;
import cn.iocoder.yudao.module.haoka.service.superiorapilog.SuperiorApiLogService;
import jakarta.annotation.Resource;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Component(ApiFrom.ApiDealStrategyImpl)
public class ApiDealServiceImpl implements ApiDealStrategyService {
@ -28,13 +31,21 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
@Resource
private SuperiorApiService superiorApiService;
@Resource
private RedissonClient redissonClient;
@Override
public ApiDealResp<OrderApiCreateResp> createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) {
String redisKey="ApiDealServiceImpl::createOrder::"+param.getId();
RLock lock = redissonClient.getLock(redisKey);
logVO.setApiType(1);
logVO.setHaokaOrderId(param.getId());
logVO.setHaokaProductId(param.getProductId());
logVO.setHaokaSuperiorApiId(param.getSuperiorApiId());
try {
lock.lock(1, TimeUnit.SECONDS);
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(param.getProductId());
if (onSaleProductPreOrder == null) {
String msg = "关联上级产品不存在";
@ -72,6 +83,7 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
logVO.setErrorInfo(e.getMessage());
return ApiDealResp.failed(e.getMessage());
} finally {
lock.unlock();
superiorApiLogService.createSuperiorApiLog(logVO);
}
}

View File

@ -55,4 +55,12 @@ public interface OrdersService extends IService<OrdersDO> {
PageResult<OrdersDO> getOrdersPage(OrdersPageReqVO pageReqVO);
void auditOrders(OrdersSaveReqVO updateReqVO);
/**
* 重新提交订单
*
* @param orderId orderId
* @return orderId
*/
public Long reCreateOrder(Long orderId);
}

View File

@ -25,6 +25,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.haoka.dal.mysql.orders.OrdersMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
/**
@ -46,6 +47,56 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
@Resource
private SmsTaskService smsTaskService;
/**
* 重新提交订单
* @param orderId
* @return
*/
public Long reCreateOrder(Long orderId){
if (ObjectUtil.isEmpty(orderId)){
throw invalidParamException("参数orderId不能为空");
}
OrdersDO ordersDO = ordersMapper.selectById(orderId);
Long statusOld = ordersDO.getStatus();
if (ObjectUtil.isEmpty(ordersDO)){
throw invalidParamException("订单不存在!");
}
// 调用上游接口下单
// 并且根据上游下单结果处理ordersDO
// 最后把 处理后的ordersDO 更新存入数据库
ordersDO = handleOrderCreate(ordersDO);
ordersMapper.updateById(ordersDO);
// 判断是否需要发送短信
// 如果订单订单状态变更需要发送短信
if (statusOld!=null && statusOld.equals(ordersDO.getStatus())){
// 创建后需要发送短信
smsTaskService.sendSMS(
ordersDO.getStatus(),
ordersDO.getId(),
ordersDO.getSource(),
ordersDO.getOnSaleProductId(),
ordersDO.getRefundStatus(),
ordersDO.getCallStatus(),
ordersDO.getAddressMobile(),
ordersDO
);
}
return orderId;
}
private OrdersDO handleOrderCreate(final OrdersDO ordersDO){
OrderApiCreateParam param = new OrderApiCreateParam();
BeanUtils.copyProperties(ordersDO,param);
ApiDealResp<OrderApiCreateResp> strategyServiceOrder = apiDealStrategyService.createOrder(param);
// todo: 根据上游创建订单结果更新 ordersDO的信息 状态上游订单id等等.....
//
return ordersDO;
}
// 19547688 -> 电信 19547688 湖南电信号码+号码ID
@Override
public Long createOrders(OrdersSaveReqVO createReqVO) {