Merge pull request 'cxw' (#17) from cxw into master
Some checks reported errors
continuous-integration/drone Build was killed
Some checks reported errors
continuous-integration/drone Build was killed
Reviewed-on: #17
This commit is contained in:
commit
7ba3baef66
@ -24,3 +24,8 @@ export const getWallet = async (params: PayWalletUserReqVO) => {
|
||||
export const getWalletPage = async (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 })
|
||||
}
|
||||
|
@ -196,6 +196,8 @@
|
||||
<UserLevelUpdateForm ref="updateLevelFormRef" @success="getList" />
|
||||
<!-- 修改用户积分弹窗 -->
|
||||
<UserPointUpdateForm ref="updatePointFormRef" @success="getList" />
|
||||
<!-- 修改用户余额弹窗 -->
|
||||
<UserBalanceUpdateForm ref="updateBalanceFormRef" @success="getList" />
|
||||
<!-- 发送优惠券弹窗 -->
|
||||
<CouponSendForm ref="couponSendFormRef" />
|
||||
</template>
|
||||
@ -209,6 +211,7 @@ import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect
|
||||
import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
|
||||
import UserLevelUpdateForm from './UserLevelUpdateForm.vue'
|
||||
import UserPointUpdateForm from './UserPointUpdateForm.vue'
|
||||
import UserBalanceUpdateForm from './UserBalanceUpdateForm.vue'
|
||||
import { CouponSendForm } from '@/views/mall/promotion/coupon/components'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
|
||||
@ -233,6 +236,7 @@ const queryParams = reactive({
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const updateLevelFormRef = ref() // 修改会员等级表单
|
||||
const updatePointFormRef = ref() // 修改会员积分表单
|
||||
const updateBalanceFormRef = ref() // 修改会员余额表单
|
||||
const selectedIds = ref<number[]>([]) // 表格的选中 ID 数组
|
||||
|
||||
/** 查询列表 */
|
||||
@ -299,7 +303,7 @@ const handleCommand = (command: string, row: UserApi.UserVO) => {
|
||||
updatePointFormRef.value.open(row.id)
|
||||
break
|
||||
case 'handleUpdateBlance':
|
||||
// todo @jason:增加一个【修改余额】
|
||||
updateBalanceFormRef.value.open(row.id)
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
@ -47,6 +47,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款");
|
||||
ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足");
|
||||
|
||||
|
||||
// ========== 钱包充值模块 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, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态");
|
||||
@ -62,6 +63,8 @@ public interface ErrorCodeConstants {
|
||||
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_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在");
|
||||
ErrorCode WALLET_RECHARGE_RANGE_EXCEPTION = new ErrorCode(1_007_007_004, "充值后余额异常");
|
||||
|
||||
|
||||
// ========== 转账模块 1-007-009-000 ==========
|
||||
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");
|
||||
|
@ -18,7 +18,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
|
||||
RECHARGE(1, "充值"),
|
||||
RECHARGE_REFUND(2, "充值退款"),
|
||||
PAYMENT(3, "支付"),
|
||||
PAYMENT_REFUND(4, "支付退款");
|
||||
PAYMENT_REFUND(4, "支付退款"),
|
||||
ADMIN_MODIFY(5, "管理员修改");
|
||||
|
||||
// TODO 后续增加
|
||||
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
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.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.convert.wallet.PayWalletConvert;
|
||||
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 org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
@ -41,6 +40,14 @@ public class PayWalletController {
|
||||
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")
|
||||
@Operation(summary = "获得会员钱包分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet:query')")
|
||||
|
@ -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;
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
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.PayWalletUserBalanceVo;
|
||||
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.enums.wallet.PayWalletBizTypeEnum;
|
||||
@ -97,4 +98,10 @@ public interface PayWalletService {
|
||||
*/
|
||||
void unfreezePrice(Long id, Integer price);
|
||||
|
||||
/**
|
||||
* 修改钱包余额(后台操作)
|
||||
* @param reqVo
|
||||
* @return void
|
||||
*/
|
||||
void updateWallet(PayWalletUserBalanceVo reqVo);
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
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.PayWalletUserBalanceVo;
|
||||
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.wallet.PayWalletDO;
|
||||
@ -18,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -32,7 +35,7 @@ import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYM
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PayWalletServiceImpl implements PayWalletService {
|
||||
public class PayWalletServiceImpl implements PayWalletService {
|
||||
|
||||
@Resource
|
||||
private PayWalletMapper walletMapper;
|
||||
@ -102,7 +105,7 @@ public class PayWalletServiceImpl implements PayWalletService {
|
||||
/**
|
||||
* 校验是否能退款
|
||||
*
|
||||
* @param refundId 支付退款单 id
|
||||
* @param refundId 支付退款单 id
|
||||
* @param walletPayNo 钱包支付 no
|
||||
*/
|
||||
private Long validateWalletCanRefund(Long refundId, String walletPayNo) {
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user