| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.mall.conversion.MallAgentRecordConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallGoodsConversion; |
| | | import cc.mrbird.febs.mall.dto.ApiAgentApplyDto; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallAgentRecord; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallAgentRecordMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallAgentService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | |
| | | |
| | | private final MallAgentRecordMapper mallAgentRecordMapper; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | public FebsResponse agentApply(ApiAgentApplyDto apiAgentApplyDto) { |
| | |
| | | if(ObjectUtil.isNotEmpty(mallAgentRecord)){ |
| | | mallAgentRecordMapper.deleteByMemberIdAndState(memberId,MallAgentRecord.APPLY_ING); |
| | | } |
| | | // String city = apiAgentApplyDto.getCity(); |
| | | // List<MallAgentRecord> cityMallAgents = mallAgentRecordMapper.selectByCity(city); |
| | | // if(CollUtil.isEmpty(cityMallAgents)){ |
| | | // return new FebsResponse().fail().message("当前城市已经无法申请"); |
| | | // } |
| | | |
| | | |
| | | DataDictionaryCustom agentAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.PRICE_AMOUNT.getType() |
| | | , DataDictionaryEnum.PRICE_AMOUNT.getCode()); |
| | | String agentAmount = agentAmountDic.getValue(); |
| | | BigDecimal bigDecimal = new BigDecimal(agentAmount); |
| | | |
| | | MallAgentRecord mallAgentRecordNew = MallAgentRecordConversion.INSTANCE.dtoToEntity(apiAgentApplyDto); |
| | | mallAgentRecordNew.setMemberId(memberId); |
| | | mallAgentRecordNew.setState(MallAgentRecord.APPLY_ING); |
| | | mallAgentRecordNew.setAgentLevel(apiAgentApplyDto.getType()); |
| | | if(apiAgentApplyDto.getType().equals(AgentLevelEnum.LEVEL_THREE.getName())){ |
| | | mallAgentRecordNew.setAmount(bigDecimal); |
| | | } |
| | | mallAgentRecordMapper.insert(mallAgentRecordNew); |
| | | |
| | | return new FebsResponse().success().message("申请成功"); |
| | | return new FebsResponse().success().data(bigDecimal); |
| | | } |
| | | |
| | | } |