AdminCustomerController.java 101 KB

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