AdminCustomerApiController.java 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. package com.goafanti.customer.controller;
  2. import java.io.IOException;
  3. import java.io.OutputStream;
  4. import java.lang.reflect.InvocationTargetException;
  5. import java.text.DateFormat;
  6. import java.text.ParseException;
  7. import java.text.SimpleDateFormat;
  8. import java.util.ArrayList;
  9. import java.util.Arrays;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12. import java.util.List;
  13. import java.util.Set;
  14. import java.util.TreeSet;
  15. import javax.annotation.Resource;
  16. import javax.servlet.http.HttpServletRequest;
  17. import javax.servlet.http.HttpServletResponse;
  18. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  19. import org.springframework.beans.factory.annotation.Value;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestMethod;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import com.alibaba.fastjson.JSON;
  24. import com.alibaba.fastjson.JSONArray;
  25. import com.goafanti.admin.service.AdminService;
  26. import com.goafanti.admin.service.AttachmentService;
  27. import com.goafanti.common.bo.Error;
  28. import com.goafanti.common.bo.Result;
  29. import com.goafanti.common.constant.AFTConstants;
  30. import com.goafanti.common.constant.ErrorConstants;
  31. import com.goafanti.common.controller.BaseApiController;
  32. import com.goafanti.common.enums.AttachmentType;
  33. import com.goafanti.common.error.BusinessException;
  34. import com.goafanti.common.model.Attachment;
  35. import com.goafanti.common.model.OrganizationContactBook;
  36. import com.goafanti.common.model.User;
  37. import com.goafanti.common.utils.BeanUtilsExt;
  38. import com.goafanti.common.utils.DateUtils;
  39. import com.goafanti.common.utils.ExcelUtils;
  40. import com.goafanti.common.utils.SHA256Util;
  41. import com.goafanti.common.utils.StringUtils;
  42. import com.goafanti.core.shiro.token.TokenManager;
  43. import com.goafanti.customer.bo.BusinessListBo;
  44. import com.goafanti.customer.bo.BussinessFollowBo;
  45. import com.goafanti.customer.bo.CustomerExcelBo;
  46. import com.goafanti.customer.bo.CustomerListIn;
  47. import com.goafanti.customer.bo.CustomerListOut;
  48. import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
  49. import com.goafanti.customer.bo.CustomerPersonalDetailBo;
  50. import com.goafanti.customer.bo.FollowBusinessBo;
  51. import com.goafanti.customer.bo.InputChannelCounts;
  52. import com.goafanti.customer.bo.InputListChannel;
  53. import com.goafanti.customer.bo.UserDetailBo;
  54. import com.goafanti.customer.service.CustomerService;
  55. import com.goafanti.customer.service.impl.AdminOrgAnnualReportServiceImpl;
  56. @RestController
  57. @RequestMapping("/api/admin/customer")
  58. public class AdminCustomerApiController extends BaseApiController{
  59. @Resource
  60. private CustomerService customerService;
  61. @Resource
  62. private AdminOrgAnnualReportServiceImpl adminOrgAnnualReportService;
  63. @Resource
  64. private AttachmentService aftFileService;
  65. @Value(value = "${upload.private.path}")
  66. private String uploadPrivatePath = null;
  67. @Resource
  68. private AdminService adminService;
  69. @Value(value = "${aesSecretKey}")
  70. private String secretKey = null;
  71. /** 私有个人客户列表 **/
  72. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  73. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  74. Result res = new Result();
  75. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  76. return res;
  77. }
  78. /** 公共个人客户列表 **/
  79. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  80. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  81. Result res = new Result();
  82. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  83. return res;
  84. }
  85. /** 个人客户查询 **/
  86. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  87. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  88. Result res = new Result();
  89. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  90. return res;
  91. }
  92. /** 管理个人客户查询 **/
  93. @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
  94. public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  95. Result res = new Result();
  96. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
  97. cli.setAid(TokenManager.getAdminId());
  98. }
  99. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  100. return res;
  101. }
  102. /** 专家查询 **/
  103. @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
  104. public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  105. Result res = new Result();
  106. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  107. return res;
  108. }
  109. /**
  110. * 私有单位客户列表
  111. * 私有客户列表
  112. **/
  113. @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
  114. public Result listPrivateOrganizationCustomer(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  115. Result res = new Result();
  116. //
  117. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 0, pageNo, pageSize));
  118. return res;
  119. }
  120. /** 跟进管理列表
  121. * 跟进列表
  122. **/
  123. @RequestMapping(value = "/listFollowManagement" , method = RequestMethod.GET)
  124. public Result listFollowManagement(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  125. Result res = new Result();
  126. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 1, pageNo, pageSize));
  127. return res;
  128. }
  129. /**
  130. * 私有单位客户导出xls
  131. * @throws IOException
  132. */
  133. @RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
  134. public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
  135. Result res = new Result();
  136. XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
  137. String fileName = "我的客户列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  138. OutputStream out = null;
  139. try {
  140. out = response.getOutputStream();
  141. } catch (IOException e) {
  142. e.printStackTrace();
  143. }
  144. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  145. response.setContentType("application/octet-stream;charset=utf-8");
  146. try {
  147. // 返回数据流
  148. wb.write(out);
  149. out.flush();
  150. out.close();
  151. } finally {
  152. out.flush();
  153. out.close();
  154. }
  155. return res;
  156. }
  157. /** 公共单位客户列表 **/
  158. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  159. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  160. Result res = new Result();
  161. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  162. return res;
  163. }
  164. /** 单位客户查询 **/
  165. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  166. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  167. Result res = new Result();
  168. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  169. return res;
  170. }
  171. /** 管理单位客户查询 **/
  172. @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
  173. public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  174. Result res = new Result();
  175. res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
  176. return res;
  177. }
  178. /** 签单的单位客户 **/
  179. @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
  180. public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  181. Result res = new Result();
  182. res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
  183. return res;
  184. }
  185. /** 签单的个人客户 **/
  186. @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
  187. public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  188. Result res = new Result();
  189. res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
  190. return res;
  191. }
  192. /** 签单客户转交 **/
  193. @RequestMapping(value = "/customerHandOver", method = RequestMethod.POST)
  194. public Result listSignPersonalCustomer(String userIds ,String receiveId){
  195. Result res = new Result();
  196. res.setData(customerService.customerHandOver( userIds , receiveId));
  197. return res;
  198. }
  199. /** 客户即时检索 **/
  200. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  201. public Result findCustomerByName(String name){
  202. Result res = new Result();
  203. res.setData(customerService.findCustomerByName(name));
  204. return res;
  205. }
  206. /** 客户即时检索(可签单客户) **/
  207. @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
  208. public Result getCustomerByName(String name,Integer type){
  209. Result res = new Result();
  210. if(type == null){
  211. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  212. return res;
  213. }
  214. if(name.length()<2) return res;
  215. if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
  216. if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
  217. if(type == 2) res.setData(customerService.getChannelCustomerByName(name));
  218. return res;
  219. }
  220. /** 客户查询 **/
  221. @RequestMapping(value = "/getUserByName",method = RequestMethod.GET)
  222. public Result getUserByName(String name){
  223. Result res = new Result();
  224. if(StringUtils.isEmpty(name)){
  225. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
  226. return res;
  227. }
  228. if(name.length()<2) return res;
  229. res.data(customerService.getUserByName(name));
  230. return res;
  231. }
  232. /** 添加客户基本信息
  233. * @throws Exception
  234. * @throws NumberFormatException **/
  235. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  236. public Result addCustomer(String name,String contacts,String contactMobile,Integer type,
  237. Integer province ,Integer city, Integer area,Integer source,String societyTag) throws Exception{
  238. Result res = new Result();
  239. if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
  240. || StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)||null==province||null==city||null==area){
  241. res.getError().add(buildError("","客户名称、联系人、联系电话、社会性质、地址不能为空"));
  242. return res;
  243. }
  244. if (customerService.checkMax(TokenManager.getAdminId())) {
  245. res.getError().add(buildError("","私有客户已达最大限制"));
  246. return res;
  247. }
  248. //将新增客户的空格去除
  249. customerService.addCustomer(name.replace(" ", ""), contacts, contactMobile,type,source,societyTag,province,city,area);
  250. return res;
  251. }
  252. /** 个人客户详情信息 **/
  253. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  254. public Result findPersonalCustomerDetail(String uid){
  255. Result res = new Result();
  256. res.setData(customerService.findPersonalCustomerDetail(uid));
  257. return res;
  258. }
  259. /** 单位客户详情信息 **/
  260. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  261. public Result findOrganizationCustomerDetail(String uid){
  262. Result res = new Result();
  263. res.setData(customerService.findOrganizationCustomerDetail(uid));
  264. return res;
  265. }
  266. /** 修改单位客户信息 **/
  267. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  268. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  269. Result res = new Result();
  270. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  271. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  272. return res;
  273. }
  274. customerService.updateOrganizationCustomer(bo);
  275. return res;
  276. }
  277. /** 修改个人客户信息 **/
  278. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  279. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  280. Result res = new Result();
  281. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  282. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  283. return res;
  284. }
  285. customerService.updatePersonalCustomer(bo);
  286. return res;
  287. }
  288. /** 查看跟进记录 **/
  289. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  290. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
  291. Result res = new Result();
  292. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
  293. return res;
  294. }
  295. /** 指导已读 **/
  296. @RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
  297. public Result pushGuidance(String uid){
  298. Result res = new Result();
  299. if (StringUtils.isBlank(uid)) {
  300. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  301. return res;
  302. }
  303. res.setData(customerService.pushGuidance(uid));
  304. return res;
  305. }
  306. /** 新增指导意见 **/
  307. @RequestMapping(value = "/addGuidance", method = RequestMethod.POST)
  308. public Result addGuidance(String followId,String guidance){
  309. Result res = new Result();
  310. if (StringUtils.isBlank(followId)||StringUtils.isBlank(guidance)) {
  311. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号、指导意见","编号、指导意见"));
  312. return res;
  313. }
  314. res.setData(customerService.addGuidance( followId, guidance));
  315. return res;
  316. }
  317. /** 查看客户账户信息 **/
  318. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  319. public Result findUserAcountDetail(String uid){
  320. Result res = new Result();
  321. UserDetailBo bo = new UserDetailBo();
  322. User user = customerService.findUserAccountDetail(uid);
  323. try {
  324. BeanUtilsExt.copyProperties(bo, user);
  325. } catch (InvocationTargetException | IllegalAccessException e) {
  326. e.printStackTrace();
  327. }
  328. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  329. bo.setCreateTimes(format.format(user.getCreateTime()));
  330. res.setData(bo);
  331. return res;
  332. }
  333. /** 修改客户账户信息 **/
  334. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  335. public Result updateUserAccount(User user){
  336. Result res = new Result();
  337. customerService.updateUserAccount(user);
  338. return res;
  339. }
  340. /** 查看客户联系人列表 **/
  341. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  342. public Result findCustomerContacts(String uid){
  343. Result res = new Result();
  344. res.setData(customerService.findCustomerContacts(uid));
  345. return res;
  346. }
  347. /** 针对已作拜访的业务作跟进 **/
  348. @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
  349. public Result toAddFollowOnHistory(String uid){
  350. Result res = new Result();
  351. if(StringUtils.isBlank(uid)){
  352. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  353. return res;
  354. }
  355. User user = customerService.findUserAccountDetail(uid);
  356. FollowBusinessBo fbb = new FollowBusinessBo();
  357. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  358. fbb.setFollowTime(format.format(new Date()));
  359. fbb.setIdentifyName(user.getIdentifyName());
  360. fbb.setUid(uid);
  361. fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  362. res.setData(fbb);
  363. return res;
  364. }
  365. /** 针对已锁定的业务作跟进 **/
  366. @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
  367. public Result toAddFollowOnLock(String uid){
  368. Result res = new Result();
  369. if(StringUtils.isBlank(uid)){
  370. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  371. return res;
  372. }
  373. User user = customerService.findUserAccountDetail(uid);
  374. FollowBusinessBo fbb = new FollowBusinessBo();
  375. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  376. fbb.setFollowTime(format.format(new Date()));
  377. fbb.setIdentifyName(user.getIdentifyName());
  378. fbb.setUid(uid);
  379. fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
  380. res.setData(fbb);
  381. return res;
  382. }
  383. /** 添加拜访记录
  384. * @throws ParseException
  385. * @throws Exception **/
  386. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  387. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
  388. Result res = new Result();
  389. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  390. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  391. return res;
  392. }
  393. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  394. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  395. if (ja != null && !ja.isEmpty()) {
  396. BusinessListBo userBusiness = null;
  397. for (int idx = 0; idx < ja.size(); idx++) {
  398. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  399. for(BusinessListBo ub:list){
  400. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  401. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  402. return res;
  403. }
  404. }
  405. list.add(userBusiness);
  406. }
  407. }
  408. FollowBusinessBo fbb = new FollowBusinessBo();
  409. fbb.setOcbId(ocbId);
  410. fbb.setUid(uid);
  411. fbb.setContactType(contactType);
  412. fbb.setResult(result);
  413. fbb.setFollowTime(followTime);
  414. fbb.setUserBusinessList(list);
  415. customerService.addFollow(fbb,null);
  416. return res;
  417. }
  418. /** 进入修改拜访记录 **/
  419. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  420. public Result toUpdateFollow(String followId){
  421. Result res = new Result();
  422. FollowBusinessBo fbb = customerService.findFollowById(followId);
  423. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  424. res.setData(fbb);
  425. return res;
  426. }
  427. /** 修改拜访记录
  428. * @throws ParseException
  429. * @throws BusinessException
  430. */
  431. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  432. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  433. Result res = new Result();
  434. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  435. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  436. return res;
  437. }
  438. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  439. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  440. if (ja != null && !ja.isEmpty()) {
  441. BusinessListBo userBusiness = null;
  442. for (int idx = 0; idx < ja.size(); idx++) {
  443. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  444. for(BusinessListBo ub:list){
  445. if(ub.getBusinessProjectId() == userBusiness.getBusinessProjectId()){
  446. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  447. return res;
  448. }
  449. }
  450. list.add(userBusiness);
  451. }
  452. }
  453. FollowBusinessBo fbb = new FollowBusinessBo();
  454. fbb.setFollowTime(followTime);
  455. fbb.setUid(uid);
  456. fbb.setContactType(contactType);
  457. fbb.setResult(result);
  458. fbb.setUserBusinessList(list);
  459. fbb.setFollowId(followId);
  460. customerService.updateFollow(fbb);
  461. return res;
  462. }
  463. /** 删除跟进记录 **/
  464. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  465. public Result deleteFollow(String followId){
  466. Result res = new Result();
  467. if(StringUtils.isBlank(followId)){
  468. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  469. return res;
  470. }
  471. customerService.deleteFollow(followId);
  472. return res;
  473. }
  474. /** 查询客户的所有联系人 **/
  475. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  476. public Result findAllContacts(String uid){
  477. Result res = new Result();
  478. res.setData(customerService.findAllContacts(uid));
  479. return res;
  480. }
  481. /** 修改企业联系人 **/
  482. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  483. public Result updateCustomerContacts(String contactList,String uid){
  484. Result res = new Result();
  485. if(StringUtils.isBlank(uid)){
  486. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  487. return res;
  488. }
  489. JSONArray ja = (JSONArray) JSON.parse(contactList);
  490. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  491. OrganizationContactBook ocb = null;
  492. if(ja != null & !ja.isEmpty()){
  493. for (int idx = 0; idx < ja.size(); idx++) {
  494. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  495. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  496. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  497. return res;
  498. }
  499. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  500. ocbList.add(ocb);
  501. }
  502. }
  503. customerService.updateCustomerContacts(ocbList,uid);
  504. return res;
  505. }
  506. /** 领取客户 **/
  507. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  508. public Result receiveCustomer(String uid,String oldAid){
  509. Result res = new Result();
  510. if(StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")){
  511. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  512. return res;
  513. }
  514. if (customerService.checkMax(TokenManager.getAdminId())) {
  515. res.getError().add(buildError("","私有客户已达最大限制"));
  516. return res;
  517. }
  518. if (customerService.checkBeforeChannel(uid)) {
  519. res.getError().add(buildError("","渠道客户丢失后不可再领取"));
  520. return res;
  521. }
  522. customerService.updateByOperatorType(uid, oldAid,AFTConstants.USER_RECEIVE);
  523. return res;
  524. }
  525. /**
  526. * 上传excel文档
  527. * @param req
  528. * @return
  529. */
  530. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  531. public Result uploadExcel(HttpServletRequest req){
  532. Result res = new Result();
  533. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  534. ExcelUtils utils = new ExcelUtils();
  535. Set<CustomerExcelBo> boSet;
  536. try {
  537. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  538. String errorMessage = "";
  539. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  540. errorMessage += utils.getVacantRows();
  541. if(StringUtils.isNotBlank(errorMessage)) {
  542. res.getError().add(new Error(errorMessage));
  543. return res;
  544. }
  545. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  546. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  547. customerService.checkCustomer(boSet,existRows,filterRows);
  548. if(existRows.size()>0){
  549. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  550. res.getError().add(new Error(errorMessage));
  551. return res;
  552. }
  553. if(filterRows.size()>0){
  554. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  555. res.getError().add(new Error(errorMessage));
  556. return res;
  557. }
  558. customerService.saveUploadData(boSet);
  559. } catch (IOException e) {
  560. e.printStackTrace();
  561. }
  562. return res;
  563. }
  564. /**
  565. * 下载科技成果批量导入Excel模板
  566. */
  567. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  568. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  569. Result res = new Result();
  570. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  571. Attachment af = aftFileService.selectAftFileBySign("organization_customer_template");
  572. if (null == af) {
  573. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  574. } else {
  575. String path = af.getFilePath();
  576. String suffix = path.substring(path.lastIndexOf("."));
  577. String fileName = af.getFileName() + suffix;
  578. downloadFile(response, fileName, path);
  579. }
  580. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  581. Attachment af = aftFileService.selectAftFileBySign("personal_customer_template");
  582. if (null == af) {
  583. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  584. } else {
  585. String path = af.getFilePath();
  586. String suffix = path.substring(path.lastIndexOf("."));
  587. String fileName = af.getFileName() + suffix;
  588. downloadFile(response, fileName, path);
  589. }
  590. }
  591. return res;
  592. }
  593. /** 转为公共客户 **/
  594. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  595. public Result transferToPublic(String uid,String aid){
  596. Result res = new Result();
  597. if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
  598. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  599. }
  600. customerService.updateByOperatorType(uid, aid, AFTConstants.USER_TRANSFER_TO_PUBLIC);
  601. return res;
  602. }
  603. /** 图片上传 **/
  604. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  605. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  606. Result res = new Result();
  607. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  608. return res;
  609. }
  610. /**
  611. *
  612. * @param startDate 开始日期
  613. * @param endDate 结束日期
  614. * @param timeSpan 时间差
  615. * @param depId 部门编号
  616. * @param pageNo 页码
  617. * @param pageSize 页数
  618. * @return
  619. * @throws ParseException
  620. */
  621. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  622. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  623. Result res = new Result();
  624. Date sDate = null;
  625. Date eDate = null;
  626. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  627. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  628. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  629. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  630. Date date = new Date();
  631. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  632. sDate = DateUtils.getYesterday();
  633. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  634. sDate = DateUtils.getLastDayOfLastWeek(date);
  635. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  636. sDate = DateUtils.getLastDayOfLastMonth(date);
  637. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  638. sDate = DateUtils.getLastDayOfLastQuarter(date);
  639. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  640. sDate = DateUtils.getLastDayOfLastYear(date);
  641. }
  642. }
  643. res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  644. return res;
  645. }
  646. /**
  647. *
  648. * @param startDate 开始日期
  649. * @param endDate 结束日期
  650. * @param timeSpan 时间差
  651. * @param depId 部门编号
  652. * @param businessGlossoryId 业务编号
  653. * @param pageNo 页码
  654. * @param pageSiz 页数
  655. * @return
  656. * @throws ParseException
  657. */
  658. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  659. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  660. Result res = new Result();
  661. Date sDate = null;
  662. Date eDate = null;
  663. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  664. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  665. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  666. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  667. Date date = new Date();
  668. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  669. sDate = DateUtils.getYesterday();
  670. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  671. sDate = DateUtils.getLastDayOfLastWeek(date);
  672. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  673. sDate = DateUtils.getLastDayOfLastMonth(date);
  674. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  675. sDate = DateUtils.getLastDayOfLastQuarter(date);
  676. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  677. sDate = DateUtils.getLastDayOfLastYear(date);
  678. }
  679. }
  680. res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  681. return res;
  682. }
  683. /**
  684. *
  685. * @param startDate 开始日期
  686. * @param endDate 结束日期
  687. * @param timeSpan 时间差
  688. * @param depId 部门编号
  689. * @param businessGlossoryId 业务编号
  690. * @param pageNo 页码
  691. * @param pageSiz 页数
  692. * @return
  693. * @throws ParseException
  694. */
  695. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  696. public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
  697. Result res = new Result();
  698. Date sDate = null;
  699. Date eDate = null;
  700. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  701. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  702. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  703. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  704. Date date = new Date();
  705. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  706. sDate = DateUtils.getYesterday();
  707. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  708. sDate = DateUtils.getLastDayOfLastWeek(date);
  709. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  710. sDate = DateUtils.getLastDayOfLastMonth(date);
  711. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  712. sDate = DateUtils.getLastDayOfLastQuarter(date);
  713. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  714. sDate = DateUtils.getLastDayOfLastYear(date);
  715. }
  716. }
  717. res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
  718. return res;
  719. }
  720. /** 管理员列表 **/
  721. @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
  722. public Result listAdminByName(String adminName){
  723. Result res = new Result();
  724. if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName));
  725. return res;
  726. }
  727. /** 转交客户到制定人 **/
  728. @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
  729. public Result transferToOther(String uid,String aid,Integer operatorType,String oldAid){
  730. Result res = new Result();
  731. if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
  732. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
  733. return res;
  734. }
  735. //默认为私有转交,4为签单转交
  736. if (operatorType==null) {
  737. operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
  738. }
  739. if (operatorType !=AFTConstants.SIGN_USER_TRANSFER_TO_OTHER&& customerService.checkMax(aid)) {
  740. res.getError().add(buildError("","对方私有客户已达最大限制"));
  741. return res;
  742. }
  743. customerService.updateByOperatorType(uid,oldAid,operatorType, aid);
  744. return res;
  745. }
  746. /**
  747. * 客户转交记录
  748. * @param uid 客户编号
  749. * @param aid 管理员编号
  750. * @param oldAid 接收者编号
  751. * @return
  752. */
  753. @RequestMapping(value = "/transferList", method = RequestMethod.GET)
  754. public Result transferList(String uid){
  755. Result res = new Result();
  756. if(StringUtils.isBlank(uid) ){
  757. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
  758. return res;
  759. }
  760. res.data(customerService.transferList( uid));
  761. return res;
  762. }
  763. /** 查询我的业务列表 **/
  764. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  765. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  766. Result res = new Result();
  767. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  768. return res;
  769. }
  770. /** 查询所有的业务列表 **/
  771. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  772. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  773. Result res = new Result();
  774. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  775. return res;
  776. }
  777. /** 业务管理列表 **/
  778. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  779. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  780. Result res = new Result();
  781. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  782. return res;
  783. }
  784. /** 查询业务字典 **/
  785. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  786. public Result findBusinessGlossory(){
  787. Result res = new Result();
  788. res.setData(customerService.findBusinessGlossory());
  789. return res;
  790. }
  791. /** 新增客户意向 **/
  792. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  793. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  794. Result res = new Result();
  795. if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
  796. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  797. return res;
  798. }
  799. if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
  800. res.getError().add(new Error("该项业务已经被跟进"));
  801. return res;
  802. }
  803. try {
  804. customerService.addBusinessAndFollow(bfb);
  805. } catch (ParseException e) {
  806. e.printStackTrace();
  807. }
  808. return res;
  809. }
  810. /** 进入新增意向服务 **/
  811. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  812. public Result toAddBusinessAndFollow(){
  813. Result res = new Result();
  814. BussinessFollowBo bo = new BussinessFollowBo();
  815. bo.setAdminName(TokenManager.getAdminToken().getName());
  816. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  817. bo.setCreateTime(format.format(new Date()));
  818. bo.setFollowTime(bo.getCreateTime());
  819. res.setData(bo);
  820. return res;
  821. }
  822. /** 进入修改业务意向 **/
  823. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  824. public Result toUpdateBusiness(String businessId){
  825. Result res = new Result();
  826. res.setData(customerService.findBusinessDetail(businessId));
  827. return res;
  828. }
  829. /** 修改业务意向 **/
  830. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  831. public Result updateBusiness(BussinessFollowBo bfb){
  832. Result res = new Result();
  833. customerService.updateBusiness(bfb);
  834. return res;
  835. }
  836. /** 进入跟进单个客户意向 **/
  837. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  838. public Result toAddFollowOneBusiness(String businessId){
  839. Result res = new Result();
  840. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  841. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  842. bo.setFollowTime(format.format(new Date()));
  843. res.setData(bo);
  844. return res;
  845. }
  846. /** 跟进单个客户意向 **/
  847. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  848. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  849. Result res = new Result();
  850. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  851. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  852. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  853. return res;
  854. }
  855. try {
  856. customerService.addFollowOneBusiness(bfb);
  857. } catch (ParseException e) {
  858. e.printStackTrace();
  859. }
  860. return res;
  861. }
  862. /** 进入修改某个客户一个业务的当次拜访 **/
  863. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  864. public Result toUpdateFollowOneBusiness(String ufbId){
  865. Result res = new Result();
  866. if(StringUtils.isBlank(ufbId)) {
  867. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  868. return res;
  869. }
  870. res.setData(customerService.findFollowOneBusiness(ufbId));
  871. return res;
  872. }
  873. /** 修改某个客户一个业务的当次拜访 **/
  874. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  875. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  876. Result res = new Result();
  877. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  878. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  879. return res;
  880. }
  881. customerService.updateFollowOneBusiness(bfb);
  882. return res;
  883. }
  884. /** 删除某个客户一个业务的当次拜访 **/
  885. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  886. public Result deleteFollowOneBusiness(String ufbId){
  887. Result res = new Result();
  888. if(StringUtils.isBlank(ufbId)){
  889. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  890. return res;
  891. }
  892. customerService.deleteFollowOneBusiness(ufbId);
  893. return res;
  894. }
  895. /** 添加单个联系人 **/
  896. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  897. public Result addOneContact(OrganizationContactBook ocb){
  898. Result res = new Result();
  899. if(StringUtils.isBlank(ocb.getUid())){
  900. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  901. return res;
  902. }
  903. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  904. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  905. return res;
  906. }
  907. customerService.addOneContact(ocb);
  908. return res;
  909. }
  910. /** 删除单个联系人 **/
  911. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  912. public Result deleteOneContact(String ocbId){
  913. Result res = new Result();
  914. if(StringUtils.isBlank(ocbId)){
  915. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  916. return res;
  917. }
  918. customerService.deleteOneContact(ocbId);
  919. return res;
  920. }
  921. /** 修改主要联系人 **/
  922. @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
  923. public Result updateMainContact(String ocbId,String uid){
  924. Result res = new Result();
  925. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  926. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  927. return res;
  928. }
  929. customerService.updateMainContact(ocbId,uid);
  930. return res;
  931. }
  932. /** 删除 业务 **/
  933. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  934. public Result deleteBusiness(String businessId){
  935. Result res = new Result();
  936. if(StringUtils.isBlank(businessId)){
  937. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  938. return res;
  939. }
  940. customerService.deleteBusiness(businessId);
  941. return res;
  942. }
  943. /** 停止业务 **/
  944. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  945. public Result stopBusiness(String businessId){
  946. Result res = new Result();
  947. if(StringUtils.isBlank(businessId)){
  948. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  949. return res;
  950. }
  951. customerService.updateBusinessToStop(businessId);
  952. return res;
  953. }
  954. /** 客户分配查询(本部门) **/
  955. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  956. public Result findAdminName(){
  957. Result res = new Result();
  958. res.setData(customerService.findAdminName());
  959. return res;
  960. }
  961. /** 分配个人客户 **/
  962. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  963. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  964. Result res = new Result();
  965. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  966. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  967. return res;
  968. }
  969. customerService.updatePersonalCustomerz(bo);
  970. return res;
  971. }
  972. /** 客户录入审核 **/
  973. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  974. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  975. Result res = new Result();
  976. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  977. return res;
  978. }
  979. /** 修改客户录入审核状态 **/
  980. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  981. public Result updateEnteringAudit(User bo){
  982. Result res = new Result();
  983. if(StringUtils.isBlank(bo.getId())){
  984. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  985. return res;
  986. }
  987. res.data(customerService.updateEnteringAudit(bo));
  988. return res;
  989. }
  990. /** 审核拒绝客户查询 **/
  991. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  992. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  993. Result res = new Result();
  994. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  995. return res;
  996. }
  997. /** 修改拒绝客户信息 **/
  998. @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
  999. public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
  1000. Result res = new Result();
  1001. if(StringUtils.isBlank(nickname)){
  1002. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
  1003. return res;
  1004. }
  1005. if(StringUtils.isBlank(mobile)){
  1006. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
  1007. return res;
  1008. }
  1009. if(StringUtils.isBlank(societyTag)){
  1010. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
  1011. return res;
  1012. }
  1013. customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
  1014. return res;
  1015. }
  1016. /** 查询客户的锁定业务 **/
  1017. @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
  1018. public Result getLockedProject(String uid){
  1019. Result res = new Result();
  1020. if(StringUtils.isBlank(uid)){
  1021. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
  1022. return res;
  1023. }
  1024. res.setData(customerService.selectLockedProject(uid));
  1025. return res;
  1026. }
  1027. /** 客户二次签项目业务 **/
  1028. @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
  1029. public Result againProjectTask(String uid,String projectId,String aid){
  1030. Result res = new Result();
  1031. if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
  1032. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
  1033. return res;
  1034. }
  1035. res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
  1036. return res;
  1037. }
  1038. /** 客户资料转交 **/
  1039. @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
  1040. public Result updateInformationMaintainerr(String id,String aid){
  1041. Result res = new Result();
  1042. if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
  1043. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1044. return res;
  1045. }
  1046. res.data(customerService.updateInformationMaintainerr(id,aid));
  1047. return res;
  1048. }
  1049. /** 个人单位客户信息列表 **/
  1050. @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
  1051. public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1052. Result res = new Result();
  1053. res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
  1054. return res;
  1055. }
  1056. /** 部门单位客户信息列表 **/
  1057. @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
  1058. public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1059. Result res = new Result();
  1060. res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
  1061. return res;
  1062. }
  1063. /** 修改客户等级 **/
  1064. @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
  1065. public Result updateUserLevel(User u){
  1066. Result res = new Result();
  1067. if(StringUtils.isBlank(u.getId())){
  1068. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1069. return res;
  1070. }
  1071. if(null==u.getLevel()){
  1072. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
  1073. return res;
  1074. }
  1075. res.data(customerService.updateUserLevel(u));
  1076. return res;
  1077. }
  1078. /** 释放客户 **/
  1079. @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
  1080. public Result pushReleaseUser(String id){
  1081. Result res = new Result();
  1082. if(StringUtils.isBlank(id)){
  1083. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1084. return res;
  1085. }
  1086. res.data(customerService.pushReleaseUser(id));
  1087. return res;
  1088. }
  1089. /**
  1090. * 企业项目申报材料上传
  1091. *
  1092. * @param req
  1093. * @param uid
  1094. * @return
  1095. */
  1096. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  1097. public Result cognizanceFile(HttpServletRequest req, String uid, String id, String sign) {
  1098. Result res = new Result();
  1099. AttachmentType attachmentType = AttachmentType.getField(sign);
  1100. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1101. res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
  1102. } else {
  1103. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1104. }
  1105. return res;
  1106. }
  1107. /**
  1108. * 企业项目申报材料预览授权
  1109. *
  1110. * @param id
  1111. * @param sign
  1112. * @return
  1113. */
  1114. @RequestMapping(value = "/techProject", method = RequestMethod.GET)
  1115. public Result previewTechProject(String id, String sign) {
  1116. Result res = new Result();
  1117. if (StringUtils.isEmpty(id)) {
  1118. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
  1119. return res;
  1120. }
  1121. AttachmentType attachmentType = AttachmentType.getField(sign);
  1122. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1123. String time = String.valueOf(Calendar.getInstance().getTime().getTime());
  1124. String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
  1125. res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
  1126. } else {
  1127. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1128. }
  1129. return res;
  1130. }
  1131. /**
  1132. * 查看营销员客户统计
  1133. * @param depId
  1134. * @param startTime
  1135. * @param endTime
  1136. * @param pageSize
  1137. * @param pageNo
  1138. * @return
  1139. */
  1140. @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
  1141. public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
  1142. Result res = new Result();
  1143. res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
  1144. return res;
  1145. }
  1146. /**
  1147. * 查看客户统计
  1148. * @param depId
  1149. * @param startTime
  1150. * @param endTime
  1151. * @param pageSize
  1152. * @param pageNo
  1153. * @return
  1154. */
  1155. @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
  1156. public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
  1157. Result res = new Result();
  1158. res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
  1159. return res;
  1160. }
  1161. /**
  1162. * 查看客户日期内新增客户
  1163. * @param depId
  1164. * @param startTime
  1165. * @param endTime
  1166. * @param type
  1167. * @param pageSize
  1168. * @param pageNo
  1169. * @return
  1170. */
  1171. @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
  1172. public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
  1173. Result res = new Result();
  1174. res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
  1175. return res;
  1176. }
  1177. /**
  1178. *
  1179. * @param inputId 业务转移客户id(接收者)
  1180. * @param uid 被转移的客户
  1181. * @param pid 呗转移的业务
  1182. * @return
  1183. */
  1184. @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
  1185. public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
  1186. Result res = new Result();
  1187. if (StringUtils.isBlank(inputId)) {
  1188. res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
  1189. return res;
  1190. }
  1191. int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
  1192. if (i<1) {
  1193. res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
  1194. return res;
  1195. }
  1196. res.data(i);
  1197. return res;
  1198. }
  1199. /**
  1200. * 渠道客户列表
  1201. **/
  1202. @RequestMapping(value = "/listChannelCustomer" , method = RequestMethod.POST)
  1203. public Result listChannelCustomer(InputListChannel in){
  1204. Result res = new Result();
  1205. res.setData(customerService.listChannelCustomer(in));
  1206. return res;
  1207. }
  1208. /**
  1209. * 渠道客户统计列表
  1210. **/
  1211. @RequestMapping(value = "/listChannelCounts" , method = RequestMethod.GET)
  1212. public Result listChannelCounts(InputChannelCounts in){
  1213. Result res = new Result();
  1214. res.setData(customerService.listChannelCounts(in));
  1215. return res;
  1216. }
  1217. /**
  1218. * 渠道客户转交
  1219. * @param userIds 用户编号集
  1220. * @param receiveId 接受者
  1221. * @param remarks 备注
  1222. * @param type 0 分配 1转交 2回退
  1223. * @return
  1224. */
  1225. @RequestMapping(value = "/channelCustomerDeliver", method = RequestMethod.POST)
  1226. public Result channelCustomerDeliver(String userIds ,String receiveId,String remarks,Integer type){
  1227. Result res = new Result();
  1228. if (StringUtils.isBlank(userIds)) {
  1229. res.getError().add(buildError("","用户编号不存在"));
  1230. return res;
  1231. }
  1232. String [] str=userIds.split(",");
  1233. List<String> uids=Arrays.asList(str);
  1234. if (type==1&&customerService.checkChannel(uids)) {
  1235. res.getError().add(buildError("","已跟进,禁止分配!"));
  1236. return res;
  1237. }
  1238. if (type==2&&customerService.checkRecovery(uids)) {
  1239. res.getError().add(buildError("","不允许二次回退"));
  1240. return res;
  1241. }
  1242. res.setData(customerService.pushChannelDeliver( uids , receiveId,remarks,type));
  1243. return res;
  1244. }
  1245. /** 修改客户名称 **/
  1246. @RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
  1247. public Result updateUserName(String uid,String userName){
  1248. Result res = new Result();
  1249. if(StringUtils.isBlank(uid) || StringUtils.isBlank(userName)){
  1250. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"uid或者名称","uid或者名称"));
  1251. return res;
  1252. }
  1253. customerService.updateUserName(uid,userName);
  1254. return res;
  1255. }
  1256. /** 客户名称 **/
  1257. @RequestMapping(value = "/listUserName", method = RequestMethod.GET)
  1258. public Result listUserName(String uid){
  1259. Result res = new Result();
  1260. if(StringUtils.isBlank(uid) || StringUtils.isBlank(uid)){
  1261. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"uid","uid"));
  1262. return res;
  1263. }
  1264. res.data(customerService.listUserName(uid));
  1265. return res;
  1266. }
  1267. }