分销修改

This commit is contained in:
张松
2025-10-28 13:42:24 +08:00
parent f83945f8f5
commit 4b8fc8a15c
8 changed files with 60 additions and 27 deletions

View File

@@ -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));
}

View File

@@ -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()));
}
}

View File

@@ -29,4 +29,6 @@ public class MkDistributionWithdrawFlowDTO implements Serializable {
@NotNull(message = "提现金额不为空")
@DecimalMin(value = "30", message = "提现金额不能小于30")
private BigDecimal amount;
}

View File

@@ -44,7 +44,7 @@ public class MkDistributionWithdrawFlow implements Serializable {
/**
* 店铺用户id
*/
private Long shopUserId;
private Long userId;
/**
* 提现金额
@@ -83,4 +83,10 @@ public class MkDistributionWithdrawFlow implements Serializable {
*/
private String status;
@Column(ignore = true)
private String nickName;
@Column(ignore = true)
private String phone;
}

View File

@@ -116,5 +116,5 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO);
Map<String, Object> withdrawDetail(long userId, Long shopId, Long id);
Map<String, Object> withdrawDetail(long userId, Long id);
}

View File

@@ -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);
}

View File

@@ -430,7 +430,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;
}
@@ -523,7 +523,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
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().setShopId(withdrawFlowDTO.getShopId()).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"));
@@ -531,9 +531,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
@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()), "已经提现");

View File

@@ -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);
}
}