AdminCustomerApiController.java 60 KB

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