sms
This commit is contained in:
parent
f711ad2468
commit
bfa2212148
|
|
@ -47,6 +47,13 @@ public class OrdersController {
|
||||||
return success(ordersService.createOrders(createReqVO));
|
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")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新订单")
|
@Operation(summary = "更新订单")
|
||||||
@PreAuthorize("@ss.hasPermission('haoka:orders:update')")
|
@PreAuthorize("@ss.hasPermission('haoka:orders:update')")
|
||||||
|
|
|
||||||
|
|
@ -46,17 +46,17 @@ public class HaokaLianTongUpdateOrderSchedule {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 */25 * * * ?")
|
// @Scheduled(cron = "0 */25 * * * ?")
|
||||||
public void updateOrder() {
|
// public void updateOrder() {
|
||||||
String type = new String();
|
// String type = new String();
|
||||||
|
//
|
||||||
log.info("开始-----------联通--更新订单开始--------------------");
|
// log.info("开始-----------联通--更新订单开始--------------------");
|
||||||
tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
|
// tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
|
||||||
TenantContextHolder.setTenantId(tenantId);
|
// TenantContextHolder.setTenantId(tenantId);
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
log.info("结束-----------联通--更新订单结束--------------------");
|
// log.info("结束-----------联通--更新订单结束--------------------");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.superiorapi.SuperiorApiService;
|
||||||
import cn.iocoder.yudao.module.haoka.service.superiorapilog.SuperiorApiLogService;
|
import cn.iocoder.yudao.module.haoka.service.superiorapilog.SuperiorApiLogService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Component(ApiFrom.ApiDealStrategyImpl)
|
@Component(ApiFrom.ApiDealStrategyImpl)
|
||||||
public class ApiDealServiceImpl implements ApiDealStrategyService {
|
public class ApiDealServiceImpl implements ApiDealStrategyService {
|
||||||
|
|
@ -28,13 +31,21 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SuperiorApiService superiorApiService;
|
private SuperiorApiService superiorApiService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiDealResp<OrderApiCreateResp> createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) {
|
public ApiDealResp<OrderApiCreateResp> createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) {
|
||||||
|
String redisKey="ApiDealServiceImpl::createOrder::"+param.getId();
|
||||||
|
RLock lock = redissonClient.getLock(redisKey);
|
||||||
logVO.setApiType(1);
|
logVO.setApiType(1);
|
||||||
logVO.setHaokaOrderId(param.getId());
|
logVO.setHaokaOrderId(param.getId());
|
||||||
logVO.setHaokaProductId(param.getProductId());
|
logVO.setHaokaProductId(param.getProductId());
|
||||||
logVO.setHaokaSuperiorApiId(param.getSuperiorApiId());
|
logVO.setHaokaSuperiorApiId(param.getSuperiorApiId());
|
||||||
try {
|
try {
|
||||||
|
lock.lock(1, TimeUnit.SECONDS);
|
||||||
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(param.getProductId());
|
OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(param.getProductId());
|
||||||
if (onSaleProductPreOrder == null) {
|
if (onSaleProductPreOrder == null) {
|
||||||
String msg = "关联上级产品不存在";
|
String msg = "关联上级产品不存在";
|
||||||
|
|
@ -72,6 +83,7 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
|
||||||
logVO.setErrorInfo(e.getMessage());
|
logVO.setErrorInfo(e.getMessage());
|
||||||
return ApiDealResp.failed(e.getMessage());
|
return ApiDealResp.failed(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
superiorApiLogService.createSuperiorApiLog(logVO);
|
superiorApiLogService.createSuperiorApiLog(logVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,12 @@ public interface OrdersService extends IService<OrdersDO> {
|
||||||
PageResult<OrdersDO> getOrdersPage(OrdersPageReqVO pageReqVO);
|
PageResult<OrdersDO> getOrdersPage(OrdersPageReqVO pageReqVO);
|
||||||
|
|
||||||
void auditOrders(OrdersSaveReqVO updateReqVO);
|
void auditOrders(OrdersSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新提交订单
|
||||||
|
*
|
||||||
|
* @param orderId orderId
|
||||||
|
* @return orderId
|
||||||
|
*/
|
||||||
|
public Long reCreateOrder(Long orderId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.haoka.dal.mysql.orders.OrdersMapper;
|
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.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
|
||||||
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,6 +47,56 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, OrdersDO> imple
|
||||||
@Resource
|
@Resource
|
||||||
private SmsTaskService smsTaskService;
|
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
|
// 19547688 -> 电信 19547688 湖南电信,:号码+号码ID
|
||||||
@Override
|
@Override
|
||||||
public Long createOrders(OrdersSaveReqVO createReqVO) {
|
public Long createOrders(OrdersSaveReqVO createReqVO) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue