添加分润进账接口
This commit is contained in:
@ -8,7 +8,8 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum WalletChangeTypeEnum {
|
||||
REFERRAL("REFERRAL", "引荐"),
|
||||
WITHDRAWAL("WITHDRAWAL", "提现");
|
||||
WITHDRAWAL("WITHDRAWAL", "提现"),
|
||||
DISTRIB("DISTRIB", "分润收入");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@ -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<Boolean> distibIncome(@RequestBody DistibIncomeReq distibIncomeReq) {
|
||||
walletService.distibIncome(distibIncomeReq);
|
||||
return Result.ok(true);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取钱包变更信息列表", notes = "获取钱包变更信息列表")
|
||||
@PostMapping("/listWalletChange")
|
||||
public Result<List<BaseWalletChangeDTO>> listWalletChange(@RequestBody WalletChangeQueryReq baseWalletChangeQueryReq) {
|
||||
|
||||
18
src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java
Normal file
18
src/main/java/com/sczx/store/dto/req/DistibIncomeReq.java
Normal file
@ -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 ;
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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<BaseWalletChangeDTO> listWalletChange(WalletChangeQueryReq baseWalletChangeQueryReq) {
|
||||
LambdaQueryWrapper<BaseWalletChangePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user