会员退款

This commit is contained in:
wangw 2025-03-06 18:31:53 +08:00
parent 8a34342922
commit 8c344d674a
1 changed files with 8 additions and 7 deletions

View File

@ -38,6 +38,7 @@ import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.czg.utils.MD5Util; import com.czg.utils.MD5Util;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.NonNull; import lombok.NonNull;
@ -315,10 +316,7 @@ public class PayServiceImpl implements PayService {
} }
} }
if (shopUser.getIsVip().equals(0)) { if (shopUser.getIsVip().equals(0)) {
shopUserService.updateChain() UpdateChain.of(ShopUser.class).set(ShopUser::getIsVip, 1).eq(ShopUser::getId, payParam.getShopUserId()).update();
.set(ShopUser::getIsVip, 1)
.eq(ShopUser::getId, payParam.getShopId())
.update();
} }
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder() ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId()) .id(shopUser.getId())
@ -329,7 +327,7 @@ public class PayServiceImpl implements PayService {
.build(); .build();
if (isFree) { if (isFree) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN); shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN);
orderInfoService.updateChain().eq(OrderInfo::getId, payParam.getOrderId()) UpdateChain.of(OrderInfo.class).eq(OrderInfo::getId, payParam.getOrderId())
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()) .set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
.set(OrderInfo::getIsFreeDine, 1) .set(OrderInfo::getIsFreeDine, 1)
.set(OrderInfo::getPayAmount, 0) .set(OrderInfo::getPayAmount, 0)
@ -425,6 +423,9 @@ public class PayServiceImpl implements PayService {
ShopUser shopUser = shopUserService.getShopUserInfo(refPayParam.getShopId(), refPayParam.getUserId()); ShopUser shopUser = shopUserService.getShopUserInfo(refPayParam.getShopId(), refPayParam.getUserId());
ShopUserFlow inFlow = userFlowService.getById(refPayParam.getFlowId()); ShopUserFlow inFlow = userFlowService.getById(refPayParam.getFlowId());
AssertUtil.isNull(inFlow, "充值记录不存在"); AssertUtil.isNull(inFlow, "充值记录不存在");
if (inFlow.getBizCode().equals("cashIn")) {
refPayParam.setCashRefund(true);
}
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(ShopUserFlow::getRelationId, refPayParam.getFlowId()); queryWrapper.eq(ShopUserFlow::getRelationId, refPayParam.getFlowId());
queryWrapper.eq(ShopUserFlow::getBizCode, ShopUserFlowBizEnum.AWARD_IN.getCode()); queryWrapper.eq(ShopUserFlow::getBizCode, ShopUserFlowBizEnum.AWARD_IN.getCode());
@ -471,12 +472,12 @@ public class PayServiceImpl implements PayService {
//更新会员余额 并生成流水 //更新会员余额 并生成流水
shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO); shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
userFlowService.updateChain() UpdateChain.of(ShopUserFlow.class)
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + refPayParam.getRefAmount()) .setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + refPayParam.getRefAmount())
.eq(ShopUserFlow::getId, inFlow.getId()) .eq(ShopUserFlow::getId, inFlow.getId())
.update(); .update();
if (giftFlow != null) { if (giftFlow != null) {
userFlowService.updateChain() UpdateChain.of(ShopUserFlow.class)
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + giftFlow.getAmount()) .setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + giftFlow.getAmount())
.eq(ShopUserFlow::getId, giftFlow.getId()) .eq(ShopUserFlow::getId, giftFlow.getId())
.update(); .update();