|
|
@@ -94,6 +94,7 @@ import java.math.RoundingMode;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.UUID;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
@@ -479,10 +480,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
return;
|
|
|
}
|
|
|
validateMultiQuantityWholeRefund(refundReq, orderDon);
|
|
|
- multiQuantityOrderService.prepareRefund(orderId);
|
|
|
- if (orderDon.getType() == OrderDon.Type.PAYPAL || orderDon.getType() == OrderDon.Type.STRIPE) {
|
|
|
+ if (requiresManualMultiQuantityRefund(orderDon)) {
|
|
|
throw BusinessRuntimeException.getInstance("PayPal/Stripe批量订单请人工核对后退款");
|
|
|
}
|
|
|
+ multiQuantityOrderService.prepareRefund(orderId);
|
|
|
OrderDonBusinessEvent refundEvent = orderDonBusinessEventService.get(
|
|
|
orderId, OrderDonBusinessEvent.Type.refund);
|
|
|
if (refundEvent != null && refundEvent.getStatus() == OrderDonBusinessEvent.Status.processing) {
|
|
|
@@ -588,17 +589,13 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- String workerToken;
|
|
|
- if (providerStatus == ProviderRefundStatus.SUCCESS) {
|
|
|
- workerToken = refundEvent.getWorkerToken();
|
|
|
- if (StrUtil.isBlank(workerToken)) {
|
|
|
- throw new IllegalStateException("refund worker token is missing");
|
|
|
- }
|
|
|
- } else {
|
|
|
- workerToken = orderDonTicketRecordService.reclaimExpiredRefund(order.getId(), leaseMinutes);
|
|
|
- if (workerToken == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (!requiresRefundLeaseReclaim(providerStatus)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String workerToken = orderDonTicketRecordService.reclaimExpiredRefund(
|
|
|
+ order.getId(), leaseMinutes);
|
|
|
+ if (workerToken == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (providerStatus == ProviderRefundStatus.FAILED) {
|
|
|
@@ -752,7 +749,16 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private enum ProviderRefundStatus {
|
|
|
+ static boolean requiresManualMultiQuantityRefund(OrderDon order) {
|
|
|
+ return order != null && (order.getType() == OrderDon.Type.PAYPAL
|
|
|
+ || order.getType() == OrderDon.Type.STRIPE);
|
|
|
+ }
|
|
|
+
|
|
|
+ static boolean requiresRefundLeaseReclaim(ProviderRefundStatus status) {
|
|
|
+ return status == ProviderRefundStatus.SUCCESS || status == ProviderRefundStatus.FAILED;
|
|
|
+ }
|
|
|
+
|
|
|
+ enum ProviderRefundStatus {
|
|
|
SUCCESS,
|
|
|
PROCESSING,
|
|
|
FAILED,
|
|
|
@@ -796,7 +802,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (record.getStatus() != OrderDonTicketRecord.Status.refunding) {
|
|
|
throw BusinessRuntimeException.getInstance("订单车票状态异常,序号: {0}", record.getItemIndex());
|
|
|
}
|
|
|
- if (record.getRelationId() != null) {
|
|
|
+ if (currentTicketRelationId(record) != null) {
|
|
|
clearMultiQuantityTicket(orderDon, record);
|
|
|
}
|
|
|
if (!orderDonTicketRecordService.markRefunded(record.getId(), workerToken)) {
|
|
|
@@ -824,16 +830,17 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
|
|
|
private void clearMultiQuantityTicket(OrderDon orderDon, OrderDonTicketRecord record) {
|
|
|
+ Long relationId = currentTicketRelationId(record);
|
|
|
OrderDonTicketRecord activeRecord = orderDonTicketRecordService.getActiveByRelationIdForUpdate(
|
|
|
- record.getRelationId());
|
|
|
+ relationId);
|
|
|
if (activeRecord == null || !activeRecord.getId().equals(record.getId())
|
|
|
|| activeRecord.getStatus() != OrderDonTicketRecord.Status.refunding
|
|
|
|| !orderDon.getId().equals(activeRecord.getOrderId())) {
|
|
|
- throw BusinessRuntimeException.getInstance("车票分配记录已变更,relationId: {0}", record.getRelationId());
|
|
|
+ throw BusinessRuntimeException.getInstance("车票分配记录已变更,relationId: {0}", relationId);
|
|
|
}
|
|
|
- GroupsRelation relation = relationMapper.selectByIdForUpdate(record.getRelationId());
|
|
|
+ GroupsRelation relation = relationMapper.selectByIdForUpdate(relationId);
|
|
|
if (relation == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("退款车票不存在,relationId: {0}", record.getRelationId());
|
|
|
+ throw BusinessRuntimeException.getInstance("退款车票不存在,relationId: {0}", relationId);
|
|
|
}
|
|
|
if (relation.getUserId() == null || relation.getUserId() == 0) {
|
|
|
return;
|
|
|
@@ -841,7 +848,11 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (!isMultiQuantityTicketOwner(orderDon, relation)) {
|
|
|
throw BusinessRuntimeException.getInstance("车票归属异常,relationId: {0}", relation.getId());
|
|
|
}
|
|
|
- relationClearService.clearTicket(relation, UserTicketClearedRecord.Source.refund);
|
|
|
+ relationClearService.clearRefundTicket(relation, activeRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long currentTicketRelationId(OrderDonTicketRecord record) {
|
|
|
+ return record.getRelationId();
|
|
|
}
|
|
|
|
|
|
static boolean isMultiQuantityTicketOwner(OrderDon orderDon, GroupsRelation relation) {
|
|
|
@@ -1601,6 +1612,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (orderDon == null) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
}
|
|
|
+ validateOrdinaryRefundRequest(orderDon, refundReq);
|
|
|
BigDecimal orderDonRefundMoney = Optional.ofNullable(orderDon.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
|
BigDecimal orderDonRefundBalance = Optional.ofNullable(orderDon.getRefundBalance()).orElse(BigDecimal.ZERO);
|
|
|
String refundType = refundReq.getRefundType();
|
|
|
@@ -1730,6 +1742,40 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
// checkMirrorRenewSku(orderDon);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 普通订单退款仍由管理端选择退款方式,但金额字段必须与退款方式一致。
|
|
|
+ * 否则错误地把纯余额订单按 money 提交时,会清票并关闭订单,却不会退回余额。
|
|
|
+ */
|
|
|
+ private void validateOrdinaryRefundRequest(OrderDon orderDon, OrderRefundReq refundReq) {
|
|
|
+ String refundType = refundReq.getRefundType();
|
|
|
+ boolean supportedType = OrderRefundReq.RefundType.money.name().equals(refundType)
|
|
|
+ || OrderRefundReq.RefundType.balance.name().equals(refundType)
|
|
|
+ || OrderRefundReq.RefundType.bxj.name().equals(refundType);
|
|
|
+ if (!supportedType) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款类型不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal refundMoney = Optional.ofNullable(refundReq.getRefundMoney()).orElse(BigDecimal.ZERO);
|
|
|
+ BigDecimal refundBalance = Optional.ofNullable(refundReq.getRefundBalance()).orElse(BigDecimal.ZERO);
|
|
|
+ if (refundMoney.signum() < 0 || refundBalance.signum() < 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款金额不能小于0");
|
|
|
+ }
|
|
|
+ // Existing user-side expired-ticket refunds use money + refundBalance with
|
|
|
+ // isOnly=true to return the balance-funded portion while refunding cash.
|
|
|
+ // Reject only the malformed management request that carries a balance
|
|
|
+ // amount without opting into that established mixed-refund path.
|
|
|
+ if (OrderRefundReq.RefundType.money.name().equals(refundType)
|
|
|
+ && !Boolean.TRUE.equals(refundReq.getIsOnly())
|
|
|
+ && (refundBalance.signum() > 0 || orderDon.getType() == OrderDon.Type.BALANCE)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退款类型与余额退款金额不匹配");
|
|
|
+ }
|
|
|
+ if (OrderRefundReq.RefundType.balance.name().equals(refundType)
|
|
|
+ && !Boolean.TRUE.equals(refundReq.getIsOnly())
|
|
|
+ && refundMoney.signum() <= 0 && refundBalance.signum() > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("退至余额的金额字段不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 退款后 处理关联
|
|
|
*/
|
|
|
@@ -1742,10 +1788,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
goodsDonStockService.upStockRelate(null, orderDon.getId(), "refund");
|
|
|
}
|
|
|
try {
|
|
|
- if (!multiQuantityOrder && !orderDon.getIsDp()) {
|
|
|
+ if (!multiQuantityOrder && !Boolean.TRUE.equals(orderDon.getIsDp())) {
|
|
|
GroupsRelation relation = relationMapper.selectById(orderDon.getRelationId());
|
|
|
//冻结车票 清除
|
|
|
- if (relation != null && relation.getIsFrozen()) {
|
|
|
+ if (relation != null && Boolean.TRUE.equals(relation.getIsFrozen())) {
|
|
|
Optional.ofNullable(receivedRecordMapper.selectOne(Wrappers.lambdaQuery(AccountNetflixFrozenTicketReceivedRecord.class).eq(AccountNetflixFrozenTicketReceivedRecord::getRelationId, relation.getId()).last("limit 1")))
|
|
|
.ifPresent(rr -> {
|
|
|
Long sendRelationId = rr.getSendRelationId();
|
|
|
@@ -1763,7 +1809,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
log.error("清除车票错误:{}", StringUtil.getErrorText(e));
|
|
|
}
|
|
|
//若存在优惠券使用,退还优惠券
|
|
|
- if (orderDon.getCouponUserId() != 0) {
|
|
|
+ if (orderDon.getCouponUserId() != null && orderDon.getCouponUserId() != 0L) {
|
|
|
couponFontService.updateOrderDonCouponStatus(orderDon);
|
|
|
}
|
|
|
//退等比例
|
|
|
@@ -1799,7 +1845,8 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
// }
|
|
|
|
|
|
//扣除 该笔订单产生的返现银河币
|
|
|
- if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (Optional.ofNullable(orderDon.getMoney()).orElse(BigDecimal.ZERO)
|
|
|
+ .compareTo(BigDecimal.ZERO) > 0) {
|
|
|
userGalaxyCoinService.subOrderGenerateGalaxyCoin(orderDon.getId(), OrderDonGalaxyCoinRecord.Source.ordinary);
|
|
|
}
|
|
|
|
|
|
@@ -1810,7 +1857,8 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
|
|
|
try {
|
|
|
marketFrontService.subSpecificChanceNum(orderDon.getUserId(), orderDon.getId(), orderDon.getGoodsId(), orderDon.getUpdateTime());
|
|
|
- if (goodsDon.getType() == 2 && !orderDon.getIsDistribute()) {
|
|
|
+ if (goodsDon != null && Objects.equals(goodsDon.getType(), 2)
|
|
|
+ && !Boolean.TRUE.equals(orderDon.getIsDistribute())) {
|
|
|
equipmentDistributeService.subDistributeBenefitsChance(orderDon.getUserId(), orderDon.getId());
|
|
|
//扣除用户自身实物权益
|
|
|
userRealOrderBenefitsService.deductUserRealGoodsBenefits(orderDon.getId());
|
|
|
@@ -1819,9 +1867,12 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
log.error("wx减少抽奖机会错误,orderId:{},error:{}", orderDon.getId(), e);
|
|
|
}
|
|
|
if (OrderRefundReq.RefundType.balance.name().equals(refundType)) {
|
|
|
- if (isOnly == null) {
|
|
|
- BigDecimal balanceAmount = Optional.ofNullable(refundBalance)
|
|
|
- .orElse(Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO));
|
|
|
+ if (!Boolean.TRUE.equals(isOnly)) {
|
|
|
+ // 普通订单选择“退还至余额”时,退款数额放在 refundMoney;
|
|
|
+ // 多件整单退款的余额部分由服务端固定写入 refundBalance。
|
|
|
+ BigDecimal balanceAmount = multiQuantityOrder
|
|
|
+ ? Optional.ofNullable(refundBalance).orElse(BigDecimal.ZERO)
|
|
|
+ : Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO);
|
|
|
if (balanceAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
userBenefitsService.addUserBalance(orderDon.getUserId(), balanceAmount,
|
|
|
UserBalanceSourceRecord.Source.refund, orderDon.getYhsId(),
|
|
|
@@ -1839,7 +1890,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
deductUserMirrorShopMoney(orderDon);
|
|
|
}
|
|
|
|
|
|
- if (orderDon.getIsFixedDistribute()) {
|
|
|
+ if (Boolean.TRUE.equals(orderDon.getIsFixedDistribute())) {
|
|
|
//商务提成 因订单退款去掉
|
|
|
UserDistributeBusinessOrderDonRecord record = businessOrderDonRecordMapper.selectOne(Wrappers.lambdaQuery(UserDistributeBusinessOrderDonRecord.class)
|
|
|
.eq(UserDistributeBusinessOrderDonRecord::getOrderId, orderDon.getId())
|
|
|
@@ -1863,7 +1914,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
}
|
|
|
//是否是优惠加购关联订单
|
|
|
- if (orderDon.getIsDp()) {
|
|
|
+ if (Boolean.TRUE.equals(orderDon.getIsDp())) {
|
|
|
OrderDiscountPlusPurchaseSkuRelation discountPlusPurchaseSkuRelation = orderDiscountPlusPurchaseSkuRelationMapper.selectOne(Wrappers.lambdaQuery(OrderDiscountPlusPurchaseSkuRelation.class)
|
|
|
.eq(OrderDiscountPlusPurchaseSkuRelation::getOrderId, orderDon.getId()).last("limit 1"));
|
|
|
if (discountPlusPurchaseSkuRelation != null) {
|
|
|
@@ -1946,7 +1997,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
handleSubRewards(orderDon);
|
|
|
|
|
|
//是否是用户套餐优惠权益订单
|
|
|
- if (orderDon.getGoodsId() == 15) {
|
|
|
+ if (Objects.equals(orderDon.getGoodsId(), 15L)) {
|
|
|
UserBenefitsComboRelationRecord userBenefitsComboRelationRecord = userBenefitsComboRelationRecordMapper.selectOne(Wrappers.lambdaQuery(UserBenefitsComboRelationRecord.class)
|
|
|
.eq(UserBenefitsComboRelationRecord::getOrderId, orderDon.getId()).last("limit 1"));
|
|
|
if (userBenefitsComboRelationRecord != null) {
|
|
|
@@ -1965,7 +2016,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
//HBO GO退款,车队上架
|
|
|
setUpIfEmpty(orderDon.getGoodsId(), orderDon.getRelationId());
|
|
|
|
|
|
- if (orderDon.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
+ if (Objects.equals(orderDon.getGoodsId(), Constant.NETFLIX_GID)) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
NetflixUserAccountSubmitRecoverRecord recoverRecord = netflixUserAccountSubmitRecoverRecordMapper.selectOne(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
.eq(NetflixUserAccountSubmitRecoverRecord::getRelationId, orderDon.getRelationId())
|
|
|
@@ -1979,12 +2030,15 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
|
|
|
//GPT独立会员
|
|
|
- if (orderDon.getGoodsId() == Constant.GPT_PLUS_GID && sku.getNum() == 1) {
|
|
|
+ if (Objects.equals(orderDon.getGoodsId(), Constant.GPT_PLUS_GID)
|
|
|
+ && sku != null && Objects.equals(sku.getNum(), 1)) {
|
|
|
subRechargeNumOrder(orderDon.getUserId(), orderDon.getRelationId(), sku.getMonths(), operator);
|
|
|
}
|
|
|
|
|
|
//GPT独立会员退款 或代充退款 退还平台发券
|
|
|
- if ((orderDon.getGoodsId() == Constant.GPT_PLUS_GID && sku.getNum() == 1) || orderDon.getGoodsId() == Constant.GPT_RECHARGE_GOODS_ID) {
|
|
|
+ if ((Objects.equals(orderDon.getGoodsId(), Constant.GPT_PLUS_GID)
|
|
|
+ && sku != null && Objects.equals(sku.getNum(), 1))
|
|
|
+ || Objects.equals(orderDon.getGoodsId(), Constant.GPT_RECHARGE_GOODS_ID)) {
|
|
|
//若不存在对应的车票 则清除优惠券
|
|
|
List<Long> skuIds = goodsDonSkuMapper.selectIdpGptAndRechargeSkuIds(Constant.GPT_PLUS_GID, Constant.GPT_RECHARGE_GOODS_ID);
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
@@ -2005,7 +2059,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
}
|
|
|
|
|
|
//claude code 退款
|
|
|
- if (orderDon.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
|
+ if (Objects.equals(orderDon.getGoodsId(), Constant.CLAUDE_CODE_GOODS_ID)) {
|
|
|
DistributeWaitingSendPoints distributeWaitingSendPoints = distributeWaitingSendPointsMapper.selectOne(Wrappers.lambdaQuery(DistributeWaitingSendPoints.class).eq(DistributeWaitingSendPoints::getOrderId, orderDon.getId()).last("limit 1"));
|
|
|
if (distributeWaitingSendPoints != null) {
|
|
|
if (distributeWaitingSendPoints.getSendStatus() == DistributeWaitingSendPoints.Status.close) {
|
|
|
@@ -2022,13 +2076,13 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
|
|
|
//处理下级渠道分销提成
|
|
|
static boolean shouldRestoreStock(GoodsDon goodsDon, boolean multiQuantityOrder) {
|
|
|
- return !multiQuantityOrder || goodsDon == null || goodsDon.getType() != 1;
|
|
|
+ return !multiQuantityOrder || goodsDon == null || !Objects.equals(goodsDon.getType(), 1);
|
|
|
}
|
|
|
|
|
|
public void handleSubRewards(OrderDon orderDon) {
|
|
|
//是否是分销订单
|
|
|
//处理下级渠道分销提成
|
|
|
- if (orderDon.getIsDistribute()) {
|
|
|
+ if (orderDon != null && Boolean.TRUE.equals(orderDon.getIsDistribute())) {
|
|
|
UserDistributeSub subRelate = userDistributeSubMapper.getSubRelate(orderDon.getUserId());
|
|
|
if (subRelate != null) {
|
|
|
List<UserDistributeSubWaiting> subWaitings = subWaitingMapper.selectList(Wrappers.lambdaQuery(UserDistributeSubWaiting.class)
|
|
|
@@ -2061,7 +2115,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
* 退款 分销提成积分扣除
|
|
|
*/
|
|
|
public void deductDsPoints(OrderDon orderDon) {
|
|
|
- if (orderDon.getIsDistribute()) {
|
|
|
+ if (orderDon != null && Boolean.TRUE.equals(orderDon.getIsDistribute())) {
|
|
|
DistributeWaitingSendPoints distributeWaitingSendPoints = distributeWaitingSendPointsMapper.selectOne(Wrappers.lambdaQuery(DistributeWaitingSendPoints.class).eq(DistributeWaitingSendPoints::getOrderId, orderDon.getId()).eq(DistributeWaitingSendPoints::getIsVip,Boolean.FALSE).last("limit 1"));
|
|
|
if (distributeWaitingSendPoints != null) {
|
|
|
BigDecimal money = orderDon.getMoney();
|
|
|
@@ -2071,7 +2125,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
BigDecimal points = distributeWaitingSendPoints.getPoints();
|
|
|
if (sendStatus == DistributeWaitingSendPoints.Status.waiting) {
|
|
|
//实物设备退款就清0
|
|
|
- if (refundMoney.compareTo(money) == 0 || orderDon.getGoodsId() == 15) {
|
|
|
+ if (refundMoney.compareTo(money) == 0 || Objects.equals(orderDon.getGoodsId(), 15L)) {
|
|
|
//待发送状态 全额退款
|
|
|
distributeWaitingSendPoints.setSendStatus(DistributeWaitingSendPoints.Status.close);
|
|
|
distributeWaitingSendPoints.setRefundPoints(points);
|
|
|
@@ -2092,9 +2146,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
BigDecimal remainPoints = points.subtract(needSubPoints);
|
|
|
distributeWaitingSendPoints.setPoints(remainPoints);
|
|
|
//原先获取积分也扣除
|
|
|
- if (distributeWaitingSendPoints.getOriPoints().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- BigDecimal oriNeedSubPoints = distributeWaitingSendPoints.getOriPoints().multiply(refundRate);
|
|
|
- distributeWaitingSendPoints.setOriPoints(distributeWaitingSendPoints.getOriPoints().subtract(oriNeedSubPoints));
|
|
|
+ BigDecimal oriPoints = distributeWaitingSendPoints.getOriPoints();
|
|
|
+ if (oriPoints != null && oriPoints.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal oriNeedSubPoints = oriPoints.multiply(refundRate);
|
|
|
+ distributeWaitingSendPoints.setOriPoints(oriPoints.subtract(oriNeedSubPoints));
|
|
|
}
|
|
|
distributeWaitingSendPointsMapper.updateById(distributeWaitingSendPoints);
|
|
|
}
|
|
|
@@ -2102,7 +2157,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
//已发送的提成 部分退款 全额退款 需要扣除用户积分
|
|
|
//扣除固定推广者积分
|
|
|
//实物设备退款就清0
|
|
|
- if (refundMoney.compareTo(money) == 0 || orderDon.getGoodsId() == 15) {
|
|
|
+ if (refundMoney.compareTo(money) == 0 || Objects.equals(orderDon.getGoodsId(), 15L)) {
|
|
|
userBenefitsService.deductDistributePoints(orderDon.getId(), distributeWaitingSendPoints.getSharedId(), points);
|
|
|
distributeWaitingSendPoints.setRefundPoints(points);
|
|
|
distributeWaitingSendPoints.setPoints(BigDecimal.ZERO);
|
|
|
@@ -2123,9 +2178,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
distributeWaitingSendPoints.setRefundPoints(needSubPoints);
|
|
|
distributeWaitingSendPoints.setPoints(points.subtract(needSubPoints));
|
|
|
//原先获取积分也扣除
|
|
|
- if (distributeWaitingSendPoints.getOriPoints().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- BigDecimal oriNeedSubPoints = distributeWaitingSendPoints.getOriPoints().multiply(refundRate);
|
|
|
- distributeWaitingSendPoints.setOriPoints(distributeWaitingSendPoints.getOriPoints().subtract(oriNeedSubPoints));
|
|
|
+ BigDecimal oriPoints = distributeWaitingSendPoints.getOriPoints();
|
|
|
+ if (oriPoints != null && oriPoints.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ BigDecimal oriNeedSubPoints = oriPoints.multiply(refundRate);
|
|
|
+ distributeWaitingSendPoints.setOriPoints(oriPoints.subtract(oriNeedSubPoints));
|
|
|
}
|
|
|
distributeWaitingSendPointsMapper.updateById(distributeWaitingSendPoints);
|
|
|
}
|