add member center some interface
2 files added
22 files modified
| | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * |
| | | * 1-静态收益 2-动态收益 3-代理收益 4-排名收益 5-董事收益 6-社区点补 7-推荐人收益 8-提现 9-转增 10-支付 11-退款 |
| | | * @author wzy |
| | | * @date 2021-09-24 |
| | | * 1-分红收入 2-业绩奖励 3-订单支付 4-退款 5-转账 |
| | | **/ |
| | | @Getter |
| | | public enum MoneyFlowTypeEnum { |
| | | /** |
| | | * 直推奖励 |
| | | * 静态收益 |
| | | */ |
| | | BONUS(1), |
| | | STATIC_BONUS(1), |
| | | /** |
| | | * 团队奖励 |
| | | * 动态收益 |
| | | */ |
| | | ACHIEVE(2), |
| | | DYNAMIC_ACHIEVE(2), |
| | | |
| | | /** |
| | | * 支付 |
| | | * 代理收益 |
| | | */ |
| | | PAY(3), |
| | | AGENT_BONUS(3), |
| | | |
| | | /** |
| | | * 退款 |
| | | * 排名收益 |
| | | */ |
| | | REFUND(4), |
| | | RANK_BONUS(4), |
| | | |
| | | /** |
| | | * 转账 |
| | | * 董事收益 |
| | | */ |
| | | TRANSFER(5), |
| | | DIRECTOR_BONUS(5), |
| | | |
| | | /** |
| | | * 社区店补 |
| | | */ |
| | | COMMUNITY_BONUS(6), |
| | | |
| | | /** |
| | | * 推荐人收益 |
| | | */ |
| | | RECOMMEND_BONUS(7), |
| | | /** |
| | | * 提现 |
| | | */ |
| | | WITHDRAWAL(6), |
| | | WITHDRAWAL(8), |
| | | /** |
| | | * 排名奖励 |
| | | * 转账 |
| | | */ |
| | | RANK(7), |
| | | TRANSFER(9), |
| | | /** |
| | | * 利润分红 |
| | | * 支付 |
| | | */ |
| | | PARENT_BONUS(8), |
| | | PAY(10), |
| | | /** |
| | | * 系统拨付 |
| | | * 退款 |
| | | */ |
| | | SYSTEM_PAY(9); |
| | | REFUND(11); |
| | | |
| | | private final int value; |
| | | |
| | |
| | | public FebsResponse canWithdrawal() { |
| | | return new FebsResponse().success().data(memberService.canMoney()); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户消费排名") |
| | | @PostMapping(value = "/findRankList") |
| | | public FebsResponse findRankList(@RequestBody RankListDto rankListDto) { |
| | | return new FebsResponse().success().data(memberService.findRankList(rankListDto)); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty(value = "类型 1-全部 2-支出 3-收入") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty(value = "流水类型 1-余额 2-赠送积分 3-竞猜积分") |
| | | private Integer flowType; |
| | | |
| | | @ApiModelProperty(hidden = true) |
| | | private Long memberId; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-04-27 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "RankListDto", description = "消费排名接口参数接收类") |
| | | public class RankListDto { |
| | | |
| | | @ApiModelProperty(value = "一页多少个", example = "10") |
| | | private Integer pageSize; |
| | | |
| | | @ApiModelProperty(value = "页码", example = "1") |
| | | private Integer pageNum; |
| | | |
| | | } |
| | |
| | | @NotBlank(message = "参数不能为空") |
| | | @ApiModelProperty(value = "交易密码") |
| | | private String tradePwd; |
| | | |
| | | @ApiModelProperty(value = "银行卡号") |
| | | private String bankNo; |
| | | |
| | | @ApiModelProperty(value = "姓名") |
| | | private String name; |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | private BigDecimal balance; |
| | | |
| | | @TableField(exist = false) |
| | | private BigDecimal amount; |
| | | |
| | | @TableField(exist = false) |
| | | private String query; |
| | | |
| | | } |
| | |
| | | * 余额 |
| | | */ |
| | | private BigDecimal balance; |
| | | |
| | | /** |
| | | * 积分 |
| | | */ |
| | | private BigDecimal score; |
| | | |
| | | /** |
| | | * 累计积分 |
| | | */ |
| | | private BigDecimal totalScore; |
| | | |
| | | /** |
| | | * 抽奖积分 |
| | | */ |
| | | private BigDecimal prizeScore; |
| | | } |
| | |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 流水类型 1-直推奖励 2-团队奖励 3-订单支付 4-退款 5-转账 6-提现 7-排名奖励 8-利润分红 |
| | | * 类型 1-静态收益 2-动态收益 3-代理收益 4-排名收益 5-董事收益 6-社区点补 7-推荐人收益 8-提现 9-转增 |
| | | */ |
| | | private Integer type; |
| | | |
| | |
| | | */ |
| | | private Integer isReturn; |
| | | public static final Integer IS_RETURN_Y = 1; |
| | | |
| | | /** |
| | | * 流水类型 1-余额 2-赠送积分 3-竞猜积分 |
| | | */ |
| | | private Integer flowType; |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.dto.AgentDto; |
| | | import cc.mrbird.febs.mall.dto.AgentLevelDto; |
| | | import cc.mrbird.febs.mall.dto.RankAwardDto; |
| | | import cc.mrbird.febs.mall.dto.RankListDto; |
| | | import cc.mrbird.febs.mall.entity.AppVersion; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | |
| | | AdminAgentLevelSetInfoVo getAgentLevelSetInfoByMemberId(@Param("id")long id); |
| | | |
| | | IPage<MallDataVo> getMallDataListInPage(Page<MallDataVo> page, @Param("record")MallMember mallMember); |
| | | |
| | | IPage<MallMember> selectRankListInPage(IPage<MallMember> page, @Param("record") MallMember mallMember); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | Integer selectCntDirectOrTeam(@Param("type") Integer type, @Param("inviteId") String inviteId); |
| | | |
| | | Integer selectCntDirect(@Param("inviteId") String inviteId); |
| | | |
| | | BigDecimal selectTotalAmount(@Param("memberId") Long memberId); |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void profitJob() { |
| | | log.info("推荐人返利执行"); |
| | | DateTime yesterday = DateUtil.yesterday(); |
| | | List<MallMoneyFlow> flows = moneyFlowMapper.selectMoneyFlowProfitByDate(yesterday); |
| | | |
| | | if (CollUtil.isEmpty(flows)) { |
| | | return; |
| | | } |
| | | |
| | | for (MallMoneyFlow flow : flows) { |
| | | MallMember member = memberMapper.selectById(flow.getMemberId()); |
| | | |
| | | List<MallMember> child = memberMapper.selectByIdAndNoLevel(member.getInviteId(), AgentLevelEnum.ZERO_LEVEL.name()); |
| | | if (CollUtil.isEmpty(child)) { |
| | | continue; |
| | | } |
| | | int size = child.size(); |
| | | BigDecimal needReturn = flow.getAmount().multiply(BigDecimal.valueOf(0.1)); |
| | | |
| | | String orderNo = MallUtils.getOrderNum("R"); |
| | | String remarkFormat = "{}, 用户:{}, 利润分红: {}"; |
| | | |
| | | BigDecimal returnMoney = needReturn.divide(BigDecimal.valueOf(size), 2, RoundingMode.DOWN); |
| | | for (MallMember mallMember : child) { |
| | | memberWalletService.addBalance(returnMoney, mallMember.getId()); |
| | | |
| | | String remark = StrUtil.format(remarkFormat, DateUtil.format(yesterday, "yyyy-MM-dd"), member.getName(), returnMoney); |
| | | memberService.addMoneyFlow(mallMember.getId(), returnMoney, MoneyFlowTypeEnum.PARENT_BONUS.getValue(), orderNo, null, remark, member.getId(), null); |
| | | } |
| | | |
| | | String remark = StrUtil.format(remarkFormat, DateUtil.format(yesterday, "yyyy-MM-dd"), member.getName(), needReturn); |
| | | memberService.addMoneyFlow(member.getId(), needReturn.negate(), MoneyFlowTypeEnum.PARENT_BONUS.getValue(), orderNo, null, remark, null, null); |
| | | memberWalletService.reduceBalance(needReturn, member.getId()); |
| | | |
| | | moneyFlowMapper.updateIsReturnByMemberId(MallMoneyFlow.IS_RETURN_Y, flow.getMemberId()); |
| | | } |
| | | // DateTime yesterday = DateUtil.yesterday(); |
| | | // List<MallMoneyFlow> flows = moneyFlowMapper.selectMoneyFlowProfitByDate(yesterday); |
| | | // |
| | | // if (CollUtil.isEmpty(flows)) { |
| | | // return; |
| | | // } |
| | | // |
| | | // for (MallMoneyFlow flow : flows) { |
| | | // MallMember member = memberMapper.selectById(flow.getMemberId()); |
| | | // |
| | | // List<MallMember> child = memberMapper.selectByIdAndNoLevel(member.getInviteId(), AgentLevelEnum.ZERO_LEVEL.name()); |
| | | // if (CollUtil.isEmpty(child)) { |
| | | // continue; |
| | | // } |
| | | // int size = child.size(); |
| | | // BigDecimal needReturn = flow.getAmount().multiply(BigDecimal.valueOf(0.1)); |
| | | // |
| | | // String orderNo = MallUtils.getOrderNum("R"); |
| | | // String remarkFormat = "{}, 用户:{}, 利润分红: {}"; |
| | | // |
| | | // BigDecimal returnMoney = needReturn.divide(BigDecimal.valueOf(size), 2, RoundingMode.DOWN); |
| | | // for (MallMember mallMember : child) { |
| | | // memberWalletService.addBalance(returnMoney, mallMember.getId()); |
| | | // |
| | | // String remark = StrUtil.format(remarkFormat, DateUtil.format(yesterday, "yyyy-MM-dd"), member.getName(), returnMoney); |
| | | // memberService.addMoneyFlow(mallMember.getId(), returnMoney, MoneyFlowTypeEnum.PARENT_BONUS.getValue(), orderNo, null, remark, member.getId(), null); |
| | | // } |
| | | // |
| | | // String remark = StrUtil.format(remarkFormat, DateUtil.format(yesterday, "yyyy-MM-dd"), member.getName(), needReturn); |
| | | // memberService.addMoneyFlow(member.getId(), needReturn.negate(), MoneyFlowTypeEnum.PARENT_BONUS.getValue(), orderNo, null, remark, null, null); |
| | | // memberWalletService.reduceBalance(needReturn, member.getId()); |
| | | // |
| | | // moneyFlowMapper.updateIsReturnByMemberId(MallMoneyFlow.IS_RETURN_Y, flow.getMemberId()); |
| | | // } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | public interface IApiMallMemberService extends IService<MallMember> { |
| | | FebsResponse register(RegisterDto registerDto); |
| | |
| | | void bindPhone(AccountAndCodeDto accountAndCodeDto); |
| | | |
| | | BigDecimal canMoney(); |
| | | |
| | | List<MallMember> findRankList(RankListDto rankListDto); |
| | | } |
| | |
| | | MallMoneyFlow flow = new MallMoneyFlow(); |
| | | flow.setMemberId(memberId); |
| | | flow.setAmount(bigDecimal); |
| | | flow.setType(MoneyFlowTypeEnum.SYSTEM_PAY.getValue()); |
| | | // flow.setType(MoneyFlowTypeEnum.SYSTEM_PAY.getValue()); |
| | | flow.setOrderNo("SYS"+MallUtils.getOrderNum()); |
| | | flow.setStatus(2); |
| | | mallMoneyFlowMapper.insert(flow); |
| | |
| | | } |
| | | memberWalletService.addBalance(returnMoney, parent.getId()); |
| | | |
| | | memberService.addMoneyFlow(parent.getId(), returnMoney, MoneyFlowTypeEnum.BONUS.getValue(), orderInfo.getOrderNo(), null, null, orderInfo.getMemberId(), null); |
| | | // memberService.addMoneyFlow(parent.getId(), returnMoney, MoneyFlowTypeEnum.BONUS.getValue(), orderInfo.getOrderNo(), null, null, orderInfo.getMemberId(), null); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (Map.Entry<Long, BigDecimal> amount : entry.getValue().entrySet()) { |
| | | memberWalletService.addBalance(amount.getValue(), amount.getKey()); |
| | | |
| | | memberService.addMoneyFlow(amount.getKey(), amount.getValue(), MoneyFlowTypeEnum.ACHIEVE.getValue(), orderInfo.getOrderNo(), null, null, orderInfo.getMemberId(), null); |
| | | // memberService.addMoneyFlow(amount.getKey(), amount.getValue(), MoneyFlowTypeEnum.ACHIEVE.getValue(), orderInfo.getOrderNo(), null, null, orderInfo.getMemberId(), null); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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 cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | } |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(mallMemberVo.getId()); |
| | | mallMemberVo.setBalance(wallet.getBalance()); |
| | | mallMemberVo.setScore(wallet.getScore()); |
| | | mallMemberVo.setPrizeScore(wallet.getPrizeScore()); |
| | | mallMemberVo.setTotalCost(mallOrderInfoMapper.selectTotalAmount(id)); |
| | | return new FebsResponse().success().data(mallMemberVo); |
| | | } |
| | | |
| | |
| | | throw new FebsException("最小提现金额为100"); |
| | | } |
| | | |
| | | MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(memberId); |
| | | if (payment == null) { |
| | | throw new FebsException("未设置收款方式"); |
| | | } |
| | | // MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(memberId); |
| | | // if (payment == null) { |
| | | // throw new FebsException("未设置收款方式"); |
| | | // } |
| | | |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | |
| | | } |
| | | return canMoney; |
| | | } |
| | | |
| | | @Override |
| | | public List<MallMember> findRankList(RankListDto rankListDto) { |
| | | IPage<MallMember> page = new Page<>(rankListDto.getPageNum(), rankListDto.getPageSize()); |
| | | |
| | | MallMember member = new MallMember(); |
| | | member.setQuery("2"); |
| | | member.setCreatedTime(new Date()); |
| | | IPage<MallMember> list = this.baseMapper.selectRankListInPage(page, member); |
| | | |
| | | List<MallMember> records = list.getRecords(); |
| | | if (CollUtil.isNotEmpty(records)) { |
| | | BigDecimal amount = records.get(records.size() - 1).getAmount(); |
| | | page.setSize(999); |
| | | member.setAmount(amount); |
| | | |
| | | IPage<MallMember> amountList = this.baseMapper.selectRankListInPage(page, member); |
| | | if (CollUtil.isNotEmpty(amountList.getRecords())) { |
| | | Map<Long, Object> map = new HashMap<>(); |
| | | for (MallMember record : records) { |
| | | map.put(record.getId(), record); |
| | | } |
| | | |
| | | for (MallMember record : amountList.getRecords()) { |
| | | if (map.get(record.getId()) == null) { |
| | | records.add(record); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return records; |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "绑定手机号") |
| | | private String bindPhone; |
| | | |
| | | @ApiModelProperty(value = "累计消费") |
| | | private BigDecimal totalCost; |
| | | |
| | | @ApiModelProperty(value = "赠送积分") |
| | | private BigDecimal score; |
| | | |
| | | @ApiModelProperty(value = "抽奖积分") |
| | | private BigDecimal prizeScore; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "金额,有正负") |
| | | private BigDecimal amount; |
| | | |
| | | @ApiModelProperty(value = "类型 1-直推奖励 2-团队奖励 3-订单支付 4-退款 5-转账 6-提现 7-排名奖励") |
| | | @ApiModelProperty(value = "类型 1-静态收益 2-动态收益 3-代理收益 4-排名收益 5-董事收益 6-社区点补 7-推荐人收益 8-提现 9-转增 10-支付 11-退款") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty(value = "对方手机号") |
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-04-27 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "RankListVo", description = "用户消费排名接口返回参数类") |
| | | public class RankListVo { |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "邀请码") |
| | | private String inviteId; |
| | | |
| | | @ApiModelProperty(value = "邀请码") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "头像") |
| | | private String avatar; |
| | | |
| | | @ApiModelProperty(value = "金额") |
| | | private BigDecimal amount; |
| | | } |
| | |
| | | username: ct_test |
| | | password: 123456 |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://120.27.238.55:3306/xc_mall?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | url: jdbc:mysql://120.27.238.55:3306/db_amz?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | |
| | | redis: |
| | | # Redis数据库索引(默认为 0) |
| | |
| | | username: ct_test |
| | | password: 123456 |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://120.27.238.55:3306/xc_mall?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | url: jdbc:mysql://120.27.238.55:3306/db_amz?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | |
| | | redis: |
| | | # Redis数据库索引(默认为 0) |
| | |
| | | username: ct_test |
| | | password: 123456 |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://120.27.238.55:3306/xc_mall?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | url: jdbc:mysql://120.27.238.55:3306/db_amz?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8 |
| | | |
| | | redis: |
| | | # Redis数据库索引(默认为 0) |
| | |
| | | ORDER BY |
| | | DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') DESC |
| | | </select> |
| | | |
| | | <select id="selectRankListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember"> |
| | | select * from ( |
| | | select a.id, a.name, a.invite_id, a.avatar, sum(b.amount) amount from mall_member a, mall_order_info b |
| | | where a.id=b.member_id and b.status = 4 |
| | | <!-- 日 --> |
| | | <if test="record.query == '1'"> |
| | | |
| | | </if> |
| | | <!-- 月 --> |
| | | <if test="record.query == '2'"> |
| | | and date_format(#{record.createdTime},'%Y-%m') = date_format(b.order_time,'%Y-%m') |
| | | </if> |
| | | <if test="record.amount != null"> |
| | | and amount = #{record.amount} |
| | | </if> |
| | | group by a.id |
| | | ) a order by amount desc, a.id |
| | | </select> |
| | | </mapper> |
| | |
| | | <if test="record.memberId != null"> |
| | | and a.member_id=#{record.memberId} |
| | | </if> |
| | | <if test="record.flowType != null and record.flowType != ''"> |
| | | and a.flow_type=#{record.flowType} |
| | | </if> |
| | | </where> |
| | | order by a.created_time desc |
| | | </select> |
| | |
| | | group by a.invite_id |
| | | ) a |
| | | </select> |
| | | |
| | | <select id="selectTotalAmount" resultType="java.math.BigDecimal"> |
| | | select sum(amount) from mall_order_info |
| | | where member_id=#{memberId} and status = 4 |
| | | </select> |
| | | </mapper> |