退单
This commit is contained in:
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -33,6 +34,7 @@ import com.peanut.modules.common.dao.UserCourseBuyDao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import com.peanut.modules.pay.alipay.service.AliPayService;
|
||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||
@@ -122,6 +124,8 @@ public class BuyOrderController {
|
||||
private BuyOrderRefundService buyOrderRefundService;
|
||||
@Autowired
|
||||
private BuyOrderRefundLogService buyOrderRefundLogService;
|
||||
@Autowired
|
||||
private AliPayService aliPayService;
|
||||
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
|
||||
public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
|
||||
@@ -661,12 +665,7 @@ public class BuyOrderController {
|
||||
|| Constants.ORDER_STATUS_OUT_OF_TIME.equals(buyOrder.getOrderStatus())) {
|
||||
return R.error("当前订单状态不支持退单");
|
||||
}
|
||||
// QueryWrapper<BuyOrderRefund> refundQueryWrapper = new QueryWrapper<>();
|
||||
// refundQueryWrapper.eq("order_id",buyOrder.getOrderId());
|
||||
// long refundOrderNums = buyOrderRefundService.count(refundQueryWrapper);
|
||||
if(buyOrder.getOrderStatus().equals(Constants.ORDER_STATUS_REFUND)){
|
||||
return R.error("请勿重复申请退款");
|
||||
}
|
||||
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_REFUND);
|
||||
buyOrderService.updateById(buyOrder);
|
||||
|
||||
@@ -697,17 +696,45 @@ public class BuyOrderController {
|
||||
int refundId = buyOrderRefund.getId();
|
||||
|
||||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||||
//BigDecimal refundPeanutCoin = buyOrder.getRealMoney() == null?BigDecimal.ZERO : buyOrder.getRealMoney();
|
||||
if(refundFee.compareTo(BigDecimal.ZERO)>0){
|
||||
transactionDetailsService.refundRecord(buyOrder,user,refundFee);
|
||||
user.setPeanutCoin(user.getPeanutCoin().add(refundFee));
|
||||
myUserService.updateById(user);
|
||||
buyOrderRefundLogService.insertRefundLog(refundId,1,1);
|
||||
buyOrderService.refundOrder(buyOrder,user,refundId);
|
||||
}
|
||||
} else if (Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())) {
|
||||
if (refundFee.compareTo(BigDecimal.ZERO) > 0) {
|
||||
Map<String, Object> refundParams = new HashMap<>();
|
||||
refundParams.put("orderSn", buyOrder.getOrderSn());
|
||||
refundParams.put("refundFee", refundFee);
|
||||
refundParams.put("reason", StringUtils.isBlank(remark) ? "后台申请退款" : remark);
|
||||
String refundResult = wxpayService.refund(refundParams);
|
||||
JSONObject resultJson = JSONObject.parseObject(refundResult);
|
||||
if (!"SUCCESS".equals(resultJson.getString("status"))) {
|
||||
return R.error("微信退款申请失败");
|
||||
}
|
||||
buyOrderRefundLogService.insertRefundLog(refundId,4,0);
|
||||
}
|
||||
} else if (Constants.PAYMENT_METHOD_ALI_PAY.equals(buyOrder.getPaymentMethod())) {
|
||||
if (refundFee.compareTo(BigDecimal.ZERO) > 0) {
|
||||
Map<String, Object> refundParams = new HashMap<>();
|
||||
refundParams.put("orderSn", buyOrder.getOrderSn());
|
||||
refundParams.put("refundFee", refundFee);
|
||||
String refundResult = aliPayService.refund(refundParams);
|
||||
JSONObject resultJson = JSONObject.parseObject(refundResult);
|
||||
JSONObject responseJson = resultJson.getJSONObject("alipay_trade_refund_response");
|
||||
if (responseJson == null
|
||||
|| !"10000".equals(responseJson.getString("code"))
|
||||
|| !"Y".equals(responseJson.getString("fund_change"))) {
|
||||
return R.error("支付宝退款申请失败");
|
||||
}
|
||||
buyOrderRefundLogService.insertRefundLog(refundId,3,1);
|
||||
}
|
||||
}
|
||||
|
||||
buyOrderService.refundOrder(buyOrder,user,refundId);
|
||||
return R.ok("ok");
|
||||
|
||||
}
|
||||
@RequestMapping("/llll")
|
||||
public R ls(){
|
||||
|
||||
Reference in New Issue
Block a user