Merge branch 'develop' of gitee.com:L-Shilin/go-fly-platform-services
This commit is contained in:
+4
@@ -158,6 +158,10 @@ public class ApiDeviceController {
|
|||||||
|
|
||||||
IotRequestResult requestResult = IotRequestResult.getInstance(object);
|
IotRequestResult requestResult = IotRequestResult.getInstance(object);
|
||||||
if (requestResult.getStatus() == 200 || requestResult.getStatus() == 500) {
|
if (requestResult.getStatus() == 200 || requestResult.getStatus() == 500) {
|
||||||
|
log.info("设置设备属性返回消息: message={}", requestResult.getMessage());
|
||||||
|
if (requestResult.getMessage().equals("Device is offline")){
|
||||||
|
return Result.failed("设备已离线请稍后重试");
|
||||||
|
}
|
||||||
Result updateResult = orderCenterService.updateOrderStatusDoing(orderNo);
|
Result updateResult = orderCenterService.updateOrderStatusDoing(orderNo);
|
||||||
if (updateResult.getResp_code() != null && updateResult.getResp_code() == 0) {
|
if (updateResult.getResp_code() != null && updateResult.getResp_code() == 0) {
|
||||||
return Result.succeed(updateResult.getData(), "设置成功");
|
return Result.succeed(updateResult.getData(), "设置成功");
|
||||||
|
|||||||
+74
-1
@@ -2,11 +2,14 @@ package com.central.order.controller;
|
|||||||
|
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.enums.RefundState;
|
import com.central.order.enums.RefundState;
|
||||||
|
import com.central.order.feign.UserCenterService;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
import com.central.order.service.IRefundService;
|
import com.central.order.service.IRefundService;
|
||||||
|
import com.central.order.service.IWxTemplateMessageService;
|
||||||
import com.central.wechat.config.WxPayConfigFactory;
|
import com.central.wechat.config.WxPayConfigFactory;
|
||||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||||
@@ -15,6 +18,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -23,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Tag(name = "订单退款管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/refund")
|
@RequestMapping("/refund")
|
||||||
public class RefundController {
|
public class RefundController {
|
||||||
@@ -36,6 +43,12 @@ public class RefundController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRefundService refundService;
|
private IRefundService refundService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IWxTemplateMessageService templateMessageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCenterService userCenterService;
|
||||||
|
|
||||||
@Value("${tencent.refund-notify-url}")
|
@Value("${tencent.refund-notify-url}")
|
||||||
private String refundNotifyUrl;
|
private String refundNotifyUrl;
|
||||||
|
|
||||||
@@ -115,6 +128,67 @@ public class RefundController {
|
|||||||
return Result.failed("处理退款失败");
|
return Result.failed("处理退款失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/auto")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result<String> autoRefundProcess(@RequestParam String orderNo) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 1. 获取订单信息
|
||||||
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
|
Assert.notNull(order, "订单不存在");
|
||||||
|
|
||||||
|
if (!order.getOrderStatus().equals(OrderStatus.DOING.getId())){
|
||||||
|
return Result.succeed("订单状态不支持退款");
|
||||||
|
}
|
||||||
|
|
||||||
|
String refundNo = "RF" + order.getOrderNo();
|
||||||
|
com.central.order.model.Refund existRefund = refundService.getRefundByNo(refundNo);
|
||||||
|
if (existRefund != null) {
|
||||||
|
return Result.succeed("退款逻辑已处理");
|
||||||
|
}
|
||||||
|
|
||||||
|
SysUser user = userCenterService.findUserById(order.getUserId());
|
||||||
|
Assert.notNull(user,"订单用户数据不存在");
|
||||||
|
|
||||||
|
// 3. 创建退款单
|
||||||
|
com.central.order.model.Refund refund = new com.central.order.model.Refund();
|
||||||
|
refund.setRefundNo(refundNo);
|
||||||
|
refund.setOrderNo(order.getOrderNo());
|
||||||
|
refund.setUserId(order.getUserId());
|
||||||
|
refund.setOrderAmount(order.getOrderAmount());
|
||||||
|
refund.setRefundAmount(order.getOrderAmount());
|
||||||
|
refund.setStatus(OrderStatus.REFUNDING.getId());
|
||||||
|
refund.setState(RefundState.APPROVING.getId());
|
||||||
|
refund.setRefundReason("机库执行任务异常自动退款");
|
||||||
|
|
||||||
|
boolean refundCreated = refundService.createRefund(refund);
|
||||||
|
if (!refundCreated) {
|
||||||
|
return Result.failed("创建退款单失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 更新订单状态
|
||||||
|
order.setOrderStatus(OrderStatus.REFUNDING.getId());
|
||||||
|
orderService.updateOrder(order);
|
||||||
|
|
||||||
|
// 5. 自动审批通过
|
||||||
|
refund.setState(RefundState.APPROVED.getId());
|
||||||
|
refundService.updateById(refund);
|
||||||
|
|
||||||
|
// 6. 调用微信退款接口
|
||||||
|
dealRefundRequest(order);
|
||||||
|
|
||||||
|
return Result.succeed("自动退款流程成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("退款流程测试失败", e);
|
||||||
|
return Result.failed("退款流程测试失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信退款申请
|
||||||
|
* @param order
|
||||||
|
*/
|
||||||
private void dealRefundRequest(Order order) {
|
private void dealRefundRequest(Order order) {
|
||||||
try {
|
try {
|
||||||
// 创建微信退款请求
|
// 创建微信退款请求
|
||||||
@@ -142,5 +216,4 @@ public class RefundController {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-5
@@ -2,20 +2,24 @@ package com.central.order.controller;
|
|||||||
|
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.order.service.IWxTemplateMessageService;
|
import com.central.order.service.IWxTemplateMessageService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Tag(name = "公众号通知")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wx/test")
|
@RequestMapping("/mp")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class WxTestController {
|
public class WxMpMessageController {
|
||||||
|
|
||||||
private final IWxTemplateMessageService templateMessageService;
|
@Autowired
|
||||||
|
private IWxTemplateMessageService templateMessageService;
|
||||||
|
|
||||||
@GetMapping("/template/send")
|
@GetMapping("/template/send")
|
||||||
public Result<String> testSendTemplate(
|
public Result<String> testSendTemplate(
|
||||||
@@ -24,8 +28,6 @@ public class WxTestController {
|
|||||||
@RequestParam String serviceName,
|
@RequestParam String serviceName,
|
||||||
@RequestParam Integer rank) {
|
@RequestParam Integer rank) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
templateMessageService.sendPaymentSuccessNotice(
|
templateMessageService.sendPaymentSuccessNotice(
|
||||||
openId, orderNo, serviceName, rank);
|
openId, orderNo, serviceName, rank);
|
||||||
@@ -36,4 +38,6 @@ public class WxTestController {
|
|||||||
return Result.failed("发送失败:" + e.getMessage());
|
return Result.failed("发送失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+70
-8
@@ -134,7 +134,11 @@ public class OrderStatusChangeListener {
|
|||||||
|
|
||||||
// 订单完成时,检查是否需要触发一键成片
|
// 订单完成时,检查是否需要触发一键成片
|
||||||
if (OrderStatus.COMPLETE.getId().equals(event.getNewStatus())) {
|
if (OrderStatus.COMPLETE.getId().equals(event.getNewStatus())) {
|
||||||
handleOrderComplete(order);
|
handleOrderComplete(order,tourism);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OrderStatus.REFUNDED.getId().equals(event.getNewStatus())) {
|
||||||
|
handleOrderRefund(order,tourism);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -192,14 +196,21 @@ public class OrderStatusChangeListener {
|
|||||||
/**
|
/**
|
||||||
* 处理订单完成逻辑
|
* 处理订单完成逻辑
|
||||||
*/
|
*/
|
||||||
private void handleOrderComplete(Order order) {
|
private void handleOrderComplete(Order order,Tourism tourism) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 1. 检查是否开启一键成片
|
//1. 素材上传完成通知
|
||||||
|
// Tourism tourism = tourismService.getTourismById(order.getTourismId());
|
||||||
|
sendMessageForResouresUploaded(order, tourism);
|
||||||
|
|
||||||
|
// 2. 检查是否开启一键成片
|
||||||
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||||
|
|
||||||
if (!isVideoEditEnabled(qrCode)) {
|
if (!isVideoEditEnabled(qrCode)) {
|
||||||
log.info("未开启一键成片功能: orderNo={}, codeId={}",
|
log.info("未开启一键成片功能: orderNo={}, codeId={}",
|
||||||
order.getOrderNo(), order.getCodeId());
|
order.getOrderNo(), order.getCodeId());
|
||||||
|
// 通知下一位游客开始拍照
|
||||||
|
sendMessageToNextOrderUser(order, tourism);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,9 +230,57 @@ public class OrderStatusChangeListener {
|
|||||||
task.setStatus(EditTaskStatus.PROCESSING);
|
task.setStatus(EditTaskStatus.PROCESSING);
|
||||||
editTaskService.saveOrUpdateTask(task);
|
editTaskService.saveOrUpdateTask(task);
|
||||||
|
|
||||||
|
sendMessageToNextOrderUser(order, tourism);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("触发一键成片或排队通知失败: orderNo={}", order.getOrderNo(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理订单完成逻辑
|
||||||
|
*/
|
||||||
|
private void handleOrderRefund(Order order,Tourism tourism) {
|
||||||
|
|
||||||
|
sendMessageForRefund(order, tourism);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款完成通知
|
||||||
|
* @param order
|
||||||
|
* @param tourism
|
||||||
|
*/
|
||||||
|
private void sendMessageForRefund(Order order, Tourism tourism) {
|
||||||
// 发送小程序订阅消息,用户素材上传完成
|
// 发送小程序订阅消息,用户素材上传完成
|
||||||
SysUser sysUser = userCenterService.findUserById(order.getUserId());
|
SysUser sysUser = userCenterService.findUserById(order.getUserId());
|
||||||
Tourism tourism = tourismService.getTourismById(order.getTourismId());
|
|
||||||
|
if (sysUser.getOpenId() != null) {
|
||||||
|
|
||||||
|
String tip = "订单退款完成";
|
||||||
|
String orderName = tourism.getTourismName();
|
||||||
|
String pageUrl = "pages/task/task";
|
||||||
|
wxMiniSubscribeService.sendServiceProcessMsg(
|
||||||
|
sysUser.getOpenId(),
|
||||||
|
orderName,
|
||||||
|
tip,
|
||||||
|
order.getOrderNo(),
|
||||||
|
DateUtils.sdf.format(order.getPayTime()),
|
||||||
|
"",
|
||||||
|
pageUrl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 素材上传完成小程序通知
|
||||||
|
* @param order
|
||||||
|
* @param tourism
|
||||||
|
*/
|
||||||
|
private void sendMessageForResouresUploaded(Order order, Tourism tourism) {
|
||||||
|
// 发送小程序订阅消息,用户素材上传完成
|
||||||
|
SysUser sysUser = userCenterService.findUserById(order.getUserId());
|
||||||
|
|
||||||
if (sysUser.getOpenId() != null) {
|
if (sysUser.getOpenId() != null) {
|
||||||
|
|
||||||
String tip = "素材上传完成";
|
String tip = "素材上传完成";
|
||||||
@@ -237,7 +296,14 @@ public class OrderStatusChangeListener {
|
|||||||
pageUrl
|
pageUrl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单完成后通知下一位用户
|
||||||
|
* @param order
|
||||||
|
* @param tourism
|
||||||
|
*/
|
||||||
|
private void sendMessageToNextOrderUser(Order order, Tourism tourism) {
|
||||||
// 新增:查找下一个排队用户
|
// 新增:查找下一个排队用户
|
||||||
Order nextOrder = orderService.getNextQueueOrder(order.getTourismId(), order.getId());
|
Order nextOrder = orderService.getNextQueueOrder(order.getTourismId(), order.getId());
|
||||||
if (nextOrder != null) {
|
if (nextOrder != null) {
|
||||||
@@ -259,10 +325,6 @@ public class OrderStatusChangeListener {
|
|||||||
log.info("已通知下一个排队用户: userId={}, openId={}, orderNo={}", nextUser.getId(), nextUser.getOpenId(), activityNo);
|
log.info("已通知下一个排队用户: userId={}, openId={}, orderNo={}", nextUser.getId(), nextUser.getOpenId(), activityNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("触发一键成片或排队通知失败: orderNo={}", order.getOrderNo(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ knife4j:
|
|||||||
zlt:
|
zlt:
|
||||||
#多租户配置
|
#多租户配置
|
||||||
tenant:
|
tenant:
|
||||||
id: webApp
|
|
||||||
enable: false
|
enable: false
|
||||||
ignoreTables:
|
ignoreTables:
|
||||||
- edit_task
|
- edit_task
|
||||||
|
|||||||
@@ -82,3 +82,6 @@ zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/notify
|
|||||||
zlt.wxpay.privateKeyPath=D:\\wx\\WXCertUtil\\cert\\1703796518_20250114_cert\\apiclient_key.pem
|
zlt.wxpay.privateKeyPath=D:\\wx\\WXCertUtil\\cert\\1703796518_20250114_cert\\apiclient_key.pem
|
||||||
# 商户APIV3密钥
|
# 商户APIV3密钥
|
||||||
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
||||||
|
|
||||||
|
|
||||||
|
zlt.tenant.id: webApp
|
||||||
|
|||||||
@@ -71,3 +71,5 @@ zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/notify
|
|||||||
zlt.wxpay.privateKeyPath=/data/zlt/cert/apiclient_key.pem
|
zlt.wxpay.privateKeyPath=/data/zlt/cert/apiclient_key.pem
|
||||||
# 商户APIV3密钥
|
# 商户APIV3密钥
|
||||||
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
|
||||||
|
|
||||||
|
zlt.tenant.id: webApp
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ zlt:
|
|||||||
/api-device/stream-urls,
|
/api-device/stream-urls,
|
||||||
/api-device/token/query,
|
/api-device/token/query,
|
||||||
/api-order/user/temp,
|
/api-order/user/temp,
|
||||||
/api-file/file/expires
|
/api-file/file/expires,
|
||||||
|
/api-order/refund/auto
|
||||||
auth:
|
auth:
|
||||||
urlPermission:
|
urlPermission:
|
||||||
#是否开启url级别权限
|
#是否开启url级别权限
|
||||||
|
|||||||
Reference in New Issue
Block a user