cxw #17

Merged
root merged 4 commits from cxw into master 2024-09-25 17:07:28 +08:00
8 changed files with 87 additions and 7 deletions

View File

@ -24,3 +24,8 @@ export const getWallet = async (params: PayWalletUserReqVO) => {
export const getWalletPage = async (params) => { export const getWalletPage = async (params) => {
return await request.get({ url: `/pay/wallet/page`, params }) return await request.get({ url: `/pay/wallet/page`, params })
} }
// 修改会员钱包余额
export const updateWalletBalance = async (data: any) => {
return await request.post({ url: `/pay/wallet/update`, data })
}

View File

@ -196,6 +196,8 @@
<UserLevelUpdateForm ref="updateLevelFormRef" @success="getList" /> <UserLevelUpdateForm ref="updateLevelFormRef" @success="getList" />
<!-- 修改用户积分弹窗 --> <!-- 修改用户积分弹窗 -->
<UserPointUpdateForm ref="updatePointFormRef" @success="getList" /> <UserPointUpdateForm ref="updatePointFormRef" @success="getList" />
<!-- 修改用户余额弹窗 -->
<UserBalanceUpdateForm ref="updateBalanceFormRef" @success="getList" />
<!-- 发送优惠券弹窗 --> <!-- 发送优惠券弹窗 -->
<CouponSendForm ref="couponSendFormRef" /> <CouponSendForm ref="couponSendFormRef" />
</template> </template>
@ -209,6 +211,7 @@ import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect
import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue' import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
import UserLevelUpdateForm from './UserLevelUpdateForm.vue' import UserLevelUpdateForm from './UserLevelUpdateForm.vue'
import UserPointUpdateForm from './UserPointUpdateForm.vue' import UserPointUpdateForm from './UserPointUpdateForm.vue'
import UserBalanceUpdateForm from './UserBalanceUpdateForm.vue'
import { CouponSendForm } from '@/views/mall/promotion/coupon/components' import { CouponSendForm } from '@/views/mall/promotion/coupon/components'
import { checkPermi } from '@/utils/permission' import { checkPermi } from '@/utils/permission'
@ -233,6 +236,7 @@ const queryParams = reactive({
const queryFormRef = ref() // const queryFormRef = ref() //
const updateLevelFormRef = ref() // const updateLevelFormRef = ref() //
const updatePointFormRef = ref() // const updatePointFormRef = ref() //
const updateBalanceFormRef = ref() //
const selectedIds = ref<number[]>([]) // ID const selectedIds = ref<number[]>([]) // ID
/** 查询列表 */ /** 查询列表 */
@ -299,7 +303,7 @@ const handleCommand = (command: string, row: UserApi.UserVO) => {
updatePointFormRef.value.open(row.id) updatePointFormRef.value.open(row.id)
break break
case 'handleUpdateBlance': case 'handleUpdateBlance':
// todo @jason updateBalanceFormRef.value.open(row.id)
break break
default: default:
break break

View File

@ -47,6 +47,7 @@ public interface ErrorCodeConstants {
ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款"); ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款");
ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足"); ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足");
// ========== 钱包充值模块 1-007-008-000 ========== // ========== 钱包充值模块 1-007-008-000 ==========
ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在"); ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在");
ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态");
@ -62,6 +63,8 @@ public interface ErrorCodeConstants {
ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在"); ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在");
ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用"); ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用");
ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在"); ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在");
ErrorCode WALLET_RECHARGE_RANGE_EXCEPTION = new ErrorCode(1_007_007_004, "充值后余额异常");
// ========== 转账模块 1-007-009-000 ========== // ========== 转账模块 1-007-009-000 ==========
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}"); ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");

View File

@ -18,7 +18,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
RECHARGE(1, "充值"), RECHARGE(1, "充值"),
RECHARGE_REFUND(2, "充值退款"), RECHARGE_REFUND(2, "充值退款"),
PAYMENT(3, "支付"), PAYMENT(3, "支付"),
PAYMENT_REFUND(4, "支付退款"); PAYMENT_REFUND(4, "支付退款"),
ADMIN_MODIFY(5, "管理员修改");
// TODO 后续增加 // TODO 后续增加

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserBalanceVo;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
@ -13,9 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
@ -41,6 +40,14 @@ public class PayWalletController {
return success(PayWalletConvert.INSTANCE.convert02(wallet)); return success(PayWalletConvert.INSTANCE.convert02(wallet));
} }
@PostMapping("/update")
@PreAuthorize("@ss.hasPermission('pay:wallet:update')")
@Operation(summary = "修改用户钱包余额(后台操作)")
public CommonResult<Boolean> updateWallet(@Valid @RequestBody PayWalletUserBalanceVo reqVo){
payWalletService.updateWallet(reqVo);
return success(true);
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得会员钱包分页") @Operation(summary = "获得会员钱包分页")
@PreAuthorize("@ss.hasPermission('pay:wallet:query')") @PreAuthorize("@ss.hasPermission('pay:wallet:query')")

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 用户修改余额 Request VO")
@Data
public class PayWalletUserBalanceVo {
@Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "余额", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal balance;
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserBalanceVo;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
@ -97,4 +98,10 @@ public interface PayWalletService {
*/ */
void unfreezePrice(Long id, Integer price); void unfreezePrice(Long id, Integer price);
/**
* 修改钱包余额后台操作
* @param reqVo
* @return void
*/
void updateWallet(PayWalletUserBalanceVo reqVo);
} }

View File

@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.pay.service.wallet;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserBalanceVo;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
@ -18,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -205,4 +208,37 @@ public class PayWalletServiceImpl implements PayWalletService {
} }
} }
@Override
public void updateWallet(PayWalletUserBalanceVo reqVo) {
// 如果
if (reqVo.getBalance().compareTo(BigDecimal.ZERO) == 0) {
return;
}
// 把单位从元转为分
BigDecimal change = new BigDecimal("100");
// 查出对应钱包信息
PayWalletDO walletDO = walletMapper.selectById(reqVo.getId());
if (reqVo.getBalance().compareTo(new BigDecimal("21474836.47")) > 0) {
throw exception(WALLET_RECHARGE_RANGE_EXCEPTION);
}
// 总共改变的金额
long changeBalance = (reqVo.getBalance().multiply(change)).longValue();
// 总余额
long totalBalance = walletDO.getBalance() + changeBalance;
// 总充值
long totalRecharge = walletDO.getTotalRecharge() + changeBalance;
if (totalBalance > 2147483647 || totalRecharge > 2147483647 || totalBalance < 0 || totalRecharge < 0) {
throw exception(WALLET_RECHARGE_RANGE_EXCEPTION);
}
walletDO.setBalance((int) totalBalance);
walletDO.setTotalRecharge((int) totalRecharge);
walletMapper.updateById(walletDO);
String title = "后台操作给用户" + (totalBalance > 0 ? "增加" : "减少") + "余额" + Math.abs(changeBalance)/100.0 + "";
WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO()
.setWalletId(reqVo.getId()).setPrice((int) changeBalance).setBalance((int) totalBalance)
.setBizType(PayWalletBizTypeEnum.ADMIN_MODIFY.getType()).setBizId("0").setTitle(title);
walletTransactionService.createWalletTransaction(transactionCreateReqBO);
}
} }