Compare commits

..

2 Commits

9 changed files with 73 additions and 18 deletions

View File

@ -24,7 +24,10 @@ import java.util.List;
public class RefundRequest implements Serializable { public class RefundRequest implements Serializable {
private static final long serialVersionUID = -9170167938995005780L; private static final long serialVersionUID = -9170167938995005780L;
@Schema(description = "数据id") @Schema(description = "数据id")
private String orderId; @NotNull(message = "订单id不能为空")
private Long orderId;
@Schema(description = "退款类型1:同意退款2:拒绝退款、3:发起退款")
@NotNull(message = "退款类型不能为空")
private Integer type;
} }

View File

@ -130,7 +130,7 @@ public class WxPayNotifyController {
// 用户支付金额 // 用户支付金额
BigDecimal payerTotal = NumberUtil.div(result.getAmount().getPayerTotal() + "", "100", 2); BigDecimal payerTotal = NumberUtil.div(result.getAmount().getPayerTotal() + "", "100", 2);
// 处理相关逻辑 // 处理相关逻辑
RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getOrderId, result.getOutRefundNo())); RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getOrderId, result.getOutTradeNo()));
if (payerTotal.compareTo(orderDO.getPayPrice()) != 0) { if (payerTotal.compareTo(orderDO.getPayPrice()) != 0) {
log.error("支付金额不匹配,订单实际支付金额:{},微信入参验证金额:{}", orderDO.getPayPrice(), payerTotal); log.error("支付金额不匹配,订单实际支付金额:{},微信入参验证金额:{}", orderDO.getPayPrice(), payerTotal);
return "failure"; return "failure";

View File

@ -1,11 +1,16 @@
package cn.iocoder.yudao.module.shop.controller.admin.recharge; 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.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; 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.controller.admin.recharge.method.Excel;
import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderInfoConvert; 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.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 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 org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -38,6 +43,7 @@ import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderService;
@RestController @RestController
@RequestMapping("/shop/recharge-order") @RequestMapping("/shop/recharge-order")
@Validated @Validated
@Slf4j
public class RechargeOrderController { public class RechargeOrderController {
@Resource @Resource
@ -45,6 +51,10 @@ public class RechargeOrderController {
@Resource @Resource
private RechargeOrderInfoService rechargeOrderInfoService; private RechargeOrderInfoService rechargeOrderInfoService;
@Autowired
private StoreOrderService storeOrderService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建订单") @Operation(summary = "创建订单")
@PreAuthorize("@ss.hasPermission('shop:recharge-order:create')") @PreAuthorize("@ss.hasPermission('shop:recharge-order:create')")
@ -64,7 +74,7 @@ public class RechargeOrderController {
@Operation(summary = "删除订单") @Operation(summary = "删除订单")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('shop:recharge-order:delete')") @PreAuthorize("@ss.hasPermission('shop:recharge-order:delete')")
public CommonResult<Boolean> deleteRechargeOrder(@RequestParam("id") Integer id) { public CommonResult<Boolean> deleteRechargeOrder(@RequestParam("id") Long id) {
rechargeOrderService.deleteRechargeOrder(id); rechargeOrderService.deleteRechargeOrder(id);
return success(true); return success(true);
} }
@ -73,7 +83,7 @@ public class RechargeOrderController {
@Operation(summary = "获得订单") @Operation(summary = "获得订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('shop:recharge-order:query')") @PreAuthorize("@ss.hasPermission('shop:recharge-order:query')")
public CommonResult<RechargeOrderRespVO> getRechargeOrder(@RequestParam("id") Integer id) { public CommonResult<RechargeOrderRespVO> getRechargeOrder(@RequestParam("id") Long id) {
RechargeOrderDO rechargeOrder = rechargeOrderService.getRechargeOrder(id); RechargeOrderDO rechargeOrder = rechargeOrderService.getRechargeOrder(id);
return success(RechargeOrderConvert.INSTANCE.convert(rechargeOrder)); return success(RechargeOrderConvert.INSTANCE.convert(rechargeOrder));
} }
@ -82,7 +92,7 @@ public class RechargeOrderController {
@Operation(summary = "获得订单列表") @Operation(summary = "获得订单列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('shop:recharge-order:query')") @PreAuthorize("@ss.hasPermission('shop:recharge-order:query')")
public CommonResult<List<RechargeOrderRespVO>> getRechargeOrderList(@RequestParam("ids") Collection<Integer> ids) { public CommonResult<List<RechargeOrderRespVO>> getRechargeOrderList(@RequestParam("ids") Collection<Long> ids) {
List<RechargeOrderDO> list = rechargeOrderService.getRechargeOrderList(ids); List<RechargeOrderDO> list = rechargeOrderService.getRechargeOrderList(ids);
return success(RechargeOrderConvert.INSTANCE.convertList(list)); return success(RechargeOrderConvert.INSTANCE.convertList(list));
} }
@ -115,4 +125,34 @@ public class RechargeOrderController {
Excel.orderExport(response, list, infoList); Excel.orderExport(response, list, infoList);
} }
@TenantIgnore
@PreAuthenticated
@Operation(summary = "退款")
@RequestMapping(value = "/memberRefund", method = RequestMethod.POST)
public CommonResult<Object> 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);
}
} }

View File

@ -80,8 +80,8 @@ public class RechargeOrderBaseVO {
private Boolean status; private Boolean status;
@Schema(description = "0 未退款 1 申请中 2 已退款 3 退款中", required = true, example = "2") @Schema(description = "0 未退款 1 申请中 2 已退款 3 退款中", required = true, example = "2")
@NotNull(message = "0 未退款 1 申请中 2 已退款 3 退款中不能为空") @NotNull(message = "0 未退款 1 申请中 2 已退款 3 退款中,4拒绝退款不能为空")
private Byte refundStatus; private Integer refundStatus;
@Schema(description = "退款图片") @Schema(description = "退款图片")
private String refundReasonWapImg; private String refundReasonWapImg;

View File

@ -11,7 +11,7 @@ import java.time.LocalDateTime;
public class RechargeOrderRespVO extends RechargeOrderBaseVO { public class RechargeOrderRespVO extends RechargeOrderBaseVO {
@Schema(description = "订单ID", required = true, example = "17164") @Schema(description = "订单ID", required = true, example = "17164")
private Integer id; private Long id;
@Schema(description = "创建时间") @Schema(description = "创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;

View File

@ -13,6 +13,6 @@ public class RechargeOrderUpdateReqVO extends RechargeOrderBaseVO {
@Schema(description = "订单ID", required = true, example = "17164") @Schema(description = "订单ID", required = true, example = "17164")
@NotNull(message = "订单ID不能为空") @NotNull(message = "订单ID不能为空")
private Integer id; private Long id;
} }

View File

@ -30,12 +30,14 @@ public interface RechargeOrderService {
*/ */
void updateRechargeOrder(@Valid RechargeOrderUpdateReqVO updateReqVO); void updateRechargeOrder(@Valid RechargeOrderUpdateReqVO updateReqVO);
void updateRechargeOrderStatus(RechargeOrderUpdateReqVO updateReqVO);
/** /**
* *
* *
* @param id * @param id
*/ */
void deleteRechargeOrder(Integer id); void deleteRechargeOrder(Long id);
/** /**
* *
@ -43,7 +45,7 @@ public interface RechargeOrderService {
* @param id * @param id
* @return * @return
*/ */
RechargeOrderDO getRechargeOrder(Integer id); RechargeOrderDO getRechargeOrder(Long id);
/** /**
* *
@ -51,7 +53,7 @@ public interface RechargeOrderService {
* @param ids * @param ids
* @return * @return
*/ */
List<RechargeOrderDO> getRechargeOrderList(Collection<Integer> ids); List<RechargeOrderDO> getRechargeOrderList(Collection<Long> ids);
/** /**
* *

View File

@ -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.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; 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.dal.mysql.recharge.RechargeOrderInfoMapper;
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse; import cn.iocoder.yudao.module.shop.response.member.MemberHeadResponse;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -61,28 +62,35 @@ public class RechargeOrderServiceImpl implements RechargeOrderService {
RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO); RechargeOrderDO updateObj = RechargeOrderConvert.INSTANCE.convert(updateReqVO);
rechargeOrderMapper.updateById(updateObj); rechargeOrderMapper.updateById(updateObj);
} }
@Override @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); validateRechargeOrderExists(id);
// 删除 // 删除
rechargeOrderMapper.deleteById(id); rechargeOrderMapper.deleteById(id);
} }
private void validateRechargeOrderExists(Integer id) { private void validateRechargeOrderExists(Long id) {
if (rechargeOrderMapper.selectById(id) == null) { if (rechargeOrderMapper.selectById(id) == null) {
throw exception(RECHARGE_ORDER_NOT_EXISTS); throw exception(RECHARGE_ORDER_NOT_EXISTS);
} }
} }
@Override @Override
public RechargeOrderDO getRechargeOrder(Integer id) { public RechargeOrderDO getRechargeOrder(Long id) {
return rechargeOrderMapper.selectById(id); return rechargeOrderMapper.selectById(id);
} }
@Override @Override
public List<RechargeOrderDO> getRechargeOrderList(Collection<Integer> ids) { public List<RechargeOrderDO> getRechargeOrderList(Collection<Long> ids) {
return rechargeOrderMapper.selectBatchIds(ids); return rechargeOrderMapper.selectBatchIds(ids);
} }

View File

@ -12,6 +12,7 @@
<select id="findListPage" resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO"> <select id="findListPage" resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RechargeOrderRespVO">
select select
a.id,
a.order_id, a.order_id,
a.pay_serial_number, a.pay_serial_number,
a.out_trade_no, a.out_trade_no,
@ -25,6 +26,7 @@
a.total_price, a.total_price,
a.pay_price, a.pay_price,
a.paid, a.paid,
a.refund_status,
d.parent_organization_name d.parent_organization_name
from cy_recharge_order a from cy_recharge_order a
left join member_user b on a.promoter_id = b.id left join member_user b on a.promoter_id = b.id