AdminCustomerApiController.java 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. package com.goafanti.customer.controller;
  2. import java.io.IOException;
  3. import java.lang.reflect.InvocationTargetException;
  4. import java.text.DateFormat;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Date;
  9. import java.util.List;
  10. import java.util.Set;
  11. import java.util.TreeSet;
  12. import javax.annotation.Resource;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import com.alibaba.fastjson.JSON;
  20. import com.alibaba.fastjson.JSONArray;
  21. import com.goafanti.admin.service.AdminService;
  22. import com.goafanti.admin.service.AftFileService;
  23. import com.goafanti.common.bo.Error;
  24. import com.goafanti.common.bo.Result;
  25. import com.goafanti.common.constant.AFTConstants;
  26. import com.goafanti.common.constant.ErrorConstants;
  27. import com.goafanti.common.controller.BaseApiController;
  28. import com.goafanti.common.error.BusinessException;
  29. import com.goafanti.common.model.AftFile;
  30. import com.goafanti.common.model.OrganizationContactBook;
  31. import com.goafanti.common.model.User;
  32. import com.goafanti.common.model.UserBusiness;
  33. import com.goafanti.common.utils.BeanUtilsExt;
  34. import com.goafanti.common.utils.DateUtils;
  35. import com.goafanti.common.utils.ExcelUtils;
  36. import com.goafanti.common.utils.StringUtils;
  37. import com.goafanti.core.shiro.token.TokenManager;
  38. import com.goafanti.customer.bo.BusinessListBo;
  39. import com.goafanti.customer.bo.BussinessFollowBo;
  40. import com.goafanti.customer.bo.CustomerExcelBo;
  41. import com.goafanti.customer.bo.CustomerListIn;
  42. import com.goafanti.customer.bo.CustomerListOut;
  43. import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
  44. import com.goafanti.customer.bo.CustomerPersonalDetailBo;
  45. import com.goafanti.customer.bo.FollowBusinessBo;
  46. import com.goafanti.customer.bo.UserDetailBo;
  47. import com.goafanti.customer.service.CustomerService;
  48. @RestController
  49. @RequestMapping("/api/admin/customer")
  50. public class AdminCustomerApiController extends BaseApiController{
  51. @Resource
  52. private CustomerService customerService;
  53. @Resource
  54. private AftFileService aftFileService;
  55. @Value(value = "${upload.private.path}")
  56. private String uploadPrivatePath = null;
  57. @Resource
  58. private AdminService adminService;
  59. /** 私有个人客户列表 **/
  60. @RequestMapping(value = "/listPrivatePersonalCustomer" , method = RequestMethod.POST)
  61. public Result listPrivatePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  62. Result res = new Result();
  63. res.setData(customerService.listPrivatePersonalCustomer(cli, pageNo, pageSize));
  64. return res;
  65. }
  66. /** 公共个人客户列表 **/
  67. @RequestMapping(value = "/listPublicPersonalCustomer" , method = RequestMethod.POST)
  68. public Result listPublicPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  69. Result res = new Result();
  70. res.setData(customerService.listPublicPersonalCustomer(cli, pageNo, pageSize));
  71. return res;
  72. }
  73. /** 个人客户查询 **/
  74. @RequestMapping(value = "/listAllPersonalCustomer" , method = RequestMethod.POST)
  75. public Result listAllPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  76. Result res = new Result();
  77. res.setData(customerService.listAllPersonalCustomer(cli, pageNo, pageSize));
  78. return res;
  79. }
  80. /** 管理个人客户查询 **/
  81. @RequestMapping(value = "/listAllManagePersonalCustomer" , method = RequestMethod.POST)
  82. public Result listAllManagePersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  83. Result res = new Result();
  84. res.setData(customerService.listAllManagePersonalCustomer(cli, pageNo, pageSize));
  85. return res;
  86. }
  87. /** 私有单位客户列表 **/
  88. @RequestMapping(value = "/listPrivateOrganizationCustomer" , method = RequestMethod.POST)
  89. public Result listPrivateOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  90. Result res = new Result();
  91. res.setData(customerService.listPrivateOrganizationCustomer(cli, pageNo, pageSize));
  92. return res;
  93. }
  94. /** 公共单位客户列表 **/
  95. @RequestMapping(value = "/listPublicOrganizationCustomer" , method = RequestMethod.POST)
  96. public Result listPublicOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  97. Result res = new Result();
  98. res.setData(customerService.listPublicOrganizationCustomer(cli, pageNo, pageSize));
  99. return res;
  100. }
  101. /** 单位客户查询 **/
  102. @RequestMapping(value = "/listAllOrganizationCustomer" , method = RequestMethod.POST)
  103. public Result listAllOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  104. Result res = new Result();
  105. res.setData(customerService.listAllOrganizationCustomer(cli, pageNo, pageSize));
  106. return res;
  107. }
  108. /** 管理单位客户查询 **/
  109. @RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
  110. public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
  111. Result res = new Result();
  112. cli.setAid(TokenManager.getAdminId());
  113. res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
  114. return res;
  115. }
  116. /** 客户即时检索 **/
  117. @RequestMapping(value = "/findCustomerByName",method = RequestMethod.GET)
  118. public Result findCustomerByName(String name){
  119. Result res = new Result();
  120. res.setData(customerService.findCustomerByName(name));
  121. return res;
  122. }
  123. /** 添加客户基本信息
  124. * @throws Exception
  125. * @throws NumberFormatException **/
  126. @RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
  127. public Result addCustomer(String name,String contacts,String contactMobile,String type,String societyTag) throws Exception{
  128. Result res = new Result();
  129. if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
  130. || StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)){
  131. res.getError().add(buildError("客户名称、联系人、联系电话、社会性质不能为空"));
  132. return res;
  133. }
  134. customerService.addCustomer(name, contacts, contactMobile, Integer.parseInt(type),societyTag);
  135. return res;
  136. }
  137. /** 个人客户详情信息 **/
  138. @RequestMapping(value = "/findPersonalCustomerDetail" ,method = RequestMethod.GET)
  139. public Result findPersonalCustomerDetail(String uid){
  140. Result res = new Result();
  141. res.setData(customerService.findPersonalCustomerDetail(uid));
  142. return res;
  143. }
  144. /** 单位客户详情信息 **/
  145. @RequestMapping(value = "/findOrganizationCustomerDetail", method = RequestMethod.GET)
  146. public Result findOrganizationCustomerDetail(String uid){
  147. Result res = new Result();
  148. res.setData(customerService.findOrganizationCustomerDetail(uid));
  149. return res;
  150. }
  151. /** 修改单位客户信息 **/
  152. @RequestMapping(value = "/updateOrganizationCustomer", method = RequestMethod.POST)
  153. public Result updateOrganizationCustomer(CustomerOrganizationDetailBo bo){
  154. Result res = new Result();
  155. if(StringUtils.isBlank(bo.getId()) || StringUtils.isBlank(bo.getUid())){
  156. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  157. return res;
  158. }
  159. customerService.updateOrganizationCustomer(bo);
  160. return res;
  161. }
  162. /** 修改个人客户信息 **/
  163. @RequestMapping(value = "/updatePersonalCustomer", method = RequestMethod.POST)
  164. public Result updatePersonalCustomer(CustomerPersonalDetailBo bo){
  165. Result res = new Result();
  166. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  167. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  168. return res;
  169. }
  170. customerService.updatePersonalCustomer(bo);
  171. return res;
  172. }
  173. /** 查看跟进记录 **/
  174. @RequestMapping(value = "/listFollowHistory", method = RequestMethod.GET)
  175. public Result listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId){
  176. Result res = new Result();
  177. res.setData(customerService.listFollowHistory(pageNo,pageSize,uid,businessGlossoryId));
  178. return res;
  179. }
  180. /** 查看客户账户信息 **/
  181. @RequestMapping(value = "/findUserAccountDetail", method = RequestMethod.GET)
  182. public Result findUserAcountDetail(String uid){
  183. Result res = new Result();
  184. UserDetailBo bo = new UserDetailBo();
  185. User user = customerService.findUserAccountDetail(uid);
  186. try {
  187. BeanUtilsExt.copyProperties(bo, user);
  188. } catch (InvocationTargetException | IllegalAccessException e) {
  189. e.printStackTrace();
  190. }
  191. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  192. bo.setCreateTimes(format.format(user.getCreateTime()));
  193. res.setData(bo);
  194. return res;
  195. }
  196. /** 修改客户账户信息 **/
  197. @RequestMapping(value = "/updateUserAccount", method = RequestMethod.POST)
  198. public Result updateUserAccount(User user){
  199. Result res = new Result();
  200. customerService.updateUserAccount(user);
  201. return res;
  202. }
  203. /** 查看客户联系人列表 **/
  204. @RequestMapping(value = "/findCustomerContacts", method = RequestMethod.GET)
  205. public Result findCustomerContacts(String uid){
  206. Result res = new Result();
  207. res.setData(customerService.findCustomerContacts(uid));
  208. return res;
  209. }
  210. /** 进入添加拜访记录 **/
  211. @RequestMapping(value = "/toAddFollow", method = RequestMethod.GET)
  212. public Result toAddFollow(String uid){
  213. Result res = new Result();
  214. if(StringUtils.isBlank(uid)){
  215. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  216. return res;
  217. }
  218. User user = customerService.findUserAccountDetail(uid);
  219. FollowBusinessBo fbb = new FollowBusinessBo();
  220. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  221. fbb.setFollowTime(format.format(new Date()));
  222. fbb.setIdentifyName(user.getIdentifyName());
  223. fbb.setUid(uid);
  224. fbb.setUserBusinessList(customerService.findBusinessByUAid(uid, TokenManager.getAdminId()));
  225. res.setData(fbb);
  226. return res;
  227. }
  228. /** 添加拜访记录
  229. * @throws ParseException
  230. * @throws Exception **/
  231. @RequestMapping(value = "/addFollow", method = RequestMethod.POST)
  232. public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime) throws BusinessException{
  233. Result res = new Result();
  234. if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
  235. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  236. return res;
  237. }
  238. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  239. List<UserBusiness> list = new ArrayList<UserBusiness>();
  240. if (ja != null && !ja.isEmpty()) {
  241. UserBusiness userBusiness = null;
  242. for (int idx = 0; idx < ja.size(); idx++) {
  243. userBusiness = ja.getJSONObject(idx).toJavaObject(UserBusiness.class);
  244. for(UserBusiness ub:list){
  245. if(ub.getBusinessGlossoryId() == userBusiness.getBusinessGlossoryId()){
  246. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  247. return res;
  248. }
  249. }
  250. list.add(userBusiness);
  251. }
  252. }
  253. FollowBusinessBo fbb = new FollowBusinessBo();
  254. fbb.setOcbId(ocbId);
  255. fbb.setUid(uid);
  256. fbb.setContactType(contactType);
  257. fbb.setResult(result);
  258. fbb.setFollowTime(followTime);
  259. fbb.setUserBusinessList(list);
  260. customerService.addFollow(fbb);
  261. return res;
  262. }
  263. /** 进入修改拜访记录 **/
  264. @RequestMapping(value = "/toUpdateFollow", method = RequestMethod.GET)
  265. public Result toUpdateFollow(String followId){
  266. Result res = new Result();
  267. FollowBusinessBo fbb = customerService.findFollowById(followId);
  268. fbb.setUserBusinessList(customerService.findBusinessByFollowId(followId));
  269. res.setData(fbb);
  270. return res;
  271. }
  272. /** 修改拜访记录
  273. * @throws ParseException
  274. * @throws BusinessException
  275. */
  276. @RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
  277. public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result) throws BusinessException{
  278. Result res = new Result();
  279. if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
  280. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  281. return res;
  282. }
  283. JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
  284. List<UserBusiness> list = new ArrayList<UserBusiness>();
  285. if (ja != null && !ja.isEmpty()) {
  286. UserBusiness userBusiness = null;
  287. for (int idx = 0; idx < ja.size(); idx++) {
  288. userBusiness = ja.getJSONObject(idx).toJavaObject(UserBusiness.class);
  289. for(UserBusiness ub:list){
  290. if(ub.getBusinessGlossoryId() == userBusiness.getBusinessGlossoryId()){
  291. res.getError().add(new com.goafanti.common.bo.Error("业务类型重复,请检查后重新提交!"));
  292. return res;
  293. }
  294. }
  295. list.add(userBusiness);
  296. }
  297. }
  298. FollowBusinessBo fbb = new FollowBusinessBo();
  299. fbb.setFollowTime(followTime);
  300. fbb.setUid(uid);
  301. fbb.setContactType(contactType);
  302. fbb.setResult(result);
  303. fbb.setUserBusinessList(list);
  304. fbb.setFollowId(followId);
  305. customerService.updateFollow(fbb);
  306. return res;
  307. }
  308. /** 删除跟进记录 **/
  309. @RequestMapping(value = "/deleteFollow", method = RequestMethod.GET)
  310. public Result deleteFollow(String followId){
  311. Result res = new Result();
  312. if(StringUtils.isBlank(followId)){
  313. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  314. return res;
  315. }
  316. customerService.deleteFollow(followId);
  317. return res;
  318. }
  319. /** 查询客户的所有联系人 **/
  320. @RequestMapping(value = "/findAllContacts", method = RequestMethod.GET)
  321. public Result findAllContacts(String uid){
  322. Result res = new Result();
  323. res.setData(customerService.findAllContacts(uid));
  324. return res;
  325. }
  326. /** 修改企业联系人 **/
  327. @RequestMapping(value = "/updateCustomerContacts", method = RequestMethod.POST)
  328. public Result updateCustomerContacts(String contactList,String uid){
  329. Result res = new Result();
  330. if(StringUtils.isBlank(uid)){
  331. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  332. return res;
  333. }
  334. JSONArray ja = (JSONArray) JSON.parse(contactList);
  335. List<OrganizationContactBook> ocbList = new ArrayList<OrganizationContactBook>();
  336. OrganizationContactBook ocb = null;
  337. if(ja != null & !ja.isEmpty()){
  338. for (int idx = 0; idx < ja.size(); idx++) {
  339. ocb = ja.getJSONObject(idx).toJavaObject(OrganizationContactBook.class);
  340. if(StringUtils.isBlank(ocb.getMobile()) || StringUtils.isBlank(ocb.getName())){
  341. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户名和手机号码为必填"));
  342. return res;
  343. }
  344. if(StringUtils.isBlank(ocb.getUid())) ocb.setUid(uid);
  345. ocbList.add(ocb);
  346. }
  347. }
  348. customerService.updateCustomerContacts(ocbList,uid);
  349. return res;
  350. }
  351. /** 领取客户 **/
  352. @RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
  353. public Result receiveCustomer(String uid){
  354. Result res = new Result();
  355. if(StringUtils.isBlank(uid)){
  356. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  357. return res;
  358. }
  359. customerService.updateByOperatorType(uid, AFTConstants.USER_RECEIVE);
  360. return res;
  361. }
  362. /** 删除客户 **/
  363. @RequestMapping(value = "/deleteCustomer", method = RequestMethod.GET)
  364. public Result deleteCustomer(String uid){
  365. Result res = new Result();
  366. if(StringUtils.isBlank(uid)){
  367. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  368. return res;
  369. }
  370. customerService.updateByOperatorType(uid, AFTConstants.USER_DELETE);
  371. return res;
  372. }
  373. /**
  374. * 上传excel文档
  375. * @param req
  376. * @return
  377. */
  378. @RequestMapping(value = "/uploadExcel",method = RequestMethod.POST)
  379. public Result uploadExcel(HttpServletRequest req){
  380. Result res = new Result();
  381. String excelPath = handleFile(res, "/customer_sys_file/", true, req, "");
  382. ExcelUtils utils = new ExcelUtils();
  383. Set<CustomerExcelBo> boSet;
  384. try {
  385. boSet = utils.parseExcel(uploadPrivatePath + excelPath);
  386. String errorMessage = "";
  387. if(boSet.size()>100) errorMessage += "导入数据不能超过一百条;";
  388. errorMessage += utils.getVacantRows();
  389. if(StringUtils.isNotBlank(errorMessage)) {
  390. res.getError().add(new Error(errorMessage));
  391. return res;
  392. }
  393. Set<Integer> existRows = new TreeSet<Integer>(); //数据库已存在
  394. Set<Integer> filterRows = new TreeSet<Integer>(); //过滤提示
  395. customerService.checkCustomer(boSet,existRows,filterRows);
  396. if(existRows.size()>0){
  397. errorMessage = StringUtils.join(existRows.toArray(),",")+ " 行客户业务已存在;";
  398. res.getError().add(new Error(errorMessage));
  399. return res;
  400. }
  401. if(filterRows.size()>0){
  402. errorMessage = StringUtils.join(filterRows.toArray(),",")+ " 行已经被系统过滤;";
  403. res.getError().add(new Error(errorMessage));
  404. return res;
  405. }
  406. customerService.saveUploadData(boSet);
  407. } catch (IOException e) {
  408. e.printStackTrace();
  409. }
  410. return res;
  411. }
  412. /**
  413. * 下载科技成果批量导入Excel模板
  414. */
  415. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  416. public Result downloadTemplateFile(HttpServletResponse response,String type) {
  417. Result res = new Result();
  418. if(AFTConstants.USER_TYPE_ORGANIZATION.equals(type)){
  419. AftFile af = aftFileService.selectAftFileBySign("organization_customer_template");
  420. if (null == af) {
  421. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  422. } else {
  423. String path = af.getFilePath();
  424. String suffix = path.substring(path.lastIndexOf("."));
  425. String fileName = af.getFileName() + suffix;
  426. downloadFile(response, fileName, path);
  427. }
  428. }else if(AFTConstants.USER_TYPE_PERSONAL.equals(type)){
  429. AftFile af = aftFileService.selectAftFileBySign("personal_customer_template");
  430. if (null == af) {
  431. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  432. } else {
  433. String path = af.getFilePath();
  434. String suffix = path.substring(path.lastIndexOf("."));
  435. String fileName = af.getFileName() + suffix;
  436. downloadFile(response, fileName, path);
  437. }
  438. }
  439. return res;
  440. }
  441. /** 转为公共客户 **/
  442. @RequestMapping(value = "/transferToPublic", method = RequestMethod.GET)
  443. public Result transferToPublic(String uid){
  444. Result res = new Result();
  445. if(StringUtils.isBlank(uid)){
  446. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  447. }
  448. customerService.updateByOperatorType(uid, AFTConstants.USER_TRANSFER_TO_PUBLIC);
  449. return res;
  450. }
  451. /** 图片上传 **/
  452. @RequestMapping(value = "/uploadCustomerImg", method = RequestMethod.POST)
  453. public Result uploadCustomerImg(HttpServletRequest req,String sign){
  454. Result res = new Result();
  455. res.setData(handleFile(res, "/customer_sys_file/", false, req, sign));
  456. return res;
  457. }
  458. /**
  459. *
  460. * @param startDate 开始日期
  461. * @param endDate 结束日期
  462. * @param timeSpan 时间差
  463. * @param depId 部门编号
  464. * @param pageNo 页码
  465. * @param pageSize 页数
  466. * @return
  467. * @throws ParseException
  468. */
  469. @RequestMapping(value = "/customerStatistics",method = RequestMethod.GET)
  470. public Result customerStatistics(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  471. Result res = new Result();
  472. Date sDate = null;
  473. Date eDate = null;
  474. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  475. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  476. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  477. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  478. Date date = new Date();
  479. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  480. sDate = DateUtils.getYesterday();
  481. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  482. sDate = DateUtils.getLastDayOfLastWeek(date);
  483. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  484. sDate = DateUtils.getLastDayOfLastMonth(date);
  485. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  486. sDate = DateUtils.getLastDayOfLastQuarter(date);
  487. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  488. sDate = DateUtils.getLastDayOfLastYear(date);
  489. }
  490. }
  491. res.setData(customerService.customerStatistics(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  492. return res;
  493. }
  494. /**
  495. *
  496. * @param startDate 开始日期
  497. * @param endDate 结束日期
  498. * @param timeSpan 时间差
  499. * @param depId 部门编号
  500. * @param businessGlossoryId 业务编号
  501. * @param pageNo 页码
  502. * @param pageSiz 页数
  503. * @return
  504. * @throws ParseException
  505. */
  506. @RequestMapping(value = "/businessStatistic", method = RequestMethod.GET)
  507. public Result businessStatistic(String startDate,String endDate,String timeSpan,String depNo,String businessGlossoryId,Integer pageNo, Integer pageSize) throws ParseException{
  508. Result res = new Result();
  509. Date sDate = null;
  510. Date eDate = null;
  511. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  512. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  513. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  514. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  515. Date date = new Date();
  516. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  517. sDate = DateUtils.getYesterday();
  518. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  519. sDate = DateUtils.getLastDayOfLastWeek(date);
  520. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  521. sDate = DateUtils.getLastDayOfLastMonth(date);
  522. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  523. sDate = DateUtils.getLastDayOfLastQuarter(date);
  524. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  525. sDate = DateUtils.getLastDayOfLastYear(date);
  526. }
  527. }
  528. res.setData(customerService.businessStatistic(sDate,eDate,depNo,businessGlossoryId,pageNo,pageSize));
  529. return res;
  530. }
  531. /**
  532. *
  533. * @param startDate 开始日期
  534. * @param endDate 结束日期
  535. * @param timeSpan 时间差
  536. * @param depId 部门编号
  537. * @param businessGlossoryId 业务编号
  538. * @param pageNo 页码
  539. * @param pageSiz 页数
  540. * @return
  541. * @throws ParseException
  542. */
  543. @RequestMapping(value = "/followStatistic",method = RequestMethod.GET)
  544. public Result followStatistic(String startDate,String endDate,String timeSpan,String depNo,Integer pageNo, Integer pageSize) throws ParseException{
  545. Result res = new Result();
  546. Date sDate = null;
  547. Date eDate = null;
  548. DateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
  549. if(StringUtils.isNotBlank(startDate)) sDate = format.parse(startDate);
  550. if(StringUtils.isNotBlank(endDate)) eDate = format.parse(endDate);
  551. if(StringUtils.isBlank(startDate)&&StringUtils.isBlank(endDate)){
  552. Date date = new Date();
  553. if(timeSpan.equals(DateUtils.DAY_SPAN)){
  554. sDate = DateUtils.getYesterday();
  555. }else if(timeSpan.equals(DateUtils.WEEK_SPAN)){
  556. sDate = DateUtils.getLastDayOfLastWeek(date);
  557. }else if(timeSpan.equals(DateUtils.MONTH_SPAN)){
  558. sDate = DateUtils.getLastDayOfLastMonth(date);
  559. }else if(timeSpan.equals(DateUtils.QUARTER_SPAN)){
  560. sDate = DateUtils.getLastDayOfLastQuarter(date);
  561. }else if(timeSpan.equals(DateUtils.YEAR_SPAN)){
  562. sDate = DateUtils.getLastDayOfLastYear(date);
  563. }
  564. }
  565. res.setData(customerService.followStatistic(sDate, eDate, depNo, pageNo, pageSize));
  566. return res;
  567. }
  568. /** 管理员列表 **/
  569. @RequestMapping(value = "/listAdminByName",method = RequestMethod.GET)
  570. public Result listAdminByName(String adminName){
  571. Result res = new Result();
  572. if(StringUtils.isNotBlank(adminName))res.setData(adminService.listAdminByName(adminName));
  573. return res;
  574. }
  575. /** 转交客户到制定人 **/
  576. @RequestMapping(value = "/transferToOther", method = RequestMethod.GET)
  577. public Result transferToOther(String uid,String aid){
  578. Result res = new Result();
  579. if(StringUtils.isBlank(uid) || StringUtils.isBlank(aid)){
  580. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "客户编号或管理员编号"));
  581. return res;
  582. }
  583. customerService.updateByOperatorType(uid, AFTConstants.USER_TRANSFER_TO_OTHER, aid);
  584. return res;
  585. }
  586. /** 查询我的业务列表 **/
  587. @RequestMapping(value = "/listBusiness", method = RequestMethod.POST)
  588. public Result listBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  589. Result res = new Result();
  590. res.setData(customerService.listBusiness(blo, pageNo, pageSize));
  591. return res;
  592. }
  593. /** 查询所有的业务列表 **/
  594. @RequestMapping(value = "/listAllBusiness", method = RequestMethod.POST)
  595. public Result listAllBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  596. Result res = new Result();
  597. res.setData(customerService.listAllBusiness(blo, pageNo, pageSize));
  598. return res;
  599. }
  600. /** 业务管理列表 **/
  601. @RequestMapping(value = "/listManageBusiness", method = RequestMethod.POST)
  602. public Result listManageBusiness(BusinessListBo blo,Integer pageNo, Integer pageSize){
  603. Result res = new Result();
  604. res.setData(customerService.listManageBusiness(blo, pageNo, pageSize));
  605. return res;
  606. }
  607. /** 查询业务字典 **/
  608. @RequestMapping(value = "/findBusinessGlossory",method = RequestMethod.GET)
  609. public Result findBusinessGlossory(){
  610. Result res = new Result();
  611. res.setData(customerService.findBusinessGlossory());
  612. return res;
  613. }
  614. /** 新增客户意向 **/
  615. @RequestMapping(value = "/addBusinessAndFollow", method = RequestMethod.POST)
  616. public Result addBusinessAndFollow(BussinessFollowBo bfb){
  617. Result res = new Result();
  618. if(StringUtils.isBlank(bfb.getBusinessGlossoryId()) || StringUtils.isBlank(bfb.getUid())){
  619. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  620. return res;
  621. }
  622. if(customerService.judgeBusiness(bfb.getUid(), Integer.parseInt(bfb.getBusinessGlossoryId()))>0){
  623. res.getError().add(new Error("该项业务已经被跟进"));
  624. return res;
  625. }
  626. try {
  627. customerService.addBusinessAndFollow(bfb);
  628. } catch (ParseException e) {
  629. e.printStackTrace();
  630. }
  631. return res;
  632. }
  633. /** 进入新增意向服务 **/
  634. @RequestMapping(value = "/toAddBusinessAndFollow", method = RequestMethod.GET)
  635. public Result toAddBusinessAndFollow(){
  636. Result res = new Result();
  637. BussinessFollowBo bo = new BussinessFollowBo();
  638. bo.setAdminName(TokenManager.getAdminToken().getName());
  639. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  640. bo.setCreateTime(format.format(new Date()));
  641. bo.setFollowTime(bo.getCreateTime());
  642. res.setData(bo);
  643. return res;
  644. }
  645. /** 进入修改业务意向 **/
  646. @RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
  647. public Result toUpdateBusiness(String businessId){
  648. Result res = new Result();
  649. res.setData(customerService.findBusinessDetail(businessId));
  650. return res;
  651. }
  652. /** 修改业务意向 **/
  653. @RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
  654. public Result updateBusiness(BussinessFollowBo bfb){
  655. Result res = new Result();
  656. customerService.updateBusiness(bfb);
  657. return res;
  658. }
  659. /** 进入跟进单个客户意向 **/
  660. @RequestMapping(value = "/toAddFollowOneBusiness", method = RequestMethod.GET)
  661. public Result toAddFollowOneBusiness(String businessId){
  662. Result res = new Result();
  663. BussinessFollowBo bo = customerService.findBusinessDetail(businessId);
  664. SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
  665. bo.setFollowTime(format.format(new Date()));
  666. res.setData(bo);
  667. return res;
  668. }
  669. /** 跟进单个客户意向 **/
  670. @RequestMapping(value = "/addFollowOneBusiness", method = RequestMethod.POST)
  671. public Result addFollowOneBusiness(BussinessFollowBo bfb){
  672. Result res = new Result();
  673. if(StringUtils.isBlank(bfb.getBusinessId()) ||
  674. StringUtils.isBlank(bfb.getUid()) || StringUtils.isBlank(bfb.getOcbId())){
  675. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
  676. return res;
  677. }
  678. try {
  679. customerService.addFollowOneBusiness(bfb);
  680. } catch (ParseException e) {
  681. e.printStackTrace();
  682. }
  683. return res;
  684. }
  685. /** 进入修改某个客户一个业务的当次拜访 **/
  686. @RequestMapping(value = "/toUpdateFollowOneBusiness", method = RequestMethod.GET)
  687. public Result toUpdateFollowOneBusiness(String ufbId){
  688. Result res = new Result();
  689. if(StringUtils.isBlank(ufbId)) {
  690. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  691. return res;
  692. }
  693. res.setData(customerService.findFollowOneBusiness(ufbId));
  694. return res;
  695. }
  696. /** 修改某个客户一个业务的当次拜访 **/
  697. @RequestMapping(value = "/updateFollowOneBusiness", method = RequestMethod.POST)
  698. public Result updateFollowOneBusiness(BussinessFollowBo bfb){
  699. Result res = new Result();
  700. if(StringUtils.isBlank(bfb.getFollowId()) || StringUtils.isBlank(bfb.getUfbId())){
  701. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  702. return res;
  703. }
  704. customerService.updateFollowOneBusiness(bfb);
  705. return res;
  706. }
  707. /** 删除某个客户一个业务的当次拜访 **/
  708. @RequestMapping(value = "/deleteFollowOneBusiness", method = RequestMethod.GET)
  709. public Result deleteFollowOneBusiness(String ufbId){
  710. Result res = new Result();
  711. if(StringUtils.isBlank(ufbId)){
  712. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  713. return res;
  714. }
  715. customerService.deleteFollowOneBusiness(ufbId);
  716. return res;
  717. }
  718. /** 添加单个联系人 **/
  719. @RequestMapping(value = "/addOneContact", method = RequestMethod.POST)
  720. public Result addOneContact(OrganizationContactBook ocb){
  721. Result res = new Result();
  722. if(StringUtils.isBlank(ocb.getUid())){
  723. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  724. return res;
  725. }
  726. if(StringUtils.isBlank(ocb.getName()) || StringUtils.isBlank(ocb.getMobile())){
  727. res.getError().add(buildError("联系人号码和联系人姓名不能为空"));
  728. return res;
  729. }
  730. customerService.addOneContact(ocb);
  731. return res;
  732. }
  733. /** 删除单个联系人 **/
  734. @RequestMapping(value = "/deleteOneContact", method = RequestMethod.GET)
  735. public Result deleteOneContact(String ocbId){
  736. Result res = new Result();
  737. if(StringUtils.isBlank(ocbId)){
  738. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  739. return res;
  740. }
  741. customerService.deleteOneContact(ocbId);
  742. return res;
  743. }
  744. /** 删除 业务 **/
  745. @RequestMapping(value = "/deleteBusiness", method =RequestMethod.GET)
  746. public Result deleteBusiness(String businessId){
  747. Result res = new Result();
  748. if(StringUtils.isBlank(businessId)){
  749. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  750. return res;
  751. }
  752. customerService.deleteBusiness(businessId);
  753. return res;
  754. }
  755. /** 停止业务 **/
  756. @RequestMapping(value = "/stopBusiness", method = RequestMethod.GET)
  757. public Result stopBusiness(String businessId){
  758. Result res = new Result();
  759. if(StringUtils.isBlank(businessId)){
  760. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
  761. return res;
  762. }
  763. customerService.updateBusinessToStop(businessId);
  764. return res;
  765. }
  766. /** 客户分配查询(本部门) **/
  767. @RequestMapping(value = "/findAdminName" , method = RequestMethod.POST)
  768. public Result findAdminName(){
  769. Result res = new Result();
  770. res.setData(customerService.findAdminName());
  771. return res;
  772. }
  773. /** 分配个人客户 **/
  774. @RequestMapping(value = "/updatePersonalCustomerz", method = RequestMethod.POST)
  775. public Result updatePersonalCustomerz(CustomerPersonalDetailBo bo){
  776. Result res = new Result();
  777. if(StringUtils.isBlank(bo.getUid()) || StringUtils.isBlank(bo.getId())){
  778. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  779. return res;
  780. }
  781. customerService.updatePersonalCustomerz(bo);
  782. return res;
  783. }
  784. /** 客户录入审核 **/
  785. @RequestMapping(value = "/findEnteringAudit" , method = RequestMethod.POST)
  786. public Result findEnteringAudit(CustomerListOut clo,Integer pageNo, Integer pageSize){
  787. Result res = new Result();
  788. res.setData(customerService.findEnteringAudit(clo, pageNo, pageSize));
  789. return res;
  790. }
  791. /** 修改客户录入审核状态 **/
  792. @RequestMapping(value = "/updateEnteringAudit", method = RequestMethod.POST)
  793. public Result updateEnteringAudit(User bo){
  794. Result res = new Result();
  795. if(StringUtils.isBlank(bo.getId())){
  796. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  797. return res;
  798. }
  799. customerService.updateEnteringAudit(bo);
  800. return res;
  801. }
  802. /** 审核拒绝客户查询 **/
  803. @RequestMapping(value = "/findEnteringAuditIsNo" , method = RequestMethod.POST)
  804. public Result findEnteringAuditIsNo(CustomerListOut clo,Integer pageNo, Integer pageSize){
  805. Result res = new Result();
  806. res.setData(customerService.findEnteringAuditIsNo(clo, pageNo, pageSize));
  807. return res;
  808. }
  809. }