From 05c49b78ce85257b1aea6a523c3b9134fb9a734a Mon Sep 17 00:00:00 2001 From: perry <292303709@qq.com> Date: Fri, 19 May 2023 19:30:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/request/member/RefundRequest.java | 7 ++- .../admin/notify/WxPayNotifyController.java | 2 +- .../recharge/RechargeOrderController.java | 46 +++++++++++++++++-- .../recharge/vo/RechargeOrderBaseVO.java | 4 +- .../recharge/vo/RechargeOrderRespVO.java | 2 +- .../recharge/vo/RechargeOrderUpdateReqVO.java | 2 +- .../recharge/RechargeOrderService.java | 8 ++-- .../recharge/RechargeOrderServiceImpl.java | 18 ++++++-- .../mapper/recharge/RechargeOrderMapper.xml | 2 + 9 files changed, 73 insertions(+), 18 deletions(-) diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/RefundRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/RefundRequest.java index afba30285..984f8988a 100644 --- a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/RefundRequest.java +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/member/RefundRequest.java @@ -24,7 +24,10 @@ import java.util.List; public class RefundRequest implements Serializable { private static final long serialVersionUID = -9170167938995005780L; @Schema(description = "数据id") - private String orderId; - + @NotNull(message = "订单id不能为空") + private Long orderId; + @Schema(description = "退款类型1:同意退款,2:拒绝退款、3:发起退款") + @NotNull(message = "退款类型不能为空") + private Integer type; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/notify/WxPayNotifyController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/notify/WxPayNotifyController.java index c8945090c..228301741 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/notify/WxPayNotifyController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/notify/WxPayNotifyController.java @@ -130,7 +130,7 @@ public class WxPayNotifyController { // 用户支付金额 BigDecimal payerTotal = NumberUtil.div(result.getAmount().getPayerTotal() + "", "100", 2); // 处理相关逻辑 - RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(RechargeOrderDO::getOrderId, result.getOutRefundNo())); + RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(RechargeOrderDO::getOrderId, result.getOutTradeNo())); if (payerTotal.compareTo(orderDO.getPayPrice()) != 0) { log.error("支付金额不匹配,订单实际支付金额:{},微信入参验证金额:{}", orderDO.getPayPrice(), payerTotal); return "failure"; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java index cb28ea2cd..53d43b741 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java @@ -1,11 +1,16 @@ package cn.iocoder.yudao.module.shop.controller.admin.recharge; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.shop.controller.admin.recharge.method.Excel; import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderInfoConvert; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; +import cn.iocoder.yudao.module.shop.request.member.RefundRequest; +import cn.iocoder.yudao.module.shop.service.order.StoreOrderService; import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderInfoService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -38,6 +43,7 @@ import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderService; @RestController @RequestMapping("/shop/recharge-order") @Validated +@Slf4j public class RechargeOrderController { @Resource @@ -45,6 +51,10 @@ public class RechargeOrderController { @Resource private RechargeOrderInfoService rechargeOrderInfoService; + + @Autowired + private StoreOrderService storeOrderService; + @PostMapping("/create") @Operation(summary = "创建订单") @PreAuthorize("@ss.hasPermission('shop:recharge-order:create')") @@ -64,7 +74,7 @@ public class RechargeOrderController { @Operation(summary = "删除订单") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('shop:recharge-order:delete')") - public CommonResult deleteRechargeOrder(@RequestParam("id") Integer id) { + public CommonResult deleteRechargeOrder(@RequestParam("id") Long id) { rechargeOrderService.deleteRechargeOrder(id); return success(true); } @@ -73,7 +83,7 @@ public class RechargeOrderController { @Operation(summary = "获得订单") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('shop:recharge-order:query')") - public CommonResult getRechargeOrder(@RequestParam("id") Integer id) { + public CommonResult getRechargeOrder(@RequestParam("id") Long id) { RechargeOrderDO rechargeOrder = rechargeOrderService.getRechargeOrder(id); return success(RechargeOrderConvert.INSTANCE.convert(rechargeOrder)); } @@ -82,7 +92,7 @@ public class RechargeOrderController { @Operation(summary = "获得订单列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @PreAuthorize("@ss.hasPermission('shop:recharge-order:query')") - public CommonResult> getRechargeOrderList(@RequestParam("ids") Collection ids) { + public CommonResult> getRechargeOrderList(@RequestParam("ids") Collection ids) { List list = rechargeOrderService.getRechargeOrderList(ids); return success(RechargeOrderConvert.INSTANCE.convertList(list)); } @@ -115,4 +125,34 @@ public class RechargeOrderController { Excel.orderExport(response, list, infoList); } + @TenantIgnore + @PreAuthenticated + @Operation(summary = "退款") + @RequestMapping(value = "/memberRefund", method = RequestMethod.POST) + public CommonResult memberRefund(@Valid @RequestBody RefundRequest request, HttpServletRequest servletRequest) throws Exception { + log.info("memberRefund会员退款===>{}", request); + Object obj=null; + //直接退款 + if(request.getType()==3){ + RechargeOrderUpdateReqVO vo = new RechargeOrderUpdateReqVO(); + vo.setId(request.getOrderId()); + vo.setRefundStatus(3); + rechargeOrderService.updateRechargeOrderStatus(vo); + obj = storeOrderService.memberRefund(request, servletRequest); + //拒绝退款 + }else if(request.getType()==2){ + RechargeOrderUpdateReqVO vo = new RechargeOrderUpdateReqVO(); + vo.setId(request.getOrderId()); + vo.setRefundStatus(4); + rechargeOrderService.updateRechargeOrderStatus(vo); + //同意 + }else if(request.getType()==1){ + RechargeOrderUpdateReqVO vo = new RechargeOrderUpdateReqVO(); + vo.setId(request.getOrderId()); + vo.setRefundStatus(3); + rechargeOrderService.updateRechargeOrderStatus(vo); + obj = storeOrderService.memberRefund(request, servletRequest); + } + return CommonResult.success(obj); + } } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderBaseVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderBaseVO.java index d621295db..b17255741 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderBaseVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderBaseVO.java @@ -80,8 +80,8 @@ public class RechargeOrderBaseVO { private Boolean status; @Schema(description = "0 未退款 1 申请中 2 已退款 3 退款中", required = true, example = "2") - @NotNull(message = "0 未退款 1 申请中 2 已退款 3 退款中不能为空") - private Byte refundStatus; + @NotNull(message = "0 未退款 1 申请中 2 已退款 3 退款中,4拒绝退款不能为空") + private Integer refundStatus; @Schema(description = "退款图片") private String refundReasonWapImg; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java index a0f2b4f6a..f6e623234 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderRespVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; public class RechargeOrderRespVO extends RechargeOrderBaseVO { @Schema(description = "订单ID", required = true, example = "17164") - private Integer id; + private Long id; @Schema(description = "创建时间") private LocalDateTime createTime; diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderUpdateReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderUpdateReqVO.java index 80dd6dbbd..25ff67c5d 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderUpdateReqVO.java @@ -13,6 +13,6 @@ public class RechargeOrderUpdateReqVO extends RechargeOrderBaseVO { @Schema(description = "订单ID", required = true, example = "17164") @NotNull(message = "订单ID不能为空") - private Integer id; + private Long id; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java index 70d26799f..3fe88778c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderService.java @@ -30,12 +30,14 @@ public interface RechargeOrderService { */ void updateRechargeOrder(@Valid RechargeOrderUpdateReqVO updateReqVO); + + void updateRechargeOrderStatus(RechargeOrderUpdateReqVO updateReqVO); /** * 删除订单 * * @param id 编号 */ - void deleteRechargeOrder(Integer id); + void deleteRechargeOrder(Long id); /** * 获得订单 @@ -43,7 +45,7 @@ public interface RechargeOrderService { * @param id 编号 * @return 订单 */ - RechargeOrderDO getRechargeOrder(Integer id); + RechargeOrderDO getRechargeOrder(Long id); /** * 获得订单列表 @@ -51,7 +53,7 @@ public interface RechargeOrderService { * @param ids 编号 * @return 订单列表 */ - List getRechargeOrderList(Collection ids); + List getRechargeOrderList(Collection ids); /** * 获得订单分页 diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java index 25ee53bcc..dc0ab8d08 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/recharge/RechargeOrderServiceImpl.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper; +import cn.iocoder.yudao.module.shop.request.member.RefundRequest; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -61,28 +62,35 @@ public class RechargeOrderServiceImpl implements RechargeOrderService { RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO); rechargeOrderMapper.updateById(updateObj); } - @Override - public void deleteRechargeOrder(Integer id) { + public void updateRechargeOrderStatus(RechargeOrderUpdateReqVO updateReqVO) { + // 校验存在 + validateRechargeOrderExists(updateReqVO.getId()); + // 更新 + RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO); + rechargeOrderMapper.updateById(updateObj); + } + @Override + public void deleteRechargeOrder(Long id) { // 校验存在 validateRechargeOrderExists(id); // 删除 rechargeOrderMapper.deleteById(id); } - private void validateRechargeOrderExists(Integer id) { + private void validateRechargeOrderExists(Long id) { if (rechargeOrderMapper.selectById(id) == null) { throw exception(RECHARGE_ORDER_NOT_EXISTS); } } @Override - public RechargeOrderDO getRechargeOrder(Integer id) { + public RechargeOrderDO getRechargeOrder(Long id) { return rechargeOrderMapper.selectById(id); } @Override - public List getRechargeOrderList(Collection ids) { + public List getRechargeOrderList(Collection ids) { return rechargeOrderMapper.selectBatchIds(ids); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml index 09dcad21f..3b046e718 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/recharge/RechargeOrderMapper.xml @@ -12,6 +12,7 @@