退单
This commit is contained in:
@@ -118,6 +118,10 @@ public class BuyOrderController {
|
||||
private UserCourseBuyLogService userCourseBuyLogService;
|
||||
@Autowired
|
||||
private CourseCatalogueService courseCatalogueService;
|
||||
@Autowired
|
||||
private BuyOrderRefundService buyOrderRefundService;
|
||||
@Autowired
|
||||
private BuyOrderRefundLogService buyOrderRefundLogService;
|
||||
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
|
||||
public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
|
||||
@@ -580,7 +584,109 @@ public class BuyOrderController {
|
||||
result.put("money", totalPrice);
|
||||
return R.ok(result);
|
||||
}
|
||||
//订单退款进度
|
||||
@RequestMapping("/refundDetail")
|
||||
public R refundOrderDetail(@RequestBody Map params){
|
||||
Object orderIdObj = params.get("orderId");
|
||||
if(orderIdObj == null || orderIdObj.toString().trim().equals("")){
|
||||
return R.error("orderId不能为空");
|
||||
}
|
||||
int order_id = Integer.parseInt(orderIdObj.toString().trim());
|
||||
QueryWrapper<BuyOrderRefund> wapper = new QueryWrapper<>();
|
||||
wapper.eq("order_id",order_id);
|
||||
BuyOrderRefund refundInfo = buyOrderRefundService.getOne(wapper);
|
||||
if(refundInfo==null){
|
||||
return R.error("退款信息不存在");
|
||||
}
|
||||
QueryWrapper<BuyOrderRefundLog> wapper2 = new QueryWrapper<>();
|
||||
wapper2.eq("refund_id",refundInfo.getId()).orderByDesc("create_time");
|
||||
List<BuyOrderRefundLog> list = buyOrderRefundLogService.list(wapper2);
|
||||
for (BuyOrderRefundLog log : list){
|
||||
if(log.getType()==1){
|
||||
log.setTitle("天医币已退还");
|
||||
log.setContent("天医币已退还到账户,可在我的->天医币中查看明细");
|
||||
}else if(log.getType()==2){
|
||||
log.setTitle("积分已退还");
|
||||
log.setContent("积分已退还到账户,可在我的->积分中查看明细");
|
||||
}else if(log.getType()==3){
|
||||
log.setTitle(log.getStatus()==1?"到账成功":"已退款,支付宝处理中");
|
||||
log.setContent(log.getStatus()==1?"已退到您的支付宝,到账时间以支付宝处理时间为准,可前往「支付宝-账单」查看":"已将退款资金提交给支付宝处理,通常情况下,退款会原路退回您的支付账户,预计会在1-7天内到账");
|
||||
}else if(log.getType()==4){
|
||||
log.setTitle(log.getStatus()==1?"到账成功":"已退款,微信处理中");
|
||||
log.setContent(log.getStatus()==1?"已退到您的微信,到账时间以微信处理时间为准,可前往「微信-账单」查看":"已将退款资金提交给微信处理,通常情况下,退款会原路退回您的支付账户,预计会在1-7天内到账");
|
||||
}
|
||||
}
|
||||
BuyOrderRefundLog log = new BuyOrderRefundLog();
|
||||
log.setId(0);
|
||||
log.setRefundId(refundInfo.getId());
|
||||
log.setType(0);
|
||||
log.setStatus(1);
|
||||
log.setCreateTime(refundInfo.getCreateTime());
|
||||
log.setTitle("发起退款");
|
||||
log.setContent("系统会在1-2天内提交处理");
|
||||
list.add(log);
|
||||
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
BigDecimal shippingMoney = refundInfo.getDeductShipping()==1?refundInfo.getShippingMoney():BigDecimal.ZERO;
|
||||
result.put("orderMoney",refundInfo.getFee().add(refundInfo.getJfDeduction().add(shippingMoney)));
|
||||
result.put("refundFee",refundInfo.getFee());
|
||||
result.put("payType",refundInfo.getPayType());
|
||||
result.put("refundJf",refundInfo.getJfDeduction());
|
||||
result.put("shippingMoney",shippingMoney);
|
||||
result.put("list",list);
|
||||
return R.ok().put("info",result);
|
||||
}
|
||||
@RequestMapping(value = "/refundOrder", method = RequestMethod.POST)
|
||||
@Transactional
|
||||
public R refundOrder(@RequestBody Map<String, Object> params) {
|
||||
Object orderIdObject = params.get("orderId");
|
||||
if(orderIdObject == null || orderIdObject.toString().trim().equals("")){
|
||||
return R.error("orderId不能为空");
|
||||
}
|
||||
int orderId = Integer.parseInt(orderIdObject.toString());
|
||||
QueryWrapper<BuyOrder> queryWapper = new QueryWrapper<>();
|
||||
queryWapper.eq("order_id",orderId);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(queryWapper);
|
||||
if(buyOrder==null){
|
||||
return R.error("订单不存在");
|
||||
}
|
||||
MyUserEntity user = myUserService.getById(buyOrder.getUserId());
|
||||
if (user == null) {
|
||||
return R.error("订单对应用户不存在");
|
||||
}
|
||||
|
||||
if (Constants.ORDER_STATUS_TO_BE_PAID.equals(buyOrder.getOrderStatus())
|
||||
|| Constants.ORDER_STATUS_FAIL.equals(buyOrder.getOrderStatus())
|
||||
|| Constants.ORDER_STATUS_REFUND.equals(buyOrder.getOrderStatus())
|
||||
|| Constants.ORDER_STATUS_OUT_OF_TIME.equals(buyOrder.getOrderStatus())) {
|
||||
return R.error("当前订单状态不支持退单");
|
||||
}
|
||||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_REFUND);
|
||||
buyOrderService.updateById(buyOrder);
|
||||
|
||||
BigDecimal refundFee = buyOrder.getRealMoney();
|
||||
BigDecimal shippingMoney = buyOrder.getShippingMoney()==null?BigDecimal.ZERO:buyOrder.getShippingMoney();
|
||||
int deductShipping = params.containsKey("deductShipping") && params.get("deductShipping")!=null?Integer.parseInt(params.get("deductShipping").toString()):0;
|
||||
if(refundFee.compareTo(BigDecimal.ZERO)>0 && shippingMoney.compareTo(BigDecimal.ZERO)>0 && deductShipping==1){
|
||||
refundFee = refundFee.subtract(shippingMoney);
|
||||
refundFee = refundFee.compareTo(BigDecimal.ZERO)>0?refundFee:BigDecimal.ZERO;
|
||||
}
|
||||
String remark = params.containsKey("remark") && params.get("remark").toString()!=null?params.get("remark").toString():"";
|
||||
int refundId = buyOrderRefundService.insertBuyOrderRefund(buyOrder,refundFee,deductShipping,remark);
|
||||
|
||||
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);
|
||||
return R.ok("ok");
|
||||
}
|
||||
@RequestMapping("/llll")
|
||||
public R ls(){
|
||||
|
||||
@@ -1166,7 +1272,7 @@ public class BuyOrderController {
|
||||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||||
.eq(ShopProductBookEntity::getProductId, productId)
|
||||
.eq(ShopProductBookEntity::getDelFlag, 0)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
|
||||
userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect);
|
||||
userEbookBuyService.addBookForUser(buyOrder, buyOrder.getUserId(), collect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user