Helius
2022-05-19 7e6bbd05a75b07cb0717812d0b51aad128361012
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
@@ -4,6 +4,8 @@
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.AgentLevelEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.entity.MallNewsInfo;
@@ -14,6 +16,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -52,6 +55,7 @@
    private final AppVersionMapper appVersionMapper;
    private final MallNewsInfoMapper mallNewsInfoMapper;
    private final MallShopApplyMapper mallShopApplyMapper;
    @Override
    public IPage<MallMember> getMallMemberList(MallMember mallMember, QueryRequest request) {
@@ -315,73 +319,7 @@
    }
    @Override
    public MallNewsInfo getNewsInfoById(long id) {
        return mallNewsInfoMapper.selectById(id);
    }
    @Override
    public IPage<AdminMallNewsInfoVo> getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request) {
        Page<AdminMallNewsInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminMallNewsInfoVo> adminMallNewsInfoVos = mallNewsInfoMapper.getNewInfoListInPage(page, mallNewsInfo);
        return adminMallNewsInfoVos;
    }
    @Override
    public FebsResponse addNewsInfo(MallNewsInfoDto mallNewsInfoDto) {
        Integer type = mallNewsInfoDto.getType();
        if(type == 2){
            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
            if(goodsId == 0L){
                return new FebsResponse().fail().message("请选择跳转的产品");
            }
        }
        MallNewsInfo mallNewsInfo = new MallNewsInfo();
        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
        mallNewsInfo.setType(mallNewsInfoDto.getType());
        if(mallNewsInfoDto.getType() == 2){
            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
        }
        mallNewsInfoMapper.insert(mallNewsInfo);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse delNewsInfo(Long id) {
        MallNewsInfo mallNewsInfo = mallNewsInfoMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallNewsInfo)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        mallNewsInfoMapper.deleteById(id);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse updateNewsInfo(MallNewsInfoDto mallNewsInfoDto) {
        MallNewsInfo mallNewsInfoBefore = mallNewsInfoMapper.selectById(mallNewsInfoDto.getId());
        if(ObjectUtil.isEmpty(mallNewsInfoBefore)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        Integer type = mallNewsInfoDto.getType();
        if(type == 2){
            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
            if(goodsId == 0L){
                return new FebsResponse().fail().message("请选择跳转的产品");
            }
        }
        MallNewsInfo mallNewsInfo = new MallNewsInfo();
        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
        mallNewsInfo.setType(mallNewsInfoDto.getType());
        if(mallNewsInfoDto.getType() == 2){
            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
        }
        mallNewsInfoMapper.insert(mallNewsInfo);
        mallNewsInfoMapper.deleteById(mallNewsInfoDto.getId());
        return new FebsResponse().success();
    }
    @Override
    @Transactional
    public FebsResponse updateSystemPay(MallSystemPayDto mallSystemPayDto) {
        Long memberId = mallSystemPayDto.getId();
        MallMember mallMember = mallMemberMapper.selectById(memberId);
@@ -398,17 +336,85 @@
        mallMemberWallet.setBalance(mallMemberWallet.getBalance().add(bigDecimal));
        mallMemberWalletMapper.updateBalanceWithId(mallMemberWallet);
//        MallMoneyFlow flow = new MallMoneyFlow();
//        flow.setMemberId(memberId);
//        flow.setAmount(bigDecimal);
        MallMoneyFlow flow = new MallMoneyFlow();
        flow.setMemberId(memberId);
        flow.setAmount(bigDecimal);
//        flow.setType(MoneyFlowTypeEnum.SYSTEM_PAY.getValue());
//        flow.setOrderNo(orderNo);
//        flow.setDescription(description);
//        flow.setRemark(remark);
//        flow.setRtMemberId(rtMemberId);
//        flow.setStatus(status);
//        mallMoneyFlowMapper.insert(flow);
        return null;
        flow.setOrderNo("SYS"+MallUtils.getOrderNum());
        flow.setStatus(2);
        mallMoneyFlowMapper.insert(flow);
        return new FebsResponse().success();
    }
    @Override
    public AdminAgentLevelSetInfoVo getAgentLevelSetInfoByMemberId(long id) {
        AdminAgentLevelSetInfoVo adminAgentLevelSetInfoVo = mallMemberMapper.getAgentLevelSetInfoByMemberId(id);
        return adminAgentLevelSetInfoVo;
    }
    @Override
    public FebsResponse agentLevelSetUpdate(AgentLevelSetUpdateDto agentLevelSetUpdateDto) {
        Long memberId = agentLevelSetUpdateDto.getId();
        MallMember mallMember = mallMemberMapper.selectById(memberId);
        if(ObjectUtil.isEmpty(mallMember)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        mallMember.setLevel(agentLevelSetUpdateDto.getLevelCode());
        mallMemberMapper.updateById(mallMember);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse resetPwd(Long id) {
        MallMember mallMember = this.baseMapper.selectById(id);
        if (mallMember == null) {
            throw new FebsException("用户不存在");
        }
        String pwd = SecureUtil.md5("a123456");
        mallMember.setPassword(pwd);
        this.baseMapper.updateById(mallMember);
        return new FebsResponse().success().message("重置成功");
    }
    @Override
    public IPage<MallDataVo> getMallDataList(MallMember mallMember, QueryRequest request) {
        Page<MallDataVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MallDataVo> mallDataVos = this.baseMapper.getMallDataListInPage(page, mallMember);
        return mallDataVos;
    }
    @Override
    public IPage<MallShopApply> findShopApplyListInPage(MallShopApply mallShopApply, QueryRequest request) {
        Page<MallShopApply> page = new Page<>(request.getPageNum(), request.getPageSize());
        return mallShopApplyMapper.selectShopApplyInPage(mallShopApply, page);
    }
    @Override
    public MallShopApply findShopApplyById(Long id) {
        return mallShopApplyMapper.selectById(id);
    }
    @Override
    public void applyCheckAgree(Long id) {
        MallShopApply apply = mallShopApplyMapper.selectById(id);
        if (!MallShopApply.APPLY_ING.equals(apply.getStatus())) {
            throw new FebsException("申请已审核, 请勿重复操作");
        }
        apply.setStatus(MallShopApply.APPLY_AGREE);
        mallShopApplyMapper.updateById(apply);
    }
    @Override
    public void applyCheckDisAgree(Long id) {
        MallShopApply apply = mallShopApplyMapper.selectById(id);
        if (!MallShopApply.APPLY_ING.equals(apply.getStatus())) {
            throw new FebsException("申请已审核, 请勿重复操作");
        }
        apply.setStatus(MallShopApply.APPLY_DISAGREE);
        mallShopApplyMapper.updateById(apply);
    }
}