Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -436,7 +436,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
// 上上级分销员
|
||||
if (distributionUser.getParentId() != null) {
|
||||
MkDistributionUser parent = getOne(new QueryWrapper().eq(MkDistributionUser::getId, distributionUser.getParentId()));
|
||||
|
||||
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
@@ -483,8 +483,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
.setRewardAmount(rewardAmount).setBillNo(IdUtil.simpleUUID());
|
||||
distributionFlowService.save(mkDistributionFlow);
|
||||
|
||||
ShopUser shopUser = shopUserService.getById(distributionUser.getId());
|
||||
updateIncome(!flag ? rewardAmount : BigDecimal.ZERO,
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId());
|
||||
flag ? rewardAmount : BigDecimal.ZERO, BigDecimal.ZERO, distributionUser.getId(), shopUser.getUserId());
|
||||
|
||||
if (flag) {
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
@@ -513,33 +514,33 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id) {
|
||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId) {
|
||||
userInfoService.updateDistributionAmount(userId, receivedIncome);
|
||||
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(withdrawFlowDTO.getShopId(), userId);
|
||||
UserInfo userInfo = userInfoService.getById(shopUserInfo.getUserId());
|
||||
MkDistributionUser distributionUser = getOne(new QueryWrapper().eq(MkDistributionUser::getId, shopUserInfo.getId()));
|
||||
AssertUtil.isNull(distributionUser, "分销员不存在");
|
||||
if (distributionUser.getReceivedIncome().subtract(withdrawFlowDTO.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
if (userInfo.getDistributionAmount().subtract(withdrawFlowDTO.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new CzgException("可提现金额不足");
|
||||
}
|
||||
|
||||
BigDecimal fee = withdrawFlowDTO.getAmount().multiply(BigDecimal.valueOf(0.08));
|
||||
BigDecimal finalAmount = withdrawFlowDTO.getAmount().subtract(fee);
|
||||
|
||||
MkDistributionWithdrawFlow withdrawFlow = new MkDistributionWithdrawFlow().setShopId(withdrawFlowDTO.getShopId()).setShopUserId(shopUserInfo.getId())
|
||||
MkDistributionWithdrawFlow withdrawFlow = new MkDistributionWithdrawFlow().setUserId(userId)
|
||||
.setAmount(finalAmount).setServiceFee(fee).setBillNo(IdUtil.simpleUUID()).setStatus(TableValueConstant.DistributionWithdrawFlow.Status.PENDING.getCode());
|
||||
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
|
||||
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
|
||||
// 扣减余额
|
||||
userInfoService.updateDistributionAmount(userId, withdrawFlow.getAmount().negate());
|
||||
return withdrawFlowService.save(withdrawFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> withdrawDetail(long userId, Long shopId, Long id) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(shopId, userId);
|
||||
MkDistributionWithdrawFlow flow = withdrawFlowService.getOne(new QueryWrapper().eq(MkDistributionWithdrawFlow::getId, id).eq(MkDistributionWithdrawFlow::getShopUserId, shopUserInfo.getId()));
|
||||
public Map<String, Object> withdrawDetail(long userId, Long id) {
|
||||
MkDistributionWithdrawFlow flow = withdrawFlowService.getOne(new QueryWrapper().eq(MkDistributionWithdrawFlow::getId, id).eq(MkDistributionWithdrawFlow::getUserId, userId));
|
||||
AssertUtil.isNull(flow, "提现记录不存在");
|
||||
AssertUtil.isTrue(TableValueConstant.DistributionWithdrawFlow.Status.FINISH.getCode().equals(flow.getStatus()), "已经提现");
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
|
||||
import com.czg.utils.MyQueryWrapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -10,10 +12,11 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MkDistributionWithdrawFlow;
|
||||
import com.czg.market.service.MkDistributionWithdrawFlowService;
|
||||
import com.czg.service.market.mapper.MkDistributionWithdrawFlowMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 提现记录表 服务层实现。
|
||||
*
|
||||
@@ -26,8 +29,34 @@ public class MkDistributionWithdrawFlowServiceImpl extends ServiceImpl<MkDistrib
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@Override
|
||||
public Page<MkDistributionWithdrawFlow> pageInfo(long userId, Long shopId) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(shopId, userId);
|
||||
return page(PageUtil.buildPage(), new QueryWrapper().eq(MkDistributionWithdrawFlow::getShopUserId, shopUserInfo.getId()));
|
||||
public Page<MkDistributionWithdrawFlow> pageInfo(long userId) {
|
||||
return page(PageUtil.buildPage(), new QueryWrapper().eq(MkDistributionWithdrawFlow::getUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MkDistributionWithdrawFlow> withdrawPageInfo(Long shopId, Long userId, LocalDateTime startTime, LocalDateTime endTime, String key) {
|
||||
QueryWrapper queryWrapper = new MyQueryWrapper()
|
||||
.selectAll(MkDistributionWithdrawFlow.class)
|
||||
.leftJoin(UserInfo.class).on(UserInfo::getId, MkDistributionWithdrawFlow::getUserId)
|
||||
.select(UserInfo::getNickName, UserInfo::getPhone)
|
||||
.eq(MkDistributionWithdrawFlow::getShopId, shopId).eq(MkDistributionWithdrawFlow::getUserId, userId)
|
||||
.ge(MkDistributionWithdrawFlow::getCreateTime, startTime)
|
||||
.le(MkDistributionWithdrawFlow::getCreateTime, endTime);
|
||||
if (StrUtil.isNotBlank(key)){
|
||||
queryWrapper.and(and -> {
|
||||
and.or(or -> {
|
||||
or.like(ShopUser::getId, key);
|
||||
});
|
||||
|
||||
and.or(or -> {
|
||||
or.like(ShopUser::getNickName, key);
|
||||
});
|
||||
|
||||
and.or(or -> {
|
||||
or.like(ShopUser::getPhone, key);
|
||||
});
|
||||
});
|
||||
}
|
||||
return page(PageUtil.buildPage(), queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user