AdminCustomerController.java 91 KB

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