| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570 |
- package com.goafanti.customer.controller;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.lang.reflect.InvocationTargetException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- import java.util.Set;
- import java.util.TreeSet;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.goafanti.common.utils.*;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.customer.bo.*;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.validation.BindingResult;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.goafanti.admin.service.AdminService;
- import com.goafanti.admin.service.AttachmentService;
- import com.goafanti.common.bo.Error;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.BaseApiController;
- import com.goafanti.common.enums.AttachmentType;
- import com.goafanti.common.error.BusinessException;
- import com.goafanti.common.model.Attachment;
- import com.goafanti.common.model.OrganizationContactBook;
- import com.goafanti.common.model.User;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.customer.service.CustomerService;
- @RestController
- @RequestMapping("/api/admin/customer")
- public class AdminCustomerApiController extends BaseApiController{
- @Resource
- private CustomerService customerService;
- @Resource
- private AttachmentService aftFileService;
- @Value(value = "${upload.private.path}")
- private String uploadPrivatePath = null;
- @Value(value = "${user.receive.max}")
- private Integer USER_RECEIVE_MAX = null;
- @Resource
- private AdminService adminService;
- @Value(value = "${aesSecretKey}")
- private String secretKey = null;
- /** 私有个人客户列表 **/
- @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
- public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 公共个人客户列表 **/
- @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
- public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 个人客户查询 **/
- @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
- public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 签单的个人客户 **/
- @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
- public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 管理个人客户查询 **/
- @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
- public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
- cli.setAid(TokenManager.getAdminId());
- }
- res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 专家查询 **/
- @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
- public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 个人客户详情信息 **/
- @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
- public Result findPersonalCustomerDetail(String uid){
- Result res = new Result();
- res.setData(customerService.findPersonalCustomerDetail(uid));
- return res;
- }
- /**
- * 私有单位客户列表
- * 私有客户列表
- **/
- @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
- public Result listPrivateOrganizationCustomer(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
- Result res = new Result();
- //
- res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 0, pageNo, pageSize));
- return res;
- }
- /**
- * 私有渠道客户列表
- *
- **/
- @RequestMapping(value = "/channelUserList" , method = RequestMethod.GET)
- public Result channelUserList(InputChannelListBo in ){
- Result res = new Result();
- in.setNewChannel(1);
- in.setShareType(0);
- res.setData(customerService.channelUserList(in));
- return res;
- }
- /**
- * 公共渠道客户列表
- *
- **/
- @RequestMapping(value = "/publicChannelUserList" , method = RequestMethod.GET)
- public Result publicChannelUserList(InputChannelListBo in ){
- Result res = new Result();
- in.setNewChannel(1);
- //获取公共
- in.setShareType(1);
- res.setData(customerService.channelUserList(in));
- return res;
- }
- /**
- * 渠道客户查询
- *
- **/
- @RequestMapping(value = "/selectChannelUserList" , method = RequestMethod.GET)
- public Result selectChannelUserList(InputChannelListBo in ){
- Result res = new Result();
- in.setNewChannel(1);
- if (in.getName()==null||in.getName().length()<2){
- res.getError().add(buildError("搜索名字必须大于2个字符"));
- return res;
- }
- res.setData(customerService.selectChannelUserList(in));
- return res;
- }
- /** 跟进管理列表
- * 跟进列表
- **/
- @RequestMapping(value = "/listFollowManagement" , method = RequestMethod.GET)
- public Result listFollowManagement(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 1, pageNo, pageSize));
- return res;
- }
- /**
- * 私有单位客户导出xls
- * @throws IOException
- */
- @RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
- public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
- Result res = new Result();
- XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
- String fileName = "我的客户列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
- OutputStream out = null;
- try {
- out = response.getOutputStream();
- } catch (IOException e) {
- e.printStackTrace();
- }
- response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
- response.setContentType("application/octet-stream;charset=utf-8");
- try {
- // 返回数据流
- wb.write(out);
- out.flush();
- out.close();
- } finally {
- out.flush();
- out.close();
- }
- return res;
- }
- /** 公共单位客户列表 **/
- @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
- public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 单位客户查询 **/
- @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
- public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- if (StringUtils.isBlank(cli.getName())){
- res.setData( new Pagination<>());
- return res;
- }
- res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 管理单位客户查询 **/
- @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
- public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 签单的单位客户 **/
- @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
- public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
- return res;
- }
- /** 签单客户转交 **/
- @RequestMapping(value = "/customerHandOver", method = RequestMethod.POST)
- public Result listSignPersonalCustomer(String userIds ,String receiveId){
- Result res = new Result();
- res.setData(customerService.customerHandOver( userIds , receiveId));
- return res;
- }
- /** 客户即时检索 **/
- @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
- public Result findCustomerByName(String name){
- Result res = new Result();
- res.setData(customerService.findCustomerByName(name));
- return res;
- }
- /** 客户即时检索(可签单客户) **/
- @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
- public Result getCustomerByName(String name,Integer type){
- Result res = new Result();
- if(type == null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- if(name.length()<2) return res;
- if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
- if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
- if(type == 2) res.setData(customerService.getChannelCustomerByName(name));
- return res;
- }
- /** 客户查询 **/
- @RequestMapping(value = "/getUserByName",method = RequestMethod.GET)
- public Result getUserByName(String name){
- Result res = new Result();
- if(StringUtils.isEmpty(name)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
- return res;
- }
- if(name.length()<2) return res;
- res.data(customerService.getUserByName(name));
- return res;
- }
- /**
- * 客户查询
- * @param name 查询名称
- * @param type 分类 0默认 1小程序App
- * @param pageNo
- * @param pageSize
- * @return
- */
- @RequestMapping(value = "/getUserByNames",method = RequestMethod.GET)
- public Result getUserByName(String name,Integer type,Integer pageNo,Integer pageSize){
- Result res = new Result();
- if(StringUtils.isEmpty(name)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
- return res;
- }
- if(name.length()<2) return res;
- res.data(customerService.getUserByNames(name,type,pageNo,pageSize));
- return res;
- }
- /** 添加客户基本信息
- * @throws Exception
- * @throws NumberFormatException **/
- @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
- public Result addCustomer(InputAddCustomer in) {
- Result res = new Result();
- if(StringUtils.isBlank(in.getName()) || StringUtils.isBlank(in.getContacts())
- || StringUtils.isBlank(in.getContactMobile()) ||null==in.getProvince()||null==in.getCity()||null==in.getArea()
- || StringUtils.isBlank(in.getBusinessScope())||null==in.getOrgCode()
- || StringUtils.isBlank(in.getIntendedProject())){
- res.getError().add(buildError("","创建客户参数不全"));
- return res;
- }
- if (customerService.checkMax(null,TokenManager.getAdminId())) {
- res.getError().add(buildError("","私有客户已达最大限制"));
- return res;
- }
- if (customerService.checkOrgCode(in.getOrgCode())){
- res.getError().add(buildError("","统一信用代码已存在"));
- return res;
- }
- //新增为私有客户
- in.setShareType(0);
- //将新增客户的空格去除
- res.data(customerService.addCustomer(in));
- return res;
- }
- @RequestMapping(value = "/addChannel", method = RequestMethod.POST)
- public Result addChannel(@Validated InputAddCustomer in, BindingResult bindingResult) {
- Result res = new Result();
- if (bindingResult.hasErrors()) {
- res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
- ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
- return res;
- }
- if (customerService.checkUserName(in.getName())){
- res.getError().add(buildError("客户名称已存在"));
- return res;
- }
- in.setType(1);
- //新增为私有客户
- in.setShareType(0);
- in.setNewChannel(1);
- //将新增客户的空格去除
- res.data(customerService.addCustomer(in));
- return res;
- }
- /** 单位客户详情信息 **/
- @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
- public Result findOrganizationCustomerDetail(String uid){
- Result res = new Result();
- res.setData(customerService.findOrganizationCustomerDetail(uid));
- return res;
- }
- /** 修改单位客户信息 **/
- @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
- public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updateOrganizationCustomer(bo);
- return res;
- }
- /** 修改个人客户信息 **/
- @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
- public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updatePersonalCustomer(bo);
- return res;
- }
- /** 查看跟进记录 **/
- @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
- public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
- Result res = new Result();
- res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
- return res;
- }
- /** 指导已读 **/
- @RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
- public Result pushGuidance(String uid){
- Result res = new Result();
- if (StringUtils.isBlank(uid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
- return res;
- }
- res.setData(customerService.pushGuidance(uid));
- return res;
- }
- /** 新增指导意见 **/
- @RequestMapping(value = "/addGuidance", method = RequestMethod.POST)
- public Result addGuidance(String followId,String guidance){
- Result res = new Result();
- if (StringUtils.isBlank(followId)||StringUtils.isBlank(guidance)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号、指导意见","编号、指导意见"));
- return res;
- }
- res.setData(customerService.addGuidance( followId, guidance));
- return res;
- }
- /** 查看客户账户信息 **/
- @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
- public Result findUserAcountDetail(String uid){
- Result res = new Result();
- UserDetailBo bo = new UserDetailBo();
- User user = customerService.findUserAccountDetail(uid);
- try {
- BeanUtilsExt.copyProperties(bo, user);
- } catch (InvocationTargetException | IllegalAccessException e) {
- e.printStackTrace();
- }
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setCreateTimes(format.format(user.getCreateTime()));
- res.setData(bo);
- return res;
- }
- /** 修改客户账户信息 **/
- @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
- public Result updateUserAccount(User user){
- Result res = new Result();
- customerService.updateUserAccount(user);
- return res;
- }
- /** 查看客户联系人列表 **/
- @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
- public Result findCustomerContacts(String uid){
- Result res = new Result();
- res.setData(customerService.findCustomerContacts(uid));
- return res;
- }
- /** 针对已作拜访的业务作跟进 **/
- @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
- public Result toAddFollowOnHistory(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- User user = customerService.findUserAccountDetail(uid);
- FollowBusinessBo fbb = new FollowBusinessBo();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- fbb.setFollowTime(format.format(new Date()));
- fbb.setIdentifyName(user.getIdentifyName());
- fbb.setUid(uid);
- fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
- res.setData(fbb);
- return res;
- }
- /** 针对已锁定的业务作跟进 **/
- @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
- public Result toAddFollowOnLock(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- User user = customerService.findUserAccountDetail(uid);
- FollowBusinessBo fbb = new FollowBusinessBo();
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- fbb.setFollowTime(format.format(new Date()));
- fbb.setIdentifyName(user.getIdentifyName());
- fbb.setUid(uid);
- fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
- res.setData(fbb);
- return res;
- }
- /** 添加拜访记录、客户跟进
- * @throws ParseException
- * @throws Exception **/
- @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
- public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
- List<BusinessListBo> list = new ArrayList<BusinessListBo>();
- if (ja != null && !ja.isEmpty()) {
- BusinessListBo userBusiness = null;
- for (int idx = 0; idx < ja.size(); idx++) {
- userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
- for(BusinessListBo ub:list){
- if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
- res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
- return res;
- }
- }
- list.add(userBusiness);
- }
- }
- FollowBusinessBo fbb = new FollowBusinessBo();
- fbb.setOcbId(ocbId);
- fbb.setUid(uid);
- fbb.setContactType(contactType);
- fbb.setResult(result);
- fbb.setFollowTime(followTime);
- fbb.setUserBusinessList(list);
- customerService.addFollow(fbb,null,1);
- return res;
- }
- /** 进入修改拜访记录 **/
- @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
- public Result toUpdateFollow(String followId){
- Result res = new Result();
- FollowBusinessBo fbb = customerService.findFollowById(followId);
- fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
- res.setData(fbb);
- return res;
- }
- /** 修改拜访记录
- * @throws ParseException
- * @throws BusinessException
- */
- @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
- public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
- List<BusinessListBo> list = new ArrayList<BusinessListBo>();
- if (ja != null && !ja.isEmpty()) {
- BusinessListBo userBusiness = null;
- for (int idx = 0; idx < ja.size(); idx++) {
- userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
- for(BusinessListBo ub:list){
- if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
- res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
- return res;
- }
- }
- list.add(userBusiness);
- }
- }
- FollowBusinessBo fbb = new FollowBusinessBo();
- fbb.setFollowTime(followTime);
- fbb.setUid(uid);
- fbb.setContactType(contactType);
- fbb.setResult(result);
- fbb.setUserBusinessList(list);
- fbb.setFollowId(followId);
- customerService.updateFollow(fbb);
- return res;
- }
- /** 删除跟进记录 **/
- @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
- public Result deleteFollow(String followId){
- Result res = new Result();
- if(StringUtils.isBlank(followId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- customerService.deleteFollow(followId);
- return res;
- }
- /** 查询客户的所有联系人 **/
- @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
- public Result findAllContacts(String uid){
- Result res = new Result();
- res.setData(customerService.findAllContacts(uid));
- return res;
- }
- /** 修改企业联系人 **/
- @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
- public Result updateCustomerContacts(String contactList,String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- JSONArray ja = (JSONArray) JSON.parse(contactList);
- List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
- OrganizationContactBook ocb = null;
- if(ja != null & !ja.isEmpty()){
- for (int idx = 0; idx < ja.size(); idx++) {
- ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
- if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
- return res;
- }
- if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
- ocbList.add(ocb);
- }
- }
- customerService.updateCustomerContacts(ocbList,uid);
- return res;
- }
- /**
- * 领取客户
- * @param uid 客户编号
- * @param oldAid 原来的客户归属人
- * @return
- */
- @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
- public Result receiveCustomer(String uid, String oldAid) {
- Result res = new Result();
- if (StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- Integer check =customerService.receiveEveryDay(uid);
- if (check!=0){
- if (check==-1){
- res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_RECEIVE));
- return res;
- }else if (check==-2){
- res.getError().add(buildError(ErrorConstants.CUSTOM_EREXCESS, USER_RECEIVE_MAX.toString(),USER_RECEIVE_MAX.toString()));
- return res;
- }else if (check==-3){
- res.getError().add(buildError("", "私有客户已达最大限制"));
- return res;
- }else if (check==-4){
- res.getError().add(buildError("", "外联客户丢失后不可再领取"));
- return res;
- }else {
- res.getError().add(buildError("领取参数异常,请联系管理员"));
- return res;
- }
- }
- customerService.updateByOperatorType(uid, null, oldAid, AFTConstants.USER_RECEIVE, null);
- return res;
- }
- /**
- * 领取为渠道
- * @param uid
- * @return
- */
- @RequestMapping(value = "/receiveAsChannel",method=RequestMethod.POST)
- public Result receiveAsChannel(String uid){
- Result res = new Result();
- if (uid ==null ){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户"));
- return res;
- }
- res.data(customerService.pushReceiveAsChannel(uid));
- return res;
- }
- /**
- * 上传excel文档
- * @param req
- * @return
- */
- @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
- public Result uploadExcel(HttpServletRequest req){
- Result res = new Result();
- String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
- ExcelUtils utils = new ExcelUtils();
- Set<CustomerExcelBo> boSet;
- try {
- boSet = utils.parseExcel(uploadPrivatePath + excelPath);
- String errorMessage = "";
- if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
- errorMessage += utils.getVacantRows();
- if(StringUtils.isNotBlank(errorMessage)) {
- res.getError().add(new Error(errorMessage));
- return res;
- }
- Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
- Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
- customerService.checkCustomer(boSet,existRows,filterRows);
- if(existRows.size()>0){
- errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
- res.getError().add(new Error(errorMessage));
- return res;
- }
- if(filterRows.size()>0){
- errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
- res.getError().add(new Error(errorMessage));
- return res;
- }
- customerService.saveUploadData(boSet);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return res;
- }
- /**
- * 下载科技成果批量导入Excel模板
- */
- @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
- public Result downloadTemplateFile(HttpServletResponse response,String type) {
- Result res = new Result();
- if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
- Attachment af = aftFileService.selectAftFileBySign("organization_customer_template");
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- String fileName = af.getFileName() + suffix;
- downloadFile(response, fileName, path);
- }
- }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
- Attachment af = aftFileService.selectAftFileBySign("personal_customer_template");
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- String fileName = af.getFileName() + suffix;
- downloadFile(response, fileName, path);
- }
- }
- return res;
- }
- /** 转为公共客户 **/
- @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
- public Result transferToPublic(String uid,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- }
- customerService.updateByOperatorType(uid, aid,null, AFTConstants.USER_TRANSFER_TO_PUBLIC,null);
- return res;
- }
- /** 图片上传 **/
- @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
- public Result uploadCustomerImg(HttpServletRequest req,String sign){
- Result res = new Result();
- res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
- return res;
- }
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depNo 部门编号
- * @param pageNo 页码
- * @param pageSize 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
- public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
- return res;
- }
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depNo 部门编号
- * @param businessGlossoryId 业务编号
- * @param pageNo 页码
- * @param pageSize 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
- public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
- return res;
- }
- /**
- *
- * @param startDate 开始日期
- * @param endDate 结束日期
- * @param timeSpan 时间差
- * @param depNo 部门编号
- * @param pageNo 页码
- * @param pageSize 页数
- * @return
- * @throws ParseException
- */
- @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
- public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
- Result res = new Result();
- Date sDate = null;
- Date eDate = null;
- DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
- if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
- if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
- if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
- Date date = new Date();
- if(timeSpan.equals(DateUtils.DAY_SPAN)){
- sDate = DateUtils.getYesterday();
- }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
- sDate = DateUtils.getLastDayOfLastWeek(date);
- }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
- sDate = DateUtils.getLastDayOfLastMonth(date);
- }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
- sDate = DateUtils.getLastDayOfLastQuarter(date);
- }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
- sDate = DateUtils.getLastDayOfLastYear(date);
- }
- }
- res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
- return res;
- }
- /**
- * 管理员列表
- * @param adminName 名称
- * @param status 0 正常 1锁定 2全部
- * @return
- */
- @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
- public Result listAdminByName(String adminName,Integer status){
- Result res = new Result();
- adminName=adminName.trim();
- if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName,status));
- return res;
- }
- /**
- * 客户转交
- * @param uid 用户编号
- * @param aid
- * @param operatorType 3私有 4签单
- * @param oldAid
- * @param data 资料同步转移 0无 1资料转交 2订单转交 3全部转交
- * @return
- */
- @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
- public Result transferToOther(String uid,String aid,Integer operatorType,Integer data,String oldAid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
- return res;
- }
- //默认为私有转交,4为签单转交
- if (operatorType==null) {
- operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
- }
- if ((operatorType ==AFTConstants.USER_TRANSFER_TO_OTHER||operatorType ==AFTConstants.USER_RECEIVE)
- && customerService.checkMax(uid,aid)) {
- res.getError().add(buildError("","对方私有客户已达最大限制"));
- return res;
- }
- if(data==null)data=0;
- res.setData(customerService.updateByOperatorType(uid, aid, oldAid, operatorType, data));
- return res;
- }
- /**
- * 客户转交记录
- * @param uid 客户编号
- * @return
- */
- @RequestMapping(value = "/transferList", method = RequestMethod.GET)
- public Result transferList(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) ){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
- return res;
- }
- res.data(customerService.transferList( uid));
- return res;
- }
- /** 查询我的业务列表 **/
- @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
- public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listBusiness(blo, pageNo, pageSize));
- return res;
- }
- /** 查询所有的业务列表 **/
- @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
- public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
- return res;
- }
- /** 业务管理列表 **/
- @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
- public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
- return res;
- }
- /** 查询业务字典 **/
- @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
- public Result findBusinessGlossory(){
- Result res = new Result();
- res.setData(customerService.findBusinessGlossory());
- return res;
- }
- /** 新增客户意向 **/
- @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
- public Result addBusinessAndFollow(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
- res.getError().add(new Error("该项业务已经被跟进"));
- return res;
- }
- try {
- customerService.addBusinessAndFollow(bfb);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return res;
- }
- /** 进入新增意向服务 **/
- @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
- public Result toAddBusinessAndFollow(){
- Result res = new Result();
- BussinessFollowBo bo = new BussinessFollowBo();
- bo.setAdminName(TokenManager.getAdminToken().getName());
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setCreateTime(format.format(new Date()));
- bo.setFollowTime(bo.getCreateTime());
- res.setData(bo);
- return res;
- }
- /** 进入修改业务意向 **/
- @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
- public Result toUpdateBusiness(String businessId){
- Result res = new Result();
- res.setData(customerService.findBusinessDetail(businessId));
- return res;
- }
- /** 修改业务意向 **/
- @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
- public Result updateBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- customerService.updateBusiness(bfb);
- return res;
- }
- /** 进入跟进单个客户意向 **/
- @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
- public Result toAddFollowOneBusiness(String businessId){
- Result res = new Result();
- BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
- bo.setFollowTime(format.format(new Date()));
- res.setData(bo);
- return res;
- }
- /** 跟进单个客户意向 **/
- @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
- public Result addFollowOneBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getBusinessId()) ||
- StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
- return res;
- }
- try {
- customerService.addFollowOneBusiness(bfb);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return res;
- }
- /** 进入修改某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
- public Result toUpdateFollowOneBusiness(String ufbId){
- Result res = new Result();
- if(StringUtils.isBlank(ufbId)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- res.setData(customerService.findFollowOneBusiness(ufbId));
- return res;
- }
- /** 修改某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
- public Result updateFollowOneBusiness(BussinessFollowBo bfb){
- Result res = new Result();
- if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateFollowOneBusiness(bfb);
- return res;
- }
- /** 删除某个客户一个业务的当次拜访 **/
- @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
- public Result deleteFollowOneBusiness(String ufbId){
- Result res = new Result();
- if(StringUtils.isBlank(ufbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteFollowOneBusiness(ufbId);
- return res;
- }
- /** 添加单个联系人 **/
- @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
- public Result addOneContact(OrganizationContactBook ocb){
- Result res = new Result();
- if(StringUtils.isBlank(ocb.getUid())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
- res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
- return res;
- }
- customerService.addOneContact(ocb);
- return res;
- }
- /** 删除单个联系人 **/
- @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
- public Result deleteOneContact(String ocbId){
- Result res = new Result();
- if(StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteOneContact(ocbId);
- return res;
- }
- /** 修改主要联系人 **/
- @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
- public Result updateMainContact(String ocbId,String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateMainContact(ocbId,uid);
- return res;
- }
- /** 删除 业务 **/
- @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
- public Result deleteBusiness(String businessId){
- Result res = new Result();
- if(StringUtils.isBlank(businessId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.deleteBusiness(businessId);
- return res;
- }
- /** 停止业务 **/
- @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
- public Result stopBusiness(String businessId){
- Result res = new Result();
- if(StringUtils.isBlank(businessId)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
- return res;
- }
- customerService.updateBusinessToStop(businessId);
- return res;
- }
- /** 客户分配查询(本部门) **/
- @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
- public Result findAdminName(){
- Result res = new Result();
- res.setData(customerService.findAdminName());
- return res;
- }
- /** 分配个人客户 **/
- @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
- public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- customerService.updatePersonalCustomerz(bo);
- return res;
- }
- /** 客户录入审核 **/
- @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
- public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
- return res;
- }
- /** 修改客户录入审核状态 **/
- @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
- public Result updateEnteringAudit(User bo){
- Result res = new Result();
- if(StringUtils.isBlank(bo.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- res.data(customerService.updateEnteringAudit(bo));
- return res;
- }
- /** 审核拒绝客户查询 **/
- @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
- public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
- return res;
- }
- /** 修改拒绝客户信息 **/
- @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
- public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
- Result res = new Result();
- if(StringUtils.isBlank(nickname)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
- return res;
- }
- if(StringUtils.isBlank(mobile)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
- return res;
- }
- if(StringUtils.isBlank(societyTag)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
- return res;
- }
- customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
- return res;
- }
- /** 查询客户的锁定业务 **/
- @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
- public Result getLockedProject(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
- return res;
- }
- res.setData(customerService.selectLockedProject(uid));
- return res;
- }
- /** 客户二次签项目业务 **/
- @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
- public Result againProjectTask(String uid,String projectId,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
- return res;
- }
- res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
- return res;
- }
- /** 客户资料转交 **/
- @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
- public Result updateInformationMaintainerr(String id,String aid){
- Result res = new Result();
- if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
- return res;
- }
- res.data(customerService.updateInformationMaintainerr(id,aid));
- return res;
- }
- /** 个人单位客户信息列表 **/
- @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
- public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
- return res;
- }
- /** 部门单位客户信息列表 **/
- @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
- public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
- Result res = new Result();
- res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
- return res;
- }
- /** 修改客户等级 **/
- @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
- public Result updateUserLevel(User u){
- Result res = new Result();
- if(StringUtils.isBlank(u.getId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
- return res;
- }
- if(null==u.getLevel()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
- return res;
- }
- res.data(customerService.updateUserLevel(u));
- return res;
- }
- /** 释放客户 **/
- @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
- public Result pushReleaseUser(String id){
- Result res = new Result();
- if(StringUtils.isBlank(id)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
- return res;
- }
- res.data(customerService.pushReleaseUser(id));
- return res;
- }
- /**
- * 企业项目申报材料上传
- *
- * @param req
- * @param uid
- * @return
- */
- @RequestMapping(value = "/upload", method = RequestMethod.POST)
- public Result cognizanceFile(HttpServletRequest req, String uid, String id, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
- res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 企业项目申报材料预览授权
- *
- * @param id
- * @param sign
- * @return
- */
- @RequestMapping(value = "/techProject", method = RequestMethod.GET)
- public Result previewTechProject(String id, String sign) {
- Result res = new Result();
- if (StringUtils.isEmpty(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
- return res;
- }
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
- String time = String.valueOf(Calendar.getInstance().getTime().getTime());
- String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
- res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 查看营销员客户统计
- * @param depId
- * @param startTime
- * @param endTime
- * @param pageSize
- * @param pageNo
- * @return
- */
- @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
- public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
- Result res = new Result();
- res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
- return res;
- }
- /**
- * 查看客户统计
- * @param depId 部门编号
- * @param startTime 开始时间
- * @param endTime 结束时间
- * @return
- */
- @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
- public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
- Result res = new Result();
- res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
- return res;
- }
- /**
- * 查看客户日期内新增客户
- * @param startTime
- * @param endTime
- * @param type 0私有 1渠道 2签单 3私有新增 4渠道新增 5私有面谈 6渠道面谈 7私有领取
- * @param pageSize
- * @param pageNo
- * @return
- */
- @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
- public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
- Result res = new Result();
- res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
- return res;
- }
- /**
- *
- * @param inputId 业务转移客户id(接收者)
- * @param uid 被转移的客户
- * @param pid 呗转移的业务
- * @return
- */
- @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
- public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
- Result res = new Result();
- if (StringUtils.isBlank(inputId)) {
- res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
- return res;
- }
- int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
- if (i<1) {
- res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
- return res;
- }
- res.data(i);
- return res;
- }
- /**
- * 渠道客户列表
- **/
- @RequestMapping(value = "/listChannelCustomer" , method = RequestMethod.POST)
- public Result listChannelCustomer(InputListChannel in){
- Result res = new Result();
- res.setData(customerService.listChannelCustomer(in));
- return res;
- }
- /**
- * 渠道客户统计列表
- **/
- @RequestMapping(value = "/listChannelCounts" , method = RequestMethod.GET)
- public Result listChannelCounts(InputChannelCounts in){
- Result res = new Result();
- res.setData(customerService.listChannelCounts(in));
- return res;
- }
- /**
- * 渠道客户转交
- * @param userIds 用户编号集
- * @param receiveId 接受者
- * @param remarks 备注
- * @param type 0 分配 1转交 2回退
- * @return
- */
- @RequestMapping(value = "/channelCustomerDeliver", method = RequestMethod.POST)
- public Result channelCustomerDeliver(String userIds ,String receiveId,String remarks,Integer type){
- Result res = new Result();
- if (StringUtils.isBlank(userIds)) {
- res.getError().add(buildError("","用户编号不存在"));
- return res;
- }
- String [] str=userIds.split(",");
- List<String> uids=Arrays.asList(str);
- if (type==1&&customerService.checkChannel(uids)) {
- res.getError().add(buildError("","已跟进,禁止分配!"));
- return res;
- }
- if (type==2&&customerService.checkRecovery(uids)) {
- res.getError().add(buildError("","不允许二次回退"));
- return res;
- }
- res.setData(customerService.pushChannelDeliver( uids , receiveId,remarks,type));
- return res;
- }
- /** 修改客户名称 **/
- @RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
- public Result updateUserName(String uid,String userName){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(userName)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,null,"uid或者名称"));
- return res;
- }
- if (userName!=null){
- userName=userName.trim();
- }
- if(customerService.checkUserName(userName)){
- res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_EXIST,null,"["+userName+"]"));
- return res;
- }
- res.data(customerService.updateUserName(uid,userName));
- return res;
- }
- @RequestMapping(value = "/checkUserName",method = RequestMethod.GET)
- public Result checkUserName(String userName){
- Result res =new Result();
- res.data(customerService.checkUserName(userName));
- return res;
- }
- /** 修改客户关键资料 **/
- @RequestMapping(value = "/updateUserDate", method = RequestMethod.POST)
- public Result updateUserDate(String uid,Integer province,Integer city,Integer area,String businessScope,String intendedProject,String introduction
- ,Integer channelType,String orgCode){
- Result res = new Result();
- if (orgCode!=null){
- orgCode=orgCode.trim();
- if (customerService.checkOrgCode(orgCode)){
- res.getError().add(buildError("","统一信用代码已存在"));
- return res;
- }
- }
- res.data(customerService.updateUserDate(uid, province, city, area, businessScope, intendedProject,introduction,channelType,orgCode));
- return res;
- }
- /** 客户名称列表 **/
- @RequestMapping(value = "/listUserName", method = RequestMethod.GET)
- public Result listUserName(String uid){
- Result res = new Result();
- if(StringUtils.isBlank(uid) || StringUtils.isBlank(uid)){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"uid","uid"));
- return res;
- }
- res.data(customerService.listUserName(uid));
- return res;
- }
- /**
- * 客户主营产品列表
- * @return
- */
- @RequestMapping(value = "/mainProductsList", method = RequestMethod.GET)
- public Result mainProductsList(InputMainProductsList in){
- Result res = new Result();
- res.data(customerService.mainProductsList(in));
- return res;
- }
- /**
- * 用户信息日志
- * @param uid
- * @return
- */
- @RequestMapping(value = "/userDateLogList",method = RequestMethod.GET)
- public Result userDateLogList(String uid){
- Result res =new Result();
- res.data(customerService.userDateLogList(uid));
- return res;
- }
- /**
- * 修改用户主营产品
- * @param id
- * @param businessScope
- * @return
- */
- @RequestMapping(value = "/updateUserBusinessScope",method = RequestMethod.POST)
- public Result updateUserBusinessScope(String id,String businessScope){
- Result res=new Result();
- if (id==null||businessScope==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
- return res;
- }
- res.data(customerService.updateuserBusinessScope(id,businessScope));
- return res;
- }
- @RequestMapping(value = "/queryUserMax",method = RequestMethod.GET)
- public Result queryUserMax(){
- Result res =new Result();
- res.setData(customerService.queryUserMax());
- return res;
- }
- }
|