Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
16f357f78e
|
|
@ -5,7 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaCheckMainShop;
|
||||
import com.czg.market.dto.MkDistributionConfigDTO;
|
||||
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
|
||||
import com.czg.market.entity.MkDistributionWithdrawFlow;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.*;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
|
|
@ -115,15 +115,15 @@ public class DistributionController {
|
|||
|
||||
/**
|
||||
* 用户提现列表
|
||||
* @param shopUserId 用户id
|
||||
* @param userId 用户id
|
||||
* @param key 搜索
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
@GetMapping("/withdrawFlow")
|
||||
public CzgResult<Page<MkDistributionWithdrawFlowDTO>> withdrawPageInfo(@RequestParam(required = false) Long shopUserId, @RequestParam(required = false) String key,
|
||||
@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
|
||||
return CzgResult.success(withdrawFlowService.withdrawPageInfo(StpKit.USER.getShopId(), shopUserId, StrUtil.isBlank(startTime) ? null : DateUtil.parseLocalDateTime(startTime),
|
||||
public CzgResult<Page<MkDistributionWithdrawFlow>> withdrawPageInfo(@RequestParam(required = false) Long userId, @RequestParam(required = false) String key,
|
||||
@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
|
||||
return CzgResult.success(withdrawFlowService.withdrawPageInfo(StpKit.USER.getShopId(), userId, StrUtil.isBlank(startTime) ? null : DateUtil.parseLocalDateTime(startTime),
|
||||
StrUtil.isBlank(endTime) ? null : DateUtil.parseLocalDateTime(endTime), key));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,20 +136,18 @@ public class UDistributionController {
|
|||
/**
|
||||
* 提现详情
|
||||
*/
|
||||
@PostMapping("/withdraw/detail")
|
||||
public CzgResult<Map<String, Object>> withdraw(@RequestParam Long id, @RequestParam Long shopId) {
|
||||
return CzgResult.success(distributionUserService.withdrawDetail(StpKit.USER.getLoginIdAsLong(), shopId, id));
|
||||
@GetMapping("/withdraw/detail")
|
||||
public CzgResult<Map<String, Object>> withdraw(@RequestParam Long id) {
|
||||
return CzgResult.success(distributionUserService.withdrawDetail(StpKit.USER.getLoginIdAsLong(), id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提现记录
|
||||
* @param shopId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/withdraw/flow")
|
||||
public CzgResult<Page<MkDistributionWithdrawFlow>> withArdwFlow(@RequestParam Long shopId) {
|
||||
return CzgResult.success(withdrawFlowService.pageInfo(StpKit.USER.getLoginIdAsLong(), shopId));
|
||||
public CzgResult<Page<MkDistributionWithdrawFlow>> withArdwFlow() {
|
||||
return CzgResult.success(withdrawFlowService.pageInfo(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
|
|
@ -110,4 +111,6 @@ public class UserInfo implements Serializable {
|
|||
private String realName;
|
||||
private String idCard;
|
||||
|
||||
private BigDecimal distributionAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.czg.account.dto.user.userinfo.UserInfoPwdEditDTO;
|
|||
import com.czg.account.entity.UserInfo;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
|
|
@ -22,4 +24,7 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
Boolean updatePwd(long userId, UserInfoPwdEditDTO userInfoPwdEditDTO);
|
||||
|
||||
Boolean getCode(Long userId, String type);
|
||||
|
||||
void updateDistributionAmount(long userId, BigDecimal amount);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class MkDistributionWithdrawFlowDTO implements Serializable {
|
||||
@NotNull
|
||||
private Long shopId;
|
||||
@NotNull(message = "提现金额不为空")
|
||||
@DecimalMin(value = "30", message = "提现金额不能小于30")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,11 @@ public class MkDistributionWithdrawFlow implements Serializable {
|
|||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 店铺用户id
|
||||
*/
|
||||
private Long shopUserId;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 提现金额
|
||||
|
|
@ -83,4 +79,10 @@ public class MkDistributionWithdrawFlow implements Serializable {
|
|||
*/
|
||||
private String status;
|
||||
|
||||
|
||||
@Column(ignore = true)
|
||||
private String nickName;
|
||||
@Column(ignore = true)
|
||||
private String phone;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,10 +111,10 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
*/
|
||||
void distribute(Long sourceId, String orderNo, BigDecimal amount, Long userId, Long shopId, String type);
|
||||
|
||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id);
|
||||
void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId);
|
||||
|
||||
|
||||
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
|
||||
|
||||
Map<String, Object> withdrawDetail(long userId, Long shopId, Long id);
|
||||
Map<String, Object> withdrawDetail(long userId, Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkDistributionWithdrawFlow;
|
||||
|
|
@ -15,7 +14,7 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
public interface MkDistributionWithdrawFlowService extends IService<MkDistributionWithdrawFlow> {
|
||||
|
||||
Page<MkDistributionWithdrawFlow> pageInfo(long userId, Long shopId);
|
||||
Page<MkDistributionWithdrawFlow> pageInfo(long userId);
|
||||
|
||||
Page<MkDistributionWithdrawFlowDTO> withdrawPageInfo(Long shopId, Long shopUserId, LocalDateTime startTime, LocalDateTime endTime, String key);
|
||||
Page<MkDistributionWithdrawFlow> withdrawPageInfo(Long shopId, Long userId, LocalDateTime startTime, LocalDateTime endTime, String key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.czg.service.account.mapper;
|
|||
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
|
|
@ -11,4 +14,5 @@ import com.mybatisflex.core.BaseMapper;
|
|||
*/
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
boolean updateAmount(long userId, BigDecimal amount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,4 +4,8 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.UserInfoMapper">
|
||||
|
||||
<update id="updateAmount">
|
||||
update tb_user_info set distribution_amount = distribution_amount + #{amount} where id = #{id}
|
||||
and distribution_amount + #{amount} >= 0
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue