|
|
@@ -11,6 +11,7 @@ import com.izouma.tcg.domain.orderInfo.OrderRefundApply;
|
|
|
import com.izouma.tcg.domain.orderInfo.TransactionRecord;
|
|
|
import com.izouma.tcg.dto.PageQuery;
|
|
|
import com.izouma.tcg.enums.OrderStatus;
|
|
|
+import com.izouma.tcg.enums.PayMethod;
|
|
|
import com.izouma.tcg.enums.RefundStatus;
|
|
|
import com.izouma.tcg.enums.TransactionRecordType;
|
|
|
import com.izouma.tcg.exception.BusinessException;
|
|
|
@@ -93,20 +94,26 @@ public class OrderRefundApplyService {
|
|
|
OrderRefundApply refundApply = orderRefundApplyRepo.save(apply);
|
|
|
|
|
|
|
|
|
- try {
|
|
|
- WxPayRefundRequest req = WxPayRefundRequest.newBuilder()
|
|
|
- .transactionId(orderInfo.getTransactionId())
|
|
|
- .outRefundNo(refundId)
|
|
|
- .totalFee(orderInfo.getTotal().multiply(BigDecimal.valueOf(100)).intValue())
|
|
|
- .refundFee(orderInfo.getTotal().multiply(BigDecimal.valueOf(100)).intValue())
|
|
|
+ if (orderInfo.getPayMethod().equals(PayMethod.WECHAT)) {
|
|
|
+ try {
|
|
|
+ WxPayRefundRequest req = WxPayRefundRequest.newBuilder()
|
|
|
+ .transactionId(orderInfo.getTransactionId())
|
|
|
+ .outRefundNo(refundId)
|
|
|
+ .totalFee(orderInfo.getTotal().multiply(BigDecimal.valueOf(100)).intValue())
|
|
|
+ .refundFee(orderInfo.getTotal().multiply(BigDecimal.valueOf(100)).intValue())
|
|
|
// .totalFee(1)
|
|
|
// .refundFee(1)
|
|
|
- .notifyUrl(refundNotifyUrl)
|
|
|
- .build();
|
|
|
- wxPayService.refund(req);
|
|
|
- } catch (WxPayException e) {
|
|
|
- log.error("发起微信退款", e);
|
|
|
- throw new BusinessException("操作失败,请稍后再试", e.getErrCodeDes());
|
|
|
+ .notifyUrl(refundNotifyUrl)
|
|
|
+ .build();
|
|
|
+ wxPayService.refund(req);
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ log.error("发起微信退款", e);
|
|
|
+ throw new BusinessException("操作失败,请稍后再试", e.getErrCodeDes());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MemberInfo memberInfo = memberInfoRepo.findAllByUserId(orderInfo.getUserId());
|
|
|
+ memberInfo.setMoney(memberInfo.getMoney().add(orderInfo.getTotal()));
|
|
|
+ memberInfoRepo.save(memberInfo);
|
|
|
}
|
|
|
}
|
|
|
|