AdminCustomerApiController.java 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. package com.goafanti.customer.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.goafanti.admin.service.AdminService;
  5. import com.goafanti.admin.service.AttachmentService;
  6. import com.goafanti.common.bo.Error;
  7. import com.goafanti.common.bo.Result;
  8. import com.goafanti.common.constant.AFTConstants;
  9. import com.goafanti.common.constant.ErrorConstants;
  10. import com.goafanti.common.controller.BaseApiController;
  11. import com.goafanti.common.enums.AttachmentType;
  12. import com.goafanti.common.error.BusinessException;
  13. import com.goafanti.common.model.Attachment;
  14. import com.goafanti.common.model.OrganizationContactBook;
  15. import com.goafanti.common.model.User;
  16. import com.goafanti.common.model.UserMid;
  17. import com.goafanti.common.utils.*;
  18. import com.goafanti.core.mybatis.page.Pagination;
  19. import com.goafanti.core.shiro.token.TokenManager;
  20. import com.goafanti.customer.bo.*;
  21. import com.goafanti.customer.service.CustomerService;
  22. import com.goafanti.customer.service.UserArchivesService;
  23. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  24. import org.springframework.beans.factory.annotation.Value;
  25. import org.springframework.validation.BindingResult;
  26. import org.springframework.validation.annotation.Validated;
  27. import org.springframework.web.bind.annotation.*;
  28. import org.springframework.web.multipart.MultipartFile;
  29. import javax.annotation.Resource;
  30. import javax.servlet.http.HttpServletRequest;
  31. import javax.servlet.http.HttpServletResponse;
  32. import java.io.IOException;
  33. import java.io.OutputStream;
  34. import java.lang.reflect.InvocationTargetException;
  35. import java.nio.charset.StandardCharsets;
  36. import java.text.DateFormat;
  37. import java.text.ParseException;
  38. import java.text.SimpleDateFormat;
  39. import java.util.*;
  40. @RestController
  41. @RequestMapping("/api/admin/customer")
  42. public class AdminCustomerApiController extends BaseApiController{
  43. @Resource
  44. private CustomerService customerService;
  45. @Resource
  46. private AttachmentService aftFileService;
  47. @Value(value = "${upload.private.path}")
  48. private String uploadPrivatePath = null;
  49. @Value(value = "${user.receive.max}")
  50. private Integer USER_RECEIVE_MAX = null;
  51. @Resource
  52. private AdminService adminService;
  53. @Resource
  54. private UserArchivesService userArchivesService;
  55. @Value(value = "${aesSecretKey}")
  56. private String secretKey = null;
  57. /** 私有个人客户列表 **/
  58. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  59. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  60. Result res = new Result();
  61. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  62. return res;
  63. }
  64. /** 公共个人客户列表 **/
  65. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  66. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  67. Result res = new Result();
  68. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  69. return res;
  70. }
  71. /** 个人客户查询 **/
  72. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  73. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  74. Result res = new Result();
  75. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  76. return res;
  77. }
  78. /** 签单的个人客户 **/
  79. @RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
  80. public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  81. Result res = new Result();
  82. res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
  83. return res;
  84. }
  85. /** 管理个人客户查询 **/
  86. @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
  87. public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  88. Result res = new Result();
  89. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
  90. cli.setAid(TokenManager.getAdminId());
  91. }
  92. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  93. return res;
  94. }
  95. /** 专家查询 **/
  96. @RequestMapping(value = "/listExpertCustomer" , method = RequestMethod.POST)
  97. public Result listExpertCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  98. Result res = new Result();
  99. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  100. return res;
  101. }
  102. /** 个人客户详情信息 **/
  103. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  104. public Result findPersonalCustomerDetail(String uid){
  105. Result res = new Result();
  106. res.setData(customerService.findPersonalCustomerDetail(uid));
  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. **/
  124. @RequestMapping(value = "/channelUserList" , method = RequestMethod.GET)
  125. public Result channelUserList(InputChannelListBo in ){
  126. Result res = new Result();
  127. in.setNewChannel(1);
  128. in.setShareType(0);
  129. res.setData(customerService.channelUserList(in));
  130. return res;
  131. }
  132. /**
  133. * 公共渠道客户列表
  134. *
  135. **/
  136. @RequestMapping(value = "/publicChannelUserList" , method = RequestMethod.GET)
  137. public Result publicChannelUserList(InputChannelListBo in ){
  138. Result res = new Result();
  139. in.setNewChannel(1);
  140. //获取公共
  141. in.setShareType(1);
  142. res.setData(customerService.channelUserList(in));
  143. return res;
  144. }
  145. /**
  146. * 渠道客户查询
  147. *
  148. **/
  149. @RequestMapping(value = "/selectChannelUserList" , method = RequestMethod.GET)
  150. public Result selectChannelUserList(InputChannelListBo in ){
  151. Result res = new Result();
  152. in.setNewChannel(1);
  153. if (in.getName()==null||in.getName().length()<2){
  154. res.getError().add(buildError("搜索名字必须大于2个字符"));
  155. return res;
  156. }
  157. res.setData(customerService.selectChannelUserList(in));
  158. return res;
  159. }
  160. /** 跟进管理列表
  161. * 跟进列表
  162. **/
  163. @RequestMapping(value = "/listFollowManagement" , method = RequestMethod.GET)
  164. public Result listFollowManagement(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize){
  165. Result res = new Result();
  166. res.setData(customerService.listPrivateOrganizationCustomer(cli, sort, sortType, 1, pageNo, pageSize));
  167. return res;
  168. }
  169. /**
  170. * 私有单位客户导出xls
  171. */
  172. @RequestMapping(value = "/privateUnitCustomerOutXls" , method = RequestMethod.GET)
  173. public Result privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize,HttpServletResponse response) throws IOException{
  174. Result res = new Result();
  175. XSSFWorkbook wb = customerService.privateUnitCustomerOutXls(cli, sort, sortType, pageNo, pageSize);
  176. String fileName = "我的客户列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  177. OutputStream out = null;
  178. try {
  179. out = response.getOutputStream();
  180. } catch (IOException e) {
  181. e.printStackTrace();
  182. }
  183. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), StandardCharsets.ISO_8859_1));
  184. response.setContentType("application/octet-stream;charset=utf-8");
  185. try {
  186. // 返回数据流
  187. wb.write(out);
  188. if (out != null) {
  189. out.flush();
  190. out.close();
  191. }
  192. } finally {
  193. if (out != null) {
  194. out.flush();
  195. out.close();
  196. }
  197. }
  198. return res;
  199. }
  200. /** 公共单位客户列表 **/
  201. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  202. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  203. Result res = new Result();
  204. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  205. return res;
  206. }
  207. /** 单位客户查询 **/
  208. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  209. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  210. Result res = new Result();
  211. if (StringUtils.isBlank(cli.getName())){
  212. res.setData( new Pagination<>());
  213. return res;
  214. }
  215. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  216. return res;
  217. }
  218. /** 管理单位客户查询 **/
  219. @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
  220. public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  221. Result res = new Result();
  222. res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
  223. return res;
  224. }
  225. /** 签单的单位客户 **/
  226. @RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
  227. public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  228. Result res = new Result();
  229. res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
  230. return res;
  231. }
  232. /** 签单客户转交 **/
  233. @RequestMapping(value = "/customerHandOver", method = RequestMethod.POST)
  234. public Result listSignPersonalCustomer(String userIds ,String receiveId){
  235. Result res = new Result();
  236. res.setData(customerService.customerHandOver( userIds , receiveId));
  237. return res;
  238. }
  239. /** 客户即时检索 **/
  240. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  241. public Result findCustomerByName(String name){
  242. Result res = new Result();
  243. res.setData(customerService.findCustomerByName(name));
  244. return res;
  245. }
  246. /** 客户即时检索(可签单客户) **/
  247. @RequestMapping(value = "/getCustomerByName",method = RequestMethod.GET)
  248. public Result getCustomerByName(String name,Integer type){
  249. Result res = new Result();
  250. if(type == null){
  251. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  252. return res;
  253. }
  254. if(name.length()<2) return res;
  255. if(type == 0) res.setData(customerService.getPrivateCustomerByName(name));
  256. if(type == 1) res.setData(customerService.getSignedCustomerByName(name));
  257. if(type == 2) res.setData(customerService.getChannelCustomerByName(name));
  258. if(type == 3) res.setData(customerService.getRestrictCustomerByName(name));
  259. return res;
  260. }
  261. /** 客户查询 **/
  262. @RequestMapping(value = "/getUserByName",method = RequestMethod.GET)
  263. public Result getUserByName(String name){
  264. Result res = new Result();
  265. if(StringUtils.isEmpty(name)){
  266. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
  267. return res;
  268. }
  269. if(name.length()<2) return res;
  270. res.data(customerService.getUserByName(name));
  271. return res;
  272. }
  273. /**
  274. * 客户查询
  275. * @param name 查询名称
  276. * @param type 分类 0默认 1小程序App
  277. */
  278. @RequestMapping(value = "/getUserByNames",method = RequestMethod.GET)
  279. public Result getUserByName(String name,Integer type,Integer pageNo,Integer pageSize){
  280. Result res = new Result();
  281. if(StringUtils.isEmpty(name)){
  282. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称","名称"));
  283. return res;
  284. }
  285. if(name.length()<2) return res;
  286. res.data(customerService.getUserByNames(name,type,pageNo,pageSize));
  287. return res;
  288. }
  289. /** 添加客户基本信息
  290. * **/
  291. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  292. public Result addCustomer(InputAddCustomer in) {
  293. Result res = new Result();
  294. if(StringUtils.isBlank(in.getName()) || StringUtils.isBlank(in.getContacts())
  295. || StringUtils.isBlank(in.getContactMobile()) ||null==in.getProvince()||null==in.getCity()||null==in.getArea()
  296. || StringUtils.isBlank(in.getBusinessScope())||null==in.getOrgCode()
  297. || StringUtils.isBlank(in.getIntendedProject())){
  298. res.getError().add(buildError("","创建客户参数不全"));
  299. return res;
  300. }
  301. //判断电话号码
  302. if (!RegexUtils.isMobile(in.getContactMobile())) {
  303. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "联系人电话格式错误", "联系人电话"));
  304. return res;
  305. }
  306. if (!customerService.checkAid(TokenManager.getAdminId(),Integer.valueOf(AFTConstants.CUSTOMER_SERVICE_SALESMAN))){
  307. if (customerService.checkMax(null,TokenManager.getAdminId())) {
  308. res.getError().add(buildError("","私有客户已达最大限制"));
  309. return res;
  310. }
  311. }
  312. if (customerService.checkOrgCode(in.getOrgCode())){
  313. res.getError().add(buildError("","统一信用代码已存在"));
  314. return res;
  315. }
  316. //新增为私有客户
  317. in.setShareType(0);
  318. //将新增客户的空格去除
  319. res.data(customerService.addCustomer(in));
  320. return res;
  321. }
  322. @RequestMapping(value = "/addChannel", method = RequestMethod.POST)
  323. public Result addChannel(@Validated InputAddCustomer in, BindingResult bindingResult) {
  324. Result res = new Result();
  325. if (bindingResult.hasErrors()) {
  326. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  327. ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
  328. return res;
  329. }
  330. if (customerService.checkUserName(null,in.getName())){
  331. res.getError().add(buildError("客户名称已存在"));
  332. return res;
  333. }
  334. //添加电话正则
  335. if (!RegexUtils.isMobile(in.getContactMobile())){
  336. res.getError().add(buildError("手机号码格式错误"));
  337. return res;
  338. }
  339. in.setType(1);
  340. //新增为私有客户
  341. in.setShareType(0);
  342. in.setNewChannel(1);
  343. //将新增客户的空格去除
  344. res.data(customerService.addCustomer(in));
  345. return res;
  346. }
  347. /** 单位客户详情信息 **/
  348. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  349. public Result findOrganizationCustomerDetail(String uid){
  350. Result res = new Result();
  351. res.setData(customerService.findOrganizationCustomerDetail(uid));
  352. return res;
  353. }
  354. /** 修改单位客户信息 **/
  355. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  356. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  357. Result res = new Result();
  358. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  359. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  360. return res;
  361. }
  362. customerService.updateOrganizationCustomer(bo);
  363. return res;
  364. }
  365. /** 修改个人客户信息 **/
  366. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  367. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  368. Result res = new Result();
  369. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  370. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  371. return res;
  372. }
  373. customerService.updatePersonalCustomer(bo);
  374. return res;
  375. }
  376. /** 查看跟进记录 **/
  377. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  378. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessProjectId,Integer type){
  379. Result res = new Result();
  380. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessProjectId,type));
  381. return res;
  382. }
  383. /** 指导已读 **/
  384. @RequestMapping(value = "/pushGuidance", method = RequestMethod.POST)
  385. public Result pushGuidance(String uid){
  386. Result res = new Result();
  387. if (StringUtils.isBlank(uid)) {
  388. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户编号"));
  389. return res;
  390. }
  391. res.setData(customerService.pushGuidance(uid));
  392. return res;
  393. }
  394. /** 新增指导意见 **/
  395. @RequestMapping(value = "/addGuidance", method = RequestMethod.POST)
  396. public Result addGuidance(String followId,String guidance){
  397. Result res = new Result();
  398. if (StringUtils.isBlank(followId)||StringUtils.isBlank(guidance)) {
  399. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号、指导意见","编号、指导意见"));
  400. return res;
  401. }
  402. res.setData(customerService.addGuidance( followId, guidance));
  403. return res;
  404. }
  405. /** 查看客户账户信息 **/
  406. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  407. public Result findUserAcountDetail(String uid){
  408. Result res = new Result();
  409. UserDetailBo bo = new UserDetailBo();
  410. User user = customerService.findUserAccountDetail(uid);
  411. try {
  412. BeanUtilsExt.copyProperties(bo, user);
  413. } catch (InvocationTargetException | IllegalAccessException e) {
  414. e.printStackTrace();
  415. }
  416. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  417. bo.setCreateTimes(format.format(user.getCreateTime()));
  418. res.setData(bo);
  419. return res;
  420. }
  421. /** 修改客户账户信息 **/
  422. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  423. public Result updateUserAccount(User user){
  424. Result res = new Result();
  425. customerService.updateUserAccount(user);
  426. return res;
  427. }
  428. /**
  429. * 查看客户联系人列表
  430. * @param uid 客户编号
  431. * @param type 联系人类型 0=我的联系人 1=所有联系人
  432. * **/
  433. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  434. public Result findCustomerContacts(String uid,Integer type){
  435. Result res = new Result();
  436. if (type==null)type=0;
  437. res.setData(customerService.findCustomerContacts(uid,type));
  438. return res;
  439. }
  440. /** 针对已作拜访的业务作跟进 **/
  441. @RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
  442. public Result toAddFollowOnHistory(String uid){
  443. Result res = new Result();
  444. if(StringUtils.isBlank(uid)){
  445. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  446. return res;
  447. }
  448. User user = customerService.findUserAccountDetail(uid);
  449. FollowBusinessBo fbb = new FollowBusinessBo();
  450. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  451. fbb.setFollowTime(format.format(new Date()));
  452. fbb.setIdentifyName(user.getIdentifyName());
  453. fbb.setUid(uid);
  454. fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  455. res.setData(fbb);
  456. return res;
  457. }
  458. /** 针对已锁定的业务作跟进 **/
  459. @RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
  460. public Result toAddFollowOnLock(String uid){
  461. Result res = new Result();
  462. if(StringUtils.isBlank(uid)){
  463. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  464. return res;
  465. }
  466. User user = customerService.findUserAccountDetail(uid);
  467. FollowBusinessBo fbb = new FollowBusinessBo();
  468. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  469. fbb.setFollowTime(format.format(new Date()));
  470. fbb.setIdentifyName(user.getIdentifyName());
  471. fbb.setUid(uid);
  472. fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
  473. res.setData(fbb);
  474. return res;
  475. }
  476. /** 添加拜访记录、客户跟进
  477. * @param type 0=客户拜访,1=限定项目拜访
  478. * **/
  479. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  480. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,
  481. String result,String followTime,Integer type,String pid) throws BusinessException{
  482. Result res = res();
  483. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  484. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  485. return res;
  486. }
  487. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  488. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  489. if (ja != null && !ja.isEmpty()) {
  490. BusinessListBo userBusiness = null;
  491. for (int idx = 0; idx < ja.size(); idx++) {
  492. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  493. for(BusinessListBo ub:list){
  494. if(Objects.equals(ub.getBusinessProjectId(), userBusiness.getBusinessProjectId())){
  495. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  496. return res;
  497. }
  498. }
  499. list.add(userBusiness);
  500. }
  501. }
  502. if (type==null)type=0;
  503. FollowBusinessBo fbb = new FollowBusinessBo();
  504. fbb.setOcbId(ocbId);
  505. fbb.setUid(uid);
  506. fbb.setContactType(contactType);
  507. fbb.setResult(result);
  508. fbb.setFollowTime(followTime);
  509. fbb.setUserBusinessList(list);
  510. customerService.addFollow(fbb,null,1,type,pid);
  511. return res.data(1);
  512. }
  513. /** 进入修改拜访记录 **/
  514. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  515. public Result toUpdateFollow(String followId){
  516. Result res = new Result();
  517. FollowBusinessBo fbb = customerService.findFollowById(followId);
  518. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  519. res.setData(fbb);
  520. return res;
  521. }
  522. /** 修改拜访记录
  523. */
  524. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  525. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  526. Result res = new Result();
  527. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  528. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  529. return res;
  530. }
  531. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  532. List<BusinessListBo> list = new ArrayList<BusinessListBo>();
  533. if (ja != null && !ja.isEmpty()) {
  534. BusinessListBo userBusiness = null;
  535. for (int idx = 0; idx < ja.size(); idx++) {
  536. userBusiness = ja.getJSONObject(idx).toJavaObject(BusinessListBo.class);
  537. for(BusinessListBo ub:list){
  538. if(Objects.equals(ub.getBusinessProjectId(), userBusiness.getBusinessProjectId())){
  539. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  540. return res;
  541. }
  542. }
  543. list.add(userBusiness);
  544. }
  545. }
  546. FollowBusinessBo fbb = new FollowBusinessBo();
  547. fbb.setFollowTime(followTime);
  548. fbb.setUid(uid);
  549. fbb.setContactType(contactType);
  550. fbb.setResult(result);
  551. fbb.setUserBusinessList(list);
  552. fbb.setFollowId(followId);
  553. customerService.updateFollow(fbb);
  554. return res;
  555. }
  556. /** 删除跟进记录 **/
  557. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  558. public Result deleteFollow(String followId){
  559. Result res = new Result();
  560. if(StringUtils.isBlank(followId)){
  561. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  562. return res;
  563. }
  564. customerService.deleteFollow(followId);
  565. return res;
  566. }
  567. /** 查询客户的所有联系人 **/
  568. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  569. public Result findAllContacts(String uid){
  570. Result res = new Result();
  571. res.setData(customerService.findAllContacts(uid));
  572. return res;
  573. }
  574. /** 修改企业联系人 **/
  575. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  576. public Result updateCustomerContacts(String contactList,String uid){
  577. Result res = new Result();
  578. if(StringUtils.isBlank(uid)){
  579. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  580. return res;
  581. }
  582. JSONArray ja = (JSONArray) JSON.parse(contactList);
  583. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  584. OrganizationContactBook ocb = null;
  585. if(ja != null && !ja.isEmpty()){
  586. for (int idx = 0; idx < ja.size(); idx++) {
  587. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  588. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  589. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  590. return res;
  591. }
  592. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  593. ocbList.add(ocb);
  594. }
  595. }
  596. customerService.updateCustomerContacts(ocbList,uid);
  597. return res;
  598. }
  599. /**
  600. * 领取客户
  601. * @param uid 客户编号
  602. * @param oldAid 原来的客户归属人
  603. */
  604. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  605. public Result receiveCustomer(String uid, String oldAid) {
  606. Result res = new Result();
  607. if (StringUtils.isBlank(uid)) {
  608. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  609. return res;
  610. }
  611. Integer check =customerService.receiveEveryDay(uid);
  612. if (check!=0){
  613. if (check==-1){
  614. res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_RECEIVE));
  615. return res;
  616. }else if (check==-2){
  617. res.getError().add(buildError(ErrorConstants.CUSTOM_EREXCESS, USER_RECEIVE_MAX.toString(),USER_RECEIVE_MAX.toString()));
  618. return res;
  619. }else if (check==-3){
  620. //客服营销员不限制上线
  621. if (!TokenManager.hasRole(AFTConstants.CUSTOMER_SERVICE_SALESMAN)){
  622. res.getError().add(buildError("", "领取失败!您的“私有客户/私有限定项目”总计已超出最大限制,请移出相关数据后,再来领取!"));
  623. return res;
  624. }
  625. }else if (check==-4){
  626. res.getError().add(buildError("", "外联客户丢失后不可再领取"));
  627. return res;
  628. }else if (check==-5){
  629. res.getError().add(buildError("", "提示:不可领取!!!当前客户,他人外呼中。"));
  630. return res;
  631. }else {
  632. res.getError().add(buildError("领取参数异常,请联系管理员"));
  633. return res;
  634. }
  635. }
  636. customerService.updateByOperatorType(uid, null, oldAid, AFTConstants.USER_RECEIVE, null);
  637. return res;
  638. }
  639. /**
  640. * 领取为渠道
  641. */
  642. @RequestMapping(value = "/receiveAsChannel",method=RequestMethod.POST)
  643. public Result receiveAsChannel(String uid){
  644. Result res = new Result();
  645. if (uid ==null ){
  646. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户"));
  647. return res;
  648. }
  649. res.data(customerService.pushReceiveAsChannel(uid));
  650. return res;
  651. }
  652. /**
  653. * 上传excel文档
  654. */
  655. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  656. public Result uploadExcel(HttpServletRequest req){
  657. Result res = new Result();
  658. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  659. ExcelUtils utils = new ExcelUtils();
  660. Set<CustomerExcelBo> boSet;
  661. try {
  662. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  663. String errorMessage = "";
  664. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  665. errorMessage += utils.getVacantRows();
  666. if(StringUtils.isNotBlank(errorMessage)) {
  667. res.getError().add(new Error(errorMessage));
  668. return res;
  669. }
  670. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  671. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  672. customerService.checkCustomer(boSet,existRows,filterRows);
  673. if(!existRows.isEmpty()){
  674. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  675. res.getError().add(new Error(errorMessage));
  676. return res;
  677. }
  678. if(!filterRows.isEmpty()){
  679. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  680. res.getError().add(new Error(errorMessage));
  681. return res;
  682. }
  683. customerService.saveUploadData(boSet);
  684. } catch (IOException e) {
  685. e.printStackTrace();
  686. }
  687. return res;
  688. }
  689. /**
  690. * 下载科技成果批量导入Excel模板
  691. */
  692. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  693. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  694. Result res = new Result();
  695. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  696. Attachment af = aftFileService.selectAftFileBySign("organization_customer_template");
  697. if (null == af) {
  698. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  699. } else {
  700. String path = af.getFilePath();
  701. String suffix = path.substring(path.lastIndexOf("."));
  702. String fileName = af.getFileName() + suffix;
  703. downloadFile(response, fileName, path);
  704. }
  705. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  706. Attachment af = aftFileService.selectAftFileBySign("personal_customer_template");
  707. if (null == af) {
  708. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  709. } else {
  710. String path = af.getFilePath();
  711. String suffix = path.substring(path.lastIndexOf("."));
  712. String fileName = af.getFileName() + suffix;
  713. downloadFile(response, fileName, path);
  714. }
  715. }
  716. return res;
  717. }
  718. /**
  719. * 转为公共客户 释放客户
  720. */
  721. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  722. public Result transferToPublic(String uid,String aid){
  723. Result res = new Result();
  724. if(StringUtils.isBlank(uid) || StringUtils.isBlank("aid")){
  725. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  726. }
  727. customerService.updateByOperatorType(uid, aid,null, AFTConstants.USER_TRANSFER_TO_PUBLIC,null);
  728. return res;
  729. }
  730. /** 图片上传 **/
  731. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  732. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  733. Result res = new Result();
  734. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  735. return res;
  736. }
  737. /**
  738. *
  739. * @param startDate 开始日期
  740. * @param endDate 结束日期
  741. * @param timeSpan 时间差
  742. * @param depNo 部门编号
  743. * @param pageNo 页码
  744. * @param pageSize 页数
  745. */
  746. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  747. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  748. Result res = new Result();
  749. Date sDate = null;
  750. Date eDate = null;
  751. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  752. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  753. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  754. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  755. Date date = new Date();
  756. switch (timeSpan) {
  757. case DateUtils.DAY_SPAN:
  758. sDate = DateUtils.getYesterday();
  759. break;
  760. case DateUtils.WEEK_SPAN:
  761. sDate = DateUtils.getLastDayOfLastWeek(date);
  762. break;
  763. case DateUtils.MONTH_SPAN:
  764. sDate = DateUtils.getLastDayOfLastMonth(date);
  765. break;
  766. case DateUtils.QUARTER_SPAN:
  767. sDate = DateUtils.getLastDayOfLastQuarter(date);
  768. break;
  769. case DateUtils.YEAR_SPAN:
  770. sDate = DateUtils.getLastDayOfLastYear(date);
  771. break;
  772. }
  773. }
  774. res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  775. return res;
  776. }
  777. /**
  778. *
  779. * @param startDate 开始日期
  780. * @param endDate 结束日期
  781. * @param timeSpan 时间差
  782. * @param depNo 部门编号
  783. * @param businessGlossoryId 业务编号
  784. * @param pageNo 页码
  785. * @param pageSize 页数
  786. */
  787. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  788. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  789. Result res = new Result();
  790. Date sDate = null;
  791. Date eDate = null;
  792. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  793. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  794. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  795. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  796. Date date = new Date();
  797. switch (timeSpan) {
  798. case DateUtils.DAY_SPAN:
  799. sDate = DateUtils.getYesterday();
  800. break;
  801. case DateUtils.WEEK_SPAN:
  802. sDate = DateUtils.getLastDayOfLastWeek(date);
  803. break;
  804. case DateUtils.MONTH_SPAN:
  805. sDate = DateUtils.getLastDayOfLastMonth(date);
  806. break;
  807. case DateUtils.QUARTER_SPAN:
  808. sDate = DateUtils.getLastDayOfLastQuarter(date);
  809. break;
  810. case DateUtils.YEAR_SPAN:
  811. sDate = DateUtils.getLastDayOfLastYear(date);
  812. break;
  813. }
  814. }
  815. res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  816. return res;
  817. }
  818. /**
  819. *
  820. * @param startDate 开始日期
  821. * @param endDate 结束日期
  822. * @param timeSpan 时间差
  823. * @param depNo 部门编号
  824. * @param pageNo 页码
  825. * @param pageSize 页数
  826. */
  827. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  828. public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
  829. Result res = new Result();
  830. Date sDate = null;
  831. Date eDate = null;
  832. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  833. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  834. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  835. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  836. Date date = new Date();
  837. switch (timeSpan) {
  838. case DateUtils.DAY_SPAN:
  839. sDate = DateUtils.getYesterday();
  840. break;
  841. case DateUtils.WEEK_SPAN:
  842. sDate = DateUtils.getLastDayOfLastWeek(date);
  843. break;
  844. case DateUtils.MONTH_SPAN:
  845. sDate = DateUtils.getLastDayOfLastMonth(date);
  846. break;
  847. case DateUtils.QUARTER_SPAN:
  848. sDate = DateUtils.getLastDayOfLastQuarter(date);
  849. break;
  850. case DateUtils.YEAR_SPAN:
  851. sDate = DateUtils.getLastDayOfLastYear(date);
  852. break;
  853. }
  854. }
  855. res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
  856. return res;
  857. }
  858. /**
  859. * 管理员列表
  860. * @param adminName 名称
  861. * @param status 0 正常 1锁定 2全部
  862. */
  863. @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
  864. public Result listAdminByName(String adminName,Integer status){
  865. Result res = new Result();
  866. adminName=adminName.trim();
  867. if(status==null) status=2;
  868. if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName,status));
  869. return res;
  870. }
  871. /**
  872. * 客户转交 私有客户转交,签单客户转交
  873. * @param uid 用户编号
  874. * @param operatorType 3私有 4签单
  875. * @param data 资料同步转移 0无 1资料转交 2订单转交 3全部转交
  876. */
  877. @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
  878. public Result transferToOther(String uid,String aid,Integer operatorType,Integer data,String oldAid){
  879. Result res = new Result();
  880. if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
  881. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
  882. return res;
  883. }
  884. //默认为私有转交,4为签单转交
  885. if (operatorType==null) operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
  886. //转交,对方不是客服营销员才需要判断最大限制
  887. if (operatorType.equals(AFTConstants.USER_TRANSFER_TO_OTHER) &&(!customerService.checkAid(aid,Integer.valueOf(AFTConstants.CUSTOMER_SERVICE_SALESMAN)))){
  888. if (customerService.checkMax(uid,aid)){
  889. res.getError().add(buildError("","对方私有客户已达最大限制"));
  890. return res;
  891. }
  892. }
  893. if(data==null)data=0;
  894. res.setData(customerService.updateByOperatorType(uid, aid, oldAid, operatorType, data));
  895. return res;
  896. }
  897. /**
  898. * 客户转交记录
  899. * @param uid 客户编号
  900. */
  901. @RequestMapping(value = "/transferList", method = RequestMethod.GET)
  902. public Result transferList(String uid){
  903. Result res = new Result();
  904. if(StringUtils.isBlank(uid) ){
  905. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号", "客户编号"));
  906. return res;
  907. }
  908. res.data(customerService.transferList( uid));
  909. return res;
  910. }
  911. /** 查询我的业务列表 **/
  912. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  913. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  914. Result res = new Result();
  915. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  916. return res;
  917. }
  918. /** 查询所有的业务列表 **/
  919. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  920. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  921. Result res = new Result();
  922. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  923. return res;
  924. }
  925. /** 业务管理列表 **/
  926. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  927. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  928. Result res = new Result();
  929. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  930. return res;
  931. }
  932. /** 查询业务字典 **/
  933. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  934. public Result findBusinessGlossory(){
  935. Result res = new Result();
  936. res.setData(customerService.findBusinessGlossory());
  937. return res;
  938. }
  939. /** 新增客户意向 **/
  940. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  941. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  942. Result res = new Result();
  943. if(StringUtils.isBlank(bfb.getBusinessProjectId()) || StringUtils.isBlank(bfb.getUid())){
  944. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  945. return res;
  946. }
  947. if(customerService.judgeBusiness(bfb.getUid(), bfb.getBusinessProjectId())>0){
  948. res.getError().add(new Error("该项业务已经被跟进"));
  949. return res;
  950. }
  951. try {
  952. customerService.addBusinessAndFollow(bfb);
  953. } catch (ParseException e) {
  954. e.printStackTrace();
  955. }
  956. return res;
  957. }
  958. /** 进入新增意向服务 **/
  959. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  960. public Result toAddBusinessAndFollow(){
  961. Result res = new Result();
  962. BussinessFollowBo bo = new BussinessFollowBo();
  963. bo.setAdminName(TokenManager.getAdminToken().getName());
  964. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  965. bo.setCreateTime(format.format(new Date()));
  966. bo.setFollowTime(bo.getCreateTime());
  967. res.setData(bo);
  968. return res;
  969. }
  970. /** 进入修改业务意向 **/
  971. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  972. public Result toUpdateBusiness(String businessId){
  973. Result res = new Result();
  974. res.setData(customerService.findBusinessDetail(businessId));
  975. return res;
  976. }
  977. /** 修改业务意向 **/
  978. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  979. public Result updateBusiness(BussinessFollowBo bfb){
  980. Result res = new Result();
  981. customerService.updateBusiness(bfb);
  982. return res;
  983. }
  984. /** 进入跟进单个客户意向 **/
  985. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  986. public Result toAddFollowOneBusiness(String businessId){
  987. Result res = new Result();
  988. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  989. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  990. bo.setFollowTime(format.format(new Date()));
  991. res.setData(bo);
  992. return res;
  993. }
  994. /** 跟进单个客户意向 **/
  995. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  996. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  997. Result res = new Result();
  998. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  999. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  1000. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  1001. return res;
  1002. }
  1003. try {
  1004. customerService.addFollowOneBusiness(bfb);
  1005. } catch (ParseException e) {
  1006. e.printStackTrace();
  1007. }
  1008. return res;
  1009. }
  1010. /** 进入修改某个客户一个业务的当次拜访 **/
  1011. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  1012. public Result toUpdateFollowOneBusiness(String ufbId){
  1013. Result res = new Result();
  1014. if(StringUtils.isBlank(ufbId)) {
  1015. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1016. return res;
  1017. }
  1018. res.setData(customerService.findFollowOneBusiness(ufbId));
  1019. return res;
  1020. }
  1021. /** 修改某个客户一个业务的当次拜访 **/
  1022. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  1023. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  1024. Result res = new Result();
  1025. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  1026. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1027. return res;
  1028. }
  1029. customerService.updateFollowOneBusiness(bfb);
  1030. return res;
  1031. }
  1032. /** 删除某个客户一个业务的当次拜访 **/
  1033. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  1034. public Result deleteFollowOneBusiness(String ufbId){
  1035. Result res = new Result();
  1036. if(StringUtils.isBlank(ufbId)){
  1037. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1038. return res;
  1039. }
  1040. customerService.deleteFollowOneBusiness(ufbId);
  1041. return res;
  1042. }
  1043. /** 添加单个联系人 **/
  1044. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  1045. public Result addOneContact(OrganizationContactBook ocb){
  1046. Result res = new Result();
  1047. if(StringUtils.isBlank(ocb.getUid())){
  1048. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"客户编号"));
  1049. return res;
  1050. }
  1051. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  1052. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  1053. return res;
  1054. }
  1055. customerService.addOneContact(ocb);
  1056. return res;
  1057. }
  1058. /** 删除单个联系人 **/
  1059. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  1060. public Result deleteOneContact(String ocbId){
  1061. Result res = new Result();
  1062. if(StringUtils.isBlank(ocbId)){
  1063. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1064. return res;
  1065. }
  1066. customerService.deleteOneContact(ocbId);
  1067. return res;
  1068. }
  1069. /** 修改主要联系人 **/
  1070. @RequestMapping(value = "/updateMainContact", method = RequestMethod.GET)
  1071. public Result updateMainContact(String ocbId,String uid){
  1072. Result res = new Result();
  1073. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  1074. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1075. return res;
  1076. }
  1077. customerService.updateMainContact(ocbId,uid);
  1078. return res;
  1079. }
  1080. /** 删除 业务 **/
  1081. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  1082. public Result deleteBusiness(String businessId){
  1083. Result res = new Result();
  1084. if(StringUtils.isBlank(businessId)){
  1085. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1086. return res;
  1087. }
  1088. customerService.deleteBusiness(businessId);
  1089. return res;
  1090. }
  1091. /** 停止业务 **/
  1092. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  1093. public Result stopBusiness(String businessId){
  1094. Result res = new Result();
  1095. if(StringUtils.isBlank(businessId)){
  1096. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  1097. return res;
  1098. }
  1099. customerService.updateBusinessToStop(businessId);
  1100. return res;
  1101. }
  1102. /** 客户分配查询(本部门) **/
  1103. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  1104. public Result findAdminName(){
  1105. Result res = new Result();
  1106. res.setData(customerService.findAdminName());
  1107. return res;
  1108. }
  1109. /** 分配个人客户 **/
  1110. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  1111. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  1112. Result res = new Result();
  1113. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  1114. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1115. return res;
  1116. }
  1117. customerService.updatePersonalCustomerz(bo);
  1118. return res;
  1119. }
  1120. /** 客户录入审核 **/
  1121. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  1122. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  1123. Result res = new Result();
  1124. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  1125. return res;
  1126. }
  1127. /** 修改客户录入审核状态 **/
  1128. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  1129. public Result updateEnteringAudit(User bo){
  1130. Result res = new Result();
  1131. if(StringUtils.isBlank(bo.getId())){
  1132. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1133. return res;
  1134. }
  1135. res.data(customerService.updateEnteringAudit(bo));
  1136. return res;
  1137. }
  1138. /** 审核拒绝客户查询 **/
  1139. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  1140. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  1141. Result res = new Result();
  1142. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  1143. return res;
  1144. }
  1145. /** 修改拒绝客户信息 **/
  1146. @RequestMapping(value = "/updateRefusedCustomer", method = RequestMethod.POST)
  1147. public Result updateRefusedCustomer(String id,String nickname,String mobile,String societyTag){
  1148. Result res = new Result();
  1149. if(StringUtils.isBlank(nickname)){
  1150. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"名称"));
  1151. return res;
  1152. }
  1153. if(StringUtils.isBlank(mobile)){
  1154. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"电话"));
  1155. return res;
  1156. }
  1157. if(StringUtils.isBlank(societyTag)){
  1158. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"社会性质"));
  1159. return res;
  1160. }
  1161. customerService.updateRefusedCustomer(id, nickname, mobile, societyTag);
  1162. return res;
  1163. }
  1164. /** 查询客户的锁定业务 **/
  1165. @RequestMapping(value = "/getLockedProject", method = RequestMethod.GET)
  1166. public Result getLockedProject(String uid){
  1167. Result res = new Result();
  1168. if(StringUtils.isBlank(uid)){
  1169. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID"));
  1170. return res;
  1171. }
  1172. res.setData(customerService.selectLockedProject(uid));
  1173. return res;
  1174. }
  1175. /** 客户二次签项目业务 **/
  1176. @RequestMapping(value = "/againProjectTask", method = RequestMethod.GET)
  1177. public Result againProjectTask(String uid,String projectId,String aid){
  1178. Result res = new Result();
  1179. if(StringUtils.isBlank(uid)||StringUtils.isBlank(projectId)){
  1180. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"参数"));
  1181. return res;
  1182. }
  1183. res.setData(customerService.updateAgainProjectTask(uid,projectId,aid));
  1184. return res;
  1185. }
  1186. /** 客户资料转交 **/
  1187. @RequestMapping(value = "/updateInformationMaintainerr", method = RequestMethod.POST)
  1188. public Result updateInformationMaintainerr(String id,String aid){
  1189. Result res = new Result();
  1190. if(StringUtils.isBlank(id) || StringUtils.isBlank(aid)){
  1191. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  1192. return res;
  1193. }
  1194. res.data(customerService.updateInformationMaintainerr(id,aid));
  1195. return res;
  1196. }
  1197. /** 个人单位客户信息列表 **/
  1198. @RequestMapping(value = "/listCustomerInformation", method = RequestMethod.POST)
  1199. public Result listCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1200. Result res = new Result();
  1201. res.data(customerService.listCustomerInformation(cli,pageNo,pageSize));
  1202. return res;
  1203. }
  1204. /** 部门单位客户信息列表 **/
  1205. @RequestMapping(value = "/listDepCustomerInformation", method = RequestMethod.POST)
  1206. public Result listDepCustomerInformation(CustomerListIn cli,Integer pageNo, Integer pageSize){
  1207. Result res = new Result();
  1208. res.data(customerService.listDepCustomerInformation(cli,pageNo,pageSize));
  1209. return res;
  1210. }
  1211. /** 修改客户等级 **/
  1212. @RequestMapping(value = "/updateUserLevel", method = RequestMethod.GET)
  1213. public Result updateUserLevel(User u){
  1214. Result res = new Result();
  1215. if(StringUtils.isBlank(u.getId())){
  1216. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1217. return res;
  1218. }
  1219. if(null==u.getLevel()){
  1220. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户等级错误","用户等级"));
  1221. return res;
  1222. }
  1223. res.data(customerService.updateUserLevel(u));
  1224. return res;
  1225. }
  1226. /** 释放客户 **/
  1227. @RequestMapping(value = "/pushReleaseUser", method = RequestMethod.GET)
  1228. public Result pushReleaseUser(String id){
  1229. Result res = new Result();
  1230. if(StringUtils.isBlank(id)){
  1231. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户ID错误","用户ID"));
  1232. return res;
  1233. }
  1234. res.data(customerService.pushReleaseUser(id));
  1235. return res;
  1236. }
  1237. /**
  1238. * 企业项目申报材料上传
  1239. *
  1240. */
  1241. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  1242. public Result cognizanceFile(HttpServletRequest req, String uid, String sign) {
  1243. Result res = new Result();
  1244. AttachmentType attachmentType = AttachmentType.getField(sign);
  1245. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1246. res.setData(handleFiles(res, "/orgApplication/", true, req, sign, uid));
  1247. } else {
  1248. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1249. }
  1250. return res;
  1251. }
  1252. /**
  1253. * 企业项目申报材料预览授权
  1254. *
  1255. */
  1256. @RequestMapping(value = "/techProject", method = RequestMethod.GET)
  1257. public Result previewTechProject(String id, String sign) {
  1258. Result res = new Result();
  1259. if (StringUtils.isEmpty(id)) {
  1260. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "企业项目申报材料ID"));
  1261. return res;
  1262. }
  1263. AttachmentType attachmentType = AttachmentType.getField(sign);
  1264. if (attachmentType == AttachmentType.ORGANIZATION_APPLICATION) {
  1265. String time = String.valueOf(Calendar.getInstance().getTime().getTime());
  1266. String auth = SHA256Util.toHash(sign + "|" + id + "|" + secretKey, time);
  1267. res.setData("sign=" + sign + "&token2=" + id + "&auth=" + auth + "&temp=" + time);
  1268. } else {
  1269. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  1270. }
  1271. return res;
  1272. }
  1273. /**
  1274. * 查看营销员客户统计
  1275. */
  1276. @RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
  1277. public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
  1278. Result res = new Result();
  1279. res.data(adminService.selectAdminCustomerStatistics( depId, startTime, endTime, pageSize, pageNo));
  1280. return res;
  1281. }
  1282. /**
  1283. * 查看客户统计
  1284. * @param depId 部门编号
  1285. * @param startTime 开始时间
  1286. * @param endTime 结束时间
  1287. */
  1288. @RequestMapping(value = "/selectAllUser", method = RequestMethod.GET)
  1289. public Result selectAllUser(String depId, String startTime,String endTime,String aName ) {
  1290. Result res = new Result();
  1291. res.data(adminService.selectAllUser( depId, startTime, endTime, aName));
  1292. return res;
  1293. }
  1294. /**
  1295. * 查看客户统计导出
  1296. * @param depId 部门编号
  1297. * @param startTime 开始时间
  1298. * @param endTime 结束时间
  1299. */
  1300. @RequestMapping(value = "/selectAllUser/export", method = RequestMethod.GET)
  1301. public Result selectAllUserExport(String depId, String startTime,String endTime,String aName ) {
  1302. return adminService.selectAllUserExport( depId, startTime, endTime, aName);
  1303. }
  1304. /**
  1305. * 查看客户日期内新增客户
  1306. * @param type 0私有 1渠道 2签单 3私有新增 4渠道新增 5私有面谈 6渠道面谈 7私有领取 8 私有转交
  1307. */
  1308. @RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
  1309. public Result selectAdminCustomerList(String aid, String startTime,String endTime,Integer type, Integer pageSize, Integer pageNo) {
  1310. Result res = new Result();
  1311. res.data(adminService.selectAdminCustomerList( aid, startTime, endTime, type, pageSize, pageNo));
  1312. return res;
  1313. }
  1314. /**
  1315. *
  1316. * @param inputId 业务转移客户id(接收者)
  1317. * @param uid 被转移的客户
  1318. * @param pid 呗转移的业务
  1319. */
  1320. @RequestMapping(value = "/privateBusinessTransfer", method = RequestMethod.POST)
  1321. public Result privateBusinessTransfer(String inputId,String uid,String pid ) {
  1322. Result res = new Result();
  1323. if (StringUtils.isBlank(inputId)) {
  1324. res.getError().add(buildError("请确认正确的接收者。","请确认正确的接收者。"));
  1325. return res;
  1326. }
  1327. int i= customerService.updatePrivateBusinessTransfer( inputId, uid, pid );
  1328. if (i<1) {
  1329. res.getError().add(buildError("请确认客户与业务归属是否正确。","请确认客户与业务归属是否正确。"));
  1330. return res;
  1331. }
  1332. res.data(i);
  1333. return res;
  1334. }
  1335. /**
  1336. * 渠道客户列表
  1337. **/
  1338. @RequestMapping(value = "/listChannelCustomer" , method = RequestMethod.POST)
  1339. public Result listChannelCustomer(InputListChannel in){
  1340. Result res = new Result();
  1341. res.setData(customerService.listChannelCustomer(in));
  1342. return res;
  1343. }
  1344. /**
  1345. * 渠道客户统计列表
  1346. **/
  1347. @RequestMapping(value = "/listChannelCounts" , method = RequestMethod.GET)
  1348. public Result listChannelCounts(InputChannelCounts in){
  1349. Result res = new Result();
  1350. res.setData(customerService.listChannelCounts(in));
  1351. return res;
  1352. }
  1353. /**
  1354. * 渠道客户转交
  1355. * @param userIds 用户编号集
  1356. * @param receiveId 接受者
  1357. * @param remarks 备注
  1358. * @param type 0 分配 1转交 2回退
  1359. */
  1360. @RequestMapping(value = "/channelCustomerDeliver", method = RequestMethod.POST)
  1361. public Result channelCustomerDeliver(String userIds ,String receiveId,String remarks,Integer type){
  1362. Result res = new Result();
  1363. if (StringUtils.isBlank(userIds)) {
  1364. res.getError().add(buildError("","用户编号不存在"));
  1365. return res;
  1366. }
  1367. String [] str=userIds.split(",");
  1368. List<String> uids=Arrays.asList(str);
  1369. if (type==1&&customerService.checkChannel(uids)) {
  1370. res.getError().add(buildError("","已跟进,禁止分配!"));
  1371. return res;
  1372. }
  1373. if (type==2&&customerService.checkRecovery(uids)) {
  1374. res.getError().add(buildError("","不允许二次回退"));
  1375. return res;
  1376. }
  1377. res.setData(customerService.pushChannelDeliver( uids , receiveId,remarks,type));
  1378. return res;
  1379. }
  1380. /** 修改客户名称 **/
  1381. @RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
  1382. public Result updateUserName(String uid,String userName){
  1383. Result res = new Result();
  1384. if(StringUtils.isBlank(uid) || StringUtils.isBlank(userName)){
  1385. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,null,"uid或者名称"));
  1386. return res;
  1387. }
  1388. userName = userName.trim();
  1389. if(customerService.checkUserName(uid,userName)){
  1390. res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_EXIST,null,"["+userName+"]"));
  1391. return res;
  1392. }
  1393. res.data(customerService.updateUserName(uid,userName));
  1394. return res;
  1395. }
  1396. @RequestMapping(value = "/checkUserName",method = RequestMethod.GET)
  1397. public Result checkUserName(String userName){
  1398. Result res =new Result();
  1399. res.data(customerService.checkUserName(null,userName));
  1400. return res;
  1401. }
  1402. /** 修改客户关键资料 **/
  1403. @RequestMapping(value = "/updateUserDate", method = RequestMethod.POST)
  1404. public Result updateUserDate(InputUserData in ){
  1405. Result res = new Result();
  1406. if (in.getOrgCode()!=null){
  1407. in.setOrgCode(in.getOrgCode().trim());
  1408. if (customerService.checkOrgCode(in.getOrgCode(),in.getUid())){
  1409. res.getError().add(buildError("","统一信用代码已存在"));
  1410. return res;
  1411. }
  1412. }
  1413. res.data(customerService.updateUserDate(in));
  1414. return res;
  1415. }
  1416. /** 客户名称列表 **/
  1417. @RequestMapping(value = "/listUserName", method = RequestMethod.GET)
  1418. public Result listUserName(String uid){
  1419. Result res = new Result();
  1420. if(StringUtils.isBlank(uid) || StringUtils.isBlank(uid)){
  1421. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"uid","uid"));
  1422. return res;
  1423. }
  1424. res.data(customerService.listUserName(uid));
  1425. return res;
  1426. }
  1427. /**
  1428. * 客户主营产品列表
  1429. */
  1430. @RequestMapping(value = "/mainProductsList", method = RequestMethod.GET)
  1431. public Result mainProductsList(InputMainProductsList in){
  1432. Result res = new Result();
  1433. res.data(customerService.mainProductsList(in));
  1434. return res;
  1435. }
  1436. /**
  1437. * 用户信息日志
  1438. */
  1439. @RequestMapping(value = "/userDateLogList",method = RequestMethod.GET)
  1440. public Result userDateLogList(String uid){
  1441. Result res =new Result();
  1442. res.data(customerService.userDateLogList(uid));
  1443. return res;
  1444. }
  1445. /**
  1446. * 修改用户主营产品
  1447. */
  1448. @RequestMapping(value = "/updateUserBusinessScope",method = RequestMethod.POST)
  1449. public Result updateUserBusinessScope(String id,String businessScope){
  1450. Result res=new Result();
  1451. if (id==null||businessScope==null){
  1452. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  1453. return res;
  1454. }
  1455. res.data(customerService.updateuserBusinessScope(id,businessScope));
  1456. return res;
  1457. }
  1458. @RequestMapping(value = "/queryUserMax",method = RequestMethod.GET)
  1459. public Result queryUserMax(){
  1460. Result res =new Result();
  1461. res.setData(customerService.queryUserMax());
  1462. return res;
  1463. }
  1464. /**
  1465. * 客户最后跟进列表
  1466. */
  1467. @RequestMapping(value = "/selectUserLastSign",method = RequestMethod.GET)
  1468. public Result selectUserLastSign (InputSelectUserLastSignBo in){
  1469. Result res =new Result();
  1470. res.setData(customerService.selectUserLastSign(in));
  1471. return res;
  1472. }
  1473. /**
  1474. * 客户最后跟进列表导出
  1475. */
  1476. @RequestMapping(value = "/selectUserLastSign/export",method = RequestMethod.GET)
  1477. public Result selectUserLastSignExport (InputSelectUserLastSignBo in){
  1478. return customerService.selectUserLastSignExport(in);
  1479. }
  1480. /**
  1481. * Excel批量导入
  1482. */
  1483. @RequestMapping(value = "/importExcel" , method = RequestMethod.POST)
  1484. public Result importExcel(@RequestParam(value = "file", required = false) MultipartFile file) {
  1485. Result res=new Result();
  1486. //判断文件是否存在
  1487. if(null == file){
  1488. res.getError().add(buildError("文件不存在!","文件不存在!"));
  1489. return res;
  1490. }
  1491. String fileName = file.getOriginalFilename();
  1492. if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
  1493. res.getError().add(buildError("格式不正确","格式不正确"));
  1494. return res;
  1495. }
  1496. // res.data(rdService.batchList(file));
  1497. return customerService.importExcel(file);
  1498. }
  1499. /**
  1500. * 获取我的客户列表
  1501. */
  1502. @GetMapping("/selectMyUser")
  1503. public Result<Pagination<SelectMyUserOut>> selectMyUser(SelectMyUserBo in ){
  1504. Result res = new Result();
  1505. res.data(customerService.selectMyUser(in));
  1506. return res;
  1507. }
  1508. /**
  1509. * 获取我的客户信息
  1510. */
  1511. @GetMapping("/selectMyUserDetails")
  1512. public Result<Pagination<SelectMyUserOut>> selectMyUserDetails(String id ){
  1513. Result res = new Result();
  1514. res.data(customerService.selectMyUserDetails(id));
  1515. return res;
  1516. }
  1517. /**
  1518. * 客户公出情况
  1519. */
  1520. @GetMapping("/getPublicReleaseList")
  1521. public Result<List<PublicReleaseListBo>> getPublicReleaseList(String id) {
  1522. Result res = new Result();
  1523. if (userArchivesService.checkPermission(id)){
  1524. res.error(buildError("查看超时,请要分享人重新分享。"));
  1525. return res;
  1526. }
  1527. res.setData(customerService.getPublicReleaseList(id));
  1528. return res;
  1529. }
  1530. /**
  1531. * 客户公出情况
  1532. */
  1533. @GetMapping("/selectPublicReleaseList")
  1534. public Result<List<PublicReleaseListBo>> selectPublicReleaseList(String id) {
  1535. Result res = new Result();
  1536. res.setData(customerService.getPublicReleaseList(id));
  1537. return res;
  1538. }
  1539. /**
  1540. * 客户标签未标记统计
  1541. */
  1542. @GetMapping("/selectUserLevel")
  1543. public Result selectUserLevel() {
  1544. Result res = new Result();
  1545. res.setData(customerService.selectUserLevel());
  1546. return res;
  1547. }
  1548. /**
  1549. * 修改用户标签
  1550. */
  1551. @PostMapping("/updateMid")
  1552. public Result updateMid(UserMid in) {
  1553. Result res = new Result();
  1554. res.data(customerService.updateMid(in));
  1555. return res;
  1556. }
  1557. /**
  1558. * 查询客户补充完整
  1559. */
  1560. @GetMapping("/checkUser")
  1561. public Result checkUser(String id) {
  1562. Result res = new Result();
  1563. res.setData(customerService.checkUser(id));
  1564. return res;
  1565. }
  1566. /**
  1567. * 补充客户并领取
  1568. */
  1569. @PostMapping("/updateAndReceiveCustomer")
  1570. public Result updateAndReceiveCustomer(InputUpdateAndReceiveCustomer in) {
  1571. Result res = new Result();
  1572. if (in.getOrgCode()!=null){
  1573. in.setOrgCode(in.getOrgCode().trim());
  1574. if (customerService.checkOrgCode(in.getOrgCode(),in.getId())){
  1575. res.getError().add(buildError("","统一信用代码已存在"));
  1576. return res;
  1577. }
  1578. }
  1579. //手机号码判断
  1580. if (in.getContactMobile()!=null){
  1581. if (!RegexUtils.isMobile(in.getContactMobile())){
  1582. res.getError().add(buildError("","手机号码格式错误"));
  1583. return res;
  1584. }
  1585. }
  1586. Result result = receiveCustomer(in.getId(), null);
  1587. res.getError().addAll(result.getError());
  1588. if (!res.getError().isEmpty()){
  1589. return res;
  1590. }
  1591. customerService.updateAndReceiveCustomer(in);
  1592. return res;
  1593. }
  1594. }