|
@@ -3,12 +3,13 @@ package com.kmall.admin.controller;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.kmall.admin.entity.MallOrderRefundEntity;
|
|
|
import com.kmall.admin.entity.OrderEntity;
|
|
|
+import com.kmall.admin.entity.OrderExceptionRecordEntity;
|
|
|
import com.kmall.admin.service.MallOrderRefundService;
|
|
|
import com.kmall.admin.entity.OrderProcessRecordEntity;
|
|
|
+import com.kmall.admin.service.OrderExceptionRecordService;
|
|
|
import com.kmall.admin.service.OrderProcessRecordService;
|
|
|
import com.kmall.admin.service.OrderService;
|
|
|
import com.kmall.api.contants.Dict;
|
|
|
-import com.kmall.api.entity.MallOrderRefund;
|
|
|
import com.kmall.common.utils.PageUtils;
|
|
|
import com.kmall.common.utils.Query;
|
|
|
import com.kmall.common.utils.R;
|
|
@@ -40,6 +41,9 @@ public class OrderController {
|
|
|
@Autowired
|
|
|
private MallOrderRefundService mallOrderRefundService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrderExceptionRecordService orderExceptionRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 列表
|
|
|
*/
|
|
@@ -199,29 +203,34 @@ public class OrderController {
|
|
|
|
|
|
if (null == orderInfo || orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_401.getItem())
|
|
|
|| orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_402.getItem())) {
|
|
|
- return R.error("订单已取消");
|
|
|
+ return R.error("订单已退款");
|
|
|
}
|
|
|
|
|
|
if (orderInfo.getOrderStatus() != 0) {
|
|
|
// todo
|
|
|
-// WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
-// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
- WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
+// WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
+// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
+ WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getMerchOrderSn().toString(),
|
|
|
0.01, 0.01);
|
|
|
if (!result.getResult_code().equals("SUCCESS")) {
|
|
|
+ MallOrderRefundEntity mallOrderRefund = mallOrderRefundService.queryObjectByOrderId(orderInfo.getId()+"");
|
|
|
MallOrderRefundEntity orderRefund = new MallOrderRefundEntity();
|
|
|
- orderRefund.setOrderId(Integer.parseInt(orderInfo.getId()+""));
|
|
|
- orderRefund.setUserId(Integer.parseInt(orderInfo.getUserId()+""));
|
|
|
- orderRefund.setRefundId(result.getRefund_id());
|
|
|
orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
|
|
|
- orderRefund.setOutRefundNo(result.getOut_refund_no());
|
|
|
- orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())));
|
|
|
- orderRefund.setRefundTime(new Date());
|
|
|
+ orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().multiply(new BigDecimal(100)).doubleValue()));
|
|
|
orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_3.getItem()));
|
|
|
- orderRefund.setRefundReason("退款失败"+result.getErr_code_des());
|
|
|
- orderRefund.setCreateTime(new Date());
|
|
|
orderRefund.setModTime(new Date());
|
|
|
- mallOrderRefundService.save(orderRefund);//退款记录
|
|
|
+ if(mallOrderRefund !=null){
|
|
|
+ orderRefund.setId(mallOrderRefund.getId());
|
|
|
+ mallOrderRefundService.update(orderRefund);//退款记录
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderExceptionRecordEntity mallOrderExceptionRecord = new OrderExceptionRecordEntity();
|
|
|
+ mallOrderExceptionRecord.setUserId(Integer.parseInt(orderInfo.getUserId()+""));
|
|
|
+ mallOrderExceptionRecord.setOrderSn(orderInfo.getOrderSn());
|
|
|
+ mallOrderExceptionRecord.setExceptionStatus(Dict.exceptionStatus.item_03.getItem());
|
|
|
+ mallOrderExceptionRecord.setExceptionContent("退款失败"+result.getErr_code_des());
|
|
|
+ mallOrderExceptionRecord.setCreateTime(new Date());
|
|
|
+ orderExceptionRecordService.save(mallOrderExceptionRecord);
|
|
|
|
|
|
return R.error(result.getErr_code_des());
|
|
|
}
|
|
@@ -260,8 +269,8 @@ public class OrderController {
|
|
|
return R.error("订单未付款,不能退款");
|
|
|
}
|
|
|
|
|
|
-// WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
-// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
+// WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
+// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
0.01, 0.01);
|
|
|
if (result.getResult_code().equals("SUCCESS")) {
|