AdminCustomerApiController.java 59 KB

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