AdminCustomerController.java 98 KB

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