|
|
@@ -55,6 +55,7 @@ import com.zhongshu.card.server.core.httpRequest.ApiRequestService;
|
|
|
import com.zhongshu.card.server.core.service.base.CommonService;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
|
|
|
+import com.zhongshu.card.server.core.service.keyExpire.impl.OrderKeyExpire;
|
|
|
import com.zhongshu.card.server.core.service.mqtt.MqttServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
|
|
|
@@ -132,6 +133,9 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
@Autowired
|
|
|
private OrganizationUserServiceImpl organizationUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrderKeyExpire orderKeyExpire;
|
|
|
+
|
|
|
/**
|
|
|
* 创建流水
|
|
|
*
|
|
|
@@ -217,9 +221,12 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
expirationTime = OrderConfig.orderExpirationTime;
|
|
|
}
|
|
|
expenseFlow.setExpirationTime(System.currentTimeMillis() + expirationTime);
|
|
|
+ expenseFlow.setExpireTime(expirationTime);
|
|
|
|
|
|
// 验证参数、填充数据
|
|
|
commonVerifyExpenseFlow(expenseFlow);
|
|
|
+ // 开始计时订单过期时间
|
|
|
+ delayedTimeout(expenseFlow);
|
|
|
return ResultContent.buildSuccess(expenseFlow);
|
|
|
}
|
|
|
|
|
|
@@ -525,7 +532,10 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
sendMessageModel.setUserId(userId);
|
|
|
log.info("mq topic : {}", topic);
|
|
|
mqttService.sendMessage(sendMessageModel);
|
|
|
+ // 记录设备使用记录数据
|
|
|
payCallService.buildDeviceUseRecord(expenseFlow);
|
|
|
+ // 取消定时任务
|
|
|
+ clearDelayedTimeout(expenseFlow);
|
|
|
} else {
|
|
|
log.error("wxSurePaymentTypeOrderPayCallSuccess 订单为空: {}", orderNo);
|
|
|
}
|
|
|
@@ -582,6 +592,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
entity.setPaymentType(PaymentType.UserWallet);
|
|
|
expenseFlowDao.save(entity);
|
|
|
}
|
|
|
+ // 添加设备使用记录
|
|
|
payCallService.buildDeviceUseRecord(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -1132,7 +1143,29 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
standardData.put("orderState", OrderState.Expired);
|
|
|
standardData.put("payRemark", "超时关闭");
|
|
|
commonService.updateData(entity.getId(), standardData, ExpenseFlow.class.getSimpleName());
|
|
|
+ clearDelayedTimeout(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 把新创建的订单加入延时
|
|
|
+ */
|
|
|
+ public void delayedTimeout(ExpenseFlow order) {
|
|
|
+ if (ObjectUtils.isEmpty(order)) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ orderKeyExpire.saveKey(order.getOrderNo(), order.getExpireTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void clearDelayedTimeout(ExpenseFlow order) {
|
|
|
+ if (ObjectUtils.isEmpty(order)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ orderKeyExpire.deleteKey(order.getOrderNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void handleDelayedTask(String orderNo) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|