修复仅用积分时订单退款失败
This commit is contained in:
@@ -98,6 +98,9 @@ public class StoreCouponController {
|
|||||||
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_EDIT')")
|
@PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_EDIT')")
|
||||||
public ResponseEntity giveOut(@Validated @RequestBody CouponGive couponGive){
|
public ResponseEntity giveOut(@Validated @RequestBody CouponGive couponGive){
|
||||||
Long couponId = couponGive.getCouponId();
|
Long couponId = couponGive.getCouponId();
|
||||||
|
if (couponGive.getUserIds().isEmpty()){
|
||||||
|
throw new YshopException("未选择任何会员");
|
||||||
|
}
|
||||||
couponGive.getUserIds().forEach(yxUser -> {
|
couponGive.getUserIds().forEach(yxUser -> {
|
||||||
//用户的券记录
|
//用户的券记录
|
||||||
storeCouponUserService.addUserCoupon(yxUser.getUid(),Math.toIntExact(couponId));
|
storeCouponUserService.addUserCoupon(yxUser.getUid(),Math.toIntExact(couponId));
|
||||||
|
|||||||
+14
-3
@@ -715,7 +715,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
|||||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||||
//修改状态
|
//修改状态
|
||||||
storeOrder.setId(orderQueryVo.getId());
|
storeOrder.setId(orderQueryVo.getId());
|
||||||
if (ShopCommonEnum.AGREE_2.getValue().equals(type)) {//同意退款
|
if (ShopCommonEnum.AGREE_2.getValue().equals(type)) {//拒绝退款
|
||||||
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue());
|
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue());
|
||||||
yxStoreOrderMapper.updateById(storeOrder);
|
yxStoreOrderMapper.updateById(storeOrder);
|
||||||
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
|
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
|
||||||
@@ -759,9 +759,20 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
|||||||
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue());
|
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue());
|
||||||
storeOrder.setRefundPrice(price);
|
storeOrder.setRefundPrice(price);
|
||||||
yxStoreOrderMapper.updateById(storeOrder);
|
yxStoreOrderMapper.updateById(storeOrder);
|
||||||
|
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "退款给用户:" + orderQueryVo.getPayIntegral() + "积分分");
|
||||||
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "退款给用户:" + orderQueryVo.getPayIntegral() + "分");
|
|
||||||
this.retrunStock(orderQueryVo.getOrderId());
|
this.retrunStock(orderQueryVo.getOrderId());
|
||||||
|
//增加判断,如果商品仅使用了积分,也对退款记录做出改变
|
||||||
|
if (orderQueryVo.getPayPrice().compareTo(BigDecimal.ZERO)==0){ //如果只使用了积分,付款为0
|
||||||
|
StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery()
|
||||||
|
.eq(StoreAfterSales::getUserId, orderQueryVo.getUid())
|
||||||
|
.eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one();
|
||||||
|
if (ObjectUtil.isNotNull(storeAfterSales)) {
|
||||||
|
storeAfterSalesService.lambdaUpdate()
|
||||||
|
.eq(StoreAfterSales::getId, storeAfterSales.getId())
|
||||||
|
.set(StoreAfterSales::getState, AfterSalesStatusEnum.STATUS_3.getValue())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "元");
|
orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "元");
|
||||||
|
|||||||
+7
-2
@@ -94,7 +94,12 @@ public class StoreAfterSalesServiceImpl extends BaseServiceImpl<StoreAfterSalesM
|
|||||||
//商品优惠前总金额
|
//商品优惠前总金额
|
||||||
BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum());
|
BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum());
|
||||||
//商品优惠总金额
|
//商品优惠总金额
|
||||||
BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice());
|
BigDecimal commodityDiscountAmount;
|
||||||
|
if (totalAmountOfGoods.compareTo(BigDecimal.ZERO)==0){
|
||||||
|
commodityDiscountAmount=new BigDecimal(0);
|
||||||
|
}else {
|
||||||
|
commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice());
|
||||||
|
}
|
||||||
//商品优惠后总金额
|
//商品优惠后总金额
|
||||||
totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
|
totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount));
|
||||||
|
|
||||||
@@ -147,7 +152,7 @@ public class StoreAfterSalesServiceImpl extends BaseServiceImpl<StoreAfterSalesM
|
|||||||
storeAfterSalesStatus.setOperator(nickname);
|
storeAfterSalesStatus.setOperator(nickname);
|
||||||
storeAfterSalesStatusMapper.insert(storeAfterSalesStatus);
|
storeAfterSalesStatusMapper.insert(storeAfterSalesStatus);
|
||||||
//如果订单未发货,直接调用退款方法(发货审核通过后进行退款需要通知及退款审核)
|
//如果订单未发货,直接调用退款方法(发货审核通过后进行退款需要通知及退款审核)
|
||||||
if (yxStoreOrder.getStatus().equals(OrderInfoEnum.STATUS_0)){
|
if (status.equals(OrderInfoEnum.STATUS_0.getValue())){
|
||||||
yxStoreOrderService.orderRefund(yxStoreOrder.getOrderId(),yxStoreOrder.getPayPrice(),
|
yxStoreOrderService.orderRefund(yxStoreOrder.getOrderId(),yxStoreOrder.getPayPrice(),
|
||||||
ShopCommonEnum.AGREE_1.getValue());
|
ShopCommonEnum.AGREE_1.getValue());
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
Reference in New Issue
Block a user