feat:支付选择优惠券
This commit is contained in:
1 parent
67320a4787
commit
b83657b1ea
15 files changed
+173
-32
No files matched your search
+12
@@ -219,6 +219,18 @@ public class HardOrderEntity extends Model<HardOrderEntity> {
|
||||
@Schema(description = "离线自动支付是否成功")
|
||||
private String offlinePaySuccess;
|
||||
|
||||
/**
|
||||
* 优惠券id
|
||||
*/
|
||||
@Schema(description = "优惠券id")
|
||||
private String couponRecordId;
|
||||
|
||||
/**
|
||||
* 优惠金额
|
||||
*/
|
||||
@Schema(description = "优惠金额")
|
||||
private Integer couponPrice;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
||||
+4
@@ -45,6 +45,7 @@ import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
|
||||
import com.bsd.pjcloud.hard.service.*;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeRefundDto;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteActCouponCancelService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeVo;
|
||||
@@ -86,6 +87,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
private final RemoteDeptService deptService;
|
||||
private final RemoteWalletRechargeService walletRechargeService;
|
||||
private final RemoteWalletSettingService walletSettingService;
|
||||
private final RemoteActCouponCancelService actCouponCancelService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -641,6 +643,8 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
}
|
||||
// 执行退款
|
||||
getSelf().refund(saveObj.getId());
|
||||
// 退优惠券
|
||||
actCouponCancelService.remoteReturn(Long.valueOf(order.getCouponRecordId()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+24
-2
@@ -86,6 +86,7 @@ import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActCancelItemDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActComCancelDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.act.ActCouponRecordRemoteCancelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
@@ -754,13 +755,20 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||
Integer balance = wallet.getBalance();
|
||||
int totalPrice = dto.getCustomPrice();
|
||||
int payPrice = dto.getCustomPrice();
|
||||
|
||||
// 用户是否使用优惠券
|
||||
int useAmountPrice = 0;
|
||||
if (ObjectUtil.isNotEmpty(dto.getActCouponRecordId())) {
|
||||
ActCouponRecordVo actCouponRecord = remoteActCouponCancelService.remoteGetDetail(dto.getActCouponRecordId(), totalPrice).getData();
|
||||
if (ObjectUtil.isEmpty(actCouponRecord)) {
|
||||
throw new RuntimeException("优惠券不存在");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(actCouponRecord.getUseAmountPrice()) && actCouponRecord.getUseAmountPrice() > 0) {
|
||||
payPrice -= actCouponRecord.getUseAmountPrice();
|
||||
if (payPrice < 0) payPrice = 0;
|
||||
useAmountPrice = actCouponRecord.getUseAmountPrice();
|
||||
}
|
||||
}
|
||||
|
||||
String subject = "未知商品x?";
|
||||
@@ -782,10 +790,14 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
.orderSourceTypeId(dto.getOrderSourceTypeId())
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
.payPrice(totalPrice)
|
||||
.payPrice(payPrice)
|
||||
.isOfflineOrder(YesNoEnum.NO.getCode())
|
||||
.productDesc(subject)
|
||||
.build();
|
||||
if (ObjectUtil.isNotEmpty(dto.getActCouponRecordId())) {
|
||||
orderObj.setCouponRecordId(String.valueOf(dto.getActCouponRecordId()));
|
||||
orderObj.setCouponPrice(useAmountPrice);
|
||||
}
|
||||
orderObj.setWalletId(wallet.getId());
|
||||
baseMapper.insert(orderObj);
|
||||
// 钱包扣款
|
||||
@@ -794,7 +806,11 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
getSelf().generateCode(orderObj);
|
||||
// 核销优惠券
|
||||
if (ObjectUtil.isNotEmpty(dto.getActCouponRecordId())) {
|
||||
|
||||
ActCouponRecordRemoteCancelDto remoteCancelDto = new ActCouponRecordRemoteCancelDto();
|
||||
remoteCancelDto.setOrderId(orderObj.getId());
|
||||
remoteCancelDto.setActCouponRecordId(dto.getActCouponRecordId());
|
||||
remoteCancelDto.setUseAmountPrice(useAmountPrice);
|
||||
remoteActCouponCancelService.remoteCancel(remoteCancelDto);
|
||||
}
|
||||
// 云音箱播报
|
||||
CompletableFuture.runAsync(() -> yyxService.send(orderObj.getMerchantId(), orderObj.getPayPrice(), userDetail.getSysUser().getPhone()));
|
||||
@@ -1048,6 +1064,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
boolean isVerify = isVerify(hardPayType);
|
||||
if (isWalletPay) {
|
||||
int payPrice = order.getTotalPrice() + order.getExtraPrice();
|
||||
if (ObjectUtil.isNotEmpty(payPrice)) {
|
||||
payPrice -= order.getCouponPrice();
|
||||
}
|
||||
if (payPrice > 0) {
|
||||
WalletBalanceTransactionDto reduceBuild = new WalletBalanceTransactionDto();
|
||||
reduceBuild.setWalletId(order.getWalletId());
|
||||
@@ -1078,6 +1097,9 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
}
|
||||
// 订单表订单状态
|
||||
Integer payPrice = isWalletPay ? order.getTotalPrice() + order.getExtraPrice() : 0;
|
||||
if (ObjectUtil.isNotEmpty(order.getCouponPrice())) {
|
||||
payPrice -= order.getCouponPrice();
|
||||
}
|
||||
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
|
||||
if (ObjectUtil.isNotEmpty(order.getOrderNo())) {
|
||||
update.setOrderNo(order.getOrderNo());
|
||||
|
||||
+2
@@ -228,6 +228,8 @@
|
||||
a.is_offline_order,
|
||||
a.product_desc,
|
||||
a.offline_pay_success,
|
||||
a.coupon_record_id,
|
||||
a.coupon_price,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
|
||||
Reference in new issue
Block a user