|
@@ -0,0 +1,159 @@
|
|
|
+package com.benyun.core.service.impl;
|
|
|
+
|
|
|
+import com.benyun.core.dao.*;
|
|
|
+import com.benyun.core.entity.*;
|
|
|
+import com.benyun.core.entity.bo.AttentionPoolBo;
|
|
|
+import com.benyun.core.entity.vo.TurnBusinessOpportunitiesVo;
|
|
|
+import com.benyun.core.entity.vo.WorkTableSearchVo;
|
|
|
+import com.benyun.core.service.AttentionPoolService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class AttentionPoolServiceImpl implements AttentionPoolService {
|
|
|
+ @Autowired
|
|
|
+ AttentionPoolDao attentionPoolDao;
|
|
|
+ @Autowired
|
|
|
+ BusinessOpportunitiesDao businessOpportunitiesDao;
|
|
|
+ @Autowired
|
|
|
+ FollowUpDao followUpDao;
|
|
|
+ @Autowired
|
|
|
+ BrandMapper brandMapper;
|
|
|
+ @Autowired
|
|
|
+ WdInfoDao wdInfoDao;
|
|
|
+ @Autowired
|
|
|
+ StoreWdDao storeWdDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<List<AttentionPoolBo>> searchList(WorkTableSearchVo workVo, String userId) {
|
|
|
+ PageHelper.startPage(workVo.getPageNum(),workVo.getPageSize(),true);
|
|
|
+ List<AttentionPool> pools = attentionPoolDao.searchByMulti(workVo.getText(), userId);
|
|
|
+ List<AttentionPoolBo> bos = new ArrayList<>();
|
|
|
+ for (AttentionPool pool : pools){
|
|
|
+ AttentionPoolBo bo = new AttentionPoolBo();
|
|
|
+ bo.setAttentionId(pool.getAttentionId());
|
|
|
+ bo.setContact(pool.getContact());
|
|
|
+ bo.setTelephone(pool.getTelephone());
|
|
|
+ bo.setBrandName(pool.getBrandName());
|
|
|
+ bo.setWdName(pool.getWdName());
|
|
|
+ bo.setWdAddrInfo(pool.getWdAddrInfo());
|
|
|
+ bo.setAttentionTime(pool.getAttentionTime());
|
|
|
+ bos.add(bo);
|
|
|
+ }
|
|
|
+ return new PageInfo(bos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int cancelAttention(String attentionId, String userId) {
|
|
|
+ BusinessOpportunitiesClue clue = businessOpportunitiesDao.searchByAttentionIdAndUserId(attentionId, userId);
|
|
|
+ if (clue != null){
|
|
|
+ List<FollowUpRecord> followUpRecords = followUpDao.searchAllByClueIdAndUserId(clue.getClueId(), userId);
|
|
|
+ if (!followUpRecords.isEmpty())
|
|
|
+ followUpDao.deleteByClueIdAndUserId(clue.getClueId(), userId);
|
|
|
+ businessOpportunitiesDao.deleteByAttentionIdAndUserId(attentionId, userId);
|
|
|
+ }
|
|
|
+ int deleteAttention = attentionPoolDao.deleteByAttentionIdAndUserId(attentionId, userId);
|
|
|
+ return deleteAttention;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int turnBusinessOpportunities(TurnBusinessOpportunitiesVo turnVo, String userId) {
|
|
|
+ BusinessOpportunitiesClue clue1 = businessOpportunitiesDao.searchByAttentionIdAndUserId(turnVo.getAttentionId(), userId);
|
|
|
+ if (clue1 == null)
|
|
|
+ return 0;
|
|
|
+ BusinessOpportunitiesClue clue = new BusinessOpportunitiesClue();
|
|
|
+ clue.setClueId(UUID.randomUUID().toString().replace("-",""));
|
|
|
+ clue.setAttentionId(turnVo.getAttentionId());
|
|
|
+ clue.setContact(turnVo.getContact());
|
|
|
+ clue.setTelephone(turnVo.getTelephone());
|
|
|
+ clue.setFollowUpCount(0);
|
|
|
+ clue.setUserId(userId);
|
|
|
+ clue.setCreateTime(new Date());
|
|
|
+ return businessOpportunitiesDao.insert(clue);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int attentionBrand(String brandId, String userId) {
|
|
|
+ AttentionPool attentionPool = attentionPoolDao.searchByBrandIdOrWdIdAndUserId(brandId,null, userId);
|
|
|
+ if (attentionPool != null) // 判断是否已经关注
|
|
|
+ return 2;
|
|
|
+ Brand brand = brandMapper.searchById(brandId);
|
|
|
+ if (brand == null) // 判断是否有该品牌
|
|
|
+ return 3;
|
|
|
+ AttentionPool pool = new AttentionPool();
|
|
|
+ pool.setAttentionId(UUID.randomUUID().toString().replace("-",""));
|
|
|
+ pool.setContact(brand.getContact());
|
|
|
+ if (brand.getContact() == null)
|
|
|
+ pool.setContact("");
|
|
|
+ pool.setTelephone(brand.getTelephone());
|
|
|
+ if (brand.getTelephone() == null)
|
|
|
+ pool.setTelephone("");
|
|
|
+ pool.setBrandId(brand.getBrandId());
|
|
|
+ pool.setBrandName(brand.getBrandName());
|
|
|
+ pool.setWdId("");
|
|
|
+ pool.setWdName("");
|
|
|
+ pool.setWdAddrInfo("");
|
|
|
+ pool.setUserId(userId);
|
|
|
+ pool.setAttentionTime(new Date());
|
|
|
+ return attentionPoolDao.insert(pool);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int cancelBrand(String brnadId, String userId) {
|
|
|
+ return attentionPoolDao.deleteByBrandIdOrWdIdAndUserId(brnadId,null,userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int attentionWdInfo(String wdId, String userId) {
|
|
|
+ AttentionPool attentionPool = attentionPoolDao.searchByBrandIdOrWdIdAndUserId(null, wdId, userId);
|
|
|
+ if (attentionPool != null) // 判断是否已经关注
|
|
|
+ return 2;
|
|
|
+ WdInfo wdInfo = wdInfoDao.selectById(wdId);
|
|
|
+ if (wdInfo == null) // 判断是否有该网点
|
|
|
+ return 3;
|
|
|
+ AttentionPool pool = new AttentionPool();
|
|
|
+ pool.setAttentionId(UUID.randomUUID().toString().replace("-",""));
|
|
|
+ pool.setWdId(wdInfo.getWdId());
|
|
|
+ pool.setWdName(wdInfo.getWdName());
|
|
|
+ pool.setWdAddrInfo(wdInfo.getAddrInfo());
|
|
|
+ StoreWd storeWd = storeWdDao.selectById(wdId);
|
|
|
+ if (storeWd != null){
|
|
|
+ pool.setContact(storeWd.getContact());
|
|
|
+ if (storeWd.getContact() == null)
|
|
|
+ pool.setContact("");
|
|
|
+ pool.setTelephone(storeWd.getTelephone());
|
|
|
+ if (storeWd.getTelephone() == null)
|
|
|
+ pool.setTelephone("");
|
|
|
+ if (storeWd.getBrandId() != null || !storeWd.getBrandId().equals("")){
|
|
|
+ Brand brand = brandMapper.searchById(storeWd.getBrandId());
|
|
|
+ if (brand != null){
|
|
|
+ pool.setBrandId(brand.getBrandId());
|
|
|
+ pool.setBrandName(brand.getBrandName());
|
|
|
+ }else {
|
|
|
+ pool.setBrandId("");
|
|
|
+ pool.setBrandName("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ pool.setContact("");
|
|
|
+ pool.setTelephone("");
|
|
|
+ pool.setBrandId("");
|
|
|
+ pool.setBrandName("");
|
|
|
+ }
|
|
|
+ pool.setUserId(userId);
|
|
|
+ pool.setAttentionTime(new Date());
|
|
|
+ return attentionPoolDao.insert(pool);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int cancelWdInfo(String wdId, String userId) {
|
|
|
+ return attentionPoolDao.deleteByBrandIdOrWdIdAndUserId(null,wdId,userId);
|
|
|
+ }
|
|
|
+}
|