| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | 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.AppVersion; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMoneyFlow; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IAdminMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | 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; |
| | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Transactional |
| | | public class AdminMallMemberServiceImpl extends ServiceImpl<MallMemberMapper, MallMember> implements IAdminMallMemberService { |
| | | |
| | | private final MallMemberMapper mallMemberMapper; |
| | | |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | |
| | |
| | | private final IApiMallMemberWalletService iApiMallMemberWalletService; |
| | | |
| | | private final AppVersionMapper appVersionMapper; |
| | | |
| | | private final MallNewsInfoMapper mallNewsInfoMapper; |
| | | private final MallShopApplyMapper mallShopApplyMapper; |
| | | |
| | | @Override |
| | | public IPage<MallMember> getMallMemberList(MallMember mallMember, QueryRequest request) { |
| | |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse activateAccount(Long id) { |
| | | MallMember mallMember = mallMemberMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(mallMember)){ |
| | | return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); |
| | | } |
| | | String level = mallMember.getLevel(); |
| | | if(StrUtil.isEmpty(level) || !AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())){ |
| | | return new FebsResponse().fail().message("该用户无法激活"); |
| | | } |
| | | mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name()); |
| | | mallMemberMapper.updateById(mallMember); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse updateSystemPay(MallSystemPayDto mallSystemPayDto) { |
| | | Long memberId = mallSystemPayDto.getId(); |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(mallMember)){ |
| | | return new FebsResponse().fail().message("系统繁忙,请刷新页面重试"); |
| | | } |
| | | |
| | | BigDecimal bigDecimal = mallSystemPayDto.getAddBalance(); |
| | | if(bigDecimal.compareTo(BigDecimal.ZERO) <= 0){ |
| | | return new FebsResponse().fail().message("拨付数目需要大于0"); |
| | | } |
| | | |
| | | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | mallMemberWallet.setBalance(mallMemberWallet.getBalance().add(bigDecimal)); |
| | | mallMemberWalletMapper.updateBalanceWithId(mallMemberWallet); |
| | | |
| | | MallMoneyFlow flow = new MallMoneyFlow(); |
| | | flow.setMemberId(memberId); |
| | | flow.setAmount(bigDecimal); |
| | | // flow.setType(MoneyFlowTypeEnum.SYSTEM_PAY.getValue()); |
| | | 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); |
| | | } |
| | | } |