From babe033c2274a9d4e03c1522717462161fbeb5da Mon Sep 17 00:00:00 2001 From: zhangli <123879394@qq.com> Date: Mon, 29 Sep 2025 00:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E6=B6=A6=E8=BF=9B?= =?UTF-8?q?=E8=B4=A6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/WalletChangeTypeEnum.java | 3 +- .../store/controller/WalletController.java | 8 ++++ .../sczx/store/dto/req/DistibIncomeReq.java | 18 +++++++++ .../sczx/store/service/IWalletService.java | 8 ++++ .../store/service/impl/WalletServiceImpl.java | 37 +++++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java diff --git a/src/main/java/com/sczx/store/common/enums/WalletChangeTypeEnum.java b/src/main/java/com/sczx/store/common/enums/WalletChangeTypeEnum.java index 8f23298..4ab28fe 100644 --- a/src/main/java/com/sczx/store/common/enums/WalletChangeTypeEnum.java +++ b/src/main/java/com/sczx/store/common/enums/WalletChangeTypeEnum.java @@ -8,7 +8,8 @@ import lombok.Getter; @Getter public enum WalletChangeTypeEnum { REFERRAL("REFERRAL", "引荐"), - WITHDRAWAL("WITHDRAWAL", "提现"); + WITHDRAWAL("WITHDRAWAL", "提现"), + DISTRIB("DISTRIB", "分润收入"); private final String code; diff --git a/src/main/java/com/sczx/store/controller/WalletController.java b/src/main/java/com/sczx/store/controller/WalletController.java index ed40a0f..79dfd55 100644 --- a/src/main/java/com/sczx/store/controller/WalletController.java +++ b/src/main/java/com/sczx/store/controller/WalletController.java @@ -6,6 +6,7 @@ import com.sczx.store.dto.BaseWalletChangeDTO; import com.sczx.store.dto.BaseWalletDTO; import com.sczx.store.dto.WalletChangeQueryReq; import com.sczx.store.dto.WithdrawalReq; +import com.sczx.store.dto.req.DistibIncomeReq; import com.sczx.store.service.IWalletService; import com.sczx.store.util.JwtUtil; import io.swagger.annotations.Api; @@ -40,6 +41,13 @@ public class WalletController { return Result.ok(walletService.getWalletInfo(userId)); } + @ApiOperation(value = "分润入账", notes = "分润入账") + @PostMapping("/distibIncome") + public Result distibIncome(@RequestBody DistibIncomeReq distibIncomeReq) { + walletService.distibIncome(distibIncomeReq); + return Result.ok(true); + } + @ApiOperation(value = "获取钱包变更信息列表", notes = "获取钱包变更信息列表") @PostMapping("/listWalletChange") public Result> listWalletChange(@RequestBody WalletChangeQueryReq baseWalletChangeQueryReq) { diff --git a/src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java b/src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java new file mode 100644 index 0000000..53a22bb --- /dev/null +++ b/src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java @@ -0,0 +1,18 @@ +package com.sczx.store.dto.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@ApiModel(value = "分润收入查询参数") +@Data +public class DistibIncomeReq { + + @ApiModelProperty("门店id") + private Long storeId; + + @ApiModelProperty("金额") + private BigDecimal amount ; +} diff --git a/src/main/java/com/sczx/store/service/IWalletService.java b/src/main/java/com/sczx/store/service/IWalletService.java index 639ac92..aa2aacf 100644 --- a/src/main/java/com/sczx/store/service/IWalletService.java +++ b/src/main/java/com/sczx/store/service/IWalletService.java @@ -5,6 +5,8 @@ import com.sczx.store.dto.BaseWalletChangeDTO; import com.sczx.store.dto.BaseWalletDTO; import com.sczx.store.dto.WalletChangeQueryReq; import com.sczx.store.dto.WithdrawalReq; +import com.sczx.store.dto.req.DistibIncomeReq; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -18,6 +20,12 @@ public interface IWalletService { */ BaseWalletDTO getWalletInfo(Long userId); + /** + * 佣金收入 + * @param distibIncomeReq + */ + void distibIncome(@RequestBody DistibIncomeReq distibIncomeReq); + /** * 根据条件获取钱包变更记录 * @param baseWalletChangeQueryReq diff --git a/src/main/java/com/sczx/store/service/impl/WalletServiceImpl.java b/src/main/java/com/sczx/store/service/impl/WalletServiceImpl.java index 1be5427..e01e476 100644 --- a/src/main/java/com/sczx/store/service/impl/WalletServiceImpl.java +++ b/src/main/java/com/sczx/store/service/impl/WalletServiceImpl.java @@ -9,11 +9,14 @@ import com.sczx.store.dto.BaseWalletChangeDTO; import com.sczx.store.dto.BaseWalletDTO; import com.sczx.store.dto.WalletChangeQueryReq; import com.sczx.store.dto.WithdrawalReq; +import com.sczx.store.dto.req.DistibIncomeReq; import com.sczx.store.exception.BizException; import com.sczx.store.po.BaseWalletChangePO; import com.sczx.store.po.BaseWalletPO; +import com.sczx.store.po.CompanyStorePO; import com.sczx.store.repository.BaseWalletChangeRepo; import com.sczx.store.repository.BaseWalletRepo; +import com.sczx.store.repository.CompanyStoreRepo; import com.sczx.store.service.IWalletService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -33,12 +36,46 @@ public class WalletServiceImpl implements IWalletService { @Autowired private BaseWalletChangeRepo baseWalletChangeRepo; + @Autowired + private CompanyStoreRepo companyStoreRepo; + @Override public BaseWalletDTO getWalletInfo(Long userId) { BaseWalletPO baseWalletPO = baseWalletRepo.getById(userId); return BaseWalletConvert.INSTANCE.po2Dto(baseWalletPO); } + @Override + public void distibIncome(DistibIncomeReq distibIncomeReq) { + CompanyStorePO companyStorePO = companyStoreRepo.getById(distibIncomeReq.getStoreId()); + if(Objects.isNull(companyStorePO)){ + throw new BizException("门店不存在"); + } + if(!StringUtils.equalsIgnoreCase(companyStorePO.getStatus(),"0")){ + throw new BizException("门店已下架"); + } + BaseWalletPO baseWalletPO = baseWalletRepo.getById(companyStorePO.getId()); + if(Objects.isNull(baseWalletPO)){ + baseWalletPO = new BaseWalletPO(); + baseWalletPO.setUserId(distibIncomeReq.getStoreId()); + baseWalletPO.setPhoneNumber(companyStorePO.getStoreNumber()); + baseWalletPO.setUserName(companyStorePO.getName()); + baseWalletPO.setWalletType(0); + baseWalletPO.setBalance(distibIncomeReq.getAmount()); + baseWalletRepo.save(baseWalletPO); + } else { + baseWalletPO.setBalance(baseWalletPO.getBalance().add(distibIncomeReq.getAmount())); + baseWalletRepo.updateById(baseWalletPO); + } + //添加钱包变动记录 + BaseWalletChangePO baseWalletChangePO = new BaseWalletChangePO(); + baseWalletChangePO.setUserId(baseWalletPO.getUserId()); + baseWalletChangePO.setChangeType(WalletChangeTypeEnum.DISTRIB.getCode()); + baseWalletChangePO.setChangeTime(LocalDateTime.now()); + baseWalletChangePO.setChangeAmount(distibIncomeReq.getAmount()); + baseWalletChangeRepo.save(baseWalletChangePO); + } + @Override public List listWalletChange(WalletChangeQueryReq baseWalletChangeQueryReq) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();