9 files added
11 files modified
| | |
| | | /** |
| | | * 退款 |
| | | */ |
| | | REFUND(11); |
| | | REFUND(11), |
| | | |
| | | /** |
| | | * 佣金转竞猜积分 |
| | | */ |
| | | COMMISSION_TO_PRIZESCORE(12), |
| | | |
| | | /** |
| | | * 佣金转余额 |
| | | */ |
| | | COMMISSION_TO_BALANCE(13); |
| | | |
| | | private final int value; |
| | | |
| | |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberPayment; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.ICommonService; |
| | | import cc.mrbird.febs.mall.service.IMallMemberWithdrawService; |
| | | import cc.mrbird.febs.mall.vo.MallMemberVo; |
| | | import cc.mrbird.febs.mall.vo.MoneyFlowVo; |
| | | import cc.mrbird.febs.mall.vo.MyCommissionVo; |
| | | import cc.mrbird.febs.mall.vo.TeamListVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | public class ApiMallMemberController { |
| | | |
| | | private final IApiMallMemberService memberService; |
| | | private final IMallMemberWithdrawService mallMemberWithdrawService; |
| | | private final IApiMallMemberWalletService walletService; |
| | | |
| | | @ApiOperation(value = "获取商城用户信息", notes = "获取商城用户信息") |
| | | @ApiResponses({ |
| | |
| | | @ApiOperation(value = "提现") |
| | | @PostMapping(value = "/withdrawal") |
| | | public FebsResponse withdrawal(@RequestBody @Validated WithdrawalDto withdrawalDto) { |
| | | memberService.withdrawal(withdrawalDto); |
| | | mallMemberWithdrawService.withdrawal(withdrawalDto); |
| | | return new FebsResponse().success().message("提交成功"); |
| | | } |
| | | |
| | |
| | | member.setName(account.getName()); |
| | | return new FebsResponse().success().data(member); |
| | | } |
| | | |
| | | @ApiOperation(value = "佣金划转") |
| | | @PostMapping(value = "/commissionChange") |
| | | public FebsResponse commissionChange(@RequestBody @Validated CommissionChangeDto commissionChange) { |
| | | walletService.commissionChange(commissionChange); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的权益") |
| | | @ApiResponses( |
| | | @ApiResponse(code = 200, message = "success", response = MyCommissionVo.class) |
| | | ) |
| | | @PostMapping(value = "/myCommission") |
| | | public FebsResponse myCommission() { |
| | | return new FebsResponse().success().data(memberService.myCommission()); |
| | | } |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.vo.MallMemberVo; |
| | | import cc.mrbird.febs.mall.vo.MyCommissionVo; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | |
| | | |
| | | public abstract MallMemberVo entityToVo(MallMember mallMember); |
| | | |
| | | public abstract MyCommissionVo entityToCommissionVo(MallMember mallMember); |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-05 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "CommissionChangeDto", description = "佣金划转参数接收类") |
| | | public class CommissionChangeDto { |
| | | |
| | | @ApiModelProperty(value = "划转金额", example = "100") |
| | | @NotNull(message = "请输入划转金额") |
| | | private BigDecimal amount; |
| | | |
| | | @ApiModelProperty(value = "类型 1-to余额 2-to竞猜积分", example = "1") |
| | | @NotNull(message = "参数错误") |
| | | private Integer type; |
| | | } |
| | |
| | | @ApiModelProperty(value = "类型 1-全部 2-支出 3-收入") |
| | | private Integer inOrOut; |
| | | |
| | | @ApiModelProperty(value = "流水类型 1-余额 2-赠送积分 3-竞猜积分") |
| | | @ApiModelProperty(value = "流水类型 1-余额 2-赠送积分 3-竞猜积分 4-佣金") |
| | | private Integer flowType; |
| | | |
| | | @ApiModelProperty(hidden = true) |
New file |
| | |
| | | package cc.mrbird.febs.mall.entity; |
| | | |
| | | import cc.mrbird.febs.common.entity.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-05 |
| | | **/ |
| | | @Data |
| | | @TableName("mall_member_withdraw") |
| | | public class MallMemberWithdraw extends BaseEntity { |
| | | |
| | | private Long memberId; |
| | | |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 状态 1-提现中 2-提现成功 3-提现失败 |
| | | */ |
| | | private Integer status; |
| | | |
| | | private String account; |
| | | |
| | | private String name; |
| | | |
| | | private String withdrawNo; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.mapper; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallMemberWithdraw; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | public interface MallMemberWithdrawMapper extends BaseMapper<MallMemberWithdraw> { |
| | | } |
| | |
| | | int updateIsReturnByMemberId(@Param("isReturn") Integer isReturn, @Param("memberId") Long memberId); |
| | | |
| | | BigDecimal selectProfitByDateAndMemberId(Long memberId); |
| | | |
| | | BigDecimal selectCommissionIncome(@Param("type") Integer type, @Param("date") Date date, @Param("memberId") Long memebrid); |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberPayment; |
| | | import cc.mrbird.febs.mall.vo.MyCommissionVo; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | void transfer(TransferDto transferDto); |
| | | |
| | | void withdrawal(WithdrawalDto withdrawalDto); |
| | | |
| | | void setPayment(MallMemberPayment mallMemberPayment); |
| | | |
| | | MallMemberPayment findMemberPayment(); |
| | |
| | | List<MallMember> findRankList(RankListDto rankListDto); |
| | | |
| | | MallMember findMemberInfoByAccount(String phone); |
| | | |
| | | MyCommissionVo myCommission(); |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.mall.dto.CommissionChangeDto; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWallet; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | |
| | | void add(BigDecimal amount, Long memberId, String field); |
| | | |
| | | void reduce(BigDecimal amount, Long memberId, String field); |
| | | |
| | | void commissionChange(CommissionChangeDto commissionChange); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.mall.dto.WithdrawalDto; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWithdraw; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | public interface IMallMemberWithdrawService extends IService<MallMemberWithdraw> { |
| | | |
| | | void withdrawal(WithdrawalDto withdrawalDto); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallMoneyFlow; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public interface IMallMoneyFlowService extends IService<MallMoneyFlow> { |
| | | |
| | | void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status, Integer flowType); |
| | | |
| | | void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, Integer flowType); |
| | | |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.ICommonService; |
| | | import cc.mrbird.febs.mall.vo.MallMemberVo; |
| | | import cc.mrbird.febs.mall.vo.MoneyFlowVo; |
| | | import cc.mrbird.febs.mall.vo.RankListVo; |
| | | import cc.mrbird.febs.mall.vo.TeamListVo; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | private final IApiMallMemberWalletService walletService; |
| | | private final MallMemberPaymentMapper mallMemberPaymentMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void withdrawal(WithdrawalDto withdrawalDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(memberId); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!mallMember.getTradePassword().equals(SecureUtil.md5(withdrawalDto.getTradePwd()))) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | if (withdrawalDto.getAmount().compareTo(BigDecimal.valueOf(100)) < 0) { |
| | | throw new FebsException("最小提现金额为100"); |
| | | } |
| | | |
| | | // MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(memberId); |
| | | // if (payment == null) { |
| | | // throw new FebsException("未设置收款方式"); |
| | | // } |
| | | |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | if (profit != null) { |
| | | // 可提现 |
| | | BigDecimal canMoney = wallet.getCommission().subtract(profit); |
| | | |
| | | if(withdrawalDto.getAmount().compareTo(canMoney) > 0) { |
| | | throw new FebsException("提现金额不足"); |
| | | } |
| | | } |
| | | |
| | | walletService.reduceCommission(withdrawalDto.getAmount(), memberId); |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | this.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue()); |
| | | } |
| | | |
| | | @Override |
| | | public void setPayment(MallMemberPayment mallMemberPayment) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | |
| | |
| | | public MallMember findMemberInfoByAccount(String phone) { |
| | | return this.baseMapper.selectInfoByAccount(phone); |
| | | } |
| | | |
| | | @Override |
| | | public MyCommissionVo myCommission() { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(id); |
| | | |
| | | MyCommissionVo commissionVo = MallMemberConversion.INSTANCE.entityToCommissionVo(mallMember); |
| | | |
| | | MallMember referMember = this.baseMapper.selectInfoByInviteId(mallMember.getReferrerId()); |
| | | if (referMember != null) { |
| | | commissionVo.setReferrerName(referMember.getName()); |
| | | commissionVo.setAvatar(referMember.getAvatar()); |
| | | } |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.AGENT_LEVEL, mallMember.getLevel()); |
| | | if (dic != null) { |
| | | commissionVo.setLevelName(dic.getDescription()); |
| | | } |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(id); |
| | | commissionVo.setCommission(wallet.getCommission()); |
| | | commissionVo.setToday(mallMoneyFlowMapper.selectCommissionIncome(1, new Date(), id)); |
| | | commissionVo.setMonth(mallMoneyFlowMapper.selectCommissionIncome(2, new Date(), id)); |
| | | commissionVo.setTotal(mallMoneyFlowMapper.selectCommissionIncome(null, null, id)); |
| | | commissionVo.setWaitCommission(BigDecimal.ZERO); |
| | | return commissionVo; |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.mall.dto.CommissionChangeDto; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWallet; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberWalletMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | |
| | | @RequiredArgsConstructor |
| | | public class ApiMallMemberWalletServiceImpl extends ServiceImpl<MallMemberWalletMapper, MallMemberWallet> implements IApiMallMemberWalletService { |
| | | |
| | | private final IMallMoneyFlowService moneyFlowService; |
| | | |
| | | @Override |
| | | public void addBalance(BigDecimal amount, Long memberId) { |
| | |
| | | while (flag) { |
| | | i++; |
| | | MallMemberWallet wallet = this.baseMapper.selectWalletByMemberId(memberId); |
| | | wallet.setCommission(wallet.getCommission().add(amount)); |
| | | |
| | | MallMemberWallet update = new MallMemberWallet(); |
| | | update.setId(wallet.getId()); |
| | |
| | | try { |
| | | declaredField = MallMemberWallet.class.getDeclaredField(field); |
| | | declaredField.setAccessible(true); |
| | | declaredField.set(update, amount); |
| | | |
| | | BigDecimal balance = (BigDecimal) declaredField.get(wallet); |
| | | declaredField.set(update, balance.add(amount)); |
| | | } catch (NoSuchFieldException | IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | throw new FebsException("金额新增失败"); |
| | | } |
| | | |
| | | int result = this.baseMapper.updateAmountWithVersion(wallet); |
| | | int result = this.baseMapper.updateAmountWithVersion(update); |
| | | if (result > 0) { |
| | | flag = false; |
| | | } else { |
| | |
| | | if (amount.compareTo(balance) > 0) { |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | declaredField.set(update, wallet.getCommission().subtract(amount)); |
| | | declaredField.set(update, balance.subtract(amount)); |
| | | |
| | | } catch (NoSuchFieldException | IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | int result = this.baseMapper.updateAmountWithVersion(wallet); |
| | | int result = this.baseMapper.updateAmountWithVersion(update); |
| | | if (result > 0) { |
| | | flag = false; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void commissionChange(CommissionChangeDto commissionChange) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | |
| | | // TODO 判断是否开启了划转 |
| | | |
| | | int type; |
| | | int flowType; |
| | | this.reduce(commissionChange.getAmount(), member.getId(), "commission"); |
| | | |
| | | // 佣金转余额 |
| | | if (commissionChange.getType() == 1) { |
| | | type = MoneyFlowTypeEnum.COMMISSION_TO_BALANCE.getValue(); |
| | | flowType = FlowTypeEnum.BALANCE.getValue(); |
| | | this.add(commissionChange.getAmount(), member.getId(), "balance"); |
| | | |
| | | // 佣金转竞猜积分 |
| | | } else if (commissionChange.getType() == 2){ |
| | | type = MoneyFlowTypeEnum.COMMISSION_TO_PRIZESCORE.getValue(); |
| | | flowType = FlowTypeEnum.PRIZE_SCORE.getValue(); |
| | | this.add(commissionChange.getAmount(), member.getId(), "prizeScore"); |
| | | } else { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | |
| | | moneyFlowService.addMoneyFlow(member.getId(), commissionChange.getAmount().negate(), type, null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(member.getId(), commissionChange.getAmount(), type, null, flowType); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.mall.dto.WithdrawalDto; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberPayment; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWallet; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWithdraw; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMallMemberWithdrawService; |
| | | import cc.mrbird.febs.mall.service.MallMemberService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-05 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MallMemberWithdrawServiceImpl extends ServiceImpl<MallMemberWithdrawMapper, MallMemberWithdraw> implements IMallMemberWithdrawService { |
| | | |
| | | private final IApiMallMemberService mallMemberService; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | private final IApiMallMemberWalletService walletService; |
| | | private final MallMemberPaymentMapper mallMemberPaymentMapper; |
| | | |
| | | @Override |
| | | public void withdrawal(WithdrawalDto withdrawalDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = mallMemberService.getById(memberId); |
| | | if (StrUtil.isBlank(mallMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!mallMember.getTradePassword().equals(SecureUtil.md5(withdrawalDto.getTradePwd()))) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | if (withdrawalDto.getAmount().compareTo(BigDecimal.valueOf(100)) < 0) { |
| | | throw new FebsException("最小提现金额为100"); |
| | | } |
| | | |
| | | MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(memberId); |
| | | if (payment == null) { |
| | | throw new FebsException("未设置收款方式"); |
| | | } |
| | | |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | if (profit != null) { |
| | | // 可提现 |
| | | BigDecimal canMoney = wallet.getCommission().subtract(profit); |
| | | |
| | | if(withdrawalDto.getAmount().compareTo(canMoney) > 0) { |
| | | throw new FebsException("提现金额不足"); |
| | | } |
| | | } |
| | | |
| | | walletService.reduce(withdrawalDto.getAmount(), memberId, "commission"); |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | |
| | | MallMemberWithdraw withdraw = new MallMemberWithdraw(); |
| | | withdraw.setWithdrawNo(orderNo); |
| | | withdraw.setMemberId(memberId); |
| | | withdraw.setAmount(withdrawalDto.getAmount()); |
| | | withdraw.setStatus(1); |
| | | this.baseMapper.insert(withdraw); |
| | | |
| | | mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue()); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallMoneyFlow; |
| | | import cc.mrbird.febs.mall.mapper.MallMoneyFlowMapper; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-05 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MallMoneyFlowServiceImpl extends ServiceImpl<MallMoneyFlowMapper, MallMoneyFlow> implements IMallMoneyFlowService { |
| | | |
| | | @Override |
| | | public void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status, Integer flowType) { |
| | | MallMoneyFlow flow = new MallMoneyFlow(); |
| | | flow.setMemberId(memberId); |
| | | flow.setAmount(amount); |
| | | flow.setType(type); |
| | | flow.setOrderNo(orderNo); |
| | | flow.setDescription(description); |
| | | flow.setRemark(remark); |
| | | flow.setRtMemberId(rtMemberId); |
| | | flow.setStatus(status); |
| | | flow.setFlowType(flowType); |
| | | this.baseMapper.insert(flow); |
| | | } |
| | | |
| | | @Override |
| | | public void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, Integer flowType) { |
| | | this.addMoneyFlow(memberId, amount, type, orderNo, null, null, null, null, flowType); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-05 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "MyCommissionVo", description = "我的权益返回参数类") |
| | | public class MyCommissionVo { |
| | | |
| | | @ApiModelProperty(value = "头像") |
| | | private String avatar; |
| | | |
| | | @ApiModelProperty(value = "昵称") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "邀请码") |
| | | private String inviteId; |
| | | |
| | | @ApiModelProperty(value = "代理等级") |
| | | private String levelName; |
| | | |
| | | @ApiModelProperty(value = "推荐人昵称") |
| | | private String referrerName; |
| | | |
| | | @ApiModelProperty(value = "推荐人头像") |
| | | private String referrerAvatar; |
| | | |
| | | @ApiModelProperty(value = "可提现") |
| | | private BigDecimal commission; |
| | | |
| | | @ApiModelProperty(value = "待结算") |
| | | private BigDecimal waitCommission; |
| | | |
| | | @ApiModelProperty(value = "本日收入") |
| | | private BigDecimal today; |
| | | |
| | | @ApiModelProperty(value = "本月收入") |
| | | private BigDecimal month; |
| | | |
| | | @ApiModelProperty(value = "累计收入") |
| | | private BigDecimal total; |
| | | |
| | | |
| | | } |
| | |
| | | , score = #{record.score} |
| | | </if> |
| | | <if test="record.prizeScore != null"> |
| | | , prize_score = #{record.prizeScoree} |
| | | , prize_score = #{record.prizeScore} |
| | | </if> |
| | | <if test="record.commission != null"> |
| | | , commission = #{record.commission} |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cc.mrbird.febs.mall.mapper.MallMemberWithdrawMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <select id="selectProfitByDateAndMemberId" resultType="java.math.BigDecimal"> |
| | | select ifnull(sum(a.amount),0) from mall_money_flow a where member_id=#{memberId} and type in (1,2) and date_format(a.CREATED_TIME, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d'); |
| | | </select> |
| | | |
| | | <select id="selectCommissionIncome" resultType="java.math.BigDecimal"> |
| | | select ifnull(sum(amount),0) from mall_money_flow |
| | | where flow_type=4 and amount > 0 and member_id=#{memberId} |
| | | <if test="type == 1"> |
| | | and date_format(created_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </if> |
| | | <if test="type == 2"> |
| | | and date_format(created_time, '%Y-%m') = date_format(#{date}, '%Y-%m') |
| | | </if> |
| | | </select> |
| | | </mapper> |