| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.druid.sql.visitor.functions.Concat; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.CustomerLogMapper; |
| | | import com.doumee.dao.business.CustomerMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.model.Customer; |
| | | import com.doumee.dao.business.model.CustomerLog; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.web.reqeust.FreeCustomizationDTO; |
| | | import com.doumee.dao.web.reqeust.RenovationCalculatorDTO; |
| | | import com.doumee.dao.web.reqeust.TestTrimStyleDTO; |
| | | import com.doumee.service.business.CustomerLogService; |
| | | import com.doumee.service.business.CustomerService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 客æ·ä¿¡æ¯è¡¨Serviceå®ç° |
| | |
| | | |
| | | @Autowired |
| | | private CustomerMapper customerMapper; |
| | | |
| | | @Autowired |
| | | private CustomerLogMapper customerLogMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | |
| | | @Override |
| | | public Long create(Customer customer) { |
| | |
| | | |
| | | |
| | | |
| | | public void saveRenovationCalculator(){ |
| | | @Override |
| | | public void saveRenovationCalculator(RenovationCalculatorDTO renovationCalculatorDTO){ |
| | | if(Objects.isNull(renovationCalculatorDTO) |
| | | || Objects.isNull(renovationCalculatorDTO.getMemberId()) |
| | | || Objects.isNull(renovationCalculatorDTO.getHouseStatus()) |
| | | || Objects.isNull(renovationCalculatorDTO.getHouseType()) |
| | | || Objects.isNull(renovationCalculatorDTO.getBudget()) |
| | | || StringUtils.isEmpty(renovationCalculatorDTO.getArea()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Member member = memberMapper.selectById(renovationCalculatorDTO.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªæ¥è¯¢å°ç¨æ·ä¿¡æ¯"); |
| | | } |
| | | if(StringUtils.isEmpty(member.getPhone())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªææææºå·"); |
| | | } |
| | | Customer customer = customerMapper.selectOne(new QueryWrapper<Customer>().lambda().eq(Customer::getPhone,member.getPhone()).eq(Customer::getIsdeleted, Constants.ZERO).last("limit 1")); |
| | | if(Objects.isNull(customer)){ |
| | | customer = new Customer(); |
| | | customer.setIsdeleted(Constants.ZERO); |
| | | customer.setPhone(member.getPhone()); |
| | | customer.setCreateDate(new Date()); |
| | | } else{ |
| | | customer.setEditDate(new Date()); |
| | | } |
| | | customer.setOpenid(member.getOpenid()); |
| | | customer.setMemberId(member.getId()); |
| | | |
| | | customerMapper.insertOrUpdate(customer); |
| | | |
| | | |
| | | //åå¨ customerLog æ°æ® |
| | | CustomerLog customerLog = new CustomerLog(); |
| | | customerLog.setCreateDate(new Date()); |
| | | customerLog.setIsdeleted(Constants.ZERO); |
| | | customerLog.setType(Constants.TWO); |
| | | customerLog.setCrmStatus(Constants.ZERO); |
| | | customerLog.setPhone(customer.getPhone()); |
| | | customerLog.setBudget(renovationCalculatorDTO.getBudget().multiply(new BigDecimal(10000)).toString()); |
| | | customerLog.setHouseStatus(renovationCalculatorDTO.getHouseStatus()); |
| | | customerLog.setArea(renovationCalculatorDTO.getArea()); |
| | | customerLog.setHouseType(renovationCalculatorDTO.getHouseType()); |
| | | customerLog.setCostomerId(customer.getId().toString()); |
| | | customerLogMapper.insert(customerLog); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveFreeCustomizationApply(FreeCustomizationDTO freeCustomizationDTO){ |
| | | if(Objects.isNull(freeCustomizationDTO) |
| | | || Objects.isNull(freeCustomizationDTO.getMemberId()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getName()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getPhone()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getCityCode()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getCityName()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getProvinceName()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getProvinceCode()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getAreaCode()) |
| | | || StringUtils.isEmpty(freeCustomizationDTO.getAreaName()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Member member = memberMapper.selectById(freeCustomizationDTO.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªæ¥è¯¢å°ç¨æ·ä¿¡æ¯"); |
| | | } |
| | | if(StringUtils.isEmpty(member.getPhone())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªææææºå·"); |
| | | } |
| | | Customer customer = customerMapper.selectOne(new QueryWrapper<Customer>().lambda() |
| | | .eq(Customer::getPhone,freeCustomizationDTO.getPhone()).eq(Customer::getIsdeleted, Constants.ZERO).last("limit 1")); |
| | | if(Objects.isNull(customer)){ |
| | | customer = new Customer(); |
| | | customer.setPhone(freeCustomizationDTO.getPhone()); |
| | | customer.setCreateDate(new Date()); |
| | | customer.setIsdeleted(Constants.ZERO); |
| | | } else{ |
| | | customer.setEditDate(new Date()); |
| | | } |
| | | customer.setOpenid(member.getOpenid()); |
| | | customer.setMemberId(member.getId()); |
| | | customer.setName(freeCustomizationDTO.getName()); |
| | | |
| | | customer.setProName(freeCustomizationDTO.getProvinceName()); |
| | | customer.setCityName(freeCustomizationDTO.getCityName()); |
| | | customer.setAreaName(freeCustomizationDTO.getAreaName()); |
| | | customer.setProvinceCode(freeCustomizationDTO.getProvinceCode()); |
| | | customer.setCityCode(freeCustomizationDTO.getCityCode()); |
| | | customer.setAreaCode(freeCustomizationDTO.getAreaCode()); |
| | | customerMapper.insertOrUpdate(customer); |
| | | |
| | | //åå¨ customerLog æ°æ® |
| | | CustomerLog customerLog = new CustomerLog(); |
| | | customerLog.setCreateDate(new Date()); |
| | | customerLog.setIsdeleted(Constants.ZERO); |
| | | customerLog.setType(Constants.ONE); |
| | | customerLog.setCrmStatus(Constants.ZERO); |
| | | customerLog.setPhone(customer.getPhone()); |
| | | customerLog.setCostomerId(customer.getId().toString()); |
| | | |
| | | customerLog.setProvinceName(freeCustomizationDTO.getProvinceName()); |
| | | customerLog.setCityName(freeCustomizationDTO.getCityName()); |
| | | customerLog.setAreaCode(freeCustomizationDTO.getAreaName()); |
| | | customerLog.setProvicneCode(freeCustomizationDTO.getProvinceCode()); |
| | | customerLog.setCityCode(freeCustomizationDTO.getCityCode()); |
| | | customerLog.setAreaCode(freeCustomizationDTO.getAreaCode()); |
| | | customerLog.setName(freeCustomizationDTO.getName()); |
| | | customerLog.setPhone(freeCustomizationDTO.getPhone()); |
| | | customerLogMapper.insert(customerLog); |
| | | } |
| | | |
| | | @Override |
| | | public void saveTestTrimStyle(TestTrimStyleDTO testTrimStyleDTO){ |
| | | if(Objects.isNull(testTrimStyleDTO) |
| | | || Objects.isNull(testTrimStyleDTO.getMemberId()) |
| | | |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getStyleInfo()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getAgeInfo()) |
| | | || Objects.isNull(testTrimStyleDTO.getSex()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getHouseType()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getAgeInfo()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getPhone()) |
| | | |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getCityCode()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getCityName()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getProvinceName()) |
| | | || StringUtils.isEmpty(testTrimStyleDTO.getProvinceCode()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Member member = memberMapper.selectById(testTrimStyleDTO.getMemberId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªæ¥è¯¢å°ç¨æ·ä¿¡æ¯"); |
| | | } |
| | | if(StringUtils.isEmpty(member.getPhone())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"æªææææºå·"); |
| | | } |
| | | Customer customer = customerMapper.selectOne(new QueryWrapper<Customer>().lambda() |
| | | .eq(Customer::getPhone,testTrimStyleDTO.getPhone()).eq(Customer::getIsdeleted, Constants.ZERO).last("limit 1")); |
| | | if(Objects.isNull(customer)){ |
| | | customer = new Customer(); |
| | | customer.setPhone(testTrimStyleDTO.getPhone()); |
| | | customer.setCreateDate(new Date()); |
| | | customer.setIsdeleted(Constants.ZERO); |
| | | } else{ |
| | | customer.setEditDate(new Date()); |
| | | } |
| | | customer.setOpenid(member.getOpenid()); |
| | | customer.setMemberId(member.getId()); |
| | | |
| | | customer.setProName(testTrimStyleDTO.getProvinceName()); |
| | | customer.setCityName(testTrimStyleDTO.getCityName()); |
| | | customer.setProvinceCode(testTrimStyleDTO.getProvinceCode()); |
| | | customer.setCityCode(testTrimStyleDTO.getCityCode()); |
| | | customerMapper.insertOrUpdate(customer); |
| | | |
| | | //åå¨ customerLog æ°æ® |
| | | CustomerLog customerLog = new CustomerLog(); |
| | | customerLog.setCreateDate(new Date()); |
| | | customerLog.setIsdeleted(Constants.ZERO); |
| | | customerLog.setType(Constants.ZERO); |
| | | customerLog.setCrmStatus(Constants.ZERO); |
| | | customerLog.setPhone(customer.getPhone()); |
| | | customerLog.setCostomerId(customer.getId().toString()); |
| | | |
| | | customerLog.setProvinceName(testTrimStyleDTO.getProvinceName()); |
| | | customerLog.setCityName(testTrimStyleDTO.getCityName()); |
| | | customerLog.setProvicneCode(testTrimStyleDTO.getProvinceCode()); |
| | | customerLog.setCityCode(testTrimStyleDTO.getCityCode()); |
| | | |
| | | customerLog.setAgeInfo(testTrimStyleDTO.getAgeInfo()); |
| | | customerLog.setHouseType(testTrimStyleDTO.getHouseType()); |
| | | customerLog.setStyleInfo(testTrimStyleDTO.getStyleInfo()); |
| | | customerLog.setSex(testTrimStyleDTO.getSex()); |
| | | customerLog.setAgeInfo(testTrimStyleDTO.getAgeInfo()); |
| | | customerLog.setPhone(testTrimStyleDTO.getPhone()); |
| | | customerLogMapper.insert(customerLog); |
| | | } |
| | | |
| | | |
| | | |
| | | |