AdminCustomerController.java 91 KB

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