我的钱包业务逻辑实现
This commit is contained in:
@@ -5,6 +5,9 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.buy507.mall.mapper.UmsMemberAccountTransactionMapper;
|
||||||
|
import com.buy507.mall.model.*;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
@@ -24,10 +27,6 @@ import com.buy507.mall.dto.MemberWithdrawApplyResult;
|
|||||||
import com.buy507.mall.mapper.DmsMemberTradeRecordMapper;
|
import com.buy507.mall.mapper.DmsMemberTradeRecordMapper;
|
||||||
import com.buy507.mall.mapper.DmsMemberWithdrawApplyMapper;
|
import com.buy507.mall.mapper.DmsMemberWithdrawApplyMapper;
|
||||||
import com.buy507.mall.mapper.UmsMemberMapper;
|
import com.buy507.mall.mapper.UmsMemberMapper;
|
||||||
import com.buy507.mall.model.DmsMemberTradeRecord;
|
|
||||||
import com.buy507.mall.model.DmsMemberWithdrawApply;
|
|
||||||
import com.buy507.mall.model.ItemType;
|
|
||||||
import com.buy507.mall.model.UmsMember;
|
|
||||||
import com.buy507.mall.service.DmsMemberWithdrawApplyService;
|
import com.buy507.mall.service.DmsMemberWithdrawApplyService;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
|
||||||
@@ -48,6 +47,9 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisLock redisLock;
|
private RedisLock redisLock;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UmsMemberAccountTransactionMapper accountTransactionMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,6 +90,15 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
|||||||
member = memberMapper.selectByPrimaryKey(member.getId());
|
member = memberMapper.selectByPrimaryKey(member.getId());
|
||||||
member.setFreeze(member.getFreeze().subtract(withdrawApply.getValue())); //修改冻结值
|
member.setFreeze(member.getFreeze().subtract(withdrawApply.getValue())); //修改冻结值
|
||||||
memberMapper.updateByPrimaryKey(member);
|
memberMapper.updateByPrimaryKey(member);
|
||||||
|
|
||||||
|
// 写入会员流水记录表
|
||||||
|
UmsMemberAccountTransaction memberTransaction = new UmsMemberAccountTransaction();
|
||||||
|
memberTransaction.setMemberId(member.getId());
|
||||||
|
memberTransaction.setRevenueAmount(withdrawApply.getValue()); // 提现金额
|
||||||
|
memberTransaction.setRemarks("提现"); // 备注
|
||||||
|
memberTransaction.setCreateTime(DateUtil.date()); // 提现时间
|
||||||
|
accountTransactionMapper.insert(memberTransaction); // 保存流水记录
|
||||||
|
|
||||||
redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time));
|
redisLock.unlock(String.valueOf(member.getId()), String.valueOf(time));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -95,7 +106,7 @@ public class DmsMemberWithdrawApplyServiceImpl implements DmsMemberWithdrawApply
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package com.buy507.mall.portal.controller;
|
package com.buy507.mall.portal.controller;
|
||||||
|
|
||||||
import com.buy507.mall.common.api.CommonResult;
|
import com.buy507.mall.common.api.CommonResult;
|
||||||
|
import com.buy507.mall.portal.domain.WithdrawApplyParam;
|
||||||
import com.buy507.mall.portal.service.MyWalletService;
|
import com.buy507.mall.portal.service.MyWalletService;
|
||||||
|
import com.buy507.mall.portal.service.UmsMemberService;
|
||||||
import com.buy507.mall.portal.vo.WalletCashVo;
|
import com.buy507.mall.portal.vo.WalletCashVo;
|
||||||
import com.buy507.mall.portal.vo.WalletPointsVo;
|
import com.buy507.mall.portal.vo.WalletPointsVo;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/wallet")
|
@RequestMapping("/wallet")
|
||||||
@@ -17,25 +17,28 @@ public class MyWalletController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MyWalletService myWalletService;
|
private MyWalletService myWalletService;
|
||||||
|
|
||||||
/**
|
@Autowired
|
||||||
* 获取现金余额和流水
|
private UmsMemberService memberService;
|
||||||
* @param userId
|
|
||||||
* @return
|
|
||||||
*/
|
@ApiOperation("获取现金余额和流水")
|
||||||
@GetMapping("/balance")
|
@GetMapping("/balance")
|
||||||
public CommonResult<WalletCashVo> getBalance(@RequestParam Long userId){
|
public CommonResult<WalletCashVo> getBalance(@RequestParam Long userId){
|
||||||
WalletCashVo walletCashVo = myWalletService.getBalanceAndCashFlow(userId);
|
WalletCashVo walletCashVo = myWalletService.getBalanceAndCashFlow(userId);
|
||||||
return CommonResult.success(walletCashVo);
|
return CommonResult.success(walletCashVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取积分余额和流水
|
@ApiOperation("获取积分余额和流水")
|
||||||
* @param userId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/points")
|
@GetMapping("/points")
|
||||||
public CommonResult<WalletPointsVo> getIntegration(@RequestParam Long userId){
|
public CommonResult<WalletPointsVo> getIntegration(@RequestParam Long userId){
|
||||||
WalletPointsVo walletPointsVo = myWalletService.getIntegrationAndPointsFlow(userId);
|
WalletPointsVo walletPointsVo = myWalletService.getIntegrationAndPointsFlow(userId);
|
||||||
return CommonResult.success(walletPointsVo);
|
return CommonResult.success(walletPointsVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("会员提现申请")
|
||||||
|
@PostMapping(value = "/withdraw")
|
||||||
|
public CommonResult withdrawApply(@RequestBody WithdrawApplyParam applyParam) {
|
||||||
|
return memberService.withdrawApply(applyParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public interface PortalCommonService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会员的折扣
|
* 获取会员的折扣
|
||||||
* @param member
|
* @param memberId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
BigDecimal getDiscount(Long memberId);
|
BigDecimal getDiscount(Long memberId);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class PortalCommonServiceImpl implements PortalCommonService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会员的折扣
|
* 获取会员的折扣
|
||||||
* @param member
|
* @param memberId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -862,6 +862,12 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取提现申请列表
|
||||||
|
* @param pageSize
|
||||||
|
* @param pageNum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MemberWithdrawApplyResult> getWithdrawApply(Integer pageSize, Integer pageNum) {
|
public List<MemberWithdrawApplyResult> getWithdrawApply(Integer pageSize, Integer pageNum) {
|
||||||
PageHelper.startPage(pageNum, pageSize);
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
@@ -870,6 +876,11 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员提现申请
|
||||||
|
* @param applyParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CommonResult withdrawApply(WithdrawApplyParam applyParam) {
|
public CommonResult withdrawApply(WithdrawApplyParam applyParam) {
|
||||||
|
|
||||||
@@ -911,7 +922,7 @@ public class UmsMemberServiceImpl implements UmsMemberService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(applyParam.getValue() <= 0) {
|
if(applyParam.getValue() <= 0) {
|
||||||
return CommonResult.validateFailed("提现积分无效");
|
return CommonResult.validateFailed("提现无效");
|
||||||
}
|
}
|
||||||
|
|
||||||
String withdrawMultipleStr = commonService.getDictionaryValue(Constants.D_WITHDRAW_MULTIPLE);
|
String withdrawMultipleStr = commonService.getDictionaryValue(Constants.D_WITHDRAW_MULTIPLE);
|
||||||
|
|||||||
Reference in New Issue
Block a user