use of cn.lili.modules.distribution.entity.dos.Distribution in project lilishop by lilishop.
the class DistributionServiceImpl method audit.
@Override
public boolean audit(String id, String status) {
// 检查分销开关
checkDistributionSetting();
// 根据id获取分销员
Distribution distribution = this.getById(id);
if (Optional.ofNullable(distribution).isPresent()) {
if (status.equals(DistributionStatusEnum.PASS.name())) {
distribution.setDistributionStatus(DistributionStatusEnum.PASS.name());
} else {
distribution.setDistributionStatus(DistributionStatusEnum.REFUSE.name());
}
return this.updateById(distribution);
}
return false;
}
use of cn.lili.modules.distribution.entity.dos.Distribution in project lilishop by lilishop.
the class DistributionServiceImpl method resume.
@Override
public boolean resume(String id) {
// 检查分销开关
checkDistributionSetting();
// 根据id获取分销员
Distribution distribution = this.getById(id);
if (Optional.ofNullable(distribution).isPresent()) {
distribution.setDistributionStatus(DistributionStatusEnum.PASS.name());
return this.updateById(distribution);
}
return false;
}
use of cn.lili.modules.distribution.entity.dos.Distribution in project lilishop by lilishop.
the class DistributionServiceImpl method applyDistribution.
@Override
@Transactional(rollbackFor = Exception.class)
public Distribution applyDistribution(DistributionApplyDTO distributionApplyDTO) {
// 检查分销开关
checkDistributionSetting();
// 判断用户是否申请过分销
Distribution distribution = getDistribution();
// 如果分销员非空并未审核则提示用户请等待,如果分销员为拒绝状态则重新提交申请
if (Optional.ofNullable(distribution).isPresent()) {
if (distribution.getDistributionStatus().equals(DistributionStatusEnum.APPLY.name())) {
throw new ServiceException(ResultCode.DISTRIBUTION_IS_APPLY);
} else if (distribution.getDistributionStatus().equals(DistributionStatusEnum.REFUSE.name())) {
distribution.setDistributionStatus(DistributionStatusEnum.APPLY.name());
BeanUtil.copyProperties(distributionApplyDTO, distribution);
this.updateById(distribution);
return distribution;
}
}
// 如果未申请分销员则新增进行申请
// 获取当前登录用户
Member member = memberService.getUserInfo();
// 新建分销员
distribution = new Distribution(member.getId(), member.getNickName(), distributionApplyDTO);
// 添加分销员
this.save(distribution);
return distribution;
}
use of cn.lili.modules.distribution.entity.dos.Distribution in project lilishop by lilishop.
the class DistributionServiceImpl method bindingDistribution.
@Override
public void bindingDistribution(String distributionId) {
// 判断用户是否登录,未登录不能进行绑定
if (UserContext.getCurrentUser() == null) {
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
}
// 储存分销关系时间
Distribution distribution = this.getById(distributionId);
if (distribution != null) {
Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
cache.put(CachePrefix.DISTRIBUTION.getPrefix() + "_" + UserContext.getCurrentUser().getId(), distribution.getId(), distributionSetting.getDistributionDay().longValue(), TimeUnit.DAYS);
}
}
use of cn.lili.modules.distribution.entity.dos.Distribution in project lilishop by lilishop.
the class DistributionCashServiceImpl method audit.
@Override
@Transactional(rollbackFor = Exception.class)
public DistributionCash audit(String id, String result) {
// 检查分销功能开关
distributionService.checkDistributionSetting();
// 获取分销佣金信息
DistributionCash distributorCash = this.getById(id);
// 只有分销员和分销佣金记录存在的情况才可以审核
if (distributorCash != null) {
// 获取分销员
Distribution distribution = distributionService.getById(distributorCash.getDistributionId());
if (distribution != null && distribution.getDistributionStatus().equals(DistributionStatusEnum.PASS.name())) {
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
// 审核通过
if (result.equals(WithdrawStatusEnum.VIA_AUDITING.name())) {
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
// 分销记录操作
distributorCash.setDistributionCashStatus(WithdrawStatusEnum.VIA_AUDITING.name());
distributorCash.setPayTime(new Date());
// 提现到余额
memberWalletService.increase(new MemberWalletUpdateDTO(distributorCash.getPrice(), distribution.getMemberId(), "分销[" + distributorCash.getSn() + "]佣金提现到余额[" + distributorCash.getPrice() + "]", DepositServiceTypeEnum.WALLET_COMMISSION.name()));
} else {
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
// 分销员可提现金额退回
distribution.setCanRebate(CurrencyUtil.add(distribution.getCanRebate(), distributorCash.getPrice()));
distributorCash.setDistributionCashStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
}
// 分销员金额相关处理
distributionService.updateById(distribution);
// 修改分销提现申请
boolean bool = this.updateById(distributorCash);
if (bool) {
// 组织会员提现审核消息
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
}
return distributorCash;
}
throw new ServiceException(ResultCode.DISTRIBUTION_NOT_EXIST);
}
throw new ServiceException(ResultCode.DISTRIBUTION_CASH_NOT_EXIST);
}
Aggregations