package cc.mrbird.febs.mall.service.impl;
|
|
import cc.mrbird.febs.common.entity.FebsResponse;
|
import cc.mrbird.febs.common.entity.QueryRequest;
|
import cc.mrbird.febs.common.enumerates.RunVipMoneyFlowTypeEnum;
|
import cc.mrbird.febs.common.enumerates.YesOrNoEnum;
|
import cc.mrbird.febs.common.exception.FebsException;
|
import cc.mrbird.febs.mall.entity.*;
|
import cc.mrbird.febs.mall.mapper.*;
|
import cc.mrbird.febs.mall.service.IAdminRunVipService;
|
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
|
import cc.mrbird.febs.rabbit.producter.AgentProducer;
|
import cn.hutool.core.util.ObjectUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Slf4j
|
@Service
|
@RequiredArgsConstructor
|
@Transactional
|
public class AdminRunVipServiceImpl extends ServiceImpl<RunVipMapper, RunVip> implements IAdminRunVipService {
|
|
private final MallChargeMapper mallChargeMapper;
|
private final MallMemberWithdrawMapper mallMemberWithdrawMapper;
|
private final MallMoneyFlowMapper mallMoneyFlowMapper;
|
private final AgentProducer agentProducer;
|
private final IApiMallMemberWalletService walletService;
|
private final RunNodeSetMapper runNodeSetMapper;
|
@Override
|
public IPage<RunVip> runVipListInPage(RunVip runVip,QueryRequest request) {
|
Page<RunVip> page = new Page<>(request.getPageNum(), request.getPageSize());
|
return this.baseMapper.selectRunVipListInPage(page);
|
}
|
|
@Override
|
public IPage<RunNodeSet> nodeListInPage(RunNodeSet runNodeSet, QueryRequest request) {
|
Page<RunNodeSet> page = new Page<>(request.getPageNum(), request.getPageSize());
|
return runNodeSetMapper.selectPage(
|
page,
|
new LambdaQueryWrapper<RunNodeSet>()
|
.orderByAsc(RunNodeSet::getOrderNumber)
|
);
|
}
|
|
@Override
|
public void addVip(RunVip config) {
|
this.baseMapper.insert(config);
|
}
|
|
@Override
|
public void editVip(RunVip config) {
|
this.baseMapper.updateById(config);
|
}
|
|
@Override
|
public IPage<MallCharge> buyList(MallCharge mallCharge, QueryRequest request) {
|
Page<MallCharge> page = new Page<>(request.getPageNum(), request.getPageSize());
|
IPage<MallCharge> adminChargeListVoIPage = mallChargeMapper.selectAdminChargeListInPage(page, mallCharge);
|
return adminChargeListVoIPage;
|
}
|
|
@Override
|
public FebsResponse chargeAgree(Integer state, Long id) {
|
MallCharge mallCharge = mallChargeMapper.selectById(id);
|
|
if(ObjectUtil.isEmpty(mallCharge)){
|
throw new FebsException("记录不存在");
|
}
|
if(YesOrNoEnum.ING.getValue() != mallCharge.getState()){
|
throw new FebsException("记录不是进行中状态");
|
}
|
if(YesOrNoEnum.YES.getValue() == state){
|
mallCharge.setState(YesOrNoEnum.YES.getValue());
|
}
|
if(YesOrNoEnum.NO.getValue() == state){
|
mallCharge.setState(YesOrNoEnum.NO.getValue());
|
}
|
mallCharge.setRevision(mallCharge.getRevision()+1);
|
mallChargeMapper.updateById(mallCharge);
|
|
if(mallCharge.getState() == YesOrNoEnum.YES.getValue()){
|
agentProducer.sendBuyVipSuccessMsg(mallCharge.getId());
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public FebsResponse sellAgree(Integer state, Long id) {
|
MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(id);
|
if(ObjectUtil.isEmpty(mallMemberWithdraw)){
|
throw new FebsException("记录不存在");
|
}
|
if(YesOrNoEnum.ING.getValue() != mallMemberWithdraw.getStatus()){
|
throw new FebsException("记录不是进行中状态");
|
}
|
if(YesOrNoEnum.YES.getValue() == state){
|
mallMemberWithdraw.setStatus(YesOrNoEnum.YES.getValue());
|
}
|
if(YesOrNoEnum.NO.getValue() == state){
|
mallMemberWithdraw.setStatus(YesOrNoEnum.NO.getValue());
|
}
|
mallMemberWithdraw.setRevision(mallMemberWithdraw.getRevision()+1);
|
mallMemberWithdrawMapper.updateById(mallMemberWithdraw);
|
|
MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectOne(new LambdaQueryWrapper<MallMoneyFlow>().eq(MallMoneyFlow::getOrderNo, mallMemberWithdraw.getWithdrawNo()));
|
mallMoneyFlow.setStatus(mallMemberWithdraw.getStatus());
|
mallMoneyFlowMapper.updateById(mallMoneyFlow);
|
if(mallMemberWithdraw.getStatus() == YesOrNoEnum.NO.getValue()){
|
walletService.addCommission(mallMemberWithdraw.getWithdrawTimes(), mallMemberWithdraw.getMemberId());
|
}
|
return new FebsResponse().success().message("操作成功");
|
}
|
|
@Override
|
public IPage<MallMemberWithdraw> sellList(MallMemberWithdraw mallMemberWithdraw, QueryRequest request) {
|
Page<MallMemberWithdraw> page = new Page<>(request.getPageNum(), request.getPageSize());
|
IPage<MallMemberWithdraw> adminChargeListVoIPage = mallChargeMapper.selectAdminWithdrawListInPage(page, mallMemberWithdraw);
|
return adminChargeListVoIPage;
|
}
|
|
@Override
|
public List<MallMoneyFlow> allMoneyType() {
|
List<MallMoneyFlow> mallMoneyFlows = new ArrayList<>();
|
RunVipMoneyFlowTypeEnum[] values = RunVipMoneyFlowTypeEnum.values();
|
for (RunVipMoneyFlowTypeEnum value : values) {
|
MallMoneyFlow mallMoneyFlow = new MallMoneyFlow();
|
mallMoneyFlow.setType(value.getValue());
|
mallMoneyFlow.setDescription(value.getDescription());
|
mallMoneyFlow.setRemark(value.getTypeDec());
|
mallMoneyFlows.add(mallMoneyFlow);
|
}
|
|
return mallMoneyFlows;
|
}
|
|
@Override
|
public void addRunNodeSet(RunNodeSet config) {
|
runNodeSetMapper.insert(config);
|
}
|
|
@Override
|
public void editRunNodeSet(RunNodeSet config) {
|
runNodeSetMapper.updateById(config);
|
}
|
|
@Override
|
public void deleteNodeById(Long id) {
|
runNodeSetMapper.deleteById(id);
|
}
|
}
|