AdminCustomerController.java 97 KB

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