AdminCustomerController.java 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128
  1. package com.iamberry.rst.controllers.cm;
  2. import com.iamberry.rst.core.cm.*;
  3. import com.iamberry.rst.core.fm.ComplaintSignclosedInfo;
  4. import com.iamberry.rst.core.fm.ComplaintSmallClassInfo;
  5. import com.iamberry.rst.core.order.Product;
  6. import com.iamberry.rst.core.order.ProductColor;
  7. import com.iamberry.rst.core.order.ProductType;
  8. import com.iamberry.rst.core.page.PagedResult;
  9. import com.iamberry.rst.core.sys.Admin;
  10. import com.iamberry.rst.core.tools.LogisticsInfo;
  11. import com.iamberry.rst.faces.address.AddressService;
  12. import com.iamberry.rst.faces.cm.*;
  13. import com.iamberry.rst.faces.fm.ComplaintSignclosedInfoService;
  14. import com.iamberry.rst.faces.fm.ComplaintSmallClassInfoService;
  15. import com.iamberry.rst.faces.order.EfastOrderService;
  16. import com.iamberry.rst.faces.order.LogisticsInfoService;
  17. import com.iamberry.rst.faces.product.ProductService;
  18. import com.iamberry.rst.faces.sms.SmsService;
  19. import com.iamberry.rst.faces.sys.SysService;
  20. import com.iamberry.rst.util.SmsConfig;
  21. import com.iamberry.rst.utils.*;
  22. import com.iamberry.wechat.tools.NameUtils;
  23. import com.iamberry.wechat.tools.ResponseJson;
  24. import com.iamberry.wechat.tools.ResultInfo;
  25. import net.sf.json.JSONArray;
  26. import net.sf.json.JSONObject;
  27. import org.apache.commons.codec.binary.Base64;
  28. import org.apache.commons.lang.StringUtils;
  29. import org.apache.poi.hssf.usermodel.*;
  30. import org.apache.shiro.authz.annotation.RequiresPermissions;
  31. import org.slf4j.Logger;
  32. import org.slf4j.LoggerFactory;
  33. import org.springframework.beans.BeanUtils;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.stereotype.Controller;
  36. import org.springframework.web.bind.annotation.RequestMapping;
  37. import org.springframework.web.bind.annotation.RequestParam;
  38. import org.springframework.web.bind.annotation.ResponseBody;
  39. import org.springframework.web.servlet.ModelAndView;
  40. import javax.servlet.ServletOutputStream;
  41. import javax.servlet.http.HttpServletRequest;
  42. import javax.servlet.http.HttpServletResponse;
  43. import java.io.*;
  44. import java.text.MessageFormat;
  45. import java.text.SimpleDateFormat;
  46. import java.util.*;
  47. /**
  48. * Created by wxm
  49. */
  50. @Controller
  51. @RequestMapping("/admin/customer")
  52. public class AdminCustomerController {
  53. private Logger logger = LoggerFactory.getLogger(AdminCustomerController.class);
  54. @Autowired
  55. private CompanyInfoService companyInfoService;
  56. @Autowired
  57. private StoreInfoService storeInfoService;
  58. @Autowired
  59. private SalesOrderService salesOrderService;
  60. @Autowired
  61. private CustomerService customerService;
  62. @Autowired
  63. private ProductService productService;
  64. @Autowired
  65. private SysService sysService;
  66. @Autowired
  67. private ComplaintTypeInfoService complaintTypeInfoService;
  68. @Autowired
  69. private VisitService visitService;
  70. @Autowired
  71. private QuestionDescribeService questionDescribeService;
  72. @Autowired
  73. private ComplaintQuestionInfoService complaintQuestionInfoService;
  74. @Autowired
  75. private SmsService smsService;
  76. @Autowired
  77. private ComplaintSignclosedInfoService complaintSignclosedInfoService;
  78. @Autowired
  79. private ComplaintSmallClassInfoService complaintSmallClassInfoService;
  80. @Autowired
  81. private AddressService addressService;
  82. @Autowired
  83. private PostageService postageService;
  84. @Autowired
  85. private EfastOrderService efastOrderService;
  86. @Autowired
  87. private RelationOrderService relationOrderService;
  88. @Autowired
  89. private GenerateKeyUtil generateKeyUtil ;
  90. @Autowired
  91. private CmRelationService cmRelationService ;
  92. @Autowired
  93. private ProcMethodService procMethodService ;
  94. @Autowired
  95. private LogisticsInfoService logisticsInfoService;
  96. /**
  97. * 获取客诉列表
  98. *
  99. * @param request
  100. * @return
  101. */
  102. @RequiresPermissions("customer:list:customer")
  103. @RequestMapping("/_customer_list")
  104. public ModelAndView getCustomer(HttpServletRequest request, CustomerInfo customer,
  105. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  106. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  107. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
  108. ModelAndView mv = new ModelAndView("cm/customer/custome_list");
  109. // PagedResult<Customer> pagedResult = ptsBomService.listCustomer(pageNO, pageSize, ptsBom, totalNum == 0);
  110. // if (totalNum != 0) {
  111. // pagedResult.setTotal(totalNum);
  112. // }
  113. // //获取产品集合,用于页面选择产品
  114. // List<Produce> list = produceService.getProduceList();
  115. // mv.addObject("produceList", list);
  116. // StitchAttrUtil.getSa().setModelAndView(customer, mv, "/admin/bom/_bom_list", pagedResult);
  117. return mv;
  118. }
  119. /**
  120. * 跳转到添加客诉页面
  121. *
  122. * @return
  123. */
  124. @RequiresPermissions("customer:add:customer")
  125. @RequestMapping(value = "/to_add_customer")
  126. public ModelAndView toAddCustomer(HttpServletRequest request) {
  127. ModelAndView mv = new ModelAndView("cm/customer/add_customer");
  128. //获取产品集合,用于页面选择产品
  129. // List<Produce> produceList = produceService.getProduceList();
  130. // mv.addObject("produceList", produceList);
  131. return mv;
  132. }
  133. /**
  134. * 跳转到修改客诉页面
  135. *
  136. * @return
  137. */
  138. @RequiresPermissions("customer:update:customer")
  139. @RequestMapping(value = "/to_update_customer")
  140. public ModelAndView toUpdateCustomer(HttpServletRequest request, Integer customerId) {
  141. ModelAndView mv = new ModelAndView("cm/customer/update_customer");
  142. ProductType productType = new ProductType();
  143. //查询产品类型集合
  144. List<ProductType> typeList = productService.listProductType(productType);
  145. //查询客诉类型集合
  146. List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  147. //查询跟进客服集合
  148. Admin admin = new Admin();
  149. admin.setAdminDept(3);
  150. admin.setAdminStatus(1);
  151. List<Admin> adminList = sysService.listSelectAdmin(admin);
  152. //获取登录人id
  153. Integer loginAdminId = AdminUtils.getLoginAdminId();
  154. //查询客诉基本信息
  155. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  156. /*查询处理方式*/
  157. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerInfo.getCustomerId());
  158. /*获取寄出寄入产品*/
  159. cmRelationService.getSendAndBackProduct(cmRelation);
  160. /*处理方式*/
  161. ProcMethod procMethod = procMethodService.getProcMethodById(cmRelation.getProcMethodId());
  162. if (customerInfo.getTypeId() == 1 || (procMethod.getProcMethodIsSend()==2 && procMethod.getProcMethodIsBack() == 2)) {
  163. customerInfo.setIsNeedSelectOrder(2); //不需要订单
  164. } else {
  165. customerInfo.setIsNeedSelectOrder(1);
  166. }
  167. //setIsNeedSelectOrder
  168. if (customerInfo.getIsNeedSelectOrder() == 1 ) {
  169. RelationOrder relationOrder = new RelationOrder();
  170. relationOrder.setRelationId(cmRelation.getRelationId());
  171. List<RelationOrder> relationOrderList = relationOrderService.getRelationOrderList(relationOrder);
  172. String[] salesIds = new String[relationOrderList.size()];
  173. for (int k = 0; k < relationOrderList.size(); k++) {
  174. salesIds[k] = String.valueOf(relationOrderList.get(k).getSalesId());
  175. }
  176. if(salesIds!=null && salesIds.length > 0){
  177. SalesOrder so = new SalesOrder();
  178. so.setSalesIds(salesIds);
  179. List<SalesOrder> orderList = salesOrderService.listSalesOrder(so);
  180. for (SalesOrder sor : orderList) {
  181. SalesOrderItem salesOrderItem = new SalesOrderItem();
  182. salesOrderItem.setItemOrderId(sor.getSalesId());
  183. List<SalesOrderItem> salesOrderItemList = salesOrderService.listSalesOrderItem(salesOrderItem);
  184. sor.setSalesOrderItemList(salesOrderItemList);
  185. }
  186. mv.addObject("salesOrderList", orderList);
  187. }
  188. } else {
  189. mv.addObject("salesOrderList", null);
  190. }
  191. if ("2".equals(customerInfo.getCustomerIsVisit())) { //1:不需要回访 2:需要回访
  192. Visit visit = new Visit();
  193. visit.setCustomerId(customerInfo.getCustomerId());
  194. visit = visitService.getVisit(visit);
  195. mv.addObject("visit", visit);
  196. }
  197. //查询关联问题
  198. ComplaintQuestionInfo complaintQuestionInfo = complaintQuestionInfoService.getQuestionById(customerInfo.getQuestionId());
  199. //查询问题小类
  200. ComplaintSmallClassInfo complaintSmallClassInfo = new ComplaintSmallClassInfo();
  201. complaintSmallClassInfo.setComplaintId(complaintQuestionInfo.getComplaintId());
  202. List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(complaintSmallClassInfo);
  203. //查询问题大类
  204. ComplaintTypeInfo complaintTypeInfo = new ComplaintTypeInfo();
  205. List<ComplaintTypeInfo> complaintTypeInfoList = complaintTypeInfoService.listComplaintTypeInfo(complaintTypeInfo);
  206. mv.addObject("cmRelation", cmRelation);
  207. mv.addObject("procMethod", procMethod);
  208. mv.addObject("customerInfo", customerInfo);
  209. mv.addObject("typeList", typeList);
  210. mv.addObject("complaintTypeList", complaintTypeList);
  211. mv.addObject("complaintTypeList", complaintTypeList);
  212. mv.addObject("adminList", adminList);
  213. mv.addObject("loginAdminId", loginAdminId);
  214. mv.addObject("complaintQuestionInfo", complaintQuestionInfo);
  215. mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
  216. mv.addObject("complaintTypeInfoList", complaintTypeInfoList);
  217. return mv;
  218. }
  219. /**
  220. * 查询问题描述
  221. *
  222. * @return
  223. */
  224. @ResponseBody
  225. @RequiresPermissions("customer:add:customer")
  226. @RequestMapping(value = "/select_question_describe")
  227. public ResponseJson selectQuestionDescribe(HttpServletRequest request, Integer customerId) throws Exception {
  228. if (customerId == null || customerId == 0) {
  229. return new ResponseJson(500, "未获取到问题描述", 500);
  230. }
  231. //查询问题描述表
  232. QuestionDescribe questionDescribe = new QuestionDescribe();
  233. questionDescribe.setCustomerId(customerId);
  234. questionDescribe = questionDescribeService.listQuestionDescribe(questionDescribe).get(0);
  235. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  236. rj.addResponseKeyValue("questionDescribe", questionDescribe);
  237. return rj;
  238. }
  239. /**
  240. * 搜索订单列表弹出框
  241. *
  242. * @return
  243. */
  244. @RequiresPermissions("customer:add:customer")
  245. @RequestMapping(value = "/select_order")
  246. public ModelAndView selectOrder(HttpServletRequest request) {
  247. ModelAndView mv = new ModelAndView("cm/customer/order_list");
  248. //获取销售公司
  249. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  250. mv.addObject("companyInfoList", companyInfoList);
  251. return mv;
  252. }
  253. /**
  254. * 添加订单列表弹出框
  255. *
  256. * @return
  257. */
  258. @RequiresPermissions("customer:add:customer")
  259. @RequestMapping(value = "/add_order")
  260. public ModelAndView addOder(HttpServletRequest request) {
  261. ModelAndView mv = new ModelAndView("cm/customer/order_add");
  262. return mv;
  263. }
  264. /**
  265. * 添加订单
  266. *
  267. * @return
  268. */
  269. @ResponseBody
  270. @RequiresPermissions("customer:add:customer")
  271. @RequestMapping(value = "/add_order_info")
  272. public ResponseJson addOrderInfo(HttpServletRequest request, SalesOrder salesOrder, String itemJson) throws Exception {
  273. List<SalesOrderItem> list = new ArrayList<>();
  274. JSONArray jsonArray = JSONArray.fromObject(itemJson);
  275. list = (List) JSONArray.toCollection(jsonArray, SalesOrderItem.class);
  276. Integer salesAmount = 0;
  277. for (int i = 0; i < list.size(); i++) {
  278. SalesOrderItem salesOrderItem = list.get(i);
  279. if (salesOrderItem.getItemIsSource() == 1) { //产品来源 1:产品颜色表,2:配件表
  280. Product product = productService.getProductById(salesOrderItem.getItemColorId());
  281. ProductColor productColor = productService.getProduceColor(salesOrderItem.getItemColorId());
  282. salesOrderItem.setItemProductType(product.getProductType());
  283. salesOrderItem.setItemProductName(product.getProductName());
  284. salesOrderItem.setItemProductPic(productColor.getColorPicture());
  285. salesOrderItem.setItemProductColor(productColor.getColorName());
  286. salesOrderItem.setItemColorBar(productColor.getColorBar());
  287. salesOrderItem.setItemProductPrice(productColor.getColorPrice());
  288. salesOrderItem.setItemProductDiscount(productColor.getColorDiscount());
  289. salesOrderItem.setItemIsSource(1);
  290. salesAmount += productColor.getColorDiscount();
  291. }
  292. }
  293. salesOrder.setSalesOpenId("0");
  294. salesOrder.setSalesAmount(salesAmount);
  295. salesOrder.setSalesPayMoney(salesAmount);
  296. salesOrder.setSalesOrderStatus(1);
  297. salesOrder.setSalesCreateTime(new Date());
  298. //salesOrder.setSalesPayTime(new Date());
  299. salesOrder.setSalesLastMoney(salesAmount);
  300. salesOrder.setSalesWaitMoney(0);
  301. salesOrder.setSalesPayMoney(salesAmount);
  302. salesOrder.setSalesSalesTime(new Date());
  303. salesOrder.setSalesDiscountMoney(salesAmount);
  304. salesOrder.setSalesPledgeMoney(0);
  305. salesOrder.setSalesRemainDeposit(0);
  306. salesOrder.setSalesType(1);
  307. salesOrder.setSalesStatus(1);//确认状态:0(未确认)1(确认)2(挂起)3(作废)
  308. salesOrder.setSalesPayStatus(2); //已付款
  309. salesOrder.setSalesProcessStatus(0); //单据状态:0(正常单)1(问题单)
  310. salesOrder.setSalesIsSend(0); //0:否 1:是 是否通知配货
  311. salesOrder.setSalesIsLocked(0); //是否锁定 0:否 1:是
  312. salesOrder.setSalesIsSeparate(0); //是否缺货 0:否 1:是
  313. salesOrder.setSalesShippingFee(0); //邮费
  314. salesOrder.setSalesDeliver(2); // 已出库
  315. Integer adminId = AdminUtils.getLoginAdminId();
  316. String orderCode = GenerateKeyUtil.createOrderCode(adminId);
  317. salesOrder.setSalesDealCode(orderCode);
  318. salesOrder.setSalesOrderId(orderCode);
  319. salesOrder.setSalesBatchId(generateKeyUtil.getSalesBatchIdKS());
  320. //salesOrder = salesOrderService.addOrderAndIteminfo(salesOrder,list);
  321. salesOrder.setSalesOrderItemList(list);
  322. try {
  323. Integer flag = customerService.addOrder(salesOrder);
  324. } catch (RuntimeException e) {
  325. return new ResponseJson(500, "添加订单失败--" + e.getMessage(), 500);
  326. }
  327. Integer orderId = salesOrder.getSalesId();
  328. ResponseJson rj = new ResponseJson(200, "添加订单成功", 200);
  329. rj.addResponseKeyValue("orderId", orderId);
  330. return rj;
  331. }
  332. /**
  333. * 查询销售公司
  334. *
  335. * @return
  336. */
  337. @ResponseBody
  338. @RequiresPermissions("customer:add:customer")
  339. @RequestMapping(value = "/select_company")
  340. public ResponseJson getCompany(HttpServletRequest request) throws Exception {
  341. //获取销售公司
  342. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  343. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  344. rj.addResponseKeyValue("companyInfoList", companyInfoList);
  345. return rj;
  346. }
  347. /**
  348. * 获取店铺集合
  349. *
  350. * @param request
  351. * @param storeInfo
  352. * @return
  353. */
  354. @ResponseBody
  355. @RequiresPermissions("customer:add:customer")
  356. @RequestMapping(value = "/select_storeInfo")
  357. public ResponseJson listStoreInfo(HttpServletRequest request, StoreInfo storeInfo) {
  358. storeInfo.setStoreStatus(1);
  359. List<StoreInfo> storeInfoList = storeInfoService.listStore(storeInfo);
  360. if (storeInfoList == null || storeInfoList.size() < 1) {
  361. return new ResponseJson(500, "查询失败", 500);
  362. } else {
  363. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  364. rj.addResponseKeyValue("storeInfoList", storeInfoList);
  365. return rj;
  366. }
  367. }
  368. /**
  369. * 获取订单集合
  370. *
  371. * @param request
  372. * @param salesOrder
  373. * @return
  374. */
  375. @ResponseBody
  376. @RequiresPermissions("customer:add:customer")
  377. @RequestMapping(value = "/select_salesOrder")
  378. public ResponseJson listOrder(HttpServletRequest request, SalesOrder salesOrder, String ids,
  379. @RequestParam(value = "pageSize", defaultValue = "20", required = false) Integer pageSize,
  380. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  381. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
  382. if (ids != null && ids.indexOf("_") > -1) {
  383. String[] salesIds = ids.split("_");
  384. salesOrder.setSalesIds(salesIds);
  385. }
  386. //分页获取订单信息
  387. PagedResult<SalesOrder> pagedResult = salesOrderService.listSalesOrderPage(pageNO, pageSize, salesOrder, totalNum == 0);
  388. List<SalesOrder> salesOrderList = pagedResult.getDataList();
  389. for (SalesOrder so:salesOrderList) {
  390. if(so.getSalesOrderStatus() != 0){
  391. ProcMethod procMethod = procMethodService.getProcMethodById(so.getSalesOrderStatus());
  392. so.setSalesOrderStatusProcTypeName(procMethod.getProcTypeName());
  393. }
  394. }
  395. if (salesOrderList == null || salesOrderList.size() < 1) {
  396. return new ResponseJson(500, "查询失败", 500);
  397. } else {
  398. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  399. rj.addResponseKeyValue("salesOrderList", salesOrderList);
  400. return rj;
  401. }
  402. }
  403. /**
  404. * 分页查询客诉列表信息
  405. *
  406. * @param request
  407. * @param customerInfo
  408. * @param pageSize
  409. * @param pageNO
  410. * @param totalNum
  411. * @return
  412. * @throws Exception
  413. */
  414. @RequiresPermissions("customer:select:customer")
  415. @RequestMapping("/select_customer_list")
  416. public ModelAndView selectCustomerList(HttpServletRequest request, CustomerInfo customerInfo,
  417. @RequestParam(value = "isFirst", defaultValue = "2", required = false) Integer isFirst,
  418. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  419. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  420. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
  421. ModelAndView mv = new ModelAndView("cm/customer/custome_list");
  422. /*if (customerInfo.getAdminId() == null && isFirst == 1) {
  423. //获取登录员工id
  424. Integer adminId = AdminUtils.getLoginAdminId();
  425. customerInfo.setAdminId(adminId);
  426. }*/
  427. PagedResult<CustomerInfo> pagedResult = customerService.listCustomer(pageNO, pageSize, customerInfo, totalNum == 0);
  428. if (totalNum != 0) {
  429. pagedResult.setTotal(totalNum);
  430. }
  431. ProductType productType = new ProductType();
  432. //查询产品类型集合
  433. List<ProductType> typeList = productService.listProductType(productType);
  434. //查询客诉类型集合
  435. List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  436. //查询客诉类型集合
  437. List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(new ComplaintSmallClassInfo());
  438. //查询处理类型
  439. List<ProcType> procTypeList = customerService.listProcType();
  440. //查询问题集合 第 30 条bug
  441. // List<QuestionDescribe> questionDescribeList = questionDescribeService.listQuestionDescribe(new QuestionDescribe());
  442. //查询跟进客服集合
  443. Admin admin = new Admin();
  444. admin.setAdminDept(3);
  445. admin.setAdminStatus(1);
  446. List<Admin> adminList = sysService.listSelectAdmin(admin);
  447. //获取登录人id
  448. Integer loginAdminId = AdminUtils.getLoginAdminId();
  449. mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
  450. mv.addObject("loginAdminId", loginAdminId);
  451. mv.addObject("typeList", typeList);
  452. mv.addObject("complaintTypeList", complaintTypeList);
  453. mv.addObject("adminList", adminList);
  454. mv.addObject("procTypeList", procTypeList);
  455. customerInfo.setVisit(null);
  456. customerInfo.setCustomerCommon(null);
  457. customerInfo.setComplaintDetectList(null);
  458. StitchAttrUtil sa = StitchAttrUtil.getSa();
  459. sa.addDatePro("yyyy-MM-dd", "startTime", "endTime");
  460. sa.setModelAndView(customerInfo, mv, "/admin/customer/select_customer_list", pagedResult);
  461. return mv;
  462. }
  463. /**
  464. * 进入客诉基本信息页面
  465. *
  466. * @param request
  467. * @return
  468. * @throws Exception
  469. */
  470. @RequiresPermissions("customer:select:customer")
  471. @RequestMapping("/_customer_info")
  472. public ModelAndView toCustomerInfo(HttpServletRequest request) throws Exception {
  473. ModelAndView mv = new ModelAndView("cm/customer/custome_detail");
  474. String customerId = request.getParameter("customerId");
  475. mv.addObject("customerId", customerId);
  476. return mv;
  477. }
  478. /**
  479. * 查询客诉基本信息
  480. *
  481. * @param request
  482. * @return
  483. * @throws Exception
  484. */
  485. @ResponseBody
  486. @RequiresPermissions("customer:select:customer")
  487. @RequestMapping("/get_customer_info")
  488. public ResponseJson getCustomerInfo(HttpServletRequest request) throws Exception {
  489. String customerId = request.getParameter("customerId");
  490. if (!StringUtils.isNotEmpty(customerId)) {
  491. return new ResponseJson(500, "该客诉信息不存在!", 500);
  492. }
  493. CustomerInfo customerInfo = new CustomerInfo();
  494. customerInfo.setCustomerId(Integer.parseInt(customerId));
  495. Map<String, Object> map = customerService.getCustomerInfo(customerInfo);
  496. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  497. //查询处理方式信息
  498. CmRelation cmRelation = new CmRelation();
  499. cmRelation.setCustomerId(customerInfo.getCustomerId());
  500. cmRelation = customerService.getCmRelationInfo(cmRelation);
  501. ProcMethod procMethod = customerService.getProcMethod(cmRelation.getProcMethodId());
  502. rj.addResponseKeyValue("cmRelation", cmRelation);
  503. rj.addResponseKeyValue("procMethod", procMethod);
  504. rj.addResponseKeyValue("customerCommon", map.get("customerCommon"));
  505. rj.addResponseKeyValue("customer", map.get("customer"));
  506. rj.addResponseKeyValue("orderList", map.get("orderList"));
  507. return rj;
  508. }
  509. /**
  510. * 进入添加回访页面
  511. *
  512. * @param request
  513. * @return
  514. * @throws Exception
  515. */
  516. @RequiresPermissions("customer:select:customer")
  517. @RequestMapping("/_add_visit")
  518. public ModelAndView toAddVisit(HttpServletRequest request) throws Exception {
  519. ModelAndView mv = new ModelAndView("cm/customer/add_visit");
  520. String customerId = request.getParameter("customerId");
  521. //查询跟进客服集合
  522. Admin admin = new Admin();
  523. admin.setAdminDept(3);
  524. admin.setAdminStatus(1);
  525. List<Admin> adminList = sysService.listSelectAdmin(admin);
  526. //获取登录人id
  527. Integer loginAdminId = AdminUtils.getLoginAdminId();
  528. mv.addObject("loginAdminId", loginAdminId);
  529. mv.addObject("customerId", customerId);
  530. mv.addObject("adminList", adminList);
  531. return mv;
  532. }
  533. /**
  534. * 添加回访信息
  535. *
  536. * @param request
  537. * @param visit
  538. * @return
  539. */
  540. @ResponseBody
  541. @RequiresPermissions("customer:add:visit")
  542. @RequestMapping("/add_visit_info")
  543. public ResponseJson addVisitInfo(HttpServletRequest request, Visit visit) throws Exception {
  544. String visitAdminId = request.getParameter("visitAdminId");
  545. if (!StringUtils.isNotEmpty(visitAdminId)) {
  546. return new ResponseJson(500, "请选择回访人!", 500);
  547. }
  548. Integer loginAdminId = AdminUtils.getLoginAdminId();
  549. visit.setAdminId(loginAdminId);
  550. visit.setDesignatedAdminId(Integer.parseInt(visitAdminId));
  551. visit.setVisitStatus(1);
  552. visit.setVisitCreateTime(new Date());
  553. int num = visitService.addVisitInfo(visit, visit.getCustomerId());
  554. if (num > 0) {
  555. return new ResponseJson(200, "修改成功!", 200);
  556. } else {
  557. return new ResponseJson(500, "修改失败!", 500);
  558. }
  559. }
  560. /**
  561. * 修改客诉状态为已解决
  562. *
  563. * @param request
  564. * @return
  565. */
  566. @ResponseBody
  567. @RequiresPermissions("customer:update:customerIsSolve")
  568. @RequestMapping("/update_customerIsSolve")
  569. public ResponseJson updateCustomerIsSolve(HttpServletRequest request) throws Exception {
  570. String customerId = request.getParameter("customerId");
  571. if (!StringUtils.isNotEmpty(customerId)) {
  572. return new ResponseJson(500, "该客诉信息不存在!", 500);
  573. }
  574. //根据id获取客诉信息
  575. CustomerInfo customer = customerService.getCustomerInfo(Integer.parseInt(customerId));
  576. if (customer == null) {
  577. return new ResponseJson(500, "该客诉信息不存在!", 500);
  578. }
  579. if (customer.getCustomerIsSolve().intValue() != 2) {
  580. return new ResponseJson(500, "该客诉信息不能修改为已解决状态!", 500);
  581. }
  582. CustomerInfo customerInfo = new CustomerInfo();
  583. customerInfo.setCustomerId(Integer.parseInt(customerId));
  584. customerInfo.setCustomerIsSolve(1);
  585. //修改客诉信息
  586. int num = customerService.updateCustomerInfo(customerInfo);
  587. if (num > 0) {
  588. return new ResponseJson(200, "修改成功!", 200);
  589. } else {
  590. return new ResponseJson(500, "修改失败!", 500);
  591. }
  592. }
  593. /**
  594. * 查询客服
  595. *
  596. * @param request
  597. * @return
  598. */
  599. @ResponseBody
  600. @RequiresPermissions("customer:add:customer")
  601. @RequestMapping("/select_sys_admin")
  602. public ResponseJson selectSysAdmin(HttpServletRequest request) throws Exception {
  603. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  604. Integer adminId = AdminUtils.getLoginAdminId();
  605. Admin admin = new Admin();
  606. admin.setAdminDept(3);
  607. admin.setAdminStatus(1);
  608. List<Admin> adminList = sysService.listSelectAdmin(admin);
  609. if (adminList.size() > 0) {
  610. rj.addResponseKeyValue("adminList", adminList);
  611. rj.addResponseKeyValue("adminId", adminId);
  612. return rj;
  613. } else {
  614. return new ResponseJson(500, "查询失败!", 500);
  615. }
  616. }
  617. /**
  618. * 查询产品类型
  619. *
  620. * @param request
  621. * @return
  622. */
  623. @ResponseBody
  624. @RequiresPermissions("customer:add:customer")
  625. @RequestMapping("/select_produce_type")
  626. public ResponseJson selectProduceType(HttpServletRequest request) throws Exception {
  627. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  628. ProductType productType = new ProductType();
  629. productType.setTypeStatus(1);
  630. List<ProductType> productTypeList = productService.listProductType(productType);
  631. if (productTypeList != null && productTypeList.size() > 0) {
  632. rj.addResponseKeyValue("productTypeList", productTypeList);
  633. return rj;
  634. } else {
  635. return new ResponseJson(500, "查询失败!", 500);
  636. }
  637. }
  638. /**
  639. * 查询产品
  640. *
  641. * @param request
  642. * @return
  643. */
  644. @ResponseBody
  645. @RequiresPermissions("customer:add:customer")
  646. @RequestMapping("/select_produce")
  647. public ResponseJson selectProduce(HttpServletRequest request) {
  648. ResponseJson rj = new ResponseJson(200, "查询成功!", 200);
  649. Product product = new Product();
  650. List<Product> productList = productService.listProduce(product);
  651. for (Product pro : productList) {
  652. ProductColor productColor = new ProductColor();
  653. productColor.setColorProductId(pro.getProductId());
  654. List<ProductColor> productColorList = productService.listProduceColor(productColor);
  655. pro.setColorList(productColorList);
  656. }
  657. if (productList != null && productList.size() > 0) {
  658. rj.addResponseKeyValue("productList", productList);
  659. return rj;
  660. } else {
  661. return new ResponseJson(500, "查询失败!", 500);
  662. }
  663. }
  664. /**
  665. * 添加客诉
  666. *
  667. * @param request
  668. * @return
  669. */
  670. @ResponseBody
  671. @RequiresPermissions("customer:add:customer")
  672. @RequestMapping("/save_customer")
  673. public ResponseJson addCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CmRelation cmRelation,
  674. String sendProdcuesJson,String closedProdcuesJson) throws Exception {
  675. ResponseJson rjx = this.isValiData(customerInfo);
  676. if (rjx.getResultCode() == 500) {
  677. return rjx;
  678. }
  679. Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
  680. String phone = customerInfo.getCustomerTel(); //手机号码
  681. Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
  682. Integer flag = 0;
  683. if (customerInfo.getIsNeedSelectOrder() == 1) { ////1:需要有订单 2:不需要有订单
  684. JSONArray jsonArray;
  685. List<SendProdcue> sendProdcueList;
  686. List<ClosedProdcue> closedProdcueList;
  687. jsonArray = JSONArray.fromObject(sendProdcuesJson);
  688. sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
  689. jsonArray = JSONArray.fromObject(closedProdcuesJson);
  690. closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
  691. cmRelation.setSendProdcues(sendProdcueList);
  692. cmRelation.setClosedProdcues(closedProdcueList);
  693. }
  694. customerInfo.setCmRelation(cmRelation);
  695. String orderId = "";
  696. if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
  697. Integer adminId = AdminUtils.getLoginAdminId();
  698. orderId = OrderNoUtil.createOrderCode(adminId);
  699. }
  700. customerInfo.setTransactionNumber(orderId);
  701. Integer customerId = customerInfo.getCustomerId();
  702. logger.info("-----------------添加客诉开始----------------------");
  703. try {
  704. flag = customerService.saveCustomerInfo(customerInfo, salesOrder);
  705. } catch (RuntimeException e) {
  706. e.printStackTrace();
  707. return new ResponseJson(500, e.getMessage(), 500);
  708. } catch (Exception e) {
  709. e.printStackTrace();
  710. return new ResponseJson(500, "添加失败", 500);
  711. }
  712. customerId = customerInfo.getCustomerId();
  713. logger.info("-----------------添加客诉结束----------------------");
  714. if (flag < 1) {
  715. return new ResponseJson(500, "添加客诉失败!", 500);
  716. }
  717. String msg = "";
  718. //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
  719. if (customerIsSolve == 3 || customerIsSolve == 4 || customerIsSolve == 5 || customerIsSolve == 6 || customerIsSolve == 7) {
  720. String solveMsg = "";
  721. switch (customerIsSolve) {
  722. case 3:
  723. solveMsg = "为您更换新机";
  724. break;
  725. case 4:
  726. solveMsg = "为您维修机器";
  727. break;
  728. case 5:
  729. solveMsg = "为您补发产品";
  730. break;
  731. case 6:
  732. solveMsg = "为您办理退货";
  733. break;
  734. case 7:
  735. solveMsg = "为您办理退货";
  736. break;
  737. }
  738. String addCustomerSuccessMsg = "";
  739. String typeMsg = "";
  740. switch (typeCompany) {
  741. case 1:
  742. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_WATERO;
  743. typeMsg = "美国WaterO售后";
  744. break;
  745. case 2:
  746. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_SHANGDUO;
  747. typeMsg = "上朵售后";
  748. break;
  749. case 3:
  750. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_YULIA;
  751. typeMsg = "YULIA售后";
  752. break;
  753. case 4:
  754. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_AIBERLE;
  755. typeMsg = "爱贝源售后";
  756. break;
  757. }
  758. // Object [] msg = new Object[]{solveMsg,typeMsg};
  759. // String text = MessageFormat.format(addCustomerSuccessMsg, msg);
  760. // logger.info("添加客诉成功后,给 "+ phone +" 手机用户发送短信:" + text );
  761. // String result = smsService.sendOtherCMS(phone, text);
  762. //
  763. // if (!"SUCCESS".equals(result)) {
  764. // return new ResponseJson(505, "添加客诉发送短信失败,失败原因:" + result + "<br>客诉信息发送失败并不影响客诉添加。客诉编号为:"+ customerId, 505);
  765. // }
  766. msg = ",请前往Efast进行换货/退货操作。";
  767. }
  768. return new ResponseJson(200, "录入客诉成功!客诉编号:" + customerId + msg, 200);
  769. }
  770. /**
  771. * 修改客诉
  772. *
  773. * @param request
  774. * @return
  775. */
  776. @ResponseBody
  777. @RequiresPermissions("customer:update:customer")
  778. @RequestMapping("/update_customer")
  779. public ResponseJson updateCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CmRelation cmRelation,
  780. String sendProdcuesJson, String closedProdcuesJson) throws Exception {
  781. ResponseJson rjx = this.isValiData(customerInfo);
  782. if (rjx.getResultCode() == 500) {
  783. return rjx;
  784. }
  785. Integer flag = 0;
  786. Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
  787. String phone = customerInfo.getCustomerTel(); //手机号码
  788. Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
  789. if (customerInfo.getIsNeedSelectOrder() == 1) {
  790. JSONArray jsonArray;
  791. List<SendProdcue> sendProdcueList;
  792. List<SendFitting> sendFittingList;
  793. List<ClosedProdcue> closedProdcueList;
  794. List<ClosedFitting> closedFittingList;
  795. jsonArray = JSONArray.fromObject(sendProdcuesJson);
  796. sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
  797. jsonArray = JSONArray.fromObject(closedProdcuesJson);
  798. closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
  799. cmRelation.setSendProdcues(sendProdcueList);
  800. cmRelation.setClosedProdcues(closedProdcueList);
  801. }
  802. String orderId = "";
  803. if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
  804. Integer adminId = AdminUtils.getLoginAdminId();
  805. orderId = OrderNoUtil.createOrderCode(adminId);
  806. }
  807. customerInfo.setTransactionNumber(orderId);
  808. customerInfo.setCmRelation(cmRelation);
  809. Integer customerId = customerInfo.getCustomerId();
  810. logger.info("-----------------修改客诉开始----------------------");
  811. try {
  812. flag = customerService.updateCustomerInfo(customerInfo, salesOrder);
  813. } catch (RuntimeException e) {
  814. e.printStackTrace();
  815. return new ResponseJson(500, e.getMessage(), 500);
  816. } catch (Exception e) {
  817. e.printStackTrace();
  818. return new ResponseJson(500, "修改失败", 500);
  819. }
  820. customerId = customerInfo.getCustomerId();
  821. logger.info("-----------------修改客诉结束----------------------");
  822. if (flag < 1) {
  823. return new ResponseJson(500, "修改客诉失败!", 500);
  824. }
  825. return new ResponseJson(200, "修改客诉成功!客诉编号为:" + customerId, 200);
  826. }
  827. /**
  828. * 验证方法
  829. *
  830. * @param customerInfo
  831. * @return
  832. */
  833. public ResponseJson isValiData(CustomerInfo customerInfo) {
  834. ResponseJson rj = new ResponseJson();
  835. if (customerInfo.getAdminId() == null) {
  836. return new ResponseJson(500, "未填写客诉id", 500);
  837. }
  838. return rj;
  839. }
  840. /**
  841. * 发送短信
  842. *
  843. * @param request
  844. * @return
  845. */
  846. @ResponseBody
  847. @RequiresPermissions("customer:add:customer")
  848. @RequestMapping("/send_phone_sms")
  849. public ResponseJson sendPhoneSms(HttpServletRequest request, String type, String phone, Integer typeCompany, ComplaintQuestionInfo complaintQuestionInfo) throws Exception {
  850. String url = NameUtils.getConfig("website");
  851. Integer flag = 1;
  852. if (typeCompany == null || typeCompany == 0) {
  853. return new ResponseJson(500, "未获取到产品类型!", 500);
  854. }
  855. String con = "";
  856. if (type != null && !"".equals(type)) {
  857. if ("p".equals(type)) { //problem" 问题处理; mailAddress:邮寄地址;
  858. if (complaintQuestionInfo.getQuestionId() == null || "".equals(complaintQuestionInfo.getQuestionId())) {
  859. complaintQuestionInfo.setQuestionState(1);
  860. complaintQuestionInfo.setQuestionIsQcDetect(0);
  861. complaintQuestionInfo = complaintQuestionInfoService.insertBackInfo(complaintQuestionInfo);
  862. } else {
  863. complaintQuestionInfo.setSmallClassId(null); //不能修改小类类型
  864. flag = complaintQuestionInfoService.updateQuestionById(complaintQuestionInfo);
  865. if (flag < 1) {
  866. return new ResponseJson(500, "问题修改失败!", 500);
  867. }
  868. }
  869. url += "/" + complaintQuestionInfo.getQuestionId() + "/" + typeCompany;
  870. switch (typeCompany) {
  871. case 1:
  872. con = SmsConfig.SEND_PRODUCT_SEND_WATERO;
  873. break;
  874. case 2:
  875. con = SmsConfig.SEND_PRODUCT_SEND_SHANGDUO;
  876. break;
  877. case 3:
  878. con = SmsConfig.SEND_PRODUCT_SEND_YULIA;
  879. break;
  880. case 4:
  881. con = SmsConfig.SEND_PRODUCT_SEND_AIBERLE;
  882. break;
  883. }
  884. } else if ("m".equals(type)) {
  885. if (complaintQuestionInfo.getQuestionId() == null) {
  886. return new ResponseJson(500, "未获取到邮寄信息!", 500);
  887. }
  888. complaintQuestionInfo.setQuestionName(null);
  889. complaintQuestionInfo.setSmallClassId(null);
  890. url += "/5/0";
  891. switch (typeCompany) {
  892. case 1:
  893. con = SmsConfig.SEND_PRODUCT_SMS_WATERO;
  894. break;
  895. case 2:
  896. con = SmsConfig.SEND_PRODUCT_SMS_SHANGDUO;
  897. break;
  898. case 3:
  899. con = SmsConfig.SEND_PRODUCT_SMS_YULIA;
  900. break;
  901. case 4:
  902. con = SmsConfig.SEND_PRODUCT_SMS_AIBERLE;
  903. break;
  904. }
  905. }
  906. }
  907. String userPhone = encodePhoneNumber(phone);
  908. String text = MessageFormat.format(con, url);
  909. logger.info("给 " + phone + " 手机用户发送短信:" + text);
  910. String result = smsService.sendOtherCMS(phone, text);
  911. if ("SUCCESS".equals(result)) {
  912. return new ResponseJson(200, "发送短信成功!", 200);
  913. } else {
  914. return new ResponseJson(500, "发送短信失败,失败原因:" + result, 500);
  915. }
  916. }
  917. String encodePhoneNumber(String number) {
  918. int encnum = Integer.parseInt(number.substring(2));
  919. int prefix = (number.charAt(1) - '2') / 2; // '3'=>0, '5'=>1, '[67]'=>2, '8'=>3
  920. encnum |= (prefix <<= 30);
  921. final byte[] raw = new byte[4];
  922. raw[0] = (byte) (encnum >>> 24);
  923. raw[1] = (byte) (encnum >>> 16);
  924. raw[2] = (byte) (encnum >>> 8);
  925. raw[3] = (byte) encnum;
  926. return Base64.encodeBase64URLSafeString(raw);
  927. }
  928. /**
  929. * 进入回访完成页面
  930. *
  931. * @param request
  932. * @return
  933. * @throws Exception
  934. */
  935. @RequiresPermissions("customer:update:visit")
  936. @RequestMapping("/_update_visit_info")
  937. public ModelAndView toUpdateVisitFinish(HttpServletRequest request) throws Exception {
  938. ModelAndView mv = new ModelAndView("cm/customer/visit_finish");
  939. String customerId = request.getParameter("customerId");
  940. mv.addObject("customerId", customerId);
  941. return mv;
  942. }
  943. /**
  944. * 添加回访完成内容
  945. *
  946. * @param request
  947. * @param visit
  948. * @return
  949. */
  950. @ResponseBody
  951. @RequiresPermissions("customer:update:visit")
  952. @RequestMapping("/update_visit_finish")
  953. public ResponseJson updateVisitFinish(HttpServletRequest request, Visit visit) throws Exception {
  954. String customerId = request.getParameter("finish_customerId");
  955. if (!StringUtils.isNotEmpty(customerId)) {
  956. return new ResponseJson(500, "该客诉信息不存在!", 500);
  957. }
  958. visit.setCustomerId(Integer.parseInt(customerId));
  959. visit.setVisitStatus(2);
  960. //修改回访信息内容
  961. int num = visitService.updateVisit(visit);
  962. if (num > 0) {
  963. return new ResponseJson(200, "添加成功!", 200);
  964. } else {
  965. return new ResponseJson(500, "添加失败!", 500);
  966. }
  967. }
  968. /**
  969. * 进入回访信息详情
  970. *
  971. * @param request
  972. * @return
  973. * @throws Exception
  974. */
  975. @RequiresPermissions("customer:get:visit")
  976. @RequestMapping("/_visit_info")
  977. public ModelAndView toVisitInfo(HttpServletRequest request) throws Exception {
  978. ModelAndView mv = new ModelAndView("cm/customer/visit_detail");
  979. String customerId = request.getParameter("customerId");
  980. // 1:未回访,2:已回访
  981. String num = request.getParameter("num");
  982. if (!StringUtils.isNotEmpty(num)) {
  983. num = "2";
  984. }
  985. mv.addObject("customerId", customerId);
  986. mv.addObject("num", num);
  987. return mv;
  988. }
  989. /**
  990. * 获取回访信息详情
  991. *
  992. * @param request
  993. * @return
  994. */
  995. @ResponseBody
  996. @RequiresPermissions("customer:get:visit")
  997. @RequestMapping("/get_visit_info")
  998. public ResponseJson getVisitInfo(HttpServletRequest request) throws Exception {
  999. String customerId = request.getParameter("customerId");
  1000. if (!StringUtils.isNotEmpty(customerId)) {
  1001. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1002. }
  1003. Visit visit = new Visit();
  1004. visit.setCustomerId(Integer.parseInt(customerId));
  1005. //查询回访信息集合
  1006. List<Visit> visitList = visitService.listVisit(visit);
  1007. if (visitList == null || visitList.size() == 0) {
  1008. return new ResponseJson(500, "该客诉没有回访信息!", 500);
  1009. }
  1010. visit = visitList.get(0);
  1011. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1012. rj.addResponseKeyValue("visit", visit);
  1013. return rj;
  1014. }
  1015. /**
  1016. * 进入问题描述页面
  1017. *
  1018. * @param request
  1019. * @return
  1020. * @throws Exception
  1021. */
  1022. @RequiresPermissions("customer:get:describe")
  1023. @RequestMapping("/_question_describe")
  1024. public ModelAndView toQuestionDescribe(HttpServletRequest request) throws Exception {
  1025. ModelAndView mv = new ModelAndView("cm/customer/describe_detail");
  1026. String customerId = request.getParameter("customerId");
  1027. mv.addObject("customerId", customerId);
  1028. return mv;
  1029. }
  1030. /**
  1031. * 获取问题描述信息
  1032. *
  1033. * @param request
  1034. * @return
  1035. */
  1036. @ResponseBody
  1037. @RequiresPermissions("customer:get:describe")
  1038. @RequestMapping("/get_describe_info")
  1039. public ResponseJson getDescribeInfo(HttpServletRequest request) throws Exception {
  1040. String customerId = request.getParameter("customerId");
  1041. if (!StringUtils.isNotEmpty(customerId)) {
  1042. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1043. }
  1044. QuestionDescribe describe = new QuestionDescribe();
  1045. describe.setCustomerId(Integer.parseInt(customerId));
  1046. //查询问题集合
  1047. List<QuestionDescribe> questionList = questionDescribeService.listQuestionDescribe(describe);
  1048. if (questionList == null || questionList.size() == 0) {
  1049. return new ResponseJson(500, "该客诉信息没有问题描述!", 500);
  1050. }
  1051. describe = questionList.get(0);
  1052. CustomerInfo customerInfo = customerService.getCustomerInfo(Integer.parseInt(customerId));
  1053. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1054. rj.addResponseKeyValue("describe", describe);
  1055. rj.addResponseKeyValue("customerInfo", customerInfo);
  1056. return rj;
  1057. }
  1058. /**
  1059. * 进入修改售后处理信息页面
  1060. *
  1061. * @param request
  1062. * @return
  1063. * @throws Exception
  1064. */
  1065. @RequiresPermissions("customer:update:renewed")
  1066. @RequestMapping("/_update_relation")
  1067. public ModelAndView toUpdateRenewed(HttpServletRequest request) throws Exception {
  1068. ModelAndView mv = new ModelAndView("cm/customer/update_relation");
  1069. String customerId = request.getParameter("customerId");
  1070. CmRelation cmRelation = new CmRelation();
  1071. cmRelation.setCustomerId(Integer.valueOf(customerId));
  1072. cmRelation = customerService.getCmRelationInfo(cmRelation);
  1073. ProcMethod procMethod = customerService.getProcMethod(cmRelation.getProcMethodId());
  1074. List<LogisticsInfo>logisticsInfoList = logisticsInfoService.getLogisticsInfoList(new LogisticsInfo());
  1075. mv.addObject("logisticsInfoList",logisticsInfoList);
  1076. mv.addObject("procMethod", procMethod);
  1077. mv.addObject("customerId", customerId);
  1078. return mv;
  1079. }
  1080. /**
  1081. * 获取售后详情
  1082. *
  1083. * @param request
  1084. * @return
  1085. */
  1086. @ResponseBody
  1087. @RequiresPermissions("customer:get:renewed")
  1088. @RequestMapping("/get_cmRelation_info")
  1089. public ResponseJson getRenewedInfo(HttpServletRequest request) throws Exception {
  1090. String customerId = request.getParameter("customerId");
  1091. if (!StringUtils.isNotEmpty(customerId)) {
  1092. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1093. }
  1094. CmRelation cmRelation = new CmRelation();
  1095. cmRelation.setCustomerId(Integer.parseInt(customerId));
  1096. //获取换新详情和检测信息
  1097. cmRelation = customerService.getCmRelationInfo(cmRelation);
  1098. if (cmRelation == null) {
  1099. return new ResponseJson(500, "该客诉没有售后信息!", 500);
  1100. } else {
  1101. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1102. rj.addResponseKeyValue("cmRelation", cmRelation);
  1103. return rj;
  1104. }
  1105. }
  1106. /**
  1107. * 修改处理信息
  1108. *
  1109. * @param request
  1110. * @param cmRelation
  1111. * @return
  1112. * @throws Exception
  1113. */
  1114. @ResponseBody
  1115. @RequiresPermissions("customer:update:renewed")
  1116. @RequestMapping("/update_cmRelation_info")
  1117. public ResponseJson updateRenewedInfo(HttpServletRequest request, CmRelation cmRelation) throws Exception {
  1118. String mergeAddress = request.getParameter("merge_address");
  1119. if (!StringUtils.isNotEmpty(cmRelation.getRelationId().toString())) {
  1120. return new ResponseJson(500, "该售后信息不能修改!", 500);
  1121. }
  1122. if (StringUtils.isNotEmpty(mergeAddress)) {
  1123. cmRelation.setRelationSendMergeAddress(mergeAddress);
  1124. }
  1125. if (cmRelation.getRelationBackStatus() != null) {
  1126. if (cmRelation.getRelationBackStatus() != 1) {
  1127. ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
  1128. cs.setSignclosedCustomerId(cmRelation.getCustomerId());
  1129. cs.setSignclosedLogistics(cmRelation.getRelationBackLogisticsCompany());
  1130. cs.setSignclosedLogisticsNumber(cmRelation.getRelationBackLogisticsNo());
  1131. complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
  1132. }
  1133. }
  1134. //修改售后信息
  1135. int num = customerService.updateCmRelation(cmRelation);
  1136. if (num > 0) {
  1137. return new ResponseJson(200, "修改成功!", 200);
  1138. } else {
  1139. return new ResponseJson(500, "修改失败!", 500);
  1140. }
  1141. }
  1142. /**
  1143. * 进入修改维修页面
  1144. *
  1145. * @param request
  1146. * @return
  1147. * @throws Exception
  1148. */
  1149. @RequiresPermissions("customer:update:repair")
  1150. @RequestMapping("/_to_update_repair")
  1151. public ModelAndView toUpdateRepair(HttpServletRequest request) throws Exception {
  1152. ModelAndView mv = new ModelAndView("cm/customer/update_repair");
  1153. String customerId = request.getParameter("customerId");
  1154. mv.addObject("customerId", customerId);
  1155. return mv;
  1156. }
  1157. /**
  1158. * 进入修改维修页面
  1159. *
  1160. * @param request
  1161. * @return
  1162. * @throws Exception
  1163. */
  1164. @ResponseBody
  1165. @RequiresPermissions("customer:update:repair")
  1166. @RequestMapping("/_update_repair")
  1167. public ResponseJson updateRepairUI(HttpServletRequest request) throws Exception {
  1168. String customerId = request.getParameter("customerId");
  1169. if (!StringUtils.isNotEmpty(customerId)) {
  1170. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1171. }
  1172. Repair repair = new Repair();
  1173. repair.setCustomerId(Integer.parseInt(customerId));
  1174. repair.setRepairState(1);
  1175. //获取维修详情和品质检测信息
  1176. repair = customerService.getRepairInfo(repair);
  1177. if (repair == null) {
  1178. return new ResponseJson(500, "该客诉没有维修信息!", 500);
  1179. } else {
  1180. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1181. rj.addResponseKeyValue("repair", repair);
  1182. return rj;
  1183. }
  1184. }
  1185. /**
  1186. * 进入修改退货页面
  1187. *
  1188. * @param request
  1189. * @return
  1190. * @throws Exception
  1191. */
  1192. @RequiresPermissions("customer:update:backGoods")
  1193. @RequestMapping("/_to_update_book_goods")
  1194. public ModelAndView toUpdateBookGoods(HttpServletRequest request) throws Exception {
  1195. ModelAndView mv = new ModelAndView("cm/customer/update_back_goods");
  1196. String customerId = request.getParameter("customerId");
  1197. mv.addObject("customerId", customerId);
  1198. return mv;
  1199. }
  1200. /**
  1201. * 进入修改售后退货页面
  1202. *
  1203. * @param request
  1204. * @return
  1205. * @throws Exception
  1206. */
  1207. @ResponseBody
  1208. @RequiresPermissions("customer:update:backGoods")
  1209. @RequestMapping("/_update_back_goods")
  1210. public ResponseJson updateBackGoodsUI(HttpServletRequest request) throws Exception {
  1211. String customerId = request.getParameter("customerId");
  1212. if (!StringUtils.isNotEmpty(customerId)) {
  1213. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1214. }
  1215. BackGoods backGoods = new BackGoods();
  1216. backGoods.setCustomerId(Integer.parseInt(customerId));
  1217. //获取售后退货信息
  1218. backGoods = customerService.getBackGoods(backGoods);
  1219. if (backGoods == null) {
  1220. return new ResponseJson(500, "该客诉没有售后退货信息!", 500);
  1221. } else {
  1222. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1223. rj.addResponseKeyValue("backGoods", backGoods);
  1224. return rj;
  1225. }
  1226. }
  1227. /**
  1228. * 进入修改补寄页面
  1229. *
  1230. * @param request
  1231. * @return
  1232. * @throws Exception
  1233. */
  1234. @RequiresPermissions("customer:update:reissue")
  1235. @RequestMapping("/_to_update_reissue")
  1236. public ModelAndView toUpdateReissue(HttpServletRequest request) throws Exception {
  1237. ModelAndView mv = new ModelAndView("cm/customer/update_reissue");
  1238. String customerId = request.getParameter("customerId");
  1239. mv.addObject("customerId", customerId);
  1240. return mv;
  1241. }
  1242. /**
  1243. * 进入修改补寄信息页面
  1244. *
  1245. * @param request
  1246. * @return
  1247. */
  1248. @ResponseBody
  1249. @RequiresPermissions("customer:update:reissue")
  1250. @RequestMapping("/get_reissue_info")
  1251. public ResponseJson getReissueInfo(HttpServletRequest request) {
  1252. String customerId = request.getParameter("customerId");
  1253. if (!StringUtils.isNotEmpty(customerId)) {
  1254. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1255. }
  1256. Reissue reissue = new Reissue();
  1257. reissue.setCustomerId(Integer.parseInt(customerId));
  1258. //获取售后补寄信息
  1259. reissue = customerService.getReissue(reissue);
  1260. if (reissue == null) {
  1261. return new ResponseJson(500, "该客诉没有售后退货信息!", 500);
  1262. } else {
  1263. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1264. rj.addResponseKeyValue("reissue", reissue);
  1265. return rj;
  1266. }
  1267. }
  1268. /**
  1269. * 进入修改退货页面
  1270. *
  1271. * @param request
  1272. * @return
  1273. * @throws Exception
  1274. */
  1275. @RequiresPermissions("customer:update:noreason")
  1276. @RequestMapping("/_update_noreason_back")
  1277. public ModelAndView toUpdateNoreasonBack(HttpServletRequest request) throws Exception {
  1278. ModelAndView mv = new ModelAndView("cm/customer/update_noreason_back");
  1279. String customerId = request.getParameter("customerId");
  1280. mv.addObject("customerId", customerId);
  1281. return mv;
  1282. }
  1283. /**
  1284. * 获取无理由退货信息
  1285. *
  1286. * @param request
  1287. * @return
  1288. * @throws Exception
  1289. */
  1290. @ResponseBody
  1291. @RequiresPermissions("customer:update:noreason")
  1292. @RequestMapping("/get_noreason_back")
  1293. public ResponseJson getNoreasonBack(HttpServletRequest request) throws Exception {
  1294. String customerId = request.getParameter("customerId");
  1295. if (!StringUtils.isNotEmpty(customerId)) {
  1296. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1297. }
  1298. NoreasonBack noreasonBack = new NoreasonBack();
  1299. noreasonBack.setCustomerId(Integer.parseInt(customerId));
  1300. noreasonBack.setNoreasonBackState(1);
  1301. //获取无理由退货信息
  1302. noreasonBack = customerService.getNoreasonBack(noreasonBack);
  1303. if (noreasonBack == null) {
  1304. return new ResponseJson(500, "该客诉没有无理由售后退货信息!", 500);
  1305. } else {
  1306. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1307. rj.addResponseKeyValue("noreasonBack", noreasonBack);
  1308. return rj;
  1309. }
  1310. }
  1311. /**
  1312. * 查询未解决客诉数量
  1313. */
  1314. @ResponseBody
  1315. @RequestMapping(value = "/selectNumberBacklog")
  1316. public ResultMsg selectTodo(HttpServletRequest request) {
  1317. ResultMsg msg = new ResultMsg();
  1318. CustomerInfo customerInfo = new CustomerInfo();
  1319. //获取登录员工id
  1320. Admin admin = AdminUtils.getLoginAdmin();
  1321. // customerInfo.setAdminId(admin.getAdminId());
  1322. // customerInfo.setCustomerIsSolve(2);
  1323. //未解决客诉数量
  1324. // Integer notSolvedCustomer = customerService.selectNotSolvedCustomer(customerInfo);
  1325. //需要向工厂确认所有已签收的产品数量
  1326. // CustomerCommon customerCommon = new CustomerCommon();
  1327. // customerCommon.setAdminId(admin.getAdminId());
  1328. // customerCommon.setRelationBackStatus(4);
  1329. // Integer amountReceivedCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1330. //需要填写Efast订单号的客诉数量
  1331. // customerCommon.setRelationBackStatus(3);
  1332. // Integer noEntryCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1333. //客诉录入后,三天后未寄回的客诉数量
  1334. // customerCommon.setRelationBackStatus(1);
  1335. // customerCommon.setRelationCreateTime(new Date());
  1336. // Integer notSendCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1337. SalesOrder salesOrder = new SalesOrder();
  1338. salesOrder.setSalesStatus(0); //未确认
  1339. Integer toBeConfirmedOrder = salesOrderService.listSalesOrderNum(salesOrder);
  1340. salesOrder = new SalesOrder();
  1341. salesOrder.setSalesShippingStatus(0); //未发货
  1342. Integer toBeAnnounced = salesOrderService.listSalesOrderNum(salesOrder);
  1343. salesOrder.setSalesShippingStatus(11); //已通知配货
  1344. Integer toBeDelivered = salesOrderService.listSalesOrderNum(salesOrder);
  1345. Calendar calendar = Calendar.getInstance();
  1346. calendar.set(Calendar.HOUR_OF_DAY,00);
  1347. calendar.set(Calendar.MINUTE,00);
  1348. calendar.set(Calendar.SECOND,01);
  1349. salesOrder = new SalesOrder();
  1350. salesOrder.setStartDate(calendar.getTime()); //startDate
  1351. Calendar ca = Calendar.getInstance();
  1352. ca.set(Calendar.HOUR_OF_DAY,23);
  1353. ca.set(Calendar.MINUTE,59);
  1354. ca.set(Calendar.SECOND,59);
  1355. salesOrder.setEndDate(ca.getTime());
  1356. Integer allToDayOrder = salesOrderService.listSalesOrderNum(salesOrder);
  1357. Map<String, Integer> numberMap = new HashMap<>();
  1358. numberMap.put("toBeConfirmedOrder", toBeConfirmedOrder);
  1359. numberMap.put("toBeAnnounced", toBeAnnounced);
  1360. numberMap.put("toBeDelivered", toBeDelivered);
  1361. numberMap.put("allToDayOrder", allToDayOrder);
  1362. // numberMap.put("notSolvedCustomer", notSolvedCustomer);
  1363. // numberMap.put("amountReceivedCustomer", amountReceivedCustomer);
  1364. // numberMap.put("noEntryCustomer", noEntryCustomer);
  1365. // numberMap.put("notSendCustomer", notSendCustomer);
  1366. numberMap.put("adminDept", admin.getAdminDept());
  1367. msg.setResultCode(ResultInfo.SUCCESSCODE);
  1368. msg.setStatus(true);
  1369. msg.setData(numberMap);
  1370. return msg;
  1371. }
  1372. // /**
  1373. // * 根据微信昵称/姓名/电话查询客诉
  1374. // *
  1375. // * @param request
  1376. // * @return
  1377. // */
  1378. // @ResponseBody
  1379. // @RequiresPermissions("customer:list:customer")
  1380. // @RequestMapping("/get_custoner_info")
  1381. // public ResponseJson getCustonerInfo(HttpServletRequest request, CustomerCommon customerCommon) throws Exception {
  1382. // if (customerCommon == null) {
  1383. // return new ResponseJson(500, "参数错误!", 500);
  1384. // }
  1385. // List<CustomerCommon> customerCommonList = customerCommonService.listCustomerCommon(customerCommon);
  1386. // if (customerCommonList.size() < 1) {
  1387. // return new ResponseJson(500, "不存在相关客诉信息!", 500);
  1388. // } else {
  1389. // ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1390. // rj.addResponseKeyValue("customer", customerCommonList.get(0));
  1391. // return rj;
  1392. // }
  1393. // }
  1394. /**
  1395. * 申请邮费
  1396. *
  1397. * @return
  1398. */
  1399. @ResponseBody
  1400. @RequiresPermissions("customer:applyPostage:customer")
  1401. @RequestMapping(value = "/apply_postage")
  1402. public ResponseJson applyPostage(HttpServletRequest request, Integer customerId) throws Exception {
  1403. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  1404. if (customerInfo == null) {
  1405. return new ResponseJson(500, "未获取到客诉", 500);
  1406. }
  1407. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerId);
  1408. if (cmRelation.getRelationBackStatus() == 1) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1409. return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
  1410. }
  1411. if (cmRelation.getRelationBackStatus() == 2) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1412. return new ResponseJson(500, "产品正在寄回中!", 500);
  1413. }
  1414. if (cmRelation.getRelationIsTransfer() == 0) { //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
  1415. return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
  1416. }
  1417. if (cmRelation.getRelationBackPostage() == null || cmRelation.getRelationBackPostage() == 0 //relationBackPostage
  1418. || cmRelation.getRelationAlipay() == null || cmRelation.getRelationAlipayName() == null) {
  1419. return new ResponseJson(500, "请填写邮费信息", 500);
  1420. }
  1421. if (customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0) {
  1422. return new ResponseJson(500, "未正确选择销售公司", 500);
  1423. }
  1424. Postage age = new Postage();
  1425. age.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1426. List<Postage> postageList = postageService.listPostage(age);
  1427. if (postageList != null && postageList.size() > 0) {
  1428. return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
  1429. }
  1430. ResponseJson rj = new ResponseJson(200, "可以申请邮费", 200);
  1431. rj.addResponseKeyValue("customerCommon", cmRelation);
  1432. rj.addResponseKeyValue("customerInfo", customerInfo);
  1433. return rj;
  1434. }
  1435. /**
  1436. * 申请邮费
  1437. *
  1438. * @return
  1439. */
  1440. @ResponseBody
  1441. @RequiresPermissions("customer:applyPostage:customer")
  1442. @RequestMapping(value = "/add_postage")
  1443. public ResponseJson addPostage(HttpServletRequest request, Integer customerId, String postageLogisticsImg) throws Exception {
  1444. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  1445. if (customerInfo == null) {
  1446. return new ResponseJson(500, "未获取到客诉", 500);
  1447. }
  1448. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerId);
  1449. if (cmRelation.getRelationBackStatus() == 1) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1450. return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
  1451. }
  1452. if (cmRelation.getRelationBackStatus() == 2) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1453. return new ResponseJson(500, "产品正在寄回中!", 500);
  1454. }
  1455. if (cmRelation.getRelationIsTransfer() == 0) { //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
  1456. return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
  1457. }
  1458. if (cmRelation.getRelationBackPostage() == null || cmRelation.getRelationBackPostage() == 0 //relationBackPostage
  1459. || cmRelation.getRelationAlipay() == null || cmRelation.getRelationAlipayName() == null) {
  1460. return new ResponseJson(500, "请填写邮费信息", 500);
  1461. }
  1462. if (customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0) {
  1463. return new ResponseJson(500, "未正确选择销售公司", 500);
  1464. }
  1465. Postage age = new Postage();
  1466. age.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1467. List<Postage> postageList = postageService.listPostage(age);
  1468. if (postageList != null && postageList.size() > 0) {
  1469. return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
  1470. }
  1471. String orderId = "";
  1472. for (SalesOrder salesOrder : cmRelation.getSalesOrderList()) {
  1473. if ("".equals(orderId)) {
  1474. orderId = salesOrder.getSalesOrderId();
  1475. } else {
  1476. orderId += "," + salesOrder.getSalesOrderId();
  1477. }
  1478. }
  1479. Integer flag = 0;
  1480. Postage postage = new Postage();
  1481. postage.setCompanyId(customerInfo.getCompanyId()); //销售公司
  1482. postage.setAdminId(customerInfo.getAdminId()); //客服
  1483. postage.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1484. postage.setPostageCustomerStatus(2); //------考虑手动点, 直接变为申请中
  1485. postage.setPostageManagerStatus(1); //------考虑手动点, 直接变为申请中
  1486. postage.setPostageOrderSource(customerInfo.getStoreId()); //店铺id
  1487. // postage.setPostageTreatmentMethod(cmRelation.getProcMethodId()); //处理方式
  1488. postage.setSalesOrderId(orderId); //efast订单号
  1489. postage.setPostageClientName(cmRelation.getRelationBackName());
  1490. postage.setPostageClientTel(cmRelation.getRelationBackTel());
  1491. postage.setPostageClientAddress(cmRelation.getRelationSendAddress());
  1492. postage.setPostageLogisticsCompany(cmRelation.getRelationBackLogisticsCompany());
  1493. postage.setPostageLogisticsNo(cmRelation.getRelationBackLogisticsNo());
  1494. postage.setPostageAmount(cmRelation.getRelationBackPostage()); //寄回邮费
  1495. postage.setPostageAlipay(cmRelation.getRelationAlipay()); //支付宝账户
  1496. postage.setPostageAlipayName(cmRelation.getRelationAlipayName()); //支付宝账号名称
  1497. postage.setPostageLogisticsImg(postageLogisticsImg);
  1498. flag = postageService.savePostage(postage);
  1499. if (flag < 1) {
  1500. return new ResponseJson(500, "申请失败", 500);
  1501. }
  1502. ResponseJson rj = new ResponseJson(200, "申请成功,请前往邮费转账列表查看", 200);
  1503. return rj;
  1504. }
  1505. /**
  1506. * 根据客诉id查询产品类型
  1507. *
  1508. * @param request
  1509. * @return
  1510. * @throws Exception
  1511. */
  1512. @ResponseBody
  1513. @RequestMapping("/getProductType")
  1514. public ResponseJson getProductType(HttpServletRequest request) throws Exception {
  1515. String customerId = request.getParameter("customerId");
  1516. if (!StringUtils.isNotEmpty(customerId)) {
  1517. return new ResponseJson(500, "查询产品类型失败!", 500);
  1518. }
  1519. //查询客诉产品类型
  1520. ProductType productType = productService.getProductType(Integer.valueOf(customerId));
  1521. if (productType == null) {
  1522. return new ResponseJson(500, "未找到产品类型!", 500);
  1523. } else {
  1524. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1525. rj.addResponseKeyValue("productType", productType);
  1526. return rj;
  1527. }
  1528. }
  1529. /**
  1530. * 根据客户信息查询旧的客诉信息
  1531. *
  1532. * @param request
  1533. * @return
  1534. * @throws Exception
  1535. */
  1536. @ResponseBody
  1537. @RequestMapping("/selectOnCustomer")
  1538. public ResponseJson listOnCustomer(HttpServletRequest request, CustomerInfo customerInfo) throws Exception {
  1539. if (customerInfo == null) {
  1540. return new ResponseJson(500, "查询客诉失败!", 500);
  1541. }
  1542. List<CustomerInfo> onCustomerList = customerService.listOnCustomer(customerInfo);
  1543. if (onCustomerList.size() == 0) {
  1544. return new ResponseJson(500, "未找到客诉!", 500);
  1545. } else {
  1546. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1547. rj.addResponseKeyValue("onCustomerList", onCustomerList);
  1548. return rj;
  1549. }
  1550. }
  1551. /**
  1552. * 根据efast订单号查询efast订单物流信息
  1553. *
  1554. * @param request
  1555. * @return
  1556. * @throws Exception
  1557. */
  1558. @ResponseBody
  1559. @RequestMapping("/getefastOrder")
  1560. public ResponseJson getEfastOrderInfo(HttpServletRequest request, String efastOrderId) throws Exception {
  1561. if (efastOrderId == null) {
  1562. return new ResponseJson(500, "查询失败!", 500);
  1563. }
  1564. JSONObject orderInfo = efastOrderService.getOrderFormEfastByOrderId(efastOrderId);
  1565. if (orderInfo == null) {
  1566. return new ResponseJson(500, "查询失败!", 500);
  1567. } else if (!orderInfo.has("orders")) {
  1568. return new ResponseJson(500, "查询失败!", 500);
  1569. } else {
  1570. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1571. rj.addResponseKeyValue("orderInfo", orderInfo.toString());
  1572. return rj;
  1573. }
  1574. }
  1575. /**
  1576. * 下载客诉信息 (2018-05-29)
  1577. *
  1578. * @param request
  1579. * @param res
  1580. * @param
  1581. * @throws Exception
  1582. */
  1583. @RequestMapping("/download_customer_excel")
  1584. public void downloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res) throws Exception {
  1585. List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer();
  1586. String[] cells = {
  1587. "日期", "姓名", "联系电话", "类别", "来源入口",
  1588. "问题类别", "小类名称", "客诉问题", "处理过程", "购买日期",
  1589. "处理结果", "销售公司", "销售渠道", "产品型号", "产品颜色",
  1590. "产品数量", "寄回快递", "寄回单号", "签收日期",
  1591. "状态", "寄出快递", "寄出快递", "开箱损", "二次客诉", "跟进客服", "工厂报价", "客户报价"
  1592. };
  1593. List<CustomerStatisticalInfo> customerStatisticalInfoList = new ArrayList<>();
  1594. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1595. for (CustomerStatisticalInfo customerInfo : customerList) {
  1596. //新建一个容器
  1597. CustomerStatisticalInfo customer = new CustomerStatisticalInfo();
  1598. //将数据copy到新容器
  1599. BeanUtils.copyProperties(customerInfo, customer);
  1600. CustomerCommon customerCommon = new CustomerCommon();
  1601. customerCommon.setCustomerId(customerInfo.getCustomerId());
  1602. customerCommon.setRelationId(customerInfo.getRelationId());
  1603. List<CustomerCommon> listCustomerCommon = customerService.listCustomerCommons(customerCommon);
  1604. if(listCustomerCommon.size() > 0) {
  1605. for (CustomerCommon common : listCustomerCommon) {
  1606. if (common.getSalesOrderList().size() > 0) {
  1607. for (SalesOrder salesOrder : common.getSalesOrderList()) {
  1608. if (salesOrder.getSalesOrderItemList().size() > 0) {
  1609. for (SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()) {
  1610. //将数据copy到新容器
  1611. CustomerStatisticalInfo customers = new CustomerStatisticalInfo();
  1612. BeanUtils.copyProperties(customer, customers);
  1613. customers.setRelationBackLogisticsCompany(common.getRelationBackLogisticsCompany());
  1614. customers.setRelationBackLogisticsNo(common.getRelationBackLogisticsNo());
  1615. customers.setRelationSendLogisticsCompany(common.getRelationSendLogisticsCompany());
  1616. customers.setRelationSendLogisticsNo(common.getRelationSendLogisticsNo());
  1617. customers.setRelationBackStatus(String.valueOf(common.getRelationBackStatus()));
  1618. customers.setRelationBackReceiptDate(common.getRelationBackReceiptDate() == null?null:format.format(common.getRelationBackReceiptDate()));
  1619. customers.setSalesPayTime(salesOrder.getSalesPayTime());
  1620. customers.setItemProductName(salesOrderItem.getItemProductName());
  1621. customers.setItemProductColor(salesOrderItem.getItemProductColor());
  1622. customers.setItemNum(String.valueOf(salesOrderItem.getItemNum()));
  1623. customers.setRelationFactoryCosts(common.getRelationFactoryCosts());
  1624. customers.setRelationCustomerCosts(common.getRelationCustomerCosts());
  1625. customerStatisticalInfoList.add(customers);
  1626. }
  1627. } else {
  1628. customerStatisticalInfoList.add(customer);
  1629. }
  1630. }
  1631. } else {
  1632. customerStatisticalInfoList.add(customer);
  1633. }
  1634. }
  1635. }else{
  1636. customerStatisticalInfoList.add(customer);
  1637. }
  1638. }
  1639. //导出订单Excel并下载
  1640. customerExcel(request,res,cells,customerStatisticalInfoList);
  1641. }
  1642. /**
  1643. * 导出订单Excel并下载
  1644. * @param request
  1645. * @param res
  1646. * @param cells
  1647. * @throws Exception
  1648. */
  1649. public void customerExcel(HttpServletRequest request,HttpServletResponse res,
  1650. String[] cells,List<CustomerStatisticalInfo> customerList) throws Exception {
  1651. //创建一个workbook,对应一个Excel文件
  1652. HSSFWorkbook wb = new HSSFWorkbook();
  1653. //在workbook中添加一个sheet,对应Excel中的一个sheet
  1654. HSSFSheet sheet = wb.createSheet("导出订单");
  1655. //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
  1656. HSSFRow row = sheet.createRow((int) 0);
  1657. //创建单元格,设置值表头,设置表头居中
  1658. HSSFCellStyle style = wb.createCellStyle();
  1659. //居中格式
  1660. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  1661. //设置表头
  1662. if (cells == null || cells.length == 0) {
  1663. return;
  1664. }
  1665. //循环设置表头
  1666. HSSFCell cell = null;
  1667. for (int i = 0;i < cells.length;i++) {
  1668. String name = cells[i];
  1669. cell = row.createCell(i);
  1670. cell.setCellValue(name);
  1671. cell.setCellStyle(style);
  1672. }
  1673. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1674. for (int i = 0; i < customerList.size(); i++) {
  1675. row = sheet.createRow((int) i + 1);
  1676. CustomerStatisticalInfo customerStatisticalInfo = customerList.get(i);
  1677. String createTime = "";
  1678. if(customerStatisticalInfo.getCreateTime() != null){
  1679. createTime = format.format(customerStatisticalInfo.getCreateTime());
  1680. }
  1681. String salesPayTime = "";
  1682. if(customerStatisticalInfo.getSalesPayTime() != null ){
  1683. salesPayTime = format.format(customerStatisticalInfo.getSalesPayTime());
  1684. }
  1685. String backLogisticsCompany = "";
  1686. if(customerStatisticalInfo.getRelationBackLogisticsCompany() != null){
  1687. backLogisticsCompany = KuaiDi100.replace(customerStatisticalInfo.getRelationBackLogisticsCompany());
  1688. }
  1689. String backStatus = "未知";
  1690. if(customerStatisticalInfo.getRelationBackStatus() != null){
  1691. if(customerStatisticalInfo.getRelationBackStatus().equals("1")){
  1692. backStatus = "未寄回";
  1693. }
  1694. if(customerStatisticalInfo.getRelationBackStatus().equals("2")){
  1695. backStatus = "已寄回";
  1696. }
  1697. if(customerStatisticalInfo.getRelationBackStatus().equals("3")){
  1698. backStatus = "已收货";
  1699. }
  1700. }
  1701. String sendLogisticsCompany = "";
  1702. if(customerStatisticalInfo.getRelationSendLogisticsCompany() != null){
  1703. sendLogisticsCompany = KuaiDi100.replace(customerStatisticalInfo.getRelationSendLogisticsCompany());
  1704. }
  1705. // 创建单元格,设置值
  1706. row.createCell(0).setCellValue(createTime);
  1707. row.createCell(1).setCellValue(customerStatisticalInfo.getCustomerName() == null ? null : customerStatisticalInfo.getCustomerName());
  1708. row.createCell(2).setCellValue(customerStatisticalInfo.getCustomerTel() == null ? null : customerStatisticalInfo.getCustomerTel());
  1709. row.createCell(3).setCellValue(customerStatisticalInfo.getCounselType() == null ? null : customerStatisticalInfo.getCounselType());
  1710. row.createCell(4).setCellValue(customerStatisticalInfo.getSourceType() == null ? null : customerStatisticalInfo.getSourceType());
  1711. row.createCell(5).setCellValue(customerStatisticalInfo.getComplaintClassName() == null ? null : customerStatisticalInfo.getComplaintClassName());
  1712. row.createCell(6).setCellValue(customerStatisticalInfo.getSmallClassName() == null ? null : customerStatisticalInfo.getSmallClassName());
  1713. row.createCell(7).setCellValue(customerStatisticalInfo.getDescribeTitle() == null ? null : customerStatisticalInfo.getDescribeTitle());
  1714. row.createCell(8).setCellValue(customerStatisticalInfo.getDescribeHandleDesc() == null ? null : customerStatisticalInfo.getDescribeHandleDesc());
  1715. row.createCell(9).setCellValue(salesPayTime);
  1716. row.createCell(10).setCellValue(customerStatisticalInfo.getCustomerIsSolve() == null ? null : customerStatisticalInfo.getCustomerIsSolve());
  1717. row.createCell(11).setCellValue(customerStatisticalInfo.getCompanyName() == null ? null : customerStatisticalInfo.getCompanyName());
  1718. row.createCell(12).setCellValue(customerStatisticalInfo.getStoreName() == null ? null : customerStatisticalInfo.getStoreName());
  1719. row.createCell(13).setCellValue(customerStatisticalInfo.getItemProductName() == null ? null : customerStatisticalInfo.getItemProductName());
  1720. row.createCell(14).setCellValue(customerStatisticalInfo.getItemProductColor() == null ? null : customerStatisticalInfo.getItemProductColor());
  1721. row.createCell(15).setCellValue(customerStatisticalInfo.getItemNum() == null ? null : customerStatisticalInfo.getItemNum());
  1722. row.createCell(16).setCellValue(backLogisticsCompany);
  1723. row.createCell(17).setCellValue(customerStatisticalInfo.getRelationBackLogisticsNo() == null ? null : customerStatisticalInfo.getRelationBackLogisticsNo());
  1724. row.createCell(18).setCellValue(customerStatisticalInfo.getRelationBackReceiptDate() == null ? null : customerStatisticalInfo.getRelationBackReceiptDate());
  1725. row.createCell(19).setCellValue(backStatus);
  1726. row.createCell(20).setCellValue(sendLogisticsCompany);
  1727. row.createCell(21).setCellValue(customerStatisticalInfo.getRelationSendLogisticsNo() == null ? null : customerStatisticalInfo.getRelationSendLogisticsNo());
  1728. row.createCell(22).setCellValue(customerStatisticalInfo.getCustomerOutDamaged() == null ? null : customerStatisticalInfo.getCustomerOutDamaged());
  1729. row.createCell(23).setCellValue(customerStatisticalInfo.getCustomerSecondaryCustomer() == null ? null : customerStatisticalInfo.getCustomerSecondaryCustomer());
  1730. row.createCell(24).setCellValue(customerStatisticalInfo.getAdminName() == null ? null : customerStatisticalInfo.getAdminName());
  1731. if(customerStatisticalInfo.getRelationFactoryCosts() == null){
  1732. row.createCell(25).setCellValue("");
  1733. }else{
  1734. row.createCell(25).setCellValue(customerStatisticalInfo.getRelationFactoryCosts());
  1735. }
  1736. if(customerStatisticalInfo.getRelationCustomerCosts() == null){
  1737. row.createCell(26).setCellValue("");
  1738. }else{
  1739. row.createCell(26).setCellValue(customerStatisticalInfo.getRelationCustomerCosts());
  1740. }
  1741. }
  1742. //下载导出订单Excel
  1743. downloadCustomerExcel(res,wb);
  1744. }
  1745. /**
  1746. * 下载导出客诉到Excel
  1747. * @param res
  1748. * @param wb
  1749. * @throws Exception
  1750. */
  1751. public void downloadCustomerExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
  1752. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1753. String fileName = format.format(new Date()) + "客诉报表";
  1754. ByteArrayOutputStream os = new ByteArrayOutputStream();
  1755. wb.write(os);
  1756. byte[] content = os.toByteArray();
  1757. InputStream is = new ByteArrayInputStream(content);
  1758. // 设置response参数,可以打开下载页面
  1759. res.reset();
  1760. res.setContentType("application/vnd.ms-excel;charset=utf-8");
  1761. res.setHeader("Content-Disposition", "attachment;filename="
  1762. + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
  1763. ServletOutputStream out = res.getOutputStream();
  1764. BufferedInputStream bis = null;
  1765. BufferedOutputStream bos = null;
  1766. try {
  1767. bis = new BufferedInputStream(is);
  1768. bos = new BufferedOutputStream(out);
  1769. byte[] buff = new byte[2048];
  1770. int bytesRead;
  1771. // Simple read/write loop.
  1772. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  1773. bos.write(buff, 0, bytesRead);
  1774. }
  1775. } catch (Exception e) {
  1776. // TODO: handle exception
  1777. e.printStackTrace();
  1778. } finally {
  1779. if (bis != null)
  1780. bis.close();
  1781. if (bos != null)
  1782. bos.close();
  1783. }
  1784. }
  1785. /**
  1786. * 跳转到添加客诉页面
  1787. *
  1788. * @return
  1789. */
  1790. @RequiresPermissions("customer:statistical:customer")
  1791. @RequestMapping(value = "/to_return_statistics")
  1792. public ModelAndView toReturnStatistics(HttpServletRequest request) {
  1793. ModelAndView mv = new ModelAndView("cm/report/return_statistics");
  1794. //获取产品集合,用于页面选择产品
  1795. ProductColor productColor = new ProductColor();
  1796. List<ProductColor> productColorList = productService.listproductAndColor(productColor);
  1797. mv.addObject("productColorList", productColorList);
  1798. //查询店铺
  1799. StoreInfo storeInfo = new StoreInfo();
  1800. List<StoreInfo> storeList = storeInfoService.listStore(storeInfo);
  1801. mv.addObject("storeList", storeList);
  1802. return mv;
  1803. }
  1804. /**
  1805. * 退换货统计
  1806. * @param request
  1807. * @param salesOrder
  1808. * @return
  1809. */
  1810. @ResponseBody
  1811. @RequestMapping("/return_statistics")
  1812. public ResponseJson returnStatistics(HttpServletRequest request,SalesOrder salesOrder){
  1813. if(salesOrder.getStartDate() == null){
  1814. Date now = new Date();
  1815. Calendar c = Calendar.getInstance();
  1816. c.setTime(now);
  1817. c.set(Calendar.DAY_OF_YEAR, 1);
  1818. c.set(Calendar.HOUR, 0);
  1819. c.set(Calendar.MINUTE, 0);
  1820. c.set(Calendar.SECOND, 0);
  1821. salesOrder.setStartDate(c.getTime());
  1822. c.add(Calendar.YEAR, 1);
  1823. c.set(Calendar.DAY_OF_YEAR, -1);
  1824. c.set(Calendar.HOUR, 23);
  1825. c.set(Calendar.MINUTE, 59);
  1826. c.set(Calendar.SECOND, 59);
  1827. salesOrder.setEndDate(c.getTime());
  1828. }
  1829. if(salesOrder.getItemColorBar() != null && !salesOrder.getItemColorBar().equals("")){
  1830. List<String> listColorBar = Arrays.asList(salesOrder.getItemColorBar().split(","));
  1831. salesOrder.setListColorBar(listColorBar);
  1832. }
  1833. /*销售总数*/
  1834. List<ReturnStatisticsInfo> listTotalSales = customerService.salesTotalSales(salesOrder);
  1835. /*总换货*/
  1836. List<ReturnStatisticsInfo> listTotalExchange = customerService.salesTotalExchange(salesOrder);
  1837. /*总退货*/
  1838. List<ReturnStatisticsInfo> listTotalReturn = customerService.salesTotalReturn(salesOrder);
  1839. /*二次换货*/
  1840. List<ReturnStatisticsInfo> listSecondaryChangeNew = customerService.salesSecondaryChangeNew(salesOrder);
  1841. /*二次换新退货*/
  1842. List<ReturnStatisticsInfo> listReturnForSecond = customerService.salesReturnForSecond(salesOrder);
  1843. /*封装数据*/
  1844. List<ReturnStatisticsInfo> listReturnStatisticsInfo = new ArrayList<>();
  1845. boolean isThereAre = false;
  1846. for (int i = 1;i<=12;i++){
  1847. ReturnStatisticsInfo returnStatisticsInfo = new ReturnStatisticsInfo();
  1848. for(int j = 0;j< listTotalSales.size(); j++){
  1849. if(i == listTotalSales.get(j).getMonths()){
  1850. returnStatisticsInfo.setMonths(i);
  1851. returnStatisticsInfo.setTotalSales(listTotalSales.get(j).getNum());
  1852. isThereAre = true;
  1853. }
  1854. }
  1855. if(!isThereAre){
  1856. returnStatisticsInfo.setMonths(i);
  1857. returnStatisticsInfo.setTotalSales(0);
  1858. }
  1859. isThereAre = false;
  1860. listReturnStatisticsInfo.add(returnStatisticsInfo);
  1861. }
  1862. for(int i = 0;i<listReturnStatisticsInfo.size();i++){
  1863. for(int j = 0;j< listTotalExchange.size(); j++){
  1864. if(i+1 == listTotalExchange.get(j).getMonths()){
  1865. listReturnStatisticsInfo.get(i).setTotalExchange(listTotalExchange.get(j).getNum());
  1866. isThereAre = true;
  1867. }
  1868. }
  1869. if(!isThereAre){
  1870. listReturnStatisticsInfo.get(i).setTotalExchange(0);
  1871. }
  1872. isThereAre = false;
  1873. for(int j = 0;j< listTotalReturn.size(); j++){
  1874. if(i+1 == listTotalReturn.get(j).getMonths()){
  1875. listReturnStatisticsInfo.get(i).setTotalReturn(listTotalReturn.get(j).getNum());
  1876. isThereAre = true;
  1877. }
  1878. }
  1879. if(!isThereAre){
  1880. listReturnStatisticsInfo.get(i).setTotalReturn(0);
  1881. }
  1882. isThereAre = false;
  1883. for(int j = 0;j< listSecondaryChangeNew.size(); j++){
  1884. if(i+1 == listSecondaryChangeNew.get(j).getMonths()){
  1885. listReturnStatisticsInfo.get(i).setSecondaryChangeNew(listSecondaryChangeNew.get(j).getNum());
  1886. isThereAre = true;
  1887. }
  1888. }
  1889. if(!isThereAre){
  1890. listReturnStatisticsInfo.get(i).setSecondaryChangeNew(0);
  1891. }
  1892. isThereAre = false;
  1893. for(int j = 0;j< listReturnForSecond.size(); j++){
  1894. if(i+1 == listReturnForSecond.get(j).getMonths()){
  1895. listReturnStatisticsInfo.get(i).setReturnForSecond(listReturnForSecond.get(j).getNum());
  1896. isThereAre = true;
  1897. }
  1898. }
  1899. if(!isThereAre){
  1900. listReturnStatisticsInfo.get(i).setReturnForSecond(0);
  1901. }
  1902. isThereAre = false;
  1903. }
  1904. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1905. rj.addResponseKeyValue("listReturnStatisticsInfo", listReturnStatisticsInfo);
  1906. return rj;
  1907. }
  1908. @RequestMapping("/to_add_customer_list")
  1909. public ModelAndView toAddCustomerList(HttpServletRequest request) throws Exception {
  1910. ModelAndView mv = new ModelAndView("cm/customer/add_custome_list");
  1911. return mv;
  1912. }
  1913. @ResponseBody
  1914. @RequestMapping("/add_customer_list")
  1915. public ResponseJson addCustomerList(HttpServletRequest request, CustomerInfo customer,
  1916. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  1917. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  1918. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
  1919. PagedResult<CustomerInfo> pagedResult = customerService.listCustomer(pageNO, pageSize, customer, totalNum == 0);
  1920. if (totalNum != 0) {
  1921. pagedResult.setTotal(totalNum);
  1922. }
  1923. //
  1924. // //查询产品类型集合
  1925. // List<ProductType> typeList = productService.listProductType(new ProductType());
  1926. // //查询客诉类型集合
  1927. // List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  1928. // //查询客诉类型集合
  1929. // List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(new ComplaintSmallClassInfo());
  1930. //查询跟进客服集合
  1931. Admin admin = new Admin();
  1932. admin.setAdminDept(3);
  1933. admin.setAdminStatus(1);
  1934. List<Admin> adminList = sysService.listSelectAdmin(admin);
  1935. ResponseJson rj = ResponseJson.getSUCCESS();
  1936. // rj.addResponseKeyValue("typeList",typeList);
  1937. // rj.addResponseKeyValue("complaintTypeList",complaintTypeList);
  1938. // rj.addResponseKeyValue("complaintSmallClassInfoList",complaintSmallClassInfoList);
  1939. rj.addResponseKeyValue("adminList",adminList);
  1940. rj.addResponseKeyValue("customerList",pagedResult.getDataList());
  1941. return rj;
  1942. }
  1943. }