AdminCustomerApiController.java 47 KB

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