fix[订单服务]:新增订单号查询景区素材,设备序号的逻辑
This commit is contained in:
@@ -4,10 +4,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: device-center
|
name: device-center
|
||||||
# cloud:
|
cloud:
|
||||||
# nacos:
|
nacos:
|
||||||
# discovery:
|
discovery:
|
||||||
# ip: 81.70.164.178
|
ip: 119.45.169.13
|
||||||
# cloud:
|
# cloud:
|
||||||
# nacos:
|
# nacos:
|
||||||
# discovery:
|
# discovery:
|
||||||
|
|||||||
+29
-4
@@ -15,10 +15,8 @@ import com.central.order.feign.UserCenterService;
|
|||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.QrCode;
|
import com.central.order.model.QrCode;
|
||||||
import com.central.order.service.IOrderFileService;
|
import com.central.order.model.TourismFile;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.*;
|
||||||
import com.central.order.service.IQrCodeService;
|
|
||||||
import com.central.order.service.ITourismService;
|
|
||||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||||
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||||
@@ -66,6 +64,9 @@ public class OrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ITourismService tourismService;
|
private ITourismService tourismService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITourismFileService tourismFileService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserCenterService userCenterService;
|
private UserCenterService userCenterService;
|
||||||
|
|
||||||
@@ -363,6 +364,30 @@ public class OrderController {
|
|||||||
return Result.failed("不满足执行条件");
|
return Result.failed("不满足执行条件");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取订单对应的景区素材")
|
||||||
|
@GetMapping("/tourism/{orderNo}")
|
||||||
|
public Result<List<TourismFile>> getTourismByOrder(@PathVariable("orderNo") String orderNo) {
|
||||||
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
|
Assert.notNull(order,"订单数据不存在");
|
||||||
|
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
||||||
|
if (!tourismFiles.isEmpty()){
|
||||||
|
for (TourismFile tourismFile : tourismFiles){
|
||||||
|
tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.succeed(tourismFiles,"获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取订单的设备")
|
||||||
|
@GetMapping("/device/{orderNo}")
|
||||||
|
public Result<String> getDeviceByOrder(@PathVariable("orderNo") String orderNo) {
|
||||||
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
|
Assert.notNull(order,"订单数据不存在");
|
||||||
|
return Result.succeed(order.getDeviceSn(),"获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将分的价格转换为元的str,方便前端显示
|
* 将分的价格转换为元的str,方便前端显示
|
||||||
* @param str
|
* @param str
|
||||||
|
|||||||
+38
-11
@@ -15,6 +15,7 @@ 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 org.jetbrains.annotations.NotNull;
|
||||||
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;
|
||||||
@@ -25,7 +26,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/refund")
|
@RequestMapping("/refund")
|
||||||
public class OrderRefundController {
|
public class RefundController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RefundService service;
|
private RefundService service;
|
||||||
@@ -63,6 +64,10 @@ public class OrderRefundController {
|
|||||||
// 创建退款订单
|
// 创建退款订单
|
||||||
com.central.order.model.Refund refund = new com.central.order.model.Refund();
|
com.central.order.model.Refund refund = new com.central.order.model.Refund();
|
||||||
refund.setRefundNo("RF" + order.getOrderNo());
|
refund.setRefundNo("RF" + order.getOrderNo());
|
||||||
|
com.central.order.model.Refund existRefund = refundService.getRefundByNo(refund.getRefundNo());
|
||||||
|
if (existRefund != null){
|
||||||
|
return Result.succeed("已提交");
|
||||||
|
}
|
||||||
refund.setOrderNo(order.getOrderNo());
|
refund.setOrderNo(order.getOrderNo());
|
||||||
refund.setUserId(order.getUserId());
|
refund.setUserId(order.getUserId());
|
||||||
refund.setOrderAmount(order.getOrderAmount());
|
refund.setOrderAmount(order.getOrderAmount());
|
||||||
@@ -72,22 +77,43 @@ public class OrderRefundController {
|
|||||||
boolean res = refundService.createRefund(refund);
|
boolean res = refundService.createRefund(refund);
|
||||||
if (res) {
|
if (res) {
|
||||||
order.setOrderStatus(OrderStatus.REFUNDING.getId());
|
order.setOrderStatus(OrderStatus.REFUNDING.getId());
|
||||||
|
orderService.updateOrder(order);
|
||||||
return Result.succeed("退款成功");
|
return Result.succeed("退款成功");
|
||||||
}
|
}
|
||||||
return Result.failed("请重试");
|
return Result.failed("请重试");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "微信支付退款")
|
@Operation(summary = "微信支付退款")
|
||||||
@PatchMapping()
|
@PostMapping("/approve")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result<com.central.order.model.Refund> refundOrder(@RequestBody String orderNo) {
|
public Result<com.central.order.model.Refund> approveOrder(@RequestBody com.central.order.model.Refund refund) {
|
||||||
|
|
||||||
|
// 检查订单是否存在
|
||||||
|
Order order = orderService.getOrderByNumber(refund.getOrderNo());
|
||||||
|
Assert.notNull(order, "ORDER DATA不存在");
|
||||||
|
if (!order.getOrderStatus().equals(OrderStatus.REFUNDING.getId())){
|
||||||
|
return Result.failed("请重试");
|
||||||
|
}
|
||||||
|
if (! refund.getStatus().equals(OrderStatus.REFUNDING.getId())){
|
||||||
|
return Result.failed("该状态不支持审核");
|
||||||
|
}
|
||||||
|
if (refund.getState().equals(RefundState.APPROVED.getId())){
|
||||||
|
dealRefundRequest(order);
|
||||||
|
return Result.succeed("已处理退款");
|
||||||
|
}
|
||||||
|
if (refund.getState().equals(RefundState.REFUSED.getId())){
|
||||||
|
order.setOrderStatus(OrderStatus.REFUND_FAILED.getId());
|
||||||
|
refund.setStatus(OrderStatus.REFUND_FAILED.getId());
|
||||||
|
orderService.updateOrder(order);
|
||||||
|
refundService.updateById(refund);
|
||||||
|
return Result.succeed("处理成功");
|
||||||
|
}
|
||||||
|
return Result.failed("处理退款失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Refund dealRefundRequest(Order order) {
|
||||||
try {
|
try {
|
||||||
// 检查订单是否存在
|
|
||||||
Order order = orderService.getOrderByNumber(orderNo);
|
|
||||||
Assert.notNull(order, "ORDER DATA不存在");
|
|
||||||
if (!order.getOrderStatus().equals(OrderStatus.REFUNDING.getId())){
|
|
||||||
return Result.failed("请重试");
|
|
||||||
}
|
|
||||||
// 创建微信退款请求
|
// 创建微信退款请求
|
||||||
CreateRequest request = new CreateRequest();
|
CreateRequest request = new CreateRequest();
|
||||||
request.setOutTradeNo(order.getOrderNo());
|
request.setOutTradeNo(order.getOrderNo());
|
||||||
@@ -102,17 +128,18 @@ public class OrderRefundController {
|
|||||||
amount.setTotal(Long.valueOf(order.getOrderAmount()));
|
amount.setTotal(Long.valueOf(order.getOrderAmount()));
|
||||||
// 退款金额,单位为分
|
// 退款金额,单位为分
|
||||||
amount.setRefund(Long.valueOf(order.getOrderAmount()));
|
amount.setRefund(Long.valueOf(order.getOrderAmount()));
|
||||||
|
amount.setCurrency("CNY");
|
||||||
request.setAmount(amount);
|
request.setAmount(amount);
|
||||||
|
|
||||||
// 发起退款请求
|
// 发起退款请求
|
||||||
Refund response = service.create(request);
|
Refund response = service.create(request);
|
||||||
Assert.notNull(response, "退款失败");
|
Assert.notNull(response, "退款失败");
|
||||||
return Result.succeed("已提交,请关注账户资金变化");
|
return response;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 记录异常信息
|
// 记录异常信息
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return Result.failed("退款失败:" + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+6
-3
@@ -1,6 +1,7 @@
|
|||||||
package com.central.order.controller;
|
package com.central.order.controller;
|
||||||
|
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
|
import com.central.order.enums.RefundState;
|
||||||
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;
|
||||||
@@ -9,6 +10,7 @@ import com.wechat.pay.java.core.notification.NotificationParser;
|
|||||||
import com.wechat.pay.java.core.notification.RequestParam;
|
import com.wechat.pay.java.core.notification.RequestParam;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||||
|
import com.wechat.pay.java.service.refund.model.Status;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -134,14 +136,15 @@ public class WxPayController {
|
|||||||
private void handleRefundResult(RefundNotification notification) {
|
private void handleRefundResult(RefundNotification notification) {
|
||||||
// 获取退款通知中的关键信息
|
// 获取退款通知中的关键信息
|
||||||
String outRefundNo = notification.getOutRefundNo();
|
String outRefundNo = notification.getOutRefundNo();
|
||||||
String refundStatus = notification.getRefundStatus().name();
|
|
||||||
|
|
||||||
|
log.info("回调返回结果"+notification);
|
||||||
// 根据退款状态进行相应处理
|
// 根据退款状态进行相应处理
|
||||||
if ("SUCCESS".equals(refundStatus)) {
|
if (Status.SUCCESS.equals(notification.getRefundStatus())) {
|
||||||
// 退款成功,更新订单状态等操作
|
// 退款成功,更新订单状态等操作
|
||||||
com.central.order.model.Refund refund = refundService.getRefundByNo(outRefundNo);
|
com.central.order.model.Refund refund = refundService.getRefundByNo(outRefundNo);
|
||||||
Assert.notNull(refund,"退款订单数据不存在");
|
Assert.notNull(refund,"退款订单数据不存在");
|
||||||
refund.setStatus(OrderStatus.REFUNDED.getId());
|
refund.setStatus(OrderStatus.REFUNDED.getId());
|
||||||
|
refund.setState(RefundState.APPROVED.getId());
|
||||||
refund.setRefundTime(new Date());
|
refund.setRefundTime(new Date());
|
||||||
refundService.updateById(refund);
|
refundService.updateById(refund);
|
||||||
|
|
||||||
@@ -149,7 +152,7 @@ public class WxPayController {
|
|||||||
Assert.notNull(order,"订单数据不存在");
|
Assert.notNull(order,"订单数据不存在");
|
||||||
order.setOrderStatus(OrderStatus.REFUNDED.getId());
|
order.setOrderStatus(OrderStatus.REFUNDED.getId());
|
||||||
orderService.updateOrder(order);
|
orderService.updateOrder(order);
|
||||||
} else if ("CLOSED".equals(refundStatus)) {
|
} else if ("CLOSED".equals(notification.getRefundStatus())) {
|
||||||
// 退款关闭,处理退款关闭逻辑
|
// 退款关闭,处理退款关闭逻辑
|
||||||
} else {
|
} else {
|
||||||
// 其他退款状态,如退款中、失败等
|
// 其他退款状态,如退款中、失败等
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ public enum OrderStatus implements ZltEnum {
|
|||||||
PAID(1, "已支付排队中"),
|
PAID(1, "已支付排队中"),
|
||||||
CANCELED(2, "已取消"),
|
CANCELED(2, "已取消"),
|
||||||
DOING(4,"正在服务中"),
|
DOING(4,"正在服务中"),
|
||||||
COMPLETE(3,"用户下载完成"),
|
COMPLETE(3,"设备执行完成"),
|
||||||
UPLOADING(5,"素材上传中"),
|
UPLOADING(5,"素材上传中"),
|
||||||
UPLOADED(6,"素材上传完成"),
|
UPLOADED(6,"素材上传完成(任务完成)"),
|
||||||
REFUNDING(7,"退款中"),
|
REFUNDING(7,"退款中"),
|
||||||
REFUNDED(8,"已退款"),
|
REFUNDED(8,"已退款"),
|
||||||
REFUND_FAILED(9,"退款失败");
|
REFUND_FAILED(9,"退款失败");
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: order-center
|
name: order-center
|
||||||
# cloud:
|
cloud:
|
||||||
# nacos:
|
nacos:
|
||||||
# discovery:
|
discovery:
|
||||||
# ip: 81.70.164.178
|
ip: 81.70.164.178
|
||||||
# cloud:
|
# cloud:
|
||||||
# nacos:
|
# nacos:
|
||||||
# discovery:
|
# discovery:
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
########################## 统一变量配置 ##########################
|
########################## 统一变量配置 ##########################
|
||||||
##### 数据库配置
|
##### 数据库配置
|
||||||
#zlt.datasource.ip=127.0.0.1
|
zlt.datasource.ip=127.0.0.1
|
||||||
#zlt.datasource.username=root
|
|
||||||
#zlt.datasource.password=root
|
|
||||||
zlt.datasource.ip=sh-cdb-i6yxaaec.sql.tencentcdb.com:58797
|
|
||||||
zlt.datasource.username=root
|
zlt.datasource.username=root
|
||||||
zlt.datasource.password=ZXC_zxc!@#123+
|
zlt.datasource.password=root
|
||||||
|
#zlt.datasource.ip=sh-cdb-i6yxaaec.sql.tencentcdb.com:58797
|
||||||
|
#zlt.datasource.username=root
|
||||||
|
#zlt.datasource.password=ZXC_zxc!@#123+
|
||||||
|
|
||||||
##### redis配置
|
##### redis配置
|
||||||
spring.data.redis.host=192.168.2.20
|
spring.data.redis.host=192.168.2.20
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
########################## bootstrap级别通用配置 ##########################
|
########################## bootstrap级别通用配置 ##########################
|
||||||
# 默认开发环境
|
# 默认开发环境
|
||||||
spring.profiles.active=dev
|
spring.profiles.active=prod
|
||||||
|
|
||||||
##### nacos(注册中心和配置中心)地址
|
##### nacos(注册中心和配置中心)地址
|
||||||
#spring.cloud.nacos.server-addr=47.94.136.130:8848
|
spring.cloud.nacos.server-addr=47.94.136.130:8848
|
||||||
spring.cloud.nacos.server-addr=127.0.0.1:8848
|
#spring.cloud.nacos.server-addr=127.0.0.1:8848
|
||||||
spring.cloud.nacos.username=nacos
|
spring.cloud.nacos.username=nacos
|
||||||
spring.cloud.nacos.password=nacos
|
spring.cloud.nacos.password=nacos
|
||||||
spring.cloud.nacos.config.file-extension=yml
|
spring.cloud.nacos.config.file-extension=yml
|
||||||
|
|||||||
@@ -9,38 +9,38 @@
|
|||||||
export default {
|
export default {
|
||||||
dev: {
|
dev: {
|
||||||
'/api-uaa/': {
|
'/api-uaa/': {
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-user/': {
|
'/api-user/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-log/': {
|
'/api-log/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-search/': {
|
'/api-search/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-generator/': {
|
'/api-generator/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-file/': {
|
'/api-file/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
'/api-order/': {
|
'/api-order/': {
|
||||||
target: 'http://127.0.0.1:9900',
|
// target: 'http://127.0.0.1:9900',
|
||||||
// target: 'http://119.45.169.13:9900',
|
target: 'http://119.45.169.13:9900',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,12 +30,17 @@ const { Link } = Typography;
|
|||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// 状态颜色映射
|
|
||||||
const statusColorMap = {
|
const statusColorMap = {
|
||||||
0: { color: 'yellow', text: '待处理' },
|
0: { color: 'yellow', text: '待支付' },
|
||||||
1: { color: 'orange', text: '待处理' },
|
1: { color: 'orange', text: '已支付排队中' },
|
||||||
3: { color: 'green', text: '已完成' },
|
2: { color: 'gray', text: '已取消' },
|
||||||
2: { color: 'red', text: '已取消' },
|
3: { color: 'red', text: '设备执行完成' },
|
||||||
|
4: { color: 'lightblue', text: '正在服务中' },
|
||||||
|
5: { color: 'pink', text: '素材上传中' },
|
||||||
|
6: { color: 'green', text: '素材上传完成' },
|
||||||
|
7: { color: 'darkgray', text: '退款中' },
|
||||||
|
8: { color: 'cyan', text: '已退款' },
|
||||||
|
9: { color: 'purple', text: '退款失败' }
|
||||||
};
|
};
|
||||||
|
|
||||||
// 渲染状态标签
|
// 渲染状态标签
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="修改景区"
|
title="修改二维码"
|
||||||
form={form}
|
form={form}
|
||||||
visible={props.updateModalVisible}
|
visible={props.updateModalVisible}
|
||||||
onFinish={props.onSubmit}
|
onFinish={props.onSubmit}
|
||||||
|
|||||||
+42
-28
@@ -1,24 +1,32 @@
|
|||||||
import {
|
import {
|
||||||
ModalForm,
|
ModalForm,
|
||||||
ProForm,
|
ProForm,
|
||||||
|
ProFormSelect,
|
||||||
ProFormText,
|
ProFormText,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export type FormValueType = Partial<ORDERS.Tourism>;
|
export type FormValueType = Partial<ORDERS.Refund>;
|
||||||
|
|
||||||
export type UpdateFormProps = {
|
export type UpdateFormProps = {
|
||||||
onVisibleChange: (flag: boolean) => void;
|
onVisibleChange: (flag: boolean) => void;
|
||||||
onSubmit: (values: FormValueType) => Promise<void>;
|
onSubmit: (values: FormValueType) => Promise<void>;
|
||||||
updateModalVisible: boolean;
|
updateModalVisible: boolean;
|
||||||
values?: ORDERS.Tourism;
|
values?: ORDERS.Refund;
|
||||||
};
|
};
|
||||||
|
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const { values } = props;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
form.setFieldsValue(values);
|
||||||
|
}, [form, values]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="修改景区"
|
title="退款审核"
|
||||||
form={form}
|
form={form}
|
||||||
visible={props.updateModalVisible}
|
visible={props.updateModalVisible}
|
||||||
onFinish={props.onSubmit}
|
onFinish={props.onSubmit}
|
||||||
@@ -26,41 +34,47 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[
|
readonly = {true}
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '名称不为空',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
width="md"
|
width="md"
|
||||||
name="tourismName"
|
name="orderNo"
|
||||||
label="名称"
|
label="订单编号"
|
||||||
placeholder="输入名称"
|
/>
|
||||||
|
<ProFormText
|
||||||
|
readonly={true}
|
||||||
|
width="md"
|
||||||
|
name="refundNo"
|
||||||
|
label="退款编号"
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '地址不为空',
|
message: '审核理由不为空',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
width="md"
|
width="md"
|
||||||
name="tourismAddress"
|
name="approveReason"
|
||||||
label="地址"
|
label="审核理由"
|
||||||
placeholder="输入地址"
|
placeholder="输入审核理由"
|
||||||
/>
|
|
||||||
<ProFormText
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '手机号不为空',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
width="md"
|
|
||||||
name="tourismPhone"
|
|
||||||
label="手机号"
|
|
||||||
placeholder="输入手机号"
|
|
||||||
/>
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '审核状态不为空',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width="md"
|
||||||
|
name="state"
|
||||||
|
label="状态"
|
||||||
|
placeholder="请选择审核状态"
|
||||||
|
options={[
|
||||||
|
{ label: '审核中', value: 0 },
|
||||||
|
{ label: '已通过', value: 1 },
|
||||||
|
{ label: '已拒绝', value: 2 },
|
||||||
|
// 添加更多选项...
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { refund } from '@/services/orders/api';
|
import { refund, updateRefund } from '@/services/orders/api';
|
||||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
PageContainer,
|
PageContainer,
|
||||||
@@ -6,29 +6,30 @@ import {
|
|||||||
ProTable,
|
ProTable,
|
||||||
QueryFilter,
|
QueryFilter,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Typography, Popconfirm, Tag } from 'antd';
|
import { Typography, Tag, Space, message } from 'antd';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
// const handleDelete = async (deletefile: FILES.File) => {
|
const handleEdit = async (fields: ORDERS.Refund) => {
|
||||||
// const hide = message.loading('正在删除');
|
const hide = message.loading('正在更新');
|
||||||
// try {
|
try {
|
||||||
// const result = await deleteFile(deletefile.id);
|
const result = await updateRefund({ ...fields });
|
||||||
// hide();
|
hide();
|
||||||
// if (result.resp_code === 0) {
|
if (result.resp_code === 0) {
|
||||||
// message.success('删除File成功');
|
message.success('审核成功');
|
||||||
// return true;
|
return true;
|
||||||
// } else {
|
} else {
|
||||||
// message.error(result.resp_msg);
|
message.error(result.resp_msg);
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// } catch (error) {
|
} catch (error) {
|
||||||
// hide();
|
hide();
|
||||||
// message.error('删除File失败');
|
message.error('审核失败');
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
||||||
// 状态颜色映射
|
// 状态颜色映射
|
||||||
const statusColorMap = {
|
const statusColorMap = {
|
||||||
@@ -61,6 +62,8 @@ const renderState = (state: {} | null | undefined) => {
|
|||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [params, setParams] = useState<Record<string, string | number>>({ });
|
const [params, setParams] = useState<Record<string, string | number>>({ });
|
||||||
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
const [currentRow, setCurrentRow] = useState<ORDERS.Refund>();
|
||||||
const columns: ProColumns<ORDERS.Refund>[] = [
|
const columns: ProColumns<ORDERS.Refund>[] = [
|
||||||
{
|
{
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
@@ -100,19 +103,17 @@ const TableList: React.FC = () => {
|
|||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
render: (_, entity) => <Popconfirm
|
render: (_, entity) =>
|
||||||
title={`确认删除文件[${entity.id}]?`}
|
<Space>
|
||||||
onConfirm={async () => {
|
<Link
|
||||||
// const success = await handleDelete(entity);
|
onClick={() => {
|
||||||
// if (success) {
|
setCurrentRow(entity);
|
||||||
// if (actionRef.current) {
|
handleUpdateModalVisible(true);
|
||||||
// actionRef.current.reload();
|
}}
|
||||||
// }
|
>
|
||||||
// }
|
修改
|
||||||
}}
|
</Link>
|
||||||
>
|
</Space>
|
||||||
<Link>审核</Link>
|
|
||||||
</Popconfirm>,
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -140,6 +141,24 @@ const TableList: React.FC = () => {
|
|||||||
showQuickJumper: true,
|
showQuickJumper: true,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async (values) => {
|
||||||
|
if (currentRow) {
|
||||||
|
|
||||||
|
const success = await handleEdit({ ...currentRow, ...values });
|
||||||
|
if (success) {
|
||||||
|
handleUpdateModalVisible(false);
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onVisibleChange={handleUpdateModalVisible}
|
||||||
|
updateModalVisible={updateModalVisible}
|
||||||
|
values={currentRow}
|
||||||
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -137,3 +137,12 @@ export async function refund(params?: { [key: string]: string | number }) {
|
|||||||
});
|
});
|
||||||
return { data: result.data, total: result.count };
|
return { data: result.data, total: result.count };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateRefund(data: ORDERS.Refund): Promise<API.Result<ORDERS.Refund>> {
|
||||||
|
const result = await request<API.Result<ORDERS.Refund>>('/api-order/refund/approve', {
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user