6 files added
17 files modified
| | |
| | | INDRECT_BONUS("BONUS_TYPE", "INDRECT_BONUS"), |
| | | AGENT_BONUS("BONUS_TYPE", "AGENT_BONUS"), |
| | | THANKFUL_BONUS("BONUS_TYPE", "THANKFUL_BONUS"), |
| | | DIRECTOR_BONUS("BONUS_TYPE", "DIRECTOR_BONUS"), |
| | | COMMUNITY_BONUS("BONUS_TYPE", "COMMUNITY_BONUS"), |
| | | |
| | | //积分中奖概率 |
| | | WIN_SCORE("WIN_PROBABILITY", "WIN_SCORE"), |
| | | //佣金中奖概率 |
| | |
| | | import cc.mrbird.febs.mall.vo.AdminAgentLevelOptionTreeVo; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | /** |
| | | * 平台账单 |
| | | * |
| | | * @param mallMember |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 会员列表 |
| | | * |
| | | * @param mallMember |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 会员列表---禁止 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 会员列表---开启 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | @ControllerEndpoint(operation = "会员列表---开启", exceptionMessage = "开启失败") |
| | | public FebsResponse openAccount(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return mallMemberService.openAccount(id); |
| | | } |
| | | |
| | | @GetMapping("changeIdentityYes/{type}/{id}") |
| | | public FebsResponse changeIdentityYes(@PathVariable("type") Integer type, @PathVariable("id") Long id) { |
| | | mallMemberService.changeIdentity(type, id, 1); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("changeIdentityNo/{type}/{id}") |
| | | public FebsResponse changeIdentityNo(@PathVariable("type") Integer type, @PathVariable("id") Long id) { |
| | | mallMemberService.changeIdentity(type, id, 2); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 资金流水-列表 |
| | | * |
| | | * @param moneyFlowListDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 会员提现-列表 |
| | | * |
| | | * @param moneyChargeListDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 会员提现-同意 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 会员提现-拒绝 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 代理列表 |
| | | * |
| | | * @param agentDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 代理级别-列表 |
| | | * |
| | | * @param agentLevelDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 代理列表---激活 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 奖励设置-列表 |
| | | * |
| | | * @param rankAwardDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * App版本-列表 |
| | | * |
| | | * @param appVersion |
| | | * @param request |
| | | * @return |
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; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-06-15 |
| | | **/ |
| | | @Data |
| | | @TableName("mall_achieve_record") |
| | | public class MallAchieveRecord extends BaseEntity { |
| | | |
| | | private Long memberId; |
| | | |
| | | private BigDecimal amount; |
| | | |
| | | private BigDecimal costAmount; |
| | | |
| | | private Date achieveTime; |
| | | |
| | | private Long orderId; |
| | | |
| | | private Long orderItemId; |
| | | |
| | | private Integer isNormal; |
| | | |
| | | private Date payTime; |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | private String levelName; |
| | | |
| | | /** |
| | | * 董事 |
| | | */ |
| | | private Integer director; |
| | | |
| | | /** |
| | | * 店长 |
| | | */ |
| | | private Integer storeMaster; |
| | | |
| | | } |
| | |
| | | private BigDecimal costPrice; |
| | | |
| | | private Integer isNormal; |
| | | |
| | | /** |
| | | * 是否结清 |
| | | */ |
| | | private Integer hasSettle; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.mapper; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallAchieveRecord; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | public interface MallAchieveRecordMapper extends BaseMapper<MallAchieveRecord> { |
| | | } |
| | |
| | | List<MallMember> selectMemberListHasChild(); |
| | | |
| | | List<MallMember> selectMemberDirectForHasLevel(@Param("inviteId") String inviteId); |
| | | |
| | | List<MallMember> selectDirectorsOrStoreMaster(@Param("type") Integer type); |
| | | } |
| | |
| | | |
| | | BigDecimal selectTotalAmountForDate(@Param("date") Date date, @Param("member") Long memberId); |
| | | |
| | | BigDecimal selectTotalAmountUnCostForDate(@Param("date") Date date, @Param("member") Long memberId, @Param("type") String type); |
| | | BigDecimal selectTotalAmountUnCostForDate(@Param("date") Date date, @Param("member") Long memberId, @Param("dateType") String dateType, @Param("isNormal") Integer isNormal); |
| | | |
| | | MallOrderInfo selectByOrderNo(@Param("orderNo") String orderNo); |
| | | |
| | | int updateOrderConfirmStatus(@Param("date") Date date); |
| | | |
| | | List<MallOrderInfo> selectOrderInfoWithNormalGoods(@Param("date") Date date); |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.quartz; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsSku; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsSkuMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderItemMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import cc.mrbird.febs.mall.service.IMemberProfitService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-06-15 |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | public class OrderSettlementJob { |
| | | |
| | | @Autowired |
| | | private MallOrderInfoMapper mallOrderInfoMapper; |
| | | |
| | | @Autowired |
| | | private IApiMallMemberWalletService memberWalletService; |
| | | |
| | | @Autowired |
| | | private IMallMoneyFlowService mallMoneyFlowService; |
| | | |
| | | @Autowired |
| | | private MallMemberMapper mallMemberMapper; |
| | | |
| | | @Autowired |
| | | private MallGoodsSkuMapper mallGoodsSkuMapper; |
| | | |
| | | @Autowired |
| | | private IMemberProfitService memberProfitService; |
| | | |
| | | /** |
| | | * 普通商品结算 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void normalGoodsSettlementJob() { |
| | | log.info("普通商品结算"); |
| | | List<MallOrderInfo> orderInfos = mallOrderInfoMapper.selectOrderInfoWithNormalGoods(DateUtil.offsetDay(new Date(), -10)); |
| | | if (CollUtil.isEmpty(orderInfos)) { |
| | | return; |
| | | } |
| | | |
| | | for (MallOrderInfo orderInfo : orderInfos) { |
| | | MallMember member = mallMemberMapper.selectById(orderInfo.getMemberId()); |
| | | if (AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())) { |
| | | continue; |
| | | } |
| | | |
| | | for (MallOrderItem item : orderInfo.getItems()) { |
| | | MallGoodsSku sku = mallGoodsSkuMapper.selectById(item.getSkuId()); |
| | | BigDecimal score = sku.getPresentPrice(); |
| | | |
| | | memberWalletService.add(score, member.getId(), "score"); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | |
| | | // 普通商品动态分红结算 |
| | | memberProfitService.dynamicProfit(orderInfo.getId(), 1); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 自动确认收货 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void orderAutoConfirmJob() { |
| | | log.info("自动确认收货"); |
| | | mallOrderInfoMapper.updateOrderConfirmStatus(DateUtil.offsetDay(new Date(), -7)); |
| | | } |
| | | } |
| | |
| | | memberProfitService.agentProfit(null); |
| | | } |
| | | |
| | | @Scheduled(cron = "0 30 1 * * ?") |
| | | public void storeAndDirectorJob() { |
| | | memberProfitService.storeAndDirectorProfit(null); |
| | | } |
| | | |
| | | /** |
| | | * 感恩奖 |
| | | */ |
| | |
| | | |
| | | FebsResponse openAccount(@NotNull(message = "{required}") Long id); |
| | | |
| | | void changeIdentity(Integer type, Long id, Integer value); |
| | | |
| | | MallMemberVo getMallMemberInfoById(@NotNull(message = "{required}") long id); |
| | | |
| | | IPage<AdminMallMoneyFlowVo> moneyFlow(QueryRequest request, MallMember mallMember); |
New file |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallAchieveRecord; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | public interface IMallAchieveService extends IService<MallAchieveRecord> { |
| | | |
| | | void add(Long orderItemId); |
| | | } |
| | |
| | | */ |
| | | void dynamicProfit(Long orderId); |
| | | |
| | | void dynamicProfit(Long orderId, Integer isNormal); |
| | | |
| | | /** |
| | | * 代理分红 |
| | | */ |
| | |
| | | * 感恩奖 |
| | | */ |
| | | void thankfulProfit(); |
| | | |
| | | /** |
| | | * 店补/董事 |
| | | */ |
| | | void storeAndDirectorProfit(Date profitDate); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void changeIdentity(Integer type, Long id, Integer value) { |
| | | MallMember mallMember = mallMemberMapper.selectById(id); |
| | | if(mallMember == null) { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | |
| | | if (type == 1) { |
| | | mallMember.setDirector(value); |
| | | } else if (type == 2){ |
| | | mallMember.setStoreMaster(value); |
| | | } else { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | |
| | | this.baseMapper.updateById(mallMember); |
| | | } |
| | | |
| | | @Override |
| | | public MallMemberVo getMallMemberInfoById(long id) { |
| | | MallMemberVo mallMemberVo = mallMemberMapper.getMallMemberInfoById(id); |
| | | return mallMemberVo; |
| | |
| | | } |
| | | |
| | | BigDecimal bigDecimal = mallSystemPayDto.getAddBalance(); |
| | | boolean isReduce = false; |
| | | if(bigDecimal.compareTo(BigDecimal.ZERO) <= 0){ |
| | | return new FebsResponse().fail().message("拨付数目需要大于0"); |
| | | isReduce = true; |
| | | } |
| | | |
| | | Integer type = mallSystemPayDto.getType(); |
| | |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | |
| | | if (isReduce) { |
| | | iApiMallMemberWalletService.reduce(mallSystemPayDto.getAddBalance().negate(), mallSystemPayDto.getId(), filedType); |
| | | } else { |
| | | iApiMallMemberWalletService.add(mallSystemPayDto.getAddBalance(), mallSystemPayDto.getId(), filedType); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow(memberId, bigDecimal, MoneyFlowTypeEnum.SYSTEM.getValue(), null, type); |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | if (mallGoods.getIsNormal() == 2) { |
| | | hasTc = true; |
| | | score = sku.getPresentPrice().multiply(mallGoods.getStaticMulti()); |
| | | |
| | | // 普通商品1:1 返还积分 |
| | | } else { |
| | | if (!AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())) { |
| | | score = sku.getPresentPrice(); |
| | | } |
| | | } |
| | | |
| | | if (score.compareTo(BigDecimal.ZERO) > 0) { |
| | | memberWalletService.add(score, member.getId(), "score"); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallAchieveRecord; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.MallAchieveRecordMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderItemMapper; |
| | | import cc.mrbird.febs.mall.service.IMallAchieveService; |
| | | 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; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-06-15 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MallAchieveServiceImpl extends ServiceImpl<MallAchieveRecordMapper, MallAchieveRecord> implements IMallAchieveService { |
| | | |
| | | private final MallOrderItemMapper mallOrderItemMapper; |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | |
| | | @Override |
| | | public void add(Long orderItemId) { |
| | | MallOrderItem item = mallOrderItemMapper.selectById(orderItemId); |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(item.getOrderId()); |
| | | |
| | | if (orderInfo.getOrderType() == 2) { |
| | | return; |
| | | } |
| | | |
| | | MallAchieveRecord achieve = new MallAchieveRecord(); |
| | | achieve.setMemberId(orderInfo.getMemberId()); |
| | | achieve.setAchieveTime(item.getCreatedTime()); |
| | | achieve.setAmount(item.getAmount()); |
| | | achieve.setCostAmount(item.getCostPrice().multiply(BigDecimal.valueOf(item.getCnt()))); |
| | | achieve.setOrderId(item.getOrderId()); |
| | | achieve.setOrderItemId(item.getId()); |
| | | achieve.setIsNormal(item.getIsNormal()); |
| | | achieve.setPayTime(orderInfo.getPayTime()); |
| | | this.baseMapper.insert(achieve); |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.IMallAchieveService; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import cc.mrbird.febs.mall.service.IMemberProfitService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | private final IMallMoneyFlowService moneyFlowService; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final IMallAchieveService mallAchieveService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | |
| | | Date profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | BigDecimal totalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D"); |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | |
| | | if (totalIncome.compareTo(BigDecimal.ZERO) == 0) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void dynamicProfit(Long orderId) { |
| | | dynamicProfit(orderId, 2); |
| | | } |
| | | |
| | | /** |
| | | * 直推20%,隔代收益为直推奖励金额的30%,a_b_c_d,d购买1000套餐,c得200,b得200*30%=60元,a得60*30%=18元。。。 |
| | | * 以此类推,结算到一元为止。 |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void dynamicProfit(Long orderId) { |
| | | public void dynamicProfit(Long orderId, Integer isNormal) { |
| | | log.info("######直推奖励, 订单ID:{}######", orderId); |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(orderId); |
| | | if (orderInfo.getOrderType() == 2) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | Integer isReturn = null; |
| | | if (item.getIsNormal() == 1) { |
| | | isReturn = 2; |
| | | // 判断套餐或者普通商品,结算对应商品的动态分红 |
| | | if (!Objects.equals(item.getIsNormal(), isNormal)) { |
| | | continue; |
| | | } |
| | | |
| | | // =======直推返利== start ===== |
| | |
| | | |
| | | walletService.add(dynamicProfit, parent.getId(), "commission"); |
| | | |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit, MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue(), isReturn); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit, MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), dynamicProfit.negate(), MoneyFlowTypeEnum.DYNAMIC_ACHIEVE.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | // =======直推返利== end ===== |
| | | |
| | |
| | | } |
| | | |
| | | walletService.add(direct, parentMember.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue(), isReturn); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(parentMember.getId(), direct.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | // =======隔代奖== end ===== |
| | | |
| | | item.setHasSettle(1); |
| | | mallOrderItemMapper.updateById(item); |
| | | |
| | | // 添加业绩 |
| | | mallAchieveService.add(item.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | if (profitDate == null) { |
| | | profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | } |
| | | BigDecimal totalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D"); |
| | | |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.AGENT_BONUS.getType(), DataDictionaryEnum.AGENT_BONUS.getCode()); |
| | | BigDecimal profit = totalIncome.divide(new BigDecimal(dic.getValue()), 2, RoundingMode.HALF_UP); |
| | |
| | | return; |
| | | } |
| | | |
| | | BigDecimal totalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M"); |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "M", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | |
| | | List<DataDictionaryCustom> rankAward = dataDictionaryCustomMapper.selectDicByType("RANK_AWARD"); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RANK_BONUS.getType(), DataDictionaryEnum.RANK_BONUS.getCode()); |
| | |
| | | } |
| | | |
| | | BigDecimal reduceProfit = income.multiply(prop); |
| | | if (reduceProfit.compareTo(BigDecimal.ZERO) > 0) { |
| | | if (reduceProfit.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | int reduce = walletService.reduce(reduceProfit.negate(), mallMember.getId(), "commission"); |
| | | int reduce = walletService.reduce(reduceProfit, mallMember.getId(), "commission"); |
| | | if (reduce == 2) { |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | int reduce1 = walletService.reduce(preProfit.negate(), child.getId(), "score"); |
| | | int reduce1 = walletService.reduce(preProfit, child.getId(), "score"); |
| | | if (reduce1 == 2) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | log.info("######==感恩奖==end==####"); |
| | | } |
| | | |
| | | @Override |
| | | public void storeAndDirectorProfit(Date profitDate) { |
| | | log.info("#####==店补/董事==start==######"); |
| | | if (profitDate == null) { |
| | | profitDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -1); |
| | | } |
| | | // 套餐业绩 |
| | | BigDecimal tcIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 2); |
| | | // 普通商品业绩 |
| | | BigDecimal normalIncome = mallOrderInfoMapper.selectTotalAmountUnCostForDate(profitDate, null, "D", 1); |
| | | BigDecimal totalIncome = tcIncome.add(normalIncome); |
| | | |
| | | // 董事 |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.DIRECTOR_BONUS.getType(), DataDictionaryEnum.DIRECTOR_BONUS.getCode()); |
| | | List<MallMember> directors = mallMemberMapper.selectDirectorsOrStoreMaster(1); |
| | | if (CollUtil.isNotEmpty(directors)) { |
| | | BigDecimal total = totalIncome.multiply(new BigDecimal(dic.getValue()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | | BigDecimal pre = total.divide(new BigDecimal(directors.size()), 2, RoundingMode.HALF_UP); |
| | | |
| | | for (MallMember director : directors) { |
| | | if (pre.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | int reduce = walletService.reduce(pre, director.getId(), "score"); |
| | | if (reduce == 2) { |
| | | continue; |
| | | } |
| | | |
| | | walletService.add(pre, director.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(director.getId(), pre, MoneyFlowTypeEnum.DIRECTOR_BONUS.getValue(), null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(director.getId(), pre.negate(), MoneyFlowTypeEnum.DIRECTOR_BONUS.getValue(), null, FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | } |
| | | |
| | | // 店补 |
| | | dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.COMMUNITY_BONUS.getType(), DataDictionaryEnum.COMMUNITY_BONUS.getCode()); |
| | | List<MallMember> storeMasters = mallMemberMapper.selectDirectorsOrStoreMaster(2); |
| | | if (CollUtil.isNotEmpty(storeMasters)) { |
| | | BigDecimal total = totalIncome.multiply(new BigDecimal(dic.getValue()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | | BigDecimal pre = total.divide(new BigDecimal(storeMasters.size()), 2, RoundingMode.HALF_UP); |
| | | |
| | | for (MallMember storeMaster : storeMasters) { |
| | | if (pre.compareTo(BigDecimal.ZERO) < 1) { |
| | | continue; |
| | | } |
| | | |
| | | int reduce = walletService.reduce(pre, storeMaster.getId(), "score"); |
| | | if (reduce == 2) { |
| | | continue; |
| | | } |
| | | |
| | | walletService.add(pre, storeMaster.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(storeMaster.getId(), pre, MoneyFlowTypeEnum.COMMUNITY_BONUS.getValue(), null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(storeMaster.getId(), pre.negate(), MoneyFlowTypeEnum.COMMUNITY_BONUS.getValue(), null, FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | } |
| | | |
| | | log.info("#####==店补/董事==end==######"); |
| | | } |
| | | } |
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.MallAchieveRecordMapper"> |
| | | |
| | | </mapper> |
| | |
| | | </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,max(order_time) orderTime from mall_member a, mall_order_info b--> |
| | | <!-- where a.id=b.member_id and b.status = 4--> |
| | | <!-- <!– 日 –>--> |
| | | <!-- <if test="record.query == '1'">--> |
| | | |
| | | <!-- </if>--> |
| | | <!-- select a.*, b.*--> |
| | | <!-- from mall_member a--> |
| | | <!-- inner join (--> |
| | | <!-- select b.referrer_id refererId, sum(a.amount) amount, max(a.order_time) orderTime--> |
| | | <!-- from mall_order_info a--> |
| | | <!-- inner join mall_member b on a.member_id=b.ID--> |
| | | <!-- inner join mall_order_item c on a.id = c.order_id and c.is_normal=2--> |
| | | <!-- where a.status in (2, 3, 4) and a.order_type=1--> |
| | | <!-- <!– 月 –>--> |
| | | <!-- <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.orderTime desc--> |
| | | <!-- group by b.referrer_id--> |
| | | <!-- ) b on a.invite_id=b.refererId--> |
| | | <!-- order by b.amount desc, b.orderTime desc--> |
| | | <!-- </select>--> |
| | | |
| | | <select id="selectRankListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember"> |
| | | select a.*, b.* |
| | | from mall_member a |
| | | inner join ( |
| | | select b.referrer_id refererId, sum(a.amount) amount, max(a.order_time) orderTime |
| | | from mall_order_info a |
| | | select b.referrer_id refererId, sum(a.amount) amount, max(a.pay_time) orderTime |
| | | from mall_achieve_record a |
| | | inner join mall_member b on a.member_id=b.ID |
| | | inner join mall_order_item c on a.id = c.order_id and c.is_normal=2 |
| | | where a.status in (2, 3, 4) and a.order_type=1 |
| | | where 1=1 |
| | | <!-- 月 --> |
| | | <if test="record.query == '2'"> |
| | | and date_format(#{record.createdTime},'%Y-%m') = date_format(b.order_time,'%Y-%m') |
| | | and date_format(#{record.createdTime},'%Y-%m') = date_format(a.achieve_time,'%Y-%m') |
| | | </if> |
| | | group by b.referrer_id |
| | | ) b on a.invite_id=b.refererId |
| | |
| | | |
| | | <select id="selectAchieveByMemberId" resultType="java.math.BigDecimal"> |
| | | select IFNULL(sum(IFNULL(a.amount, 0)), 0) |
| | | from mall_order_info a |
| | | from mall_achieve_record a |
| | | inner join mall_member b on a.member_id=b.ID |
| | | inner join mall_order_item c on a.id = c.order_id and c.is_normal=2 |
| | | where a.status in (2, 3, 4) and a.order_type=1 |
| | | where 1=1 |
| | | <if test="type == 1"> |
| | | and b.invite_id=#{inviteId} |
| | | </if> |
| | | <if test="type == 2"> |
| | | and b.referrer_id=#{inviteId} |
| | | and find_in_set(#{inviteId}, b.referrer_ids) |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | select * from mall_member |
| | | where referrer_id=#{inviteId} and level != 'ZERO_LEVEL' |
| | | </select> |
| | | |
| | | <select id="selectDirectorsOrStoreMaster" resultType="cc.mrbird.febs.mall.entity.MallMember"> |
| | | select * from mall_member |
| | | <where> |
| | | 1=1 |
| | | <if test="type == 1"> |
| | | and director = 1 |
| | | </if> |
| | | <if test="type == 2"> |
| | | and store_master = 1 |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | |
| | | and member_id=#{memberId} |
| | | </if> |
| | | <if test="date != null"> |
| | | and date_format(a.receving_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | and date_format(a.receiving_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | select IFNULL(sum(IFNULL(b.amount,0) - IFNULL(b.cost_price*b.cnt, 0)),0) |
| | | from mall_order_info a |
| | | inner join mall_order_item b on a.id=b.order_id |
| | | where a.status in (2, 3, 4) and a.is_normal = 2 and a.order_type=1 |
| | | where a.order_type=1 |
| | | <if test="isNormal == 2"> |
| | | and a.status in (2, 3, 4) and b.is_normal = 2 and b.has_settle=1 |
| | | </if> |
| | | <if test="isNormal == 1"> |
| | | and a.status=4 and b.is_normal = 1 and b.has_settle=1 |
| | | </if> |
| | | <if test="member != null"> |
| | | and member_id=#{memberId} |
| | | </if> |
| | | <if test="date != null and type == 'D'"> |
| | | and date_format(a.receving_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | <if test='date != null and dateType == "D"'> |
| | | and date_format(a.pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </if> |
| | | <if test="date != null and type == 'M'"> |
| | | and date_format(a.receving_time, '%Y-%m') = date_format(#{date}, '%Y-%m') |
| | | <if test='date != null and dateType == "M"'> |
| | | and date_format(a.pay_time, '%Y-%m') = date_format(#{date}, '%Y-%m') |
| | | </if> |
| | | <if test="date != null and type == 'Y'"> |
| | | and date_format(a.receving_time, '%Y') = date_format(#{date}, '%Y') |
| | | <if test='date != null and dateType == "Y"'> |
| | | and date_format(a.pay_time, '%Y') = date_format(#{date}, '%Y') |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectByOrderNo" resultType="cc.mrbird.febs.mall.entity.MallOrderInfo"> |
| | | select * from mall_order_info where order_no=#{orderNo} |
| | | </select> |
| | | |
| | | <update id="updateOrderConfirmStatus"> |
| | | update mall_order_info |
| | | set status=4, |
| | | receiving_time=new Date() |
| | | where status=3 and date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </update> |
| | | |
| | | <select id="selectOrderInfoWithNormalGoods" resultMap="OrderInfoMap"> |
| | | select * from mall_order_info a |
| | | inner join mall_order_item b on a.id=b.order_id and b.is_normal=1 |
| | | where date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </select> |
| | | </mapper> |
| | |
| | | <input type="checkbox" value={{d.id}} lay-text="正常|禁用" lay-skin="switch" lay-filter="switchStatus"> |
| | | {{# } }} |
| | | </script> |
| | | <script type="text/html" id="switchStoreMaster"> |
| | | {{# if(d.storeMaster === 1) { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchStoreMaster"> |
| | | {{# } else { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchStoreMaster"> |
| | | {{# } }} |
| | | </script> |
| | | <script type="text/html" id="switchDirector"> |
| | | {{# if(d.director === 1) { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchDirector"> |
| | | {{# } else { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchDirector"> |
| | | {{# } }} |
| | | </script> |
| | | <style> |
| | | .layui-form-onswitch { |
| | | background-color: #5FB878 !important; |
| | |
| | | }); |
| | | } |
| | | |
| | | function changeIdentityYes(type, id) { |
| | | febs.get(ctx + 'admin/mallMember/changeIdentityYes/' + type + "/" + id, null, function () { |
| | | febs.alert.success('设置成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | function changeIdentityNo(type, id) { |
| | | febs.get(ctx + 'admin/mallMember/changeIdentityNo/' + type + "/" + id, null, function () { |
| | | febs.alert.success('设置成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | |
| | | function resetPwd(id, type) { |
| | | febs.post(ctx + 'admin/mallMember/resetPwdNew/' + type + "/"+ id, null, function () { |
| | | febs.alert.success('重置成功'); |
| | |
| | | {field: 'inviteId', title: '邀请码', minWidth: 100,align:'left'}, |
| | | {field: 'referrerName', title: '推荐人', minWidth: 100,align:'left'}, |
| | | {field: 'levelName', title: '会员类型', minWidth: 100,align:'left'}, |
| | | {field: 'storeMaster', title: '店长', templet:'#switchStoreMaster', minWidth: 100}, |
| | | {field: 'director', title: '董事', templet:'#switchDirector', minWidth: 100}, |
| | | {field: 'accountType', title: '账号类型', |
| | | templet: function (d) { |
| | | if (d.accountType === 2) { |
| | |
| | | closeAccount(data.value); |
| | | } |
| | | }) |
| | | |
| | | form.on('switch(switchStoreMaster)', function (data) { |
| | | if (data.elem.checked) { |
| | | changeIdentityYes(2, data.value); |
| | | } else { |
| | | changeIdentityNo(2, data.value); |
| | | } |
| | | }) |
| | | |
| | | form.on('switch(switchDirector)', function (data) { |
| | | if (data.elem.checked) { |
| | | changeIdentityYes(1, data.value); |
| | | } else { |
| | | changeIdentityNo(1, data.value); |
| | | } |
| | | }) |
| | | }) |
| | | </script> |
| | |
| | | <label class="layui-form-label febs-form-item-require">拨付数目:</label> |
| | | <div class="layui-input-block"> |
| | | <input type="number" name="addBalance" lay-verify="required" autocomplete="off" class="layui-input"> |
| | | <div class="layui-word-aux">输入负数即减少数量</div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item febs-hide"> |
| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderItemMapper; |
| | | import cc.mrbird.febs.mall.service.IAgentService; |
| | | import cc.mrbird.febs.mall.service.IMallAchieveService; |
| | | import cc.mrbird.febs.mall.service.IMemberProfitService; |
| | | import cc.mrbird.febs.rabbit.consumer.AgentConsumer; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | public void thankfulProfit() { |
| | | memberProfitService.thankfulProfit(); |
| | | } |
| | | |
| | | @Autowired |
| | | private MallOrderInfoMapper mallOrderInfoMapper; |
| | | |
| | | @Test |
| | | public void directorProfitTest() { |
| | | memberProfitService.storeAndDirectorProfit(new Date()); |
| | | } |
| | | |
| | | @Autowired |
| | | private MallOrderItemMapper mallOrderItemMapper; |
| | | |
| | | @Autowired |
| | | private IMallAchieveService mallAchieveService; |
| | | |
| | | @Test |
| | | public void achieveTest() { |
| | | List<MallOrderItem> items = mallOrderItemMapper.selectList(null); |
| | | for (MallOrderItem item : items) { |
| | | mallAchieveService.add(item.getId()); |
| | | } |
| | | } |
| | | } |