| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- package com.goafanti.customer.service.impl;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.dao.UserBusinessMapper;
- import com.goafanti.common.dao.UserFollowBusinessMapper;
- import com.goafanti.common.dao.UserFollowMapper;
- import com.goafanti.common.model.UserBusiness;
- import com.goafanti.common.model.UserFollow;
- import com.goafanti.common.model.UserFollowBusiness;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.customer.bo.BusinessListBo;
- import com.goafanti.customer.bo.BussinessFollowBo;
- import com.goafanti.customer.service.BusinessService;
- @Service
- public class BusinessServiceImpl extends BaseMybatisDao<UserBusinessMapper> implements BusinessService {
- @Autowired
- private UserBusinessMapper userBusinessMapper;
- @Autowired
- private UserFollowMapper userFollowMapper;
- @Autowired
- private UserFollowBusinessMapper userFollowBusinessMapper;
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<BusinessListBo> listBusiness(BusinessListBo blo,Integer pageNo,Integer pageSize) {
- blo.setAid(TokenManager.getAdminId());
- return (Pagination<BusinessListBo>) findPage("selectBusinessList", "selectBusinessCount", disposeParams(blo), pageNo, pageSize);
- }
-
- private Map<String,Object> disposeParams(BusinessListBo blo){
- Map<String, Object> params = new HashMap<String, Object>();
- if(StringUtils.isNotBlank(blo.getAid())) params.put("aid", blo.getAid());
- if(StringUtils.isNotBlank(blo.getAdminName())) params.put("adminName", blo.getAdminName());
- if(StringUtils.isNotBlank(blo.getBusinessId())) params.put("businessId", blo.getBusinessId());
- if(StringUtils.isNotBlank(blo.getStartDate())) params.put("startDate", blo.getStartDate()+" 00:00:00");
- if(StringUtils.isNotBlank(blo.getEndDate())) params.put("endDate", blo.getEndDate()+ " 23:59:59");
- if(StringUtils.isNotBlank(blo.getIdentifyName())) params.put("identity", blo.getIdentifyName());
- if(StringUtils.isNoneBlank(blo.getFollowSituation())) params.put("followSituation", blo.getFollowSituation());
- if(StringUtils.isNotBlank(blo.getCustomerStatus())) params.put("customerStatus", blo.getCustomerStatus());
- return params;
- }
- @Override
- public List<BusinessListBo> findBusinessGlossory() {
- return userBusinessMapper.findBusinessGlossory();
- }
- @Override
- public int judgeBusiness(String uid, Integer businessGlossoryId) {
-
- return userBusinessMapper.judgeBusiness(uid,businessGlossoryId,"");
- }
- @Override
- @Transactional
- public void addBusinessAndFollow(BussinessFollowBo bfb) throws ParseException {
- UserBusiness ub = new UserBusiness();
- String ubId = UUID.randomUUID().toString();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- ub.setCustomerStatus(Integer.parseInt(bfb.getCustomerStatus()));
- ub.setFollowSituation(Integer.parseInt(bfb.getFollowSituation()));
- ub.setId(ubId);
- ub.setUid(bfb.getUid());
- ub.setAid(TokenManager.getAdminId());
- ub.setRemarks(bfb.getRemarks());
- ub.setBusinessGlossoryId(Integer.parseInt(bfb.getBusinessGlossoryId()));
- ub.setUpdateTime(format.parse(bfb.getCreateTime()));
- ub.setCreateTime(format.parse(bfb.getCreateTime()));
- userBusinessMapper.insert(ub);
- if (StringUtils.isNotBlank(bfb.getOcbId())) { // 跟进联系人不为空则添加跟进记录
- UserFollow uf = new UserFollow();
- String ufId = UUID.randomUUID().toString();
- uf.setId(ufId);
- uf.setUid(bfb.getUid());
- uf.setCreateTime(format.parse(bfb.getFollowTime()));
- uf.setOcbId(bfb.getOcbId());
- uf.setResult(bfb.getResult());
- uf.setContactType(Integer.parseInt(bfb.getContactType()));
- uf.setAid(TokenManager.getAdminId());
- uf.setEffective(0);
- int followCount = userBusinessMapper.judgeBusiness(bfb.getUid(), null, TokenManager.getAdminId()) + 1;
- uf.setFollowCount(followCount);
- userFollowMapper.insert(uf);
- UserFollowBusiness ufb = new UserFollowBusiness();
- ufb.setId(UUID.randomUUID().toString());
- ufb.setBusinessId(ubId);
- ufb.setFollowId(ufId);
- ufb.setCustomerStatus(ub.getCustomerStatus());
- ufb.setFollowSituation(ub.getFollowSituation());
- userFollowBusinessMapper.insert(ufb);
- }
- }
- @Override
- public List<UserBusiness> findBusinessByUAid(String uid, String aid) {
-
- return userBusinessMapper.findBusinessByUAid(uid,aid);
- }
- @Override
- public BussinessFollowBo findBusinessDetail(String businessId) {
-
- return userBusinessMapper.findBusinessDetail(businessId);
- }
- @Override
- public int updateBusiness(BussinessFollowBo bfb) {
- UserBusiness userBusiness = new UserBusiness();
- userBusiness.setId(bfb.getBusinessId());
- userBusiness.setCustomerStatus(Integer.parseInt(bfb.getCustomerStatus()));
- userBusiness.setFollowSituation(Integer.parseInt(bfb.getFollowSituation()));
- userBusiness.setRemarks(bfb.getRemarks());
- userBusiness.setUpdateTime(new Date());
- userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
- return 1;
- }
- @Override
- @Transactional
- public int followOneBusiness(BussinessFollowBo bfb) throws ParseException {
- Date updateTime = new Date();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- UserBusiness userBusiness = new UserBusiness();
- userBusiness.setId(bfb.getBusinessId());
- userBusiness.setUpdateTime(updateTime);
- userBusiness.setCustomerStatus(Integer.parseInt(bfb.getCustomerStatus()));
- userBusiness.setFollowSituation(Integer.parseInt(bfb.getFollowSituation()));
- userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
- UserFollow userFollow = new UserFollow();
- String followId = UUID.randomUUID().toString();
- int followCount = userBusinessMapper.judgeBusiness(bfb.getUid(), null, TokenManager.getAdminId()) + 1;
- userFollow.setId(followId);
- userFollow.setResult(bfb.getResult());
- userFollow.setCreateTime(format.parse(bfb.getFollowTime()));
- userFollow.setEffective(0);
- userFollow.setOcbId(bfb.getOcbId());
- userFollow.setFollowCount(followCount);
- userFollow.setContactType(Integer.parseInt(bfb.getContactType()));
- userFollow.setAid(TokenManager.getAdminId());
- userFollowMapper.insert(userFollow);
- UserFollowBusiness userFollowBusiness = new UserFollowBusiness();
- String ufbId = UUID.randomUUID().toString();
- userFollowBusiness.setId(ufbId);
- userFollowBusiness.setFollowId(followId);
- userFollowBusiness.setBusinessGlossoryId(Integer.parseInt(bfb.getBusinessGlossoryId()));
- userFollowBusiness.setBusinessId(bfb.getBusinessId());
- userFollowBusiness.setCustomerStatus(Integer.parseInt(bfb.getCustomerStatus()));
- userFollowBusiness.setFollowSituation(Integer.parseInt(bfb.getFollowSituation()));
- userFollowBusiness.setRemarks(bfb.getRemarks());
- userFollowBusinessMapper.insert(userFollowBusiness);
- return 1;
- }
- }
|