|
@@ -6,6 +6,9 @@ import com.kmall.admin.entity.OrderExceptionRecordEntity;
|
|
|
import com.kmall.admin.entity.OrderRefundEntity;
|
|
|
import com.kmall.admin.service.*;
|
|
|
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.common.utils.PageUtils;
|
|
|
import com.kmall.common.utils.Query;
|
|
@@ -204,24 +207,28 @@ public class OrderController {
|
|
|
public Object cancel(Long orderId) {
|
|
|
//
|
|
|
OrderEntity orderInfo = orderService.queryObject(orderId);
|
|
|
-
|
|
|
- if (null == orderInfo || orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_401.getItem())
|
|
|
+ if (null == orderInfo) {
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if (orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_401.getItem())
|
|
|
|| orderInfo.getOrderStatus() == Integer.parseInt(Dict.orderStatus.item_402.getItem())) {
|
|
|
return R.error("订单已退款");
|
|
|
}
|
|
|
|
|
|
if (orderInfo.getOrderStatus() != 0) {
|
|
|
- // todo
|
|
|
+ // todo 退款
|
|
|
// WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getOrderSn().toString(),
|
|
|
-// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
+// orderInfo.getActualPrice().doubleValue(), refundMoney.doubleValue());
|
|
|
WechatRefundApiResult result = WechatUtil.wxRefund(orderInfo.getMerchOrderSn().toString(),
|
|
|
0.01, 0.01);
|
|
|
- if (!result.getResult_code().equals("SUCCESS")) {
|
|
|
+ if (result.getResult_code().equals("SUCCESS")) {
|
|
|
+ orderService.cancelOrder(orderInfo,result);
|
|
|
+ }else{
|
|
|
OrderRefundEntity mallOrderRefund = orderRefundService.queryObjectByOrderId(orderInfo.getId());
|
|
|
OrderRefundEntity orderRefund = new OrderRefundEntity();
|
|
|
orderRefund.setRefundType(Integer.parseInt(Dict.RefundType.item_1.getItem()));
|
|
|
orderRefund.setRefundMoney(BigDecimal.valueOf(orderInfo.getActualPrice().multiply(new BigDecimal(100)).doubleValue()));
|
|
|
- orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_3.getItem()));
|
|
|
+ orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_4.getItem()));
|
|
|
orderRefund.setModTime(new Date());
|
|
|
if(mallOrderRefund !=null){
|
|
|
orderRefund.setId(mallOrderRefund.getId());
|
|
@@ -238,7 +245,6 @@ public class OrderController {
|
|
|
|
|
|
return R.error(result.getErr_code_des());
|
|
|
}
|
|
|
- orderService.cancelOrder(orderInfo,result);
|
|
|
}
|
|
|
|
|
|
return R.ok();
|