AdminCustomerController.java 104 KB

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