AdminCustomerController.java 145 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327
  1. package com.iamberry.rst.controllers.cm;
  2. import com.iamberry.redis.RedisUtils;
  3. import com.iamberry.rst.core.address.City;
  4. import com.iamberry.rst.core.address.District;
  5. import com.iamberry.rst.core.address.Province;
  6. import com.iamberry.rst.core.cm.*;
  7. import com.iamberry.rst.core.fm.*;
  8. import com.iamberry.rst.core.order.Product;
  9. import com.iamberry.rst.core.order.ProductColor;
  10. import com.iamberry.rst.core.order.ProductType;
  11. import com.iamberry.rst.core.page.PagedResult;
  12. import com.iamberry.rst.core.sys.Admin;
  13. import com.iamberry.rst.core.tools.KuaiDi100;
  14. import com.iamberry.rst.core.tools.LogisticsInfo;
  15. import com.iamberry.rst.faces.address.AddressService;
  16. import com.iamberry.rst.faces.cm.*;
  17. import com.iamberry.rst.faces.fm.ComplaintDetectInfoService;
  18. import com.iamberry.rst.faces.fm.ComplaintSignclosedInfoService;
  19. import com.iamberry.rst.faces.fm.ComplaintSmallClassInfoService;
  20. import com.iamberry.rst.faces.order.EfastOrderService;
  21. import com.iamberry.rst.faces.order.LogisticsInfoService;
  22. import com.iamberry.rst.faces.order.OrderDepartService;
  23. import com.iamberry.rst.faces.product.ProductService;
  24. import com.iamberry.rst.faces.sms.SmsService;
  25. import com.iamberry.rst.faces.sys.SysService;
  26. import com.iamberry.rst.util.GenerateKeyUtil;
  27. import com.iamberry.rst.util.SmsConfig;
  28. import com.iamberry.rst.utils.*;
  29. import com.iamberry.wechat.tools.NameUtils;
  30. import com.iamberry.wechat.tools.ResponseJson;
  31. import com.iamberry.wechat.tools.ResultInfo;
  32. import net.sf.json.JSONArray;
  33. import net.sf.json.JSONObject;
  34. import org.apache.commons.codec.binary.Base64;
  35. import org.apache.commons.lang.StringUtils;
  36. import org.apache.poi.hssf.usermodel.*;
  37. import org.apache.poi.ss.util.CellRangeAddress;
  38. import org.apache.shiro.authz.annotation.RequiresPermissions;
  39. import org.slf4j.Logger;
  40. import org.slf4j.LoggerFactory;
  41. import org.springframework.beans.BeanUtils;
  42. import org.springframework.beans.factory.annotation.Autowired;
  43. import org.springframework.stereotype.Controller;
  44. import org.springframework.web.bind.annotation.RequestMapping;
  45. import org.springframework.web.bind.annotation.RequestParam;
  46. import org.springframework.web.bind.annotation.ResponseBody;
  47. import org.springframework.web.multipart.commons.CommonsMultipartFile;
  48. import org.springframework.web.servlet.ModelAndView;
  49. import javax.servlet.ServletOutputStream;
  50. import javax.servlet.http.HttpServletRequest;
  51. import javax.servlet.http.HttpServletResponse;
  52. import java.io.*;
  53. import java.text.MessageFormat;
  54. import java.text.NumberFormat;
  55. import java.text.SimpleDateFormat;
  56. import java.util.*;
  57. /**
  58. * Created by wxm
  59. */
  60. @Controller
  61. @RequestMapping("/admin/customer")
  62. public class AdminCustomerController {
  63. private Logger logger = LoggerFactory.getLogger(AdminCustomerController.class);
  64. @Autowired
  65. private CompanyInfoService companyInfoService;
  66. @Autowired
  67. private StoreInfoService storeInfoService;
  68. @Autowired
  69. private SalesOrderService salesOrderService;
  70. @Autowired
  71. private CustomerService customerService;
  72. @Autowired
  73. private ProductService productService;
  74. @Autowired
  75. private SysService sysService;
  76. @Autowired
  77. private ComplaintTypeInfoService complaintTypeInfoService;
  78. @Autowired
  79. private VisitService visitService;
  80. @Autowired
  81. private QuestionDescribeService questionDescribeService;
  82. @Autowired
  83. private ComplaintQuestionInfoService complaintQuestionInfoService;
  84. @Autowired
  85. private SmsService smsService;
  86. @Autowired
  87. private ComplaintSignclosedInfoService complaintSignclosedInfoService;
  88. @Autowired
  89. private ComplaintSmallClassInfoService complaintSmallClassInfoService;
  90. @Autowired
  91. private AddressService addressService;
  92. @Autowired
  93. private PostageService postageService;
  94. @Autowired
  95. private EfastOrderService efastOrderService;
  96. @Autowired
  97. private RelationOrderService relationOrderService;
  98. @Autowired
  99. private GenerateKeyUtil generateKeyUtil ;
  100. @Autowired
  101. private CmRelationService cmRelationService ;
  102. @Autowired
  103. private ProcMethodService procMethodService ;
  104. @Autowired
  105. private LogisticsInfoService logisticsInfoService;
  106. @Autowired
  107. private ComplaintDetectInfoService complaintDetectInfoService;
  108. @Autowired
  109. private OrderDepartService orderDepartService;
  110. /**
  111. * 获取客诉列表
  112. *
  113. * @param request
  114. * @return
  115. */
  116. @RequiresPermissions("customer:list:customer")
  117. @RequestMapping("/_customer_list")
  118. public ModelAndView getCustomer(HttpServletRequest request, CustomerInfo customer,
  119. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  120. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  121. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
  122. ModelAndView mv = new ModelAndView("cm/customer/custome_list");
  123. // PagedResult<Customer> pagedResult = ptsBomService.listCustomer(pageNO, pageSize, ptsBom, totalNum == 0);
  124. // if (totalNum != 0) {
  125. // pagedResult.setTotal(totalNum);
  126. // }
  127. // //获取产品集合,用于页面选择产品
  128. // List<Produce> list = produceService.getProduceList();
  129. // mv.addObject("produceList", list);
  130. // StitchAttrUtil.getSa().setModelAndView(customer, mv, "/admin/bom/_bom_list", pagedResult);
  131. return mv;
  132. }
  133. /**
  134. * 跳转到添加客诉页面
  135. *
  136. * @return
  137. */
  138. @RequiresPermissions("customer:add:customer")
  139. @RequestMapping(value = "/to_add_customer")
  140. public ModelAndView toAddCustomer(HttpServletRequest request) {
  141. ModelAndView mv = new ModelAndView("cm/customer/add_customer");
  142. //获取产品集合,用于页面选择产品
  143. // List<Produce> produceList = produceService.getProduceList();
  144. // mv.addObject("produceList", produceList);
  145. return mv;
  146. }
  147. /**
  148. * 跳转到修改客诉页面
  149. *
  150. * @return
  151. */
  152. @RequiresPermissions("customer:update:customer")
  153. @RequestMapping(value = "/to_update_customer")
  154. public ModelAndView toUpdateCustomer(HttpServletRequest request, Integer customerId) {
  155. ModelAndView mv = new ModelAndView("cm/customer/update_customer");
  156. ProductType productType = new ProductType();
  157. //查询产品类型集合
  158. List<ProductType> typeList = productService.listProductType(productType);
  159. //查询客诉类型集合
  160. List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  161. //查询跟进客服集合
  162. Admin admin = new Admin();
  163. admin.setAdminDept(3);
  164. admin.setAdminStatus(1);
  165. List<Admin> adminList = sysService.listSelectAdmin(admin);
  166. //获取登录人id
  167. Integer loginAdminId = AdminUtils.getLoginAdminId();
  168. //查询客诉基本信息
  169. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  170. /*查询处理方式*/
  171. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerInfo.getCustomerId());
  172. /*获取寄出寄入产品*/
  173. cmRelationService.getSendAndBackProduct(cmRelation);
  174. /*处理方式*/
  175. ProcMethod procMethod = procMethodService.getProcMethodById(cmRelation.getProcMethodId());
  176. if (customerInfo.getTypeId() == 1 || (procMethod.getProcMethodIsSend()==2 && procMethod.getProcMethodIsBack() == 2)) {
  177. customerInfo.setIsNeedSelectOrder(2); //不需要订单
  178. } else {
  179. customerInfo.setIsNeedSelectOrder(1);
  180. }
  181. //setIsNeedSelectOrder
  182. if (customerInfo.getIsNeedSelectOrder() == 1 ) {
  183. RelationOrder relationOrder = new RelationOrder();
  184. relationOrder.setRelationId(cmRelation.getRelationId());
  185. List<RelationOrder> relationOrderList = relationOrderService.getRelationOrderList(relationOrder);
  186. String[] salesIds = new String[relationOrderList.size()];
  187. for (int k = 0; k < relationOrderList.size(); k++) {
  188. salesIds[k] = String.valueOf(relationOrderList.get(k).getSalesId());
  189. }
  190. if(salesIds!=null && salesIds.length > 0){
  191. SalesOrder so = new SalesOrder();
  192. so.setSalesIds(salesIds);
  193. List<SalesOrder> orderList = salesOrderService.listSalesOrder(so);
  194. for (SalesOrder sor : orderList) {
  195. SalesOrderItem salesOrderItem = new SalesOrderItem();
  196. salesOrderItem.setItemOrderId(sor.getSalesId());
  197. List<SalesOrderItem> salesOrderItemList = salesOrderService.listSalesOrderItem(salesOrderItem);
  198. sor.setSalesOrderItemList(salesOrderItemList);
  199. }
  200. mv.addObject("salesOrderList", orderList);
  201. }
  202. } else {
  203. mv.addObject("salesOrderList", null);
  204. }
  205. if ("2".equals(customerInfo.getCustomerIsVisit())) { //1:不需要回访 2:需要回访
  206. Visit visit = new Visit();
  207. visit.setCustomerId(customerInfo.getCustomerId());
  208. visit = visitService.getVisit(visit);
  209. mv.addObject("visit", visit);
  210. }
  211. //查询关联问题
  212. ComplaintQuestionInfo complaintQuestionInfo = complaintQuestionInfoService.getQuestionById(customerInfo.getQuestionId());
  213. //查询问题小类
  214. ComplaintSmallClassInfo complaintSmallClassInfo = new ComplaintSmallClassInfo();
  215. complaintSmallClassInfo.setComplaintId(complaintQuestionInfo.getComplaintId());
  216. List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(complaintSmallClassInfo);
  217. //查询问题大类
  218. ProductType pType = productService.getProductType(customerInfo.getCustomerId());
  219. ComplaintTypeInfo complaintTypeInfo = new ComplaintTypeInfo();
  220. complaintTypeInfo.setComplaintType(pType.getComplaintType());
  221. List<ComplaintTypeInfo> complaintTypeInfoList = complaintTypeInfoService.listComplaintTypeInfo(complaintTypeInfo);
  222. mv.addObject("cmRelation", cmRelation);
  223. mv.addObject("procMethod", procMethod);
  224. mv.addObject("customerInfo", customerInfo);
  225. mv.addObject("typeList", typeList);
  226. mv.addObject("complaintTypeList", complaintTypeList);
  227. mv.addObject("complaintTypeList", complaintTypeList);
  228. mv.addObject("adminList", adminList);
  229. mv.addObject("loginAdminId", loginAdminId);
  230. mv.addObject("complaintQuestionInfo", complaintQuestionInfo);
  231. mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
  232. mv.addObject("complaintTypeInfoList", complaintTypeInfoList);
  233. return mv;
  234. }
  235. /**
  236. * 查询问题描述
  237. *
  238. * @return
  239. */
  240. @ResponseBody
  241. @RequiresPermissions("customer:add:customer")
  242. @RequestMapping(value = "/select_question_describe")
  243. public ResponseJson selectQuestionDescribe(HttpServletRequest request, Integer customerId) throws Exception {
  244. if (customerId == null || customerId == 0) {
  245. return new ResponseJson(500, "未获取到问题描述", 500);
  246. }
  247. //查询问题描述表
  248. QuestionDescribe questionDescribe = new QuestionDescribe();
  249. questionDescribe.setCustomerId(customerId);
  250. questionDescribe = questionDescribeService.listQuestionDescribe(questionDescribe).get(0);
  251. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  252. rj.addResponseKeyValue("questionDescribe", questionDescribe);
  253. return rj;
  254. }
  255. /**
  256. * 搜索订单列表弹出框
  257. *
  258. * @return
  259. */
  260. @RequiresPermissions("customer:add:customer")
  261. @RequestMapping(value = "/select_order")
  262. public ModelAndView selectOrder(HttpServletRequest request) {
  263. ModelAndView mv = new ModelAndView("cm/customer/order_list");
  264. //获取销售公司
  265. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  266. mv.addObject("companyInfoList", companyInfoList);
  267. return mv;
  268. }
  269. /**
  270. * 添加订单列表弹出框
  271. *
  272. * @return
  273. */
  274. @RequiresPermissions("customer:add:customer")
  275. @RequestMapping(value = "/add_order")
  276. public ModelAndView addOder(HttpServletRequest request) {
  277. ModelAndView mv = new ModelAndView("cm/customer/order_add");
  278. return mv;
  279. }
  280. /**
  281. * 添加订单
  282. *
  283. * @return
  284. */
  285. @ResponseBody
  286. @RequiresPermissions("customer:add:customer")
  287. @RequestMapping(value = "/add_order_info")
  288. public ResponseJson addOrderInfo(HttpServletRequest request, SalesOrder salesOrder, String itemJson) throws Exception {
  289. List<SalesOrderItem> list = new ArrayList<>();
  290. JSONArray jsonArray = JSONArray.fromObject(itemJson);
  291. list = (List) JSONArray.toCollection(jsonArray, SalesOrderItem.class);
  292. Integer salesAmount = 0;
  293. for (int i = 0; i < list.size(); i++) {
  294. SalesOrderItem salesOrderItem = list.get(i);
  295. if (salesOrderItem.getItemIsSource() == 1) { //产品来源 1:产品颜色表,2:配件表
  296. Product product = productService.getProductById(salesOrderItem.getItemColorId());
  297. ProductColor productColor = productService.getProduceColor(salesOrderItem.getItemColorId());
  298. salesOrderItem.setItemProductType(product.getProductType());
  299. salesOrderItem.setItemProductName(product.getProductName());
  300. salesOrderItem.setItemProductPic(productColor.getColorPicture());
  301. salesOrderItem.setItemProductColor(productColor.getColorName());
  302. salesOrderItem.setItemColorBar(productColor.getColorBar());
  303. salesOrderItem.setItemProductPrice(productColor.getColorPrice());
  304. salesOrderItem.setItemProductDiscount(productColor.getColorDiscount());
  305. salesOrderItem.setItemIsSource(1);
  306. salesAmount += productColor.getColorDiscount();
  307. }
  308. }
  309. salesOrder.setSalesOpenId("0");
  310. salesOrder.setSalesAmount(salesAmount);
  311. salesOrder.setSalesPayMoney(salesAmount);
  312. salesOrder.setSalesOrderStatus(1);
  313. salesOrder.setSalesCreateTime(new Date());
  314. //salesOrder.setSalesPayTime(new Date());
  315. salesOrder.setSalesLastMoney(salesAmount);
  316. salesOrder.setSalesWaitMoney(0);
  317. salesOrder.setSalesPayMoney(salesAmount);
  318. salesOrder.setSalesSalesTime(new Date());
  319. salesOrder.setSalesDiscountMoney(salesAmount);
  320. salesOrder.setSalesPledgeMoney(0);
  321. salesOrder.setSalesRemainDeposit(0);
  322. salesOrder.setSalesType(1);
  323. salesOrder.setSalesStatus(1);//确认状态:0(未确认)1(确认)2(挂起)3(作废)
  324. salesOrder.setSalesPayStatus(2); //已付款
  325. salesOrder.setSalesProcessStatus(0); //单据状态:0(正常单)1(问题单)
  326. salesOrder.setSalesIsSend(0); //0:否 1:是 是否通知配货
  327. salesOrder.setSalesIsLocked(0); //是否锁定 0:否 1:是
  328. salesOrder.setSalesIsSeparate(0); //是否缺货 0:否 1:是
  329. salesOrder.setSalesShippingFee(0); //邮费
  330. salesOrder.setSalesDeliver(2); // 已出库
  331. Integer adminId = AdminUtils.getLoginAdminId();
  332. String orderCode = GenerateKeyUtil.createOrderCode(adminId);
  333. salesOrder.setSalesDealCode(orderCode);
  334. salesOrder.setSalesOrderId(orderCode);
  335. salesOrder.setSalesBatchId(generateKeyUtil.getSalesBatchIdKS());
  336. //salesOrder = salesOrderService.addOrderAndIteminfo(salesOrder,list);
  337. salesOrder.setSalesOrderItemList(list);
  338. try {
  339. Integer flag = customerService.addOrder(salesOrder);
  340. } catch (RuntimeException e) {
  341. return new ResponseJson(500, "添加订单失败--" + e.getMessage(), 500);
  342. }
  343. Integer orderId = salesOrder.getSalesId();
  344. ResponseJson rj = new ResponseJson(200, "添加订单成功", 200);
  345. rj.addResponseKeyValue("orderId", orderId);
  346. return rj;
  347. }
  348. /**
  349. * 查询销售公司
  350. *
  351. * @return
  352. */
  353. @ResponseBody
  354. @RequiresPermissions("customer:add:customer")
  355. @RequestMapping(value = "/select_company")
  356. public ResponseJson getCompany(HttpServletRequest request) throws Exception {
  357. //获取销售公司
  358. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  359. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  360. rj.addResponseKeyValue("companyInfoList", companyInfoList);
  361. return rj;
  362. }
  363. /**
  364. * 获取店铺集合
  365. *
  366. * @param request
  367. * @param storeInfo
  368. * @param isMyStore 为1则需要判断是否是自己包含的店铺, 为其他则查询所有店铺
  369. * @return
  370. */
  371. @ResponseBody
  372. @RequiresPermissions("customer:add:customer")
  373. @RequestMapping(value = "/select_storeInfo")
  374. public ResponseJson listStoreInfo(HttpServletRequest request, StoreInfo storeInfo,
  375. @RequestParam(value = "isMyStore", defaultValue = "2", required = false) Integer isMyStore) {
  376. if(isMyStore == 1){
  377. //判断用户只能查看自己所能查询的公司的订单
  378. Integer[] storeIds = orderDepartService.getDepartStoreIds(AdminUtils.getLoginAdminId());
  379. storeInfo.setStoreIds(storeIds);
  380. }
  381. storeInfo.setStoreStatus(1);
  382. List<StoreInfo> storeInfoList = storeInfoService.listStore(storeInfo);
  383. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  384. rj.addResponseKeyValue("storeInfoList", storeInfoList);
  385. return rj;
  386. }
  387. /**
  388. * 获取订单集合
  389. *
  390. * @param request
  391. * @param salesOrder
  392. * @return
  393. */
  394. @ResponseBody
  395. @RequiresPermissions("customer:add:customer")
  396. @RequestMapping(value = "/select_salesOrder")
  397. public ResponseJson listOrder(HttpServletRequest request, SalesOrder salesOrder, String ids,
  398. @RequestParam(value = "pageSize", defaultValue = "20", required = false) Integer pageSize,
  399. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  400. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
  401. if (ids != null && ids.indexOf("_") > -1) {
  402. String[] salesIds = ids.split("_");
  403. salesOrder.setSalesIds(salesIds);
  404. }
  405. //分页获取订单信息
  406. PagedResult<SalesOrder> pagedResult = salesOrderService.listSalesOrderPage(pageNO, pageSize, salesOrder, totalNum == 0);
  407. List<SalesOrder> salesOrderList = pagedResult.getDataList();
  408. for (SalesOrder so:salesOrderList) {
  409. if(so.getSalesOrderStatus() != 0){
  410. ProcMethod procMethod = procMethodService.getProcMethodById(so.getSalesOrderStatus());
  411. so.setSalesOrderStatusProcTypeName(procMethod.getProcTypeName());
  412. }
  413. }
  414. if (salesOrderList == null || salesOrderList.size() < 1) {
  415. return new ResponseJson(500, "查询失败", 500);
  416. } else {
  417. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  418. rj.addResponseKeyValue("salesOrderList", salesOrderList);
  419. return rj;
  420. }
  421. }
  422. /**
  423. * 分页查询客诉列表信息
  424. *
  425. * @param request
  426. * @param customerInfo
  427. * @param pageSize
  428. * @param pageNO
  429. * @param totalNum
  430. * @return
  431. * @throws Exception
  432. */
  433. @RequiresPermissions("customer:select:customer")
  434. @RequestMapping("/select_customer_list")
  435. public ModelAndView selectCustomerList(HttpServletRequest request, CustomerInfo customerInfo,
  436. @RequestParam(value = "isFirst", defaultValue = "2", required = false) Integer isFirst,
  437. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  438. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  439. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
  440. ModelAndView mv = new ModelAndView("cm/customer/custome_list");
  441. /*if (customerInfo.getAdminId() == null && isFirst == 1) {
  442. //获取登录员工id
  443. Integer adminId = AdminUtils.getLoginAdminId();
  444. customerInfo.setAdminId(adminId);
  445. }*/
  446. //获取登录人id
  447. Integer loginAdminId = AdminUtils.getLoginAdminId();
  448. if(customerInfo != null){
  449. if(customerInfo.getAfterState() != null) {
  450. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  451. Calendar date = Calendar.getInstance();
  452. date.setTime(new Date());
  453. switch (customerInfo.getAfterState()) {
  454. case 1:
  455. //今日签收
  456. customerInfo.setAfterTime(sdf.format(date.getTime()));
  457. break;
  458. case 2:
  459. //昨日签收
  460. date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
  461. customerInfo.setAfterTime(sdf.format(date.getTime()));
  462. break;
  463. case 3:
  464. //前日签收
  465. date.set(Calendar.DATE, date.get(Calendar.DATE) - 2);
  466. customerInfo.setAfterTime(sdf.format(date.getTime()));
  467. break;
  468. }
  469. String isOneself = request.getParameter("isOneself");
  470. if(isOneself != null){
  471. if(isOneself.equals("2")){
  472. customerInfo.setAdminId(loginAdminId);
  473. }
  474. }
  475. }
  476. }
  477. PagedResult<CustomerInfo> pagedResult = customerService.listCustomer(pageNO, pageSize, customerInfo, totalNum == 0);
  478. if (totalNum != 0) {
  479. pagedResult.setTotal(totalNum);
  480. }
  481. //查询寄出状态
  482. if(pagedResult.getDataList().size() > 0){
  483. for(CustomerInfo info : pagedResult.getDataList()){
  484. if(info.getSalesOrderList().size() > 0){
  485. info.setSendStatus(info.getSalesOrderList().get(0).getSalesStatus());
  486. }
  487. }
  488. }
  489. ProductType productType = new ProductType();
  490. //查询产品类型集合
  491. List<ProductType> typeList = productService.listProductType(productType);
  492. //查询客诉类型集合
  493. List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  494. //查询客诉类型集合
  495. List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(new ComplaintSmallClassInfo());
  496. //查询处理类型
  497. List<ProcType> procTypeList = customerService.listProcType();
  498. //店铺(销售渠道)
  499. List<StoreInfo> listStoreInfo = storeInfoService.listStore(new StoreInfo());
  500. //客诉问题
  501. ComplaintQuestionInfo complaintQuestionInfo = new ComplaintQuestionInfo();
  502. List<ComplaintQuestionInfo> listComplaintQuestionInfo = complaintQuestionInfoService.listQuestionAll(complaintQuestionInfo);
  503. //查询问题集合 第 30 条bug
  504. // List<QuestionDescribe> questionDescribeList = questionDescribeService.listQuestionDescribe(new QuestionDescribe());
  505. //查询跟进客服集合
  506. Admin admin = new Admin();
  507. admin.setAdminDept(3);
  508. admin.setAdminStatus(1);
  509. List<Admin> adminList = sysService.listSelectAdmin(admin);
  510. mv.addObject("listComplaintQuestionInfo",listComplaintQuestionInfo);
  511. mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
  512. mv.addObject("loginAdminId", loginAdminId);
  513. mv.addObject("typeList", typeList);
  514. mv.addObject("complaintTypeList", complaintTypeList);
  515. mv.addObject("adminList", adminList);
  516. mv.addObject("procTypeList", procTypeList);
  517. mv.addObject("listStoreInfo", listStoreInfo);
  518. customerInfo.setVisit(null);
  519. customerInfo.setCustomerCommon(null);
  520. customerInfo.setComplaintDetectList(null);
  521. StitchAttrUtil sa = StitchAttrUtil.getSa();
  522. sa.addDatePro("yyyy-MM-dd", "startTime", "endTime");
  523. sa.setModelAndView(customerInfo, mv, "/admin/customer/select_customer_list", pagedResult);
  524. return mv;
  525. }
  526. /**
  527. * 进入客诉基本信息页面
  528. *
  529. * @param request
  530. * @return
  531. * @throws Exception
  532. */
  533. @RequiresPermissions("customer:select:customer")
  534. @RequestMapping("/_customer_info")
  535. public ModelAndView toCustomerInfo(HttpServletRequest request) throws Exception {
  536. ModelAndView mv = new ModelAndView("cm/customer/custome_detail");
  537. String customerId = request.getParameter("customerId");
  538. CmRelation cmRelation = new CmRelation();
  539. cmRelation.setCustomerId(Integer.valueOf(customerId));
  540. cmRelation = customerService.getCmRelationInfo(cmRelation);
  541. ProcMethod procMethod = customerService.getProcMethod(cmRelation.getProcMethodId());
  542. List<LogisticsInfo>logisticsInfoList = logisticsInfoService.getLogisticsInfoList(new LogisticsInfo());
  543. List<PostageInfo> listPostageInfo = customerService.listPostageInfo(cmRelation.getRelationId());
  544. List<SendbackInfo> listSendbackInfo = customerService.listSendbackInfo(cmRelation.getRelationId());
  545. //查询寄回产品
  546. ClosedProdcue record = new ClosedProdcue();
  547. record.setRelationId(cmRelation.getRelationId());
  548. List <ClosedProdcue> listClosedProdcue = customerService.listclosedProdcue(record);
  549. SalesOrder salesOrder = new SalesOrder();
  550. salesOrder.setSalesCustomerId(cmRelation.getCustomerId());
  551. List<SalesOrder> salesOrderList = salesOrderService.salesOrderListAndItem(salesOrder);
  552. mv.addObject("listClosedProdcue",listClosedProdcue);
  553. mv.addObject("listSendbackInfo",listSendbackInfo);
  554. mv.addObject("logisticsInfoList",logisticsInfoList);
  555. mv.addObject("listPostageInfo", listPostageInfo);
  556. mv.addObject("procMethod", procMethod);
  557. mv.addObject("customerId", customerId);
  558. mv.addObject("salesOrderList", salesOrderList);
  559. return mv;
  560. }
  561. /**
  562. * 查询客诉基本信息
  563. *
  564. * @param request
  565. * @return
  566. * @throws Exception
  567. */
  568. @ResponseBody
  569. @RequiresPermissions("customer:select:customer")
  570. @RequestMapping("/get_customer_info")
  571. public ResponseJson getCustomerInfo(HttpServletRequest request) throws Exception {
  572. String customerId = request.getParameter("customerId");
  573. if (!StringUtils.isNotEmpty(customerId)) {
  574. return new ResponseJson(500, "该客诉信息不存在!", 500);
  575. }
  576. CustomerInfo customerInfo = new CustomerInfo();
  577. customerInfo.setCustomerId(Integer.parseInt(customerId));
  578. Map<String, Object> map = customerService.getCustomerInfo(customerInfo);
  579. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  580. //查询处理方式信息
  581. CmRelation cmRelation = new CmRelation();
  582. cmRelation.setCustomerId(customerInfo.getCustomerId());
  583. cmRelation = customerService.getCmRelationInfo(cmRelation);
  584. ProcMethod procMethod = customerService.getProcMethod(cmRelation.getProcMethodId());
  585. CustomerInfo ci = (CustomerInfo) map.get("customer");
  586. if(ci != null){
  587. if(ci.getCustomerProvinceId() != null && !"".equals(ci.getCustomerProvinceId())){
  588. Province province = new Province();
  589. province.setProvinceId(Integer.valueOf(ci.getCustomerProvinceId()));
  590. List<Province> provinceList = addressService.listProvince(province);
  591. ci.setCustomerProvinceName(provinceList.get(0).getProvince());
  592. }else{
  593. ci.setCustomerProvinceName("");
  594. }
  595. if(ci.getCustomerCityId() != null && !"".equals(ci.getCustomerCityId())){
  596. City city = new City();
  597. city.setCityId(Integer.valueOf(ci.getCustomerCityId()));
  598. List<City> cityList = addressService.listCity(city);
  599. ci.setCustomerCityName(cityList.get(0).getCity());
  600. }else{
  601. ci.setCustomerCityName("");
  602. }
  603. if(ci.getCustomerDistrictId() != null && !"".equals(ci.getCustomerDistrictId())){
  604. District district = new District();
  605. district.setDistrictId(Integer.valueOf(ci.getCustomerDistrictId()));
  606. List<District> districtList = addressService.listDistrict(district);
  607. ci.setCustomerDistrictName(districtList.get(0).getDistrict());
  608. }else{
  609. ci.setCustomerDistrictName("");
  610. }
  611. }
  612. //已完成维修、原机退货,并且发货状态为待下单的维修记录,则需要查询当前客诉对应的维修机器
  613. List<ComplaintDetectInfo> listDetet = complaintDetectInfoService.listDetectByCustomerId(Integer.valueOf(customerId));
  614. rj.addResponseKeyValue("listDetet", listDetet);
  615. rj.addResponseKeyValue("cmRelation", cmRelation);
  616. rj.addResponseKeyValue("procMethod", procMethod);
  617. rj.addResponseKeyValue("customerCommon", map.get("customerCommon"));
  618. rj.addResponseKeyValue("customer", map.get("customer"));
  619. rj.addResponseKeyValue("orderList", map.get("orderList"));
  620. rj.addResponseKeyValue("colorIds", map.get("colorIds"));
  621. return rj;
  622. }
  623. /**
  624. * 查询客诉基本信息
  625. *
  626. * @param request
  627. * @return
  628. * @throws Exception
  629. */
  630. @ResponseBody
  631. @RequiresPermissions("customer:select:customer")
  632. @RequestMapping("/get_customer")
  633. public ResponseJson getCustomer(HttpServletRequest request) throws Exception {
  634. String customerId = request.getParameter("customerId");
  635. if (!StringUtils.isNotEmpty(customerId)) {
  636. return new ResponseJson(500, "该客诉信息不存在!", 500);
  637. }
  638. SalesOrder salesOrder = new SalesOrder();
  639. salesOrder.setSalesCustomerId(Integer.valueOf(customerId));
  640. List<SalesOrder> salesOrderList = salesOrderService.salesOrderListAndItem(salesOrder);
  641. ResponseJson rj = ResponseJson.getSUCCESS();
  642. rj.addResponseKeyValue("salesOrderList", salesOrderList);
  643. return rj;
  644. }
  645. /**
  646. * 进入添加回访页面
  647. *
  648. * @param request
  649. * @return
  650. * @throws Exception
  651. */
  652. @RequiresPermissions("customer:select:customer")
  653. @RequestMapping("/_add_visit")
  654. public ModelAndView toAddVisit(HttpServletRequest request) throws Exception {
  655. ModelAndView mv = new ModelAndView("cm/customer/add_visit");
  656. String customerId = request.getParameter("customerId");
  657. //查询跟进客服集合
  658. Admin admin = new Admin();
  659. admin.setAdminDept(3);
  660. admin.setAdminStatus(1);
  661. List<Admin> adminList = sysService.listSelectAdmin(admin);
  662. //获取登录人id
  663. Integer loginAdminId = AdminUtils.getLoginAdminId();
  664. mv.addObject("loginAdminId", loginAdminId);
  665. mv.addObject("customerId", customerId);
  666. mv.addObject("adminList", adminList);
  667. return mv;
  668. }
  669. /**
  670. * 添加回访信息
  671. *
  672. * @param request
  673. * @param visit
  674. * @return
  675. */
  676. @ResponseBody
  677. @RequiresPermissions("customer:add:visit")
  678. @RequestMapping("/add_visit_info")
  679. public ResponseJson addVisitInfo(HttpServletRequest request, Visit visit) throws Exception {
  680. String visitAdminId = request.getParameter("visitAdminId");
  681. if (!StringUtils.isNotEmpty(visitAdminId)) {
  682. return new ResponseJson(500, "请选择回访人!", 500);
  683. }
  684. Integer loginAdminId = AdminUtils.getLoginAdminId();
  685. visit.setAdminId(loginAdminId);
  686. visit.setDesignatedAdminId(Integer.parseInt(visitAdminId));
  687. visit.setVisitStatus(1);
  688. visit.setVisitCreateTime(new Date());
  689. int num = visitService.addVisitInfo(visit, visit.getCustomerId());
  690. if (num > 0) {
  691. return new ResponseJson(200, "修改成功!", 200);
  692. } else {
  693. return new ResponseJson(500, "修改失败!", 500);
  694. }
  695. }
  696. /**
  697. * 修改客诉状态为已解决
  698. *
  699. * @param request
  700. * @return
  701. */
  702. @ResponseBody
  703. @RequiresPermissions("customer:update:customerIsSolve")
  704. @RequestMapping("/update_customerIsSolve")
  705. public ResponseJson updateCustomerIsSolve(HttpServletRequest request) throws Exception {
  706. String customerId = request.getParameter("customerId");
  707. if (!StringUtils.isNotEmpty(customerId)) {
  708. return new ResponseJson(500, "该客诉信息不存在!", 500);
  709. }
  710. //根据id获取客诉信息
  711. CustomerInfo customer = customerService.getCustomerInfo(Integer.parseInt(customerId));
  712. if (customer == null) {
  713. return new ResponseJson(500, "该客诉信息不存在!", 500);
  714. }
  715. if (customer.getCustomerIsSolve().intValue() != 2) {
  716. return new ResponseJson(500, "该客诉信息不能修改为已解决状态!", 500);
  717. }
  718. CustomerInfo customerInfo = new CustomerInfo();
  719. customerInfo.setCustomerId(Integer.parseInt(customerId));
  720. customerInfo.setCustomerIsSolve(1);
  721. //修改客诉信息
  722. int num = customerService.updateCustomerInfo(customerInfo);
  723. if (num > 0) {
  724. return new ResponseJson(200, "修改成功!", 200);
  725. } else {
  726. return new ResponseJson(500, "修改失败!", 500);
  727. }
  728. }
  729. /**
  730. * 查询客服
  731. *
  732. * @param request
  733. * @return
  734. */
  735. @ResponseBody
  736. @RequiresPermissions("customer:add:customer")
  737. @RequestMapping("/select_sys_admin")
  738. public ResponseJson selectSysAdmin(HttpServletRequest request) throws Exception {
  739. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  740. Integer adminId = AdminUtils.getLoginAdminId();
  741. Admin admin = new Admin();
  742. admin.setAdminDept(3);
  743. admin.setAdminStatus(1);
  744. List<Admin> adminList = sysService.listSelectAdmin(admin);
  745. if (adminList.size() > 0) {
  746. rj.addResponseKeyValue("adminList", adminList);
  747. rj.addResponseKeyValue("adminId", adminId);
  748. return rj;
  749. } else {
  750. return new ResponseJson(500, "查询失败!", 500);
  751. }
  752. }
  753. /**
  754. * 查询产品类型
  755. *
  756. * @param request
  757. * @return
  758. */
  759. @ResponseBody
  760. @RequiresPermissions("customer:add:customer")
  761. @RequestMapping("/select_produce_type")
  762. public ResponseJson selectProduceType(HttpServletRequest request) throws Exception {
  763. ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
  764. ProductType productType = new ProductType();
  765. productType.setTypeStatus(1);
  766. List<ProductType> productTypeList = productService.listProductType(productType);
  767. if (productTypeList != null && productTypeList.size() > 0) {
  768. rj.addResponseKeyValue("productTypeList", productTypeList);
  769. return rj;
  770. } else {
  771. return new ResponseJson(500, "查询失败!", 500);
  772. }
  773. }
  774. /**
  775. * 查询产品
  776. *
  777. * @param request
  778. * @return
  779. */
  780. @ResponseBody
  781. @RequiresPermissions("customer:add:customer")
  782. @RequestMapping("/select_produce")
  783. public ResponseJson selectProduce(HttpServletRequest request) {
  784. ResponseJson rj = new ResponseJson(200, "查询成功!", 200);
  785. Product product = new Product();
  786. List<Product> productList = productService.listProduce(product);
  787. for (Product pro : productList) {
  788. ProductColor productColor = new ProductColor();
  789. productColor.setColorProductId(pro.getProductId());
  790. List<ProductColor> productColorList = productService.listProduceColor(productColor);
  791. pro.setColorList(productColorList);
  792. }
  793. if (productList != null && productList.size() > 0) {
  794. rj.addResponseKeyValue("productList", productList);
  795. return rj;
  796. } else {
  797. return new ResponseJson(500, "查询失败!", 500);
  798. }
  799. }
  800. /**
  801. * 添加客诉
  802. *
  803. * @param request
  804. * @return
  805. */
  806. @ResponseBody
  807. @RequiresPermissions("customer:add:customer")
  808. @RequestMapping("/save_customer")
  809. public ResponseJson addCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CmRelation cmRelation,
  810. String sendProdcuesJson,String closedProdcuesJson) throws Exception {
  811. ResponseJson rjx = this.isValiData(customerInfo);
  812. if (rjx.getResultCode() == 500) {
  813. return rjx;
  814. }
  815. if(customerInfo.getCustomerTel() != null && !"".equals(customerInfo.getCustomerTel())){
  816. customerInfo.setCustomerTel(customerInfo.getCustomerTel().trim());
  817. }
  818. if(cmRelation.getRelationBackTel() != null && !"".equals(cmRelation.getRelationBackTel())){
  819. cmRelation.setRelationBackTel(cmRelation.getRelationBackTel().trim());
  820. }
  821. if(cmRelation.getRelationSendTel() != null && !"".equals(cmRelation.getRelationSendTel())){
  822. cmRelation.setRelationSendTel(cmRelation.getRelationSendTel().trim());
  823. }
  824. Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
  825. String phone = customerInfo.getCustomerTel(); //手机号码
  826. Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
  827. Integer flag = 0;
  828. if (customerInfo.getIsNeedSelectOrder() == 1) { ////1:需要有订单 2:不需要有订单
  829. JSONArray jsonArray;
  830. List<SendProdcue> sendProdcueList;
  831. List<ClosedProdcue> closedProdcueList;
  832. jsonArray = JSONArray.fromObject(sendProdcuesJson);
  833. sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
  834. jsonArray = JSONArray.fromObject(closedProdcuesJson);
  835. closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
  836. cmRelation.setSendProdcues(sendProdcueList);
  837. cmRelation.setClosedProdcues(closedProdcueList);
  838. }
  839. customerInfo.setCmRelation(cmRelation);
  840. String orderId = "";
  841. if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
  842. Integer adminId = AdminUtils.getLoginAdminId();
  843. orderId = OrderNoUtil.createOrderCode(adminId);
  844. }
  845. customerInfo.setTransactionNumber(orderId);
  846. Integer customerId = customerInfo.getCustomerId();
  847. logger.info("-----------------添加客诉开始----------------------");
  848. try {
  849. flag = customerService.saveCustomerInfo(customerInfo, salesOrder);
  850. } catch (RuntimeException e) {
  851. e.printStackTrace();
  852. return new ResponseJson(500, e.getMessage(), 500);
  853. } catch (Exception e) {
  854. e.printStackTrace();
  855. return new ResponseJson(500, "添加失败", 500);
  856. }
  857. customerId = customerInfo.getCustomerId();
  858. logger.info("-----------------添加客诉结束----------------------");
  859. if (flag < 1) {
  860. return new ResponseJson(500, "添加客诉失败!", 500);
  861. }
  862. String msg = "";
  863. //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
  864. if (customerIsSolve == 3 || customerIsSolve == 4 || customerIsSolve == 5 || customerIsSolve == 6 || customerIsSolve == 7) {
  865. String solveMsg = "";
  866. switch (customerIsSolve) {
  867. case 3:
  868. solveMsg = "为您更换新机";
  869. break;
  870. case 4:
  871. solveMsg = "为您维修机器";
  872. break;
  873. case 5:
  874. solveMsg = "为您补发产品";
  875. break;
  876. case 6:
  877. solveMsg = "为您办理退货";
  878. break;
  879. case 7:
  880. solveMsg = "为您办理退货";
  881. break;
  882. }
  883. String addCustomerSuccessMsg = "";
  884. String typeMsg = "";
  885. switch (typeCompany) {
  886. case 1:
  887. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_WATERO;
  888. typeMsg = "美国WaterO售后";
  889. break;
  890. case 2:
  891. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_SHANGDUO;
  892. typeMsg = "上朵售后";
  893. break;
  894. case 3:
  895. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_YULIA;
  896. typeMsg = "YULIA售后";
  897. break;
  898. case 4:
  899. addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_AIBERLE;
  900. typeMsg = "爱贝源售后";
  901. break;
  902. }
  903. // Object [] msg = new Object[]{solveMsg,typeMsg};
  904. // String text = MessageFormat.format(addCustomerSuccessMsg, msg);
  905. // logger.info("添加客诉成功后,给 "+ phone +" 手机用户发送短信:" + text );
  906. // String result = smsService.sendOtherCMS(phone, text);
  907. //
  908. // if (!"SUCCESS".equals(result)) {
  909. // return new ResponseJson(505, "添加客诉发送短信失败,失败原因:" + result + "<br>客诉信息发送失败并不影响客诉添加。客诉编号为:"+ customerId, 505);
  910. // }
  911. msg = ",请前往Efast进行换货/退货操作。";
  912. }
  913. return new ResponseJson(200, "录入客诉成功!客诉编号:" + customerId + msg, 200);
  914. }
  915. /**
  916. * 修改客诉
  917. *
  918. * @param request
  919. * @return
  920. */
  921. @ResponseBody
  922. @RequiresPermissions("customer:update:customer")
  923. @RequestMapping("/update_customer")
  924. public ResponseJson updateCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CmRelation cmRelation,
  925. String sendProdcuesJson, String closedProdcuesJson) throws Exception {
  926. ResponseJson rjx = this.isValiData(customerInfo);
  927. if (rjx.getResultCode() == 500) {
  928. return rjx;
  929. }
  930. Integer flag = 0;
  931. if(customerInfo.getCustomerTel() != null && !"".equals(customerInfo.getCustomerTel())){
  932. customerInfo.setCustomerTel(customerInfo.getCustomerTel().trim());
  933. }
  934. if(cmRelation.getRelationBackTel() != null && !"".equals(cmRelation.getRelationBackTel())){
  935. cmRelation.setRelationBackTel(cmRelation.getRelationBackTel().trim());
  936. }
  937. if(cmRelation.getRelationSendTel() != null && !"".equals(cmRelation.getRelationSendTel())){
  938. cmRelation.setRelationSendTel(cmRelation.getRelationSendTel().trim());
  939. }
  940. Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
  941. String phone = customerInfo.getCustomerTel(); //手机号码
  942. Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
  943. if (customerInfo.getIsNeedSelectOrder() == 1) {
  944. JSONArray jsonArray;
  945. List<SendProdcue> sendProdcueList;
  946. List<ClosedProdcue> closedProdcueList;
  947. jsonArray = JSONArray.fromObject(sendProdcuesJson);
  948. sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
  949. jsonArray = JSONArray.fromObject(closedProdcuesJson);
  950. closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
  951. cmRelation.setSendProdcues(sendProdcueList);
  952. cmRelation.setClosedProdcues(closedProdcueList);
  953. }
  954. String orderId = "";
  955. if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
  956. Integer adminId = AdminUtils.getLoginAdminId();
  957. orderId = OrderNoUtil.createOrderCode(adminId);
  958. }
  959. customerInfo.setTransactionNumber(orderId);
  960. customerInfo.setCmRelation(cmRelation);
  961. Integer customerId = customerInfo.getCustomerId();
  962. logger.info("-----------------修改客诉开始----------------------");
  963. try {
  964. flag = customerService.updateCustomerInfo(customerInfo, salesOrder);
  965. } catch (RuntimeException e) {
  966. e.printStackTrace();
  967. return new ResponseJson(500, e.getMessage(), 500);
  968. } catch (Exception e) {
  969. e.printStackTrace();
  970. return new ResponseJson(500, "修改失败", 500);
  971. }
  972. customerId = customerInfo.getCustomerId();
  973. logger.info("-----------------修改客诉结束----------------------");
  974. if (flag < 1) {
  975. return new ResponseJson(500, "修改客诉失败!", 500);
  976. }
  977. return new ResponseJson(200, "修改客诉成功!客诉编号为:" + customerId, 200);
  978. }
  979. /**
  980. * 验证方法
  981. *
  982. * @param customerInfo
  983. * @return
  984. */
  985. public ResponseJson isValiData(CustomerInfo customerInfo) {
  986. ResponseJson rj = new ResponseJson();
  987. if (customerInfo.getAdminId() == null) {
  988. return new ResponseJson(500, "未填写客诉id", 500);
  989. }
  990. return rj;
  991. }
  992. /**
  993. * 发送短信
  994. *
  995. * @param request
  996. * @return
  997. */
  998. @ResponseBody
  999. @RequiresPermissions("customer:add:customer")
  1000. @RequestMapping("/send_phone_sms")
  1001. public ResponseJson sendPhoneSms(HttpServletRequest request, String type, String phone, Integer typeCompany, ComplaintQuestionInfo complaintQuestionInfo) throws Exception {
  1002. String url = NameUtils.getConfig("website");
  1003. Integer flag = 1;
  1004. if (typeCompany == null || typeCompany == 0) {
  1005. return new ResponseJson(500, "未获取到产品类型!", 500);
  1006. }
  1007. String con = "";
  1008. if (type != null && !"".equals(type)) {
  1009. if ("p".equals(type)) { //problem" 问题处理; mailAddress:邮寄地址;
  1010. if (complaintQuestionInfo.getQuestionId() == null || "".equals(complaintQuestionInfo.getQuestionId())) {
  1011. complaintQuestionInfo.setQuestionState(1);
  1012. complaintQuestionInfo.setQuestionIsQcDetect(0);
  1013. complaintQuestionInfo = complaintQuestionInfoService.insertBackInfo(complaintQuestionInfo);
  1014. } else {
  1015. complaintQuestionInfo.setSmallClassId(null); //不能修改小类类型
  1016. flag = complaintQuestionInfoService.updateQuestionById(complaintQuestionInfo);
  1017. if (flag < 1) {
  1018. return new ResponseJson(500, "问题修改失败!", 500);
  1019. }
  1020. }
  1021. url += "/" + complaintQuestionInfo.getQuestionId() + "/" + typeCompany;
  1022. switch (typeCompany) {
  1023. case 1:
  1024. con = SmsConfig.SEND_PRODUCT_SEND_WATERO;
  1025. break;
  1026. case 2:
  1027. con = SmsConfig.SEND_PRODUCT_SEND_SHANGDUO;
  1028. break;
  1029. case 3:
  1030. con = SmsConfig.SEND_PRODUCT_SEND_YULIA;
  1031. break;
  1032. case 4:
  1033. con = SmsConfig.SEND_PRODUCT_SEND_AIBERLE;
  1034. break;
  1035. }
  1036. } else if ("m".equals(type)) {
  1037. if (complaintQuestionInfo.getQuestionId() == null) {
  1038. return new ResponseJson(500, "未获取到邮寄信息!", 500);
  1039. }
  1040. complaintQuestionInfo.setQuestionName(null);
  1041. complaintQuestionInfo.setSmallClassId(null);
  1042. url += "/5/0";
  1043. switch (typeCompany) {
  1044. case 1:
  1045. con = SmsConfig.SEND_PRODUCT_SMS_WATERO;
  1046. break;
  1047. case 2:
  1048. con = SmsConfig.SEND_PRODUCT_SMS_SHANGDUO;
  1049. break;
  1050. case 3:
  1051. con = SmsConfig.SEND_PRODUCT_SMS_YULIA;
  1052. break;
  1053. case 4:
  1054. con = SmsConfig.SEND_PRODUCT_SMS_AIBERLE;
  1055. break;
  1056. }
  1057. }
  1058. }
  1059. String userPhone = encodePhoneNumber(phone);
  1060. String text = MessageFormat.format(con, url);
  1061. logger.info("给 " + phone + " 手机用户发送短信:" + text);
  1062. String result = smsService.sendOtherCMS(phone, text);
  1063. if ("SUCCESS".equals(result)) {
  1064. return new ResponseJson(200, "发送短信成功!", 200);
  1065. } else {
  1066. return new ResponseJson(500, "发送短信失败,失败原因:" + result, 500);
  1067. }
  1068. }
  1069. String encodePhoneNumber(String number) {
  1070. int encnum = Integer.parseInt(number.substring(2));
  1071. int prefix = (number.charAt(1) - '2') / 2; // '3'=>0, '5'=>1, '[67]'=>2, '8'=>3
  1072. encnum |= (prefix <<= 30);
  1073. final byte[] raw = new byte[4];
  1074. raw[0] = (byte) (encnum >>> 24);
  1075. raw[1] = (byte) (encnum >>> 16);
  1076. raw[2] = (byte) (encnum >>> 8);
  1077. raw[3] = (byte) encnum;
  1078. return Base64.encodeBase64URLSafeString(raw);
  1079. }
  1080. /**
  1081. * 进入回访完成页面
  1082. *
  1083. * @param request
  1084. * @return
  1085. * @throws Exception
  1086. */
  1087. @RequiresPermissions("customer:update:visit")
  1088. @RequestMapping("/_update_visit_info")
  1089. public ModelAndView toUpdateVisitFinish(HttpServletRequest request) throws Exception {
  1090. ModelAndView mv = new ModelAndView("cm/customer/visit_finish");
  1091. String customerId = request.getParameter("customerId");
  1092. mv.addObject("customerId", customerId);
  1093. return mv;
  1094. }
  1095. /**
  1096. * 添加回访完成内容
  1097. *
  1098. * @param request
  1099. * @param visit
  1100. * @return
  1101. */
  1102. @ResponseBody
  1103. @RequiresPermissions("customer:update:visit")
  1104. @RequestMapping("/update_visit_finish")
  1105. public ResponseJson updateVisitFinish(HttpServletRequest request, Visit visit) throws Exception {
  1106. String customerId = request.getParameter("finish_customerId");
  1107. if (!StringUtils.isNotEmpty(customerId)) {
  1108. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1109. }
  1110. visit.setCustomerId(Integer.parseInt(customerId));
  1111. visit.setVisitStatus(2);
  1112. //修改回访信息内容
  1113. int num = visitService.updateVisit(visit);
  1114. if (num > 0) {
  1115. return new ResponseJson(200, "添加成功!", 200);
  1116. } else {
  1117. return new ResponseJson(500, "添加失败!", 500);
  1118. }
  1119. }
  1120. /**
  1121. * 进入回访信息详情
  1122. *
  1123. * @param request
  1124. * @return
  1125. * @throws Exception
  1126. */
  1127. @RequiresPermissions("customer:get:visit")
  1128. @RequestMapping("/_visit_info")
  1129. public ModelAndView toVisitInfo(HttpServletRequest request) throws Exception {
  1130. ModelAndView mv = new ModelAndView("cm/customer/visit_detail");
  1131. String customerId = request.getParameter("customerId");
  1132. // 1:未回访,2:已回访
  1133. String num = request.getParameter("num");
  1134. if (!StringUtils.isNotEmpty(num)) {
  1135. num = "2";
  1136. }
  1137. mv.addObject("customerId", customerId);
  1138. mv.addObject("num", num);
  1139. return mv;
  1140. }
  1141. /**
  1142. * 获取回访信息详情
  1143. *
  1144. * @param request
  1145. * @return
  1146. */
  1147. @ResponseBody
  1148. @RequiresPermissions("customer:get:visit")
  1149. @RequestMapping("/get_visit_info")
  1150. public ResponseJson getVisitInfo(HttpServletRequest request) throws Exception {
  1151. String customerId = request.getParameter("customerId");
  1152. if (!StringUtils.isNotEmpty(customerId)) {
  1153. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1154. }
  1155. Visit visit = new Visit();
  1156. visit.setCustomerId(Integer.parseInt(customerId));
  1157. //查询回访信息集合
  1158. List<Visit> visitList = visitService.listVisit(visit);
  1159. if (visitList == null || visitList.size() == 0) {
  1160. return new ResponseJson(500, "该客诉没有回访信息!", 500);
  1161. }
  1162. visit = visitList.get(0);
  1163. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1164. rj.addResponseKeyValue("visit", visit);
  1165. return rj;
  1166. }
  1167. /**
  1168. * 进入问题描述页面
  1169. *
  1170. * @param request
  1171. * @return
  1172. * @throws Exception
  1173. */
  1174. @RequiresPermissions("customer:get:describe")
  1175. @RequestMapping("/_question_describe")
  1176. public ModelAndView toQuestionDescribe(HttpServletRequest request) throws Exception {
  1177. ModelAndView mv = new ModelAndView("cm/customer/describe_detail");
  1178. String customerId = request.getParameter("customerId");
  1179. mv.addObject("customerId", customerId);
  1180. return mv;
  1181. }
  1182. /**
  1183. * 获取问题描述信息
  1184. *
  1185. * @param request
  1186. * @return
  1187. */
  1188. @ResponseBody
  1189. @RequiresPermissions("customer:get:describe")
  1190. @RequestMapping("/get_describe_info")
  1191. public ResponseJson getDescribeInfo(HttpServletRequest request) throws Exception {
  1192. String customerId = request.getParameter("customerId");
  1193. if (!StringUtils.isNotEmpty(customerId)) {
  1194. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1195. }
  1196. QuestionDescribe describe = new QuestionDescribe();
  1197. describe.setCustomerId(Integer.parseInt(customerId));
  1198. //查询问题集合
  1199. List<QuestionDescribe> questionList = questionDescribeService.listQuestionDescribe(describe);
  1200. if (questionList == null || questionList.size() == 0) {
  1201. return new ResponseJson(500, "该客诉信息没有问题描述!", 500);
  1202. }
  1203. describe = questionList.get(0);
  1204. CustomerInfo customerInfo = customerService.getCustomerInfo(Integer.parseInt(customerId));
  1205. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1206. rj.addResponseKeyValue("describe", describe);
  1207. rj.addResponseKeyValue("customerInfo", customerInfo);
  1208. return rj;
  1209. }
  1210. /**
  1211. * 进入修改售后处理信息页面
  1212. *
  1213. * @param request
  1214. * @return
  1215. * @throws Exception
  1216. */
  1217. @RequiresPermissions("customer:update:renewed")
  1218. @RequestMapping("/_update_relation")
  1219. public ModelAndView toUpdateRenewed(HttpServletRequest request) throws Exception {
  1220. ModelAndView mv = new ModelAndView("cm/customer/update_relation");
  1221. String customerId = request.getParameter("customerId");
  1222. String type = request.getParameter("type");
  1223. if(type != null && !type.equals("")){
  1224. mv.addObject("type",type);
  1225. }else{
  1226. mv.addObject("type",0);
  1227. }
  1228. CmRelation cmRelation = new CmRelation();
  1229. cmRelation.setCustomerId(Integer.valueOf(customerId));
  1230. cmRelation = customerService.getCmRelationInfo(cmRelation);
  1231. ProcMethod procMethod = customerService.getProcMethod(cmRelation.getProcMethodId());
  1232. List<LogisticsInfo>logisticsInfoList = logisticsInfoService.getLogisticsInfoList(new LogisticsInfo());
  1233. List<PostageInfo> listPostageInfo = customerService.listPostageInfo(cmRelation.getRelationId());
  1234. List<SendbackInfo> listSendbackInfo = customerService.listSendbackInfo(cmRelation.getRelationId());
  1235. List<InformationInfo> listInformationInfo = customerService.listInformationInfo(cmRelation.getRelationId());
  1236. ComplaintDetectInfo detectInfo = new ComplaintDetectInfo();
  1237. detectInfo.setCustomerId(Integer.valueOf(customerId));
  1238. List<ComplaintDetectInfo> detectList = complaintDetectInfoService.listComplaintDetect(detectInfo);
  1239. ComplaintSignclosedInfo complaintSignclosedInfo = new ComplaintSignclosedInfo();
  1240. complaintSignclosedInfo.setSignclosedCustomerId(Integer.valueOf(customerId));
  1241. List<ComplaintSignclosedInfo> signclosedList = complaintSignclosedInfoService.listSignclosed(complaintSignclosedInfo);
  1242. //查询寄回产品
  1243. ClosedProdcue record = new ClosedProdcue();
  1244. record.setRelationId(cmRelation.getRelationId());
  1245. List <ClosedProdcue> listClosedProdcue = customerService.listclosedProdcue(record);
  1246. //查询售前客服
  1247. Admin admin = new Admin();
  1248. admin.setAdminDept(22);//售前部id
  1249. List<Admin> adminlist = sysService.listSelectAdmin(admin);
  1250. mv.addObject("listInformationInfo",listInformationInfo);
  1251. mv.addObject("listClosedProdcue",listClosedProdcue);
  1252. mv.addObject("listSendbackInfo",listSendbackInfo);
  1253. mv.addObject("logisticsInfoList",logisticsInfoList);
  1254. mv.addObject("listPostageInfo", listPostageInfo);
  1255. mv.addObject("procMethod", procMethod);
  1256. mv.addObject("customerId", customerId);
  1257. mv.addObject("detectList", detectList);
  1258. mv.addObject("signclosedList", signclosedList);
  1259. mv.addObject("adminlist", adminlist);
  1260. return mv;
  1261. }
  1262. /**
  1263. * 获取售后详情
  1264. *
  1265. * @param request
  1266. * @return
  1267. */
  1268. @ResponseBody
  1269. @RequiresPermissions("customer:get:renewed")
  1270. @RequestMapping("/get_cmRelation_info")
  1271. public ResponseJson getRenewedInfo(HttpServletRequest request) throws Exception {
  1272. String customerId = request.getParameter("customerId");
  1273. if (!StringUtils.isNotEmpty(customerId)) {
  1274. return new ResponseJson(500, "该客诉信息不存在!", 500);
  1275. }
  1276. CmRelation cmRelation = new CmRelation();
  1277. cmRelation.setCustomerId(Integer.parseInt(customerId));
  1278. //获取换新详情和检测信息
  1279. cmRelation = customerService.getCmRelationInfo(cmRelation);
  1280. if (cmRelation == null) {
  1281. return new ResponseJson(500, "该客诉没有售后信息!", 500);
  1282. } else {
  1283. //查询寄出状态
  1284. SalesOrder salesOrder = new SalesOrder();
  1285. salesOrder.setSalesCustomerId(Integer.valueOf(customerId));
  1286. List<SalesOrder> salesOrderList = salesOrderService.salesOrderListAndItem(salesOrder);
  1287. if(salesOrderList.size() > 0){
  1288. cmRelation.setRelationSendStatus(salesOrderList.get(0).getSalesStatus());
  1289. }else{
  1290. cmRelation.setRelationSendStatus(0);
  1291. }
  1292. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1293. rj.addResponseKeyValue("cmRelation", cmRelation);
  1294. return rj;
  1295. }
  1296. }
  1297. /**
  1298. * 修改处理信息
  1299. *
  1300. * @param request
  1301. * @param cmRelation
  1302. * @return
  1303. * @throws Exception
  1304. */
  1305. @ResponseBody
  1306. @RequiresPermissions("customer:update:renewed")
  1307. @RequestMapping("/update_cmRelation_info")
  1308. public ResponseJson updateRenewedInfo(HttpServletRequest request, CmRelation cmRelation) throws Exception {
  1309. String mergeAddress = request.getParameter("merge_address");
  1310. if (!StringUtils.isNotEmpty(cmRelation.getRelationId().toString())) {
  1311. return new ResponseJson(500, "该售后信息不能修改!", 500);
  1312. }
  1313. if (StringUtils.isNotEmpty(mergeAddress)) {
  1314. cmRelation.setRelationSendMergeAddress(mergeAddress);
  1315. }
  1316. if (cmRelation.getRelationBackStatus() != null) {
  1317. if (cmRelation.getRelationBackStatus() != 1) {
  1318. ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
  1319. cs.setSignclosedCustomerId(cmRelation.getCustomerId());
  1320. cs.setSignclosedLogistics(cmRelation.getRelationBackLogisticsCompany());
  1321. cs.setSignclosedLogisticsNumber(cmRelation.getRelationBackLogisticsNo());
  1322. complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
  1323. }
  1324. }
  1325. //修改售后信息
  1326. int num = customerService.updateCmRelation(cmRelation);
  1327. if (num > 0) {
  1328. return new ResponseJson(200, "修改成功!", 200);
  1329. } else {
  1330. return new ResponseJson(500, "修改失败!", 500);
  1331. }
  1332. }
  1333. /**
  1334. * 查询未解决客诉数量
  1335. */
  1336. @ResponseBody
  1337. @RequestMapping(value = "/selectNumberBacklog")
  1338. public ResultMsg selectTodo(HttpServletRequest request) {
  1339. ResultMsg msg = new ResultMsg();
  1340. CustomerInfo customerInfo = new CustomerInfo();
  1341. //获取登录员工id
  1342. Admin admin = AdminUtils.getLoginAdmin();
  1343. // customerInfo.setAdminId(admin.getAdminId());
  1344. // customerInfo.setCustomerIsSolve(2);
  1345. //未解决客诉数量
  1346. // Integer notSolvedCustomer = customerService.selectNotSolvedCustomer(customerInfo);
  1347. //需要向工厂确认所有已签收的产品数量
  1348. // CustomerCommon customerCommon = new CustomerCommon();
  1349. // customerCommon.setAdminId(admin.getAdminId());
  1350. // customerCommon.setRelationBackStatus(4);
  1351. // Integer amountReceivedCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1352. //需要填写Efast订单号的客诉数量
  1353. // customerCommon.setRelationBackStatus(3);
  1354. // Integer noEntryCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1355. //客诉录入后,三天后未寄回的客诉数量
  1356. // customerCommon.setRelationBackStatus(1);
  1357. // customerCommon.setRelationCreateTime(new Date());
  1358. // Integer notSendCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
  1359. SalesOrder salesOrder = new SalesOrder();
  1360. salesOrder.setSalesStatus(0); //未确认
  1361. Integer toBeConfirmedOrder = salesOrderService.listSalesOrderNum(salesOrder);
  1362. salesOrder = new SalesOrder();
  1363. salesOrder.setSalesShippingStatus(0); //未发货
  1364. Integer toBeAnnounced = salesOrderService.listSalesOrderNum(salesOrder);
  1365. salesOrder.setSalesShippingStatus(11); //已通知配货
  1366. Integer toBeDelivered = salesOrderService.listSalesOrderNum(salesOrder);
  1367. Calendar calendar = Calendar.getInstance();
  1368. calendar.set(Calendar.HOUR_OF_DAY,00);
  1369. calendar.set(Calendar.MINUTE,00);
  1370. calendar.set(Calendar.SECOND,01);
  1371. salesOrder = new SalesOrder();
  1372. salesOrder.setStartDate(calendar.getTime()); //startDate
  1373. Calendar ca = Calendar.getInstance();
  1374. ca.set(Calendar.HOUR_OF_DAY,23);
  1375. ca.set(Calendar.MINUTE,59);
  1376. ca.set(Calendar.SECOND,59);
  1377. salesOrder.setEndDate(ca.getTime());
  1378. Integer allToDayOrder = salesOrderService.listSalesOrderNum(salesOrder);
  1379. Map<String, Object> numberMap = new HashMap<>();
  1380. numberMap.put("toBeConfirmedOrder", toBeConfirmedOrder);
  1381. numberMap.put("toBeAnnounced", toBeAnnounced);
  1382. numberMap.put("toBeDelivered", toBeDelivered);
  1383. numberMap.put("allToDayOrder", allToDayOrder);
  1384. // numberMap.put("notSolvedCustomer", notSolvedCustomer);
  1385. // numberMap.put("amountReceivedCustomer", amountReceivedCustomer);
  1386. // numberMap.put("noEntryCustomer", noEntryCustomer);
  1387. // numberMap.put("notSendCustomer", notSendCustomer);
  1388. numberMap.put("adminDept", admin.getAdminDept());
  1389. SalesOrder salesOrderNum = salesOrderService.getStatusNum();
  1390. numberMap.put("salesOrderNum", salesOrderNum);
  1391. msg.setResultCode(ResultInfo.SUCCESSCODE);
  1392. msg.setStatus(true);
  1393. msg.setData(numberMap);
  1394. return msg;
  1395. }
  1396. // /**
  1397. // * 根据微信昵称/姓名/电话查询客诉
  1398. // *
  1399. // * @param request
  1400. // * @return
  1401. // */
  1402. // @ResponseBody
  1403. // @RequiresPermissions("customer:list:customer")
  1404. // @RequestMapping("/get_custoner_info")
  1405. // public ResponseJson getCustonerInfo(HttpServletRequest request, CustomerCommon customerCommon) throws Exception {
  1406. // if (customerCommon == null) {
  1407. // return new ResponseJson(500, "参数错误!", 500);
  1408. // }
  1409. // List<CustomerCommon> customerCommonList = customerCommonService.listCustomerCommon(customerCommon);
  1410. // if (customerCommonList.size() < 1) {
  1411. // return new ResponseJson(500, "不存在相关客诉信息!", 500);
  1412. // } else {
  1413. // ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1414. // rj.addResponseKeyValue("customer", customerCommonList.get(0));
  1415. // return rj;
  1416. // }
  1417. // }
  1418. /**
  1419. * 申请邮费
  1420. *
  1421. * @return
  1422. */
  1423. @ResponseBody
  1424. @RequiresPermissions("customer:applyPostage:customer")
  1425. @RequestMapping(value = "/apply_postage")
  1426. public ResponseJson applyPostage(HttpServletRequest request, Integer customerId) throws Exception {
  1427. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  1428. if (customerInfo == null) {
  1429. return new ResponseJson(500, "未获取到客诉", 500);
  1430. }
  1431. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerId);
  1432. if (cmRelation.getRelationBackStatus() == 1) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1433. return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
  1434. }
  1435. if (cmRelation.getRelationBackStatus() == 2) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1436. return new ResponseJson(500, "产品正在寄回中!", 500);
  1437. }
  1438. if (cmRelation.getRelationIsTransfer() == 0) { //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
  1439. return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
  1440. }
  1441. if (cmRelation.getRelationBackPostage() == null || cmRelation.getRelationBackPostage() == 0 //relationBackPostage
  1442. || cmRelation.getRelationAlipay() == null || cmRelation.getRelationAlipayName() == null) {
  1443. return new ResponseJson(500, "请填写邮费信息", 500);
  1444. }
  1445. if (customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0) {
  1446. return new ResponseJson(500, "未正确选择销售公司", 500);
  1447. }
  1448. Postage age = new Postage();
  1449. age.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1450. List<Postage> postageList = postageService.listPostage(age);
  1451. if (postageList != null && postageList.size() > 0) {
  1452. return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
  1453. }
  1454. ResponseJson rj = new ResponseJson(200, "可以申请邮费", 200);
  1455. rj.addResponseKeyValue("customerCommon", cmRelation);
  1456. rj.addResponseKeyValue("customerInfo", customerInfo);
  1457. return rj;
  1458. }
  1459. /**
  1460. * 申请邮费
  1461. *
  1462. * @return
  1463. */
  1464. @ResponseBody
  1465. @RequiresPermissions("customer:applyPostage:customer")
  1466. @RequestMapping(value = "/add_postage")
  1467. public ResponseJson addPostage(HttpServletRequest request, Integer customerId, String postageLogisticsImg) throws Exception {
  1468. CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
  1469. if (customerInfo == null) {
  1470. return new ResponseJson(500, "未获取到客诉", 500);
  1471. }
  1472. CmRelation cmRelation = cmRelationService.getCmRelationByCustomerId(customerId);
  1473. if (cmRelation.getRelationBackStatus() == 1) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1474. return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
  1475. }
  1476. if (cmRelation.getRelationBackStatus() == 2) { //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
  1477. return new ResponseJson(500, "产品正在寄回中!", 500);
  1478. }
  1479. if (cmRelation.getRelationIsTransfer() == 0) { //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
  1480. return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
  1481. }
  1482. if (cmRelation.getRelationBackPostage() == null || cmRelation.getRelationBackPostage() == 0 //relationBackPostage
  1483. || cmRelation.getRelationAlipay() == null || cmRelation.getRelationAlipayName() == null) {
  1484. return new ResponseJson(500, "请填写邮费信息", 500);
  1485. }
  1486. if (customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0) {
  1487. return new ResponseJson(500, "未正确选择销售公司", 500);
  1488. }
  1489. Postage age = new Postage();
  1490. age.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1491. List<Postage> postageList = postageService.listPostage(age);
  1492. if (postageList != null && postageList.size() > 0) {
  1493. return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
  1494. }
  1495. /*String orderId = "";
  1496. for (SalesOrder salesOrder : cmRelation.getSalesOrderList()) {
  1497. if ("".equals(orderId)) {
  1498. orderId = salesOrder.getSalesOrderId();
  1499. } else {
  1500. orderId += "," + salesOrder.getSalesOrderId();
  1501. }
  1502. }*/
  1503. Integer flag = 0;
  1504. Postage postage = new Postage();
  1505. postage.setCompanyId(customerInfo.getCompanyId()); //销售公司
  1506. postage.setAdminId(customerInfo.getAdminId()); //客服
  1507. postage.setCustomerId(customerInfo.getCustomerId()); //客诉id
  1508. postage.setPostageCustomerStatus(2); //------考虑手动点, 直接变为申请中
  1509. postage.setPostageManagerStatus(1); //------考虑手动点, 直接变为申请中
  1510. postage.setPostageOrderSource(customerInfo.getStoreId()); //店铺id
  1511. // postage.setPostageTreatmentMethod(cmRelation.getProcMethodId()); //处理方式
  1512. // postage.setSalesOrderId(orderId); //efast订单号
  1513. postage.setPostageClientName(cmRelation.getRelationBackName());
  1514. postage.setPostageClientTel(cmRelation.getRelationBackTel());
  1515. postage.setPostageClientAddress(cmRelation.getRelationSendAddress());
  1516. postage.setPostageLogisticsCompany(cmRelation.getRelationBackLogisticsCompany());
  1517. postage.setPostageLogisticsNo(cmRelation.getRelationBackLogisticsNo());
  1518. postage.setPostageAmount(cmRelation.getRelationBackPostage()); //寄回邮费
  1519. postage.setPostageAlipay(cmRelation.getRelationAlipay()); //支付宝账户
  1520. postage.setPostageAlipayName(cmRelation.getRelationAlipayName()); //支付宝账号名称
  1521. postage.setPostageLogisticsImg(postageLogisticsImg);
  1522. flag = postageService.savePostage(postage);
  1523. if (flag < 1) {
  1524. return new ResponseJson(500, "申请失败", 500);
  1525. }
  1526. ResponseJson rj = new ResponseJson(200, "申请成功,请前往邮费转账列表查看", 200);
  1527. return rj;
  1528. }
  1529. /**
  1530. * 根据客诉id查询产品类型
  1531. *
  1532. * @param request
  1533. * @return
  1534. * @throws Exception
  1535. */
  1536. @ResponseBody
  1537. @RequestMapping("/getProductType")
  1538. public ResponseJson getProductType(HttpServletRequest request) throws Exception {
  1539. String customerId = request.getParameter("customerId");
  1540. if (!StringUtils.isNotEmpty(customerId)) {
  1541. return new ResponseJson(500, "查询产品类型失败!", 500);
  1542. }
  1543. //查询客诉产品类型
  1544. ProductType productType = productService.getProductType(Integer.valueOf(customerId));
  1545. if (productType == null) {
  1546. return new ResponseJson(500, "未找到产品类型!", 500);
  1547. } else {
  1548. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1549. rj.addResponseKeyValue("productType", productType);
  1550. return rj;
  1551. }
  1552. }
  1553. /**
  1554. * 根据客户信息查询旧的客诉信息
  1555. *
  1556. * @param request
  1557. * @return
  1558. * @throws Exception
  1559. */
  1560. @ResponseBody
  1561. @RequestMapping("/selectOnCustomer")
  1562. public ResponseJson listOnCustomer(HttpServletRequest request, CustomerInfo customerInfo) throws Exception {
  1563. if (customerInfo == null) {
  1564. return new ResponseJson(500, "查询客诉失败!", 500);
  1565. }
  1566. List<CustomerInfo> onCustomerList = customerService.listOnCustomer(customerInfo);
  1567. if (onCustomerList.size() == 0) {
  1568. return new ResponseJson(500, "未找到客诉!", 500);
  1569. } else {
  1570. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1571. rj.addResponseKeyValue("onCustomerList", onCustomerList);
  1572. return rj;
  1573. }
  1574. }
  1575. /**
  1576. * 根据efast订单号查询efast订单物流信息
  1577. *
  1578. * @param request
  1579. * @return
  1580. * @throws Exception
  1581. */
  1582. @ResponseBody
  1583. @RequestMapping("/getefastOrder")
  1584. public ResponseJson getEfastOrderInfo(HttpServletRequest request, String efastOrderId) throws Exception {
  1585. if (efastOrderId == null) {
  1586. return new ResponseJson(500, "查询失败!", 500);
  1587. }
  1588. JSONObject orderInfo = efastOrderService.getOrderFormEfastByOrderId(efastOrderId);
  1589. if (orderInfo == null) {
  1590. return new ResponseJson(500, "查询失败!", 500);
  1591. } else if (!orderInfo.has("orders")) {
  1592. return new ResponseJson(500, "查询失败!", 500);
  1593. } else {
  1594. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1595. rj.addResponseKeyValue("orderInfo", orderInfo.toString());
  1596. return rj;
  1597. }
  1598. }
  1599. /**
  1600. * 进入下载客诉页面
  1601. *
  1602. * @param request
  1603. * @param res
  1604. * @param
  1605. * @throws Exception
  1606. */
  1607. @ResponseBody
  1608. @RequestMapping("/to_download_customer_excel")
  1609. public ModelAndView toDownloadCustomerExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
  1610. ModelAndView mv = new ModelAndView("cm/customer/download_customer");
  1611. Admin admin = AdminUtils.getLoginAdmin();
  1612. //获取销售公司
  1613. List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
  1614. //查询店铺
  1615. StoreInfo storeInfo = new StoreInfo();
  1616. storeInfo.setCompanyId(companyInfoList.get(0).getCompanyId());
  1617. List<StoreInfo> storeList = storeInfoService.listStore(storeInfo);
  1618. //查询处理类型
  1619. List<ProcType> procTypeList = customerService.listProcType();
  1620. //查询登录人下载客诉记录
  1621. DownloadProgressInfo downloadProgressInfo = new DownloadProgressInfo();
  1622. downloadProgressInfo.setDownloadAdminId(admin.getAdminId());
  1623. List<DownloadProgressInfo> listDownloadProgressInfo = customerService.listDownloadProgressInfo(downloadProgressInfo);
  1624. mv.addObject("listDownloadProgressInfo",listDownloadProgressInfo);
  1625. mv.addObject("companyInfoList",companyInfoList);
  1626. mv.addObject("storeList",storeList);
  1627. mv.addObject("procTypeList",procTypeList);
  1628. return mv;
  1629. }
  1630. /**
  1631. * 查询下载客诉信息 (2018-05-29)
  1632. *
  1633. * @param request
  1634. * @param res
  1635. * @param
  1636. * @throws Exception
  1637. */
  1638. @ResponseBody
  1639. @RequestMapping("/list_download_customer_excel")
  1640. public ResponseJson listdownloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res) throws Exception {
  1641. Admin admin = AdminUtils.getLoginAdmin();
  1642. //查询登录人下载客诉记录
  1643. DownloadProgressInfo downloadProgressInfo = new DownloadProgressInfo();
  1644. /*downloadProgressInfo.setDownloadStatus(1);*/
  1645. downloadProgressInfo.setDownloadAdminId(admin.getAdminId());
  1646. List<DownloadProgressInfo> listDownloadProgressInfo = customerService.listDownloadProgressInfo(downloadProgressInfo);
  1647. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  1648. rj.addResponseKeyValue("listDownloadProgressInfo", listDownloadProgressInfo);
  1649. return rj;
  1650. }
  1651. /**
  1652. * 下载客诉信息 (2018-05-29)
  1653. *
  1654. * @param request
  1655. * @param res
  1656. * @param
  1657. * @throws Exception
  1658. */
  1659. @ResponseBody
  1660. @RequestMapping("/download_customer_excel")
  1661. public ResponseJson downloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
  1662. String path = request.getSession().getServletContext().getRealPath("/");
  1663. new Thread(new Mythread(path,customerInfo)).start();
  1664. return new ResponseJson(200, "查询成功", 200);
  1665. }
  1666. class Mythread extends Thread{
  1667. private String path;
  1668. private CustomerInfo customerInfo;
  1669. public Mythread(String path,CustomerInfo customerInfo) {
  1670. this.path=path;
  1671. this.customerInfo=customerInfo;
  1672. }
  1673. @Override
  1674. public void run(){
  1675. Admin admin = AdminUtils.getLoginAdmin();
  1676. //添加一条下载记录
  1677. DownloadProgressInfo downloadProgressInfo = new DownloadProgressInfo();
  1678. downloadProgressInfo.setDownloadAdminId(admin.getAdminId());
  1679. downloadProgressInfo.setDownloadProgress("00.00");
  1680. downloadProgressInfo.setDownloadStatus(1);
  1681. customerService.addDownloadProgressInfo(downloadProgressInfo);
  1682. //循环一次的时间(毫秒)
  1683. long cycleOne = 0;
  1684. long cycleOnes = 0;
  1685. int s = 0;
  1686. List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer(customerInfo);
  1687. String[] cells = {
  1688. "日期", "姓名", "联系电话", "类别", "来源入口",
  1689. "问题类别", "小类名称", "客诉问题", "处理过程", "购买日期",
  1690. "处理方式","处理结果", "销售公司", "销售渠道", "产品型号", "产品颜色","产品类型",
  1691. "产品数量", "寄回快递", "寄回单号", "签收日期",
  1692. "状态", "寄出快递", "寄出单号", "开箱损", "二次客诉", "跟进客服", "工厂报价", "客户报价", "邮费信息"
  1693. };
  1694. List<CustomerStatisticalInfo> customerStatisticalInfoList = new ArrayList<>();
  1695. SimpleDateFormat sdf4=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1696. for (CustomerStatisticalInfo customerInfo : customerList) {
  1697. long startTime=System.currentTimeMillis(); //获取开始时间
  1698. s++;
  1699. //新建一个容器
  1700. CustomerStatisticalInfo customer = new CustomerStatisticalInfo();
  1701. //将数据copy到新容器
  1702. BeanUtils.copyProperties(customerInfo, customer);
  1703. CustomerCommon customerCommon = new CustomerCommon();
  1704. customerCommon.setCustomerId(customerInfo.getCustomerId());
  1705. customerCommon.setRelationId(customerInfo.getRelationId());
  1706. List<CustomerCommon> listCustomerCommon = customerService.listCustomerCommons(customerCommon);
  1707. if(listCustomerCommon.size() > 0) {
  1708. for (CustomerCommon common : listCustomerCommon) {
  1709. if (common.getSalesOrderList().size() > 0) {
  1710. for (SalesOrder salesOrder : common.getSalesOrderList()) {
  1711. if (salesOrder.getSalesOrderItemList().size() > 0) {
  1712. for (SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()) {
  1713. if(common.getSignclosedInfos().size() > 0){
  1714. for(ComplaintSignclosedInfo signclosedInfo : common.getSignclosedInfos()){
  1715. for (SignclosedProductInfo signclosedProductInfo : signclosedInfo.getSignclosedProductInfoList()) {
  1716. //将数据copy到新容器
  1717. CustomerStatisticalInfo customers = new CustomerStatisticalInfo();
  1718. BeanUtils.copyProperties(customer, customers);
  1719. customers.setRelationBackLogisticsCompany(signclosedInfo.getSignclosedLogistics());
  1720. customers.setRelationBackLogisticsNo(signclosedInfo.getSignclosedLogisticsNumber());
  1721. customers.setRelationBackStatus(String.valueOf(signclosedInfo.getSignclosedIsReceiving()));
  1722. if(signclosedInfo.getSignclosedDate() == null){
  1723. customers.setRelationBackReceiptDate(null);
  1724. }else{
  1725. customers.setRelationBackReceiptDate(sdf4.format(signclosedInfo.getSignclosedDate()));
  1726. }
  1727. customers.setSignclosedProductInfo(signclosedProductInfo.getProductName()+"("+signclosedProductInfo.getColorName()+")"+"*"+signclosedProductInfo.getProductNum());
  1728. customers.setItemProductColor(signclosedProductInfo.getColorName());
  1729. customers.setRelationSendLogisticsCompany(salesOrder.getSalesPostNum());
  1730. customers.setRelationSendLogisticsNo(salesOrder.getSalesPostFirm());
  1731. customers.setSalesPayTime(salesOrder.getSalesPayTime());
  1732. customers.setItemProductName(salesOrderItem.getItemProductName());
  1733. customers.setItemNum(String.valueOf(salesOrderItem.getItemNum()));
  1734. if(salesOrderItem.getTypeName() != null || !salesOrderItem.getTypeName().equals("")){
  1735. customers.setTypeName(String.valueOf(salesOrderItem.getTypeName()));
  1736. }
  1737. customers.setRelationFactoryCosts(customerInfo.getRelationFactoryCosts());
  1738. customers.setRelationCustomerCosts(customerInfo.getRelationCustomerCosts());
  1739. customers.setSignclosedProductInfos(common.getSignclosedProductInfos());
  1740. String postageString = "";
  1741. //查询邮费信息
  1742. List<PostageInfo> listPostageInfo = customerService.listPostageInfo(customers.getRelationId());
  1743. if(listPostageInfo.size() > 0){
  1744. for(PostageInfo postageInfo : listPostageInfo){
  1745. String state = "";
  1746. if(postageInfo.getPostageStatus() == 1){
  1747. state = "未申请";
  1748. }
  1749. if(postageInfo.getPostageStatus() == 2){
  1750. state = "已申请(待转账)";
  1751. }
  1752. if(postageInfo.getPostageStatus() == 3){
  1753. state = "已转账";
  1754. }
  1755. postageString = postageString+"状态:"+state+" ,金额:"+postageInfo.getPostageAmount()/100+" ,支付宝账号:"+postageInfo.getPostageAlipay()+";";
  1756. }
  1757. }
  1758. customers.setPostageString(postageString);
  1759. customerStatisticalInfoList.add(customers);
  1760. }
  1761. }
  1762. }
  1763. }
  1764. } else {
  1765. customerStatisticalInfoList.add(customer);
  1766. }
  1767. }
  1768. } else {
  1769. customerStatisticalInfoList.add(customer);
  1770. }
  1771. }
  1772. }else{
  1773. customerStatisticalInfoList.add(customer);
  1774. }
  1775. long endTime=System.currentTimeMillis(); //获取结束时间
  1776. NumberFormat numberFormat = NumberFormat.getInstance();
  1777. float percentage = (float) s / (float) customerList.size() * 100;
  1778. String result = numberFormat.format(percentage);
  1779. if(s == 1){
  1780. cycleOne = endTime - startTime;
  1781. SimpleDateFormat sdf3=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1782. cycleOnes = cycleOne * customerList.size();
  1783. //修改预计下载完成时间
  1784. downloadProgressInfo.setDownloadDate(sdf3.format(new Date().getTime()+cycleOnes));
  1785. downloadProgressInfo.setDownloadProgress(result);
  1786. customerService.updateDownloadProgressInfo(downloadProgressInfo);
  1787. }else{
  1788. numberFormat.setMaximumFractionDigits(2);
  1789. downloadProgressInfo.setDownloadProgress(result);
  1790. customerService.updateDownloadProgressInfo(downloadProgressInfo);
  1791. }
  1792. }
  1793. //导出订单Excel并下载
  1794. try {
  1795. customerExcel(cells,customerStatisticalInfoList,downloadProgressInfo,path);
  1796. } catch (Exception e) {
  1797. e.printStackTrace();
  1798. }
  1799. }
  1800. }
  1801. /**
  1802. * 导出订单Excel并下载
  1803. * @param cells
  1804. * @throws Exception
  1805. */
  1806. public void customerExcel(String[] cells,List<CustomerStatisticalInfo> customerList,
  1807. DownloadProgressInfo downloadProgressInfo,String path) throws Exception {
  1808. //创建一个workbook,对应一个Excel文件
  1809. HSSFWorkbook wb = new HSSFWorkbook();
  1810. //在workbook中添加一个sheet,对应Excel中的一个sheet
  1811. HSSFSheet sheet = wb.createSheet("导出订单");
  1812. //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
  1813. HSSFRow row = sheet.createRow((int) 0);
  1814. //创建单元格,设置值表头,设置表头居中
  1815. HSSFCellStyle style = wb.createCellStyle();
  1816. //居中格式
  1817. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  1818. //设置表头
  1819. if (cells == null || cells.length == 0) {
  1820. return;
  1821. }
  1822. //循环设置表头
  1823. HSSFCell cell = null;
  1824. for (int i = 0;i < cells.length;i++) {
  1825. String name = cells[i];
  1826. cell = row.createCell(i);
  1827. cell.setCellValue(name);
  1828. cell.setCellStyle(style);
  1829. }
  1830. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1831. for (int i = 0; i < customerList.size(); i++) {
  1832. row = sheet.createRow((int) i + 1);
  1833. CustomerStatisticalInfo customerStatisticalInfo = customerList.get(i);
  1834. String createTime = "";
  1835. if(customerStatisticalInfo.getCreateTime() != null){
  1836. createTime = format.format(customerStatisticalInfo.getCreateTime());
  1837. }
  1838. String salesPayTime = "";
  1839. if(customerStatisticalInfo.getSalesPayTime() != null ){
  1840. salesPayTime = format.format(customerStatisticalInfo.getSalesPayTime());
  1841. }
  1842. String backLogisticsCompany = "";
  1843. if(customerStatisticalInfo.getRelationBackLogisticsCompany() != null){
  1844. backLogisticsCompany = KuaiDi100.replace(customerStatisticalInfo.getRelationBackLogisticsCompany());
  1845. }
  1846. String backStatus = "未知";
  1847. if(customerStatisticalInfo.getRelationBackStatus() != null){
  1848. if(customerStatisticalInfo.getRelationBackStatus().equals("1")){
  1849. backStatus = "未寄回";
  1850. }
  1851. if(customerStatisticalInfo.getRelationBackStatus().equals("2")){
  1852. backStatus = "已寄回";
  1853. }
  1854. if(customerStatisticalInfo.getRelationBackStatus().equals("3")){
  1855. backStatus = "已收货";
  1856. }
  1857. }
  1858. String sendLogisticsCompany = "";
  1859. if(customerStatisticalInfo.getRelationSendLogisticsCompany() != null){
  1860. sendLogisticsCompany = KuaiDi100.replace(customerStatisticalInfo.getRelationSendLogisticsCompany());
  1861. }
  1862. // 创建单元格,设置值
  1863. row.createCell(0).setCellValue(createTime);
  1864. row.createCell(1).setCellValue(customerStatisticalInfo.getCustomerName() == null ? null : customerStatisticalInfo.getCustomerName());
  1865. row.createCell(2).setCellValue(customerStatisticalInfo.getCustomerTel() == null ? null : customerStatisticalInfo.getCustomerTel());
  1866. row.createCell(3).setCellValue(customerStatisticalInfo.getCounselType() == null ? null : customerStatisticalInfo.getCounselType());
  1867. row.createCell(4).setCellValue(customerStatisticalInfo.getSourceType() == null ? null : customerStatisticalInfo.getSourceType());
  1868. row.createCell(5).setCellValue(customerStatisticalInfo.getComplaintClassName() == null ? null : customerStatisticalInfo.getComplaintClassName());
  1869. row.createCell(6).setCellValue(customerStatisticalInfo.getSmallClassName() == null ? null : customerStatisticalInfo.getSmallClassName());
  1870. row.createCell(7).setCellValue(customerStatisticalInfo.getDescribeTitle() == null ? null : customerStatisticalInfo.getDescribeTitle());
  1871. row.createCell(8).setCellValue(customerStatisticalInfo.getDescribeHandleDesc() == null ? null : customerStatisticalInfo.getDescribeHandleDesc());
  1872. row.createCell(9).setCellValue(salesPayTime);
  1873. row.createCell(10).setCellValue(customerStatisticalInfo.getProcMethodName() == null ? null : customerStatisticalInfo.getProcMethodName());
  1874. row.createCell(11).setCellValue(customerStatisticalInfo.getCustomerIsSolve() == null ? null : customerStatisticalInfo.getCustomerIsSolve());
  1875. row.createCell(12).setCellValue(customerStatisticalInfo.getCompanyName() == null ? null : customerStatisticalInfo.getCompanyName());
  1876. row.createCell(13).setCellValue(customerStatisticalInfo.getStoreName() == null ? null : customerStatisticalInfo.getStoreName());
  1877. /*StringBuffer sb = new StringBuffer("");
  1878. if(customerStatisticalInfo.getSignclosedProductInfos().size() > 0){
  1879. for(SignclosedProductInfo sign : customerStatisticalInfo.getSignclosedProductInfos()){
  1880. sb.append(sign.getProductName()+"("+sign.getColorName()+")"+"*"+sign.getProductNum()+";");
  1881. }
  1882. }*/
  1883. if(customerStatisticalInfo.getSignclosedProductInfo() == null){
  1884. row.createCell(14).setCellValue("");
  1885. }else{
  1886. row.createCell(14).setCellValue(customerStatisticalInfo.getSignclosedProductInfo().toString());
  1887. }
  1888. row.createCell(15).setCellValue(customerStatisticalInfo.getItemProductColor() == null ? null : customerStatisticalInfo.getItemProductColor());
  1889. row.createCell(16).setCellValue(customerStatisticalInfo.getTypeName() == null ? null : customerStatisticalInfo.getTypeName());
  1890. row.createCell(17).setCellValue(customerStatisticalInfo.getItemNum() == null ? null : customerStatisticalInfo.getItemNum());
  1891. row.createCell(18).setCellValue(backLogisticsCompany);
  1892. row.createCell(19).setCellValue(customerStatisticalInfo.getRelationBackLogisticsNo() == null ? null : customerStatisticalInfo.getRelationBackLogisticsNo());
  1893. row.createCell(20).setCellValue(customerStatisticalInfo.getRelationBackReceiptDate() == null ? null : customerStatisticalInfo.getRelationBackReceiptDate());
  1894. row.createCell(21).setCellValue(backStatus);
  1895. row.createCell(22).setCellValue(sendLogisticsCompany);
  1896. row.createCell(23).setCellValue(customerStatisticalInfo.getRelationSendLogisticsNo() == null ? null : customerStatisticalInfo.getRelationSendLogisticsNo());
  1897. row.createCell(24).setCellValue(customerStatisticalInfo.getCustomerOutDamaged() == null ? null : customerStatisticalInfo.getCustomerOutDamaged());
  1898. row.createCell(25).setCellValue(customerStatisticalInfo.getCustomerSecondaryCustomer() == null ? null : customerStatisticalInfo.getCustomerSecondaryCustomer());
  1899. row.createCell(26).setCellValue(customerStatisticalInfo.getAdminName() == null ? null : customerStatisticalInfo.getAdminName());
  1900. if(customerStatisticalInfo.getRelationFactoryCosts() == null){
  1901. row.createCell(27).setCellValue("");
  1902. }else{
  1903. row.createCell(27).setCellValue(customerStatisticalInfo.getRelationFactoryCosts());
  1904. }
  1905. if(customerStatisticalInfo.getRelationCustomerCosts() == null){
  1906. row.createCell(28).setCellValue("");
  1907. }else{
  1908. row.createCell(28).setCellValue(customerStatisticalInfo.getRelationCustomerCosts());
  1909. }
  1910. row.createCell(29).setCellValue(customerStatisticalInfo.getPostageString());
  1911. }
  1912. //下载导出订单Excel
  1913. downloadCustomerExcel(wb,downloadProgressInfo,path,"客诉报表");
  1914. }
  1915. /**
  1916. * 下载导出客诉到本地
  1917. * @param wb
  1918. * @throws Exception
  1919. */
  1920. public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo,String path,String name) throws Exception{
  1921. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1922. String fileName = format.format(new Date()) + name;
  1923. try {
  1924. FileOutputStream fout = new FileOutputStream(path+"/common/customerExcel/"+fileName+downloadProgressInfo.getDownloadId()+".xls");
  1925. wb.write(fout);
  1926. fout.close();
  1927. } catch (Exception e) {
  1928. e.printStackTrace();
  1929. }
  1930. downloadProgressInfo.setDownloadStatus(2);
  1931. downloadProgressInfo.setDownloadUrl("\\common\\customerExcel\\"+fileName+downloadProgressInfo.getDownloadId()+".xls");
  1932. customerService.updateDownloadProgressInfo(downloadProgressInfo);
  1933. }
  1934. /**
  1935. * 下载导出客诉到Excel
  1936. * @param res
  1937. * @param wb
  1938. * @throws Exception
  1939. */
  1940. public void downloadCustomerExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
  1941. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
  1942. String fileName = format.format(new Date()) + "客诉报表";
  1943. ByteArrayOutputStream os = new ByteArrayOutputStream();
  1944. wb.write(os);
  1945. byte[] content = os.toByteArray();
  1946. InputStream is = new ByteArrayInputStream(content);
  1947. // 设置response参数,可以打开下载页面
  1948. res.reset();
  1949. res.setContentType("application/vnd.ms-excel;charset=utf-8");
  1950. res.setHeader("Content-Disposition", "attachment;filename="
  1951. + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
  1952. ServletOutputStream out = res.getOutputStream();
  1953. BufferedInputStream bis = null;
  1954. BufferedOutputStream bos = null;
  1955. try {
  1956. bis = new BufferedInputStream(is);
  1957. bos = new BufferedOutputStream(out);
  1958. byte[] buff = new byte[2048];
  1959. int bytesRead;
  1960. // Simple read/write loop.
  1961. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  1962. bos.write(buff, 0, bytesRead);
  1963. }
  1964. } catch (Exception e) {
  1965. // TODO: handle exception
  1966. e.printStackTrace();
  1967. } finally {
  1968. if (bis != null)
  1969. bis.close();
  1970. if (bos != null)
  1971. bos.close();
  1972. }
  1973. }
  1974. /**
  1975. * 跳转到添加客诉页面
  1976. *
  1977. * @return
  1978. */
  1979. @RequiresPermissions("customer:statistical:customer")
  1980. @RequestMapping(value = "/to_return_statistics")
  1981. public ModelAndView toReturnStatistics(HttpServletRequest request) {
  1982. ModelAndView mv = new ModelAndView("cm/report/return_statistics");
  1983. //获取产品集合,用于页面选择产品
  1984. ProductColor productColor = new ProductColor();
  1985. List<ProductColor> productColorList = productService.listproductAndColor(productColor);
  1986. mv.addObject("productColorList", productColorList);
  1987. //查询店铺
  1988. StoreInfo storeInfo = new StoreInfo();
  1989. List<StoreInfo> storeList = storeInfoService.listStore(storeInfo);
  1990. mv.addObject("storeList", storeList);
  1991. return mv;
  1992. }
  1993. /**
  1994. * 退换货统计
  1995. * @param request
  1996. * @param salesOrder
  1997. * @return
  1998. */
  1999. @ResponseBody
  2000. @RequestMapping("/return_statistics")
  2001. public ResponseJson returnStatistics(HttpServletRequest request,SalesOrder salesOrder){
  2002. if(salesOrder.getStartDate() == null){
  2003. Date now = new Date();
  2004. Calendar c = Calendar.getInstance();
  2005. c.setTime(now);
  2006. c.set(Calendar.DAY_OF_YEAR, 1);
  2007. c.set(Calendar.HOUR, 0);
  2008. c.set(Calendar.MINUTE, 0);
  2009. c.set(Calendar.SECOND, 0);
  2010. salesOrder.setStartDate(c.getTime());
  2011. c.add(Calendar.YEAR, 1);
  2012. c.set(Calendar.DAY_OF_YEAR, -1);
  2013. c.set(Calendar.HOUR, 23);
  2014. c.set(Calendar.MINUTE, 59);
  2015. c.set(Calendar.SECOND, 59);
  2016. salesOrder.setEndDate(c.getTime());
  2017. }
  2018. if(salesOrder.getItemColorBar() != null && !salesOrder.getItemColorBar().equals("")){
  2019. List<String> listColorBar = Arrays.asList(salesOrder.getItemColorBar().split(","));
  2020. salesOrder.setListColorBar(listColorBar);
  2021. }
  2022. /*销售总数*/
  2023. List<ReturnStatisticsInfo> listTotalSales = customerService.salesTotalSales(salesOrder);
  2024. /*总换货*/
  2025. List<ReturnStatisticsInfo> listTotalExchange = customerService.salesTotalExchange(salesOrder);
  2026. /*总退货*/
  2027. List<ReturnStatisticsInfo> listTotalReturn = customerService.salesTotalReturn(salesOrder);
  2028. /*二次换货*/
  2029. List<ReturnStatisticsInfo> listSecondaryChangeNew = customerService.salesSecondaryChangeNew(salesOrder);
  2030. /*二次换新退货*/
  2031. List<ReturnStatisticsInfo> listReturnForSecond = customerService.salesReturnForSecond(salesOrder);
  2032. /*封装数据*/
  2033. List<ReturnStatisticsInfo> listReturnStatisticsInfo = new ArrayList<>();
  2034. boolean isThereAre = false;
  2035. for (int i = 1;i<=12;i++){
  2036. ReturnStatisticsInfo returnStatisticsInfo = new ReturnStatisticsInfo();
  2037. for(int j = 0;j< listTotalSales.size(); j++){
  2038. if(i == listTotalSales.get(j).getMonths()){
  2039. returnStatisticsInfo.setMonths(i);
  2040. returnStatisticsInfo.setTotalSales(listTotalSales.get(j).getNum());
  2041. isThereAre = true;
  2042. }
  2043. }
  2044. if(!isThereAre){
  2045. returnStatisticsInfo.setMonths(i);
  2046. returnStatisticsInfo.setTotalSales(0);
  2047. }
  2048. isThereAre = false;
  2049. listReturnStatisticsInfo.add(returnStatisticsInfo);
  2050. }
  2051. for(int i = 0;i<listReturnStatisticsInfo.size();i++){
  2052. for(int j = 0;j< listTotalExchange.size(); j++){
  2053. if(i+1 == listTotalExchange.get(j).getMonths()){
  2054. listReturnStatisticsInfo.get(i).setTotalExchange(listTotalExchange.get(j).getNum());
  2055. isThereAre = true;
  2056. }
  2057. }
  2058. if(!isThereAre){
  2059. listReturnStatisticsInfo.get(i).setTotalExchange(0);
  2060. }
  2061. isThereAre = false;
  2062. for(int j = 0;j< listTotalReturn.size(); j++){
  2063. if(i+1 == listTotalReturn.get(j).getMonths()){
  2064. listReturnStatisticsInfo.get(i).setTotalReturn(listTotalReturn.get(j).getNum());
  2065. isThereAre = true;
  2066. }
  2067. }
  2068. if(!isThereAre){
  2069. listReturnStatisticsInfo.get(i).setTotalReturn(0);
  2070. }
  2071. isThereAre = false;
  2072. for(int j = 0;j< listSecondaryChangeNew.size(); j++){
  2073. if(i+1 == listSecondaryChangeNew.get(j).getMonths()){
  2074. listReturnStatisticsInfo.get(i).setSecondaryChangeNew(listSecondaryChangeNew.get(j).getNum());
  2075. isThereAre = true;
  2076. }
  2077. }
  2078. if(!isThereAre){
  2079. listReturnStatisticsInfo.get(i).setSecondaryChangeNew(0);
  2080. }
  2081. isThereAre = false;
  2082. for(int j = 0;j< listReturnForSecond.size(); j++){
  2083. if(i+1 == listReturnForSecond.get(j).getMonths()){
  2084. listReturnStatisticsInfo.get(i).setReturnForSecond(listReturnForSecond.get(j).getNum());
  2085. isThereAre = true;
  2086. }
  2087. }
  2088. if(!isThereAre){
  2089. listReturnStatisticsInfo.get(i).setReturnForSecond(0);
  2090. }
  2091. isThereAre = false;
  2092. }
  2093. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  2094. rj.addResponseKeyValue("listReturnStatisticsInfo", listReturnStatisticsInfo);
  2095. return rj;
  2096. }
  2097. @RequestMapping("/to_add_customer_list")
  2098. public ModelAndView toAddCustomerList(HttpServletRequest request) throws Exception {
  2099. ModelAndView mv = new ModelAndView("cm/customer/add_custome_list");
  2100. return mv;
  2101. }
  2102. @ResponseBody
  2103. @RequestMapping("/add_customer_list")
  2104. public ResponseJson addCustomerList(HttpServletRequest request, CustomerInfo customer,
  2105. @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
  2106. @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
  2107. @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
  2108. PagedResult<CustomerInfo> pagedResult = customerService.listCustomer(pageNO, pageSize, customer, totalNum == 0);
  2109. if (totalNum != 0) {
  2110. pagedResult.setTotal(totalNum);
  2111. }
  2112. //
  2113. // //查询产品类型集合
  2114. // List<ProductType> typeList = productService.listProductType(new ProductType());
  2115. // //查询客诉类型集合
  2116. // List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
  2117. // //查询客诉类型集合
  2118. // List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(new ComplaintSmallClassInfo());
  2119. //查询跟进客服集合
  2120. Admin admin = new Admin();
  2121. admin.setAdminDept(3);
  2122. admin.setAdminStatus(1);
  2123. List<Admin> adminList = sysService.listSelectAdmin(admin);
  2124. ResponseJson rj = ResponseJson.getSUCCESS();
  2125. // rj.addResponseKeyValue("typeList",typeList);
  2126. // rj.addResponseKeyValue("complaintTypeList",complaintTypeList);
  2127. // rj.addResponseKeyValue("complaintSmallClassInfoList",complaintSmallClassInfoList);
  2128. rj.addResponseKeyValue("adminList",adminList);
  2129. rj.addResponseKeyValue("customerList",pagedResult.getDataList());
  2130. return rj;
  2131. }
  2132. /**
  2133. * 获取邮费信息
  2134. * @param request
  2135. * @param postageId
  2136. * @return
  2137. */
  2138. @ResponseBody
  2139. @RequestMapping("/get_PostageInfo")
  2140. public ResponseJson getPostageInfo(HttpServletRequest request,Integer postageId){
  2141. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  2142. if(postageId == null){
  2143. return new ResponseJson(500, "查询失败!", 500);
  2144. }
  2145. PostageInfo postageInfo = customerService.getPostageInfo(postageId);
  2146. rj.addResponseKeyValue("postageInfo",postageInfo);
  2147. return rj;
  2148. }
  2149. /**
  2150. * 添加邮费信息
  2151. * @param request
  2152. * @param postageInfo
  2153. * @return
  2154. */
  2155. @ResponseBody
  2156. @RequestMapping("/add_PostageInfo")
  2157. public ResponseJson addPostageInfo(HttpServletRequest request,PostageInfo postageInfo){
  2158. ResponseJson rj = new ResponseJson(200, "添加成功", 200);
  2159. if(postageInfo == null){
  2160. return new ResponseJson(500, "添加失败,请检查参数!", 500);
  2161. }
  2162. postageInfo.setAdminId(AdminUtils.getLoginAdminId());
  2163. Integer msg = customerService.addPostageInfo(postageInfo);
  2164. if(msg < 1){
  2165. return new ResponseJson(500, "添加失败", 500);
  2166. }
  2167. rj.addResponseKeyValue("postageInfo",postageInfo);
  2168. return rj;
  2169. }
  2170. /**
  2171. * 修改邮费信息
  2172. * @param request
  2173. * @param postageInfo
  2174. * @return
  2175. */
  2176. @ResponseBody
  2177. @RequestMapping("/update_PostageInfo")
  2178. public ResponseJson updatePostageInfo(HttpServletRequest request,PostageInfo postageInfo){
  2179. ResponseJson rj = new ResponseJson(200, "修改成功", 200);
  2180. if(postageInfo == null){
  2181. return new ResponseJson(500, "修改失败,请检查参数!", 500);
  2182. }
  2183. Integer msg = customerService.updatePostageInfo(postageInfo);
  2184. if(msg < 1){
  2185. return new ResponseJson(500, "修改失败", 500);
  2186. }
  2187. rj.addResponseKeyValue("postageInfo",postageInfo);
  2188. return rj;
  2189. }
  2190. /**
  2191. * 删除邮费信息
  2192. * @param request
  2193. * @param postageId
  2194. * @return
  2195. */
  2196. @ResponseBody
  2197. @RequestMapping("/delete_PostageInfo")
  2198. public ResponseJson deletePostageInfo(HttpServletRequest request,Integer postageId){
  2199. ResponseJson rj = new ResponseJson(200, "删除成功", 200);
  2200. if(postageId == null){
  2201. return new ResponseJson(500, "删除失败,请检查参数!", 500);
  2202. }
  2203. Integer msg = customerService.deletePostageInfo(postageId);
  2204. if(msg < 1){
  2205. return new ResponseJson(500, "删除失败", 500);
  2206. }
  2207. return rj;
  2208. }
  2209. /**
  2210. * 获取寄回信息
  2211. * @param request
  2212. * @param sendbackId
  2213. * @return
  2214. */
  2215. @ResponseBody
  2216. @RequestMapping("/get_SendbackInfo")
  2217. public ResponseJson getSendbackInfo(HttpServletRequest request,Integer sendbackId){
  2218. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  2219. if(sendbackId == null){
  2220. return new ResponseJson(500, "查询失败!", 500);
  2221. }
  2222. SendbackInfo sendbackInfo = customerService.getSendbackInfo(sendbackId);
  2223. rj.addResponseKeyValue("sendbackInfo",sendbackInfo);
  2224. return rj;
  2225. }
  2226. /**
  2227. * 添加寄回信息
  2228. * @param request
  2229. * @param sendbackInfo
  2230. * @return
  2231. */
  2232. @ResponseBody
  2233. @RequestMapping("/add_SendbackInfo")
  2234. public ResponseJson addSendbackInfo(HttpServletRequest request,SendbackInfo sendbackInfo){
  2235. ResponseJson rj = new ResponseJson(200, "添加成功", 200);
  2236. if(sendbackInfo == null){
  2237. return new ResponseJson(500, "添加失败,请检查参数!", 500);
  2238. }
  2239. /*signTime*/
  2240. SendbackInfo info = customerService.addSendbackInfo(sendbackInfo);
  2241. if(info == null){
  2242. return new ResponseJson(500, "添加失败", 500);
  2243. }
  2244. SendbackInfo info1 = customerService.getSendbackInfo(sendbackInfo.getSendbackId());
  2245. rj.addResponseKeyValue("sendbackInfo",info1);
  2246. return rj;
  2247. }
  2248. /**
  2249. * 修改寄回信息
  2250. * @param request
  2251. * @param sendbackInfo
  2252. * @return
  2253. */
  2254. @ResponseBody
  2255. @RequestMapping("/update_SendbackInfo")
  2256. public ResponseJson updateSendbackInfo(HttpServletRequest request,SendbackInfo sendbackInfo){
  2257. ResponseJson rj = new ResponseJson(200, "修改成功", 200);
  2258. if(sendbackInfo == null){
  2259. return new ResponseJson(500, "修改失败,请检查参数!", 500);
  2260. }
  2261. SendbackInfo info = customerService.updateSendbackInfo(sendbackInfo);
  2262. if(info == null){
  2263. return new ResponseJson(500, "修改失败", 500);
  2264. }
  2265. SendbackInfo info1 = customerService.getSendbackInfo(sendbackInfo.getSendbackId());
  2266. rj.addResponseKeyValue("sendbackInfo",info1);
  2267. return rj;
  2268. }
  2269. /**
  2270. * 修改寄回状态为已签收
  2271. * @param request
  2272. * @param sendbackInfo
  2273. * @return
  2274. */
  2275. @ResponseBody
  2276. @RequestMapping("/update_SendbackStatus")
  2277. public ResponseJson updateSendbackStatus(HttpServletRequest request,SendbackInfo sendbackInfo){
  2278. ResponseJson rj = new ResponseJson(200, "修改成功", 200);
  2279. if(sendbackInfo == null){
  2280. return new ResponseJson(500, "修改失败,请检查参数!", 500);
  2281. }
  2282. if(customerService.updateSendbackStatus(sendbackInfo) < 1){
  2283. return new ResponseJson(500, "修改失败", 500);
  2284. }
  2285. SendbackInfo info1 = customerService.getSendbackInfo(sendbackInfo.getSendbackId());
  2286. rj.addResponseKeyValue("sendbackInfo",info1);
  2287. return rj;
  2288. }
  2289. /**
  2290. * 删除单个寄回信息
  2291. * @param request
  2292. * @param sendbackId
  2293. * @return
  2294. */
  2295. @ResponseBody
  2296. @RequestMapping("/delete_SendbackInfo")
  2297. public ResponseJson deleteSendbackInfo(HttpServletRequest request,Integer sendbackId){
  2298. ResponseJson rj = new ResponseJson(200, "删除成功", 200);
  2299. if(sendbackId == null){
  2300. return new ResponseJson(500, "删除失败,请检查参数!", 500);
  2301. }
  2302. Integer msg = customerService.deleteSendbackInfo(sendbackId);
  2303. if(msg > 0){
  2304. complaintSignclosedInfoService.delSignclosedBySendbackId(sendbackId);
  2305. }else{
  2306. return new ResponseJson(500, "删除失败", 500);
  2307. }
  2308. return rj;
  2309. }
  2310. /**
  2311. * 同步邮费信息
  2312. * @param request
  2313. * @param
  2314. * @return
  2315. */
  2316. /*@ResponseBody
  2317. @RequestMapping("/synchronize_PostageInfo")*/
  2318. public ResponseJson synchronizePostageInfo(HttpServletRequest request){
  2319. String msg = customerService.synchronizePostageInfo();
  2320. return new ResponseJson(200, msg, 200);
  2321. }
  2322. /**
  2323. * 同步寄回信息
  2324. * @param request
  2325. * @param
  2326. * @return
  2327. */
  2328. /*@ResponseBody
  2329. @RequestMapping("/synchronizeSendbackInfo")*/
  2330. public ResponseJson synchronizeSendbackInfo(HttpServletRequest request){
  2331. String msg = customerService.synchronizeSendbackInfo();
  2332. return new ResponseJson(200, msg, 200);
  2333. }
  2334. /**
  2335. * 添加收费
  2336. * @param request
  2337. * @param informationInfo
  2338. * @return
  2339. */
  2340. @ResponseBody
  2341. @RequestMapping("/add_informationInfo")
  2342. public ResponseJson addInformationInfo(HttpServletRequest request,InformationInfo informationInfo){
  2343. ResponseJson rj = new ResponseJson(200, "添加成功", 200);
  2344. if(informationInfo == null){
  2345. return new ResponseJson(500, "添加失败,请检查参数!", 500);
  2346. }
  2347. /*signTime*/
  2348. Integer msg = customerService.addInformationInfo(informationInfo);
  2349. if(msg < 1){
  2350. return new ResponseJson(500, "添加失败", 500);
  2351. }
  2352. InformationInfo info = customerService.getInformationInfo(informationInfo.getFeeId());
  2353. rj.addResponseKeyValue("informationInfo",info);
  2354. return rj;
  2355. }
  2356. /**
  2357. * 上传交易图片
  2358. * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
  2359. */
  2360. @ResponseBody
  2361. @RequestMapping("/fee_fileUpload")
  2362. public ResponseJson fileUpload(HttpServletRequest request, @RequestParam(value = "file",required = false) CommonsMultipartFile file) throws IOException {
  2363. ResponseJson responseJson = new ResponseJson();
  2364. if(file == null || file.getOriginalFilename() == null || "".equals(file.getOriginalFilename())){
  2365. responseJson.setReturnCode(500);
  2366. return responseJson;
  2367. }
  2368. System.out.println("fileName:"+file.getOriginalFilename());
  2369. String realPath = request.getSession().getServletContext().getRealPath("/");
  2370. String oldName = file.getOriginalFilename();
  2371. //名称
  2372. String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().toString().lastIndexOf("."));
  2373. String name = System.currentTimeMillis()+suffix;
  2374. String path = UploadFileUtils.cmFeePayPictureUploadFile(realPath,name,file);
  2375. String url = request.getScheme()+"://"+ request.getServerName();
  2376. responseJson.setReturnCode(200);
  2377. responseJson.addResponseKeyValue("allImgUrl",url + "/" + path);
  2378. responseJson.addResponseKeyValue("imgUrl",path);
  2379. responseJson.addResponseKeyValue("oldName",oldName);
  2380. responseJson.addResponseKeyValue("name",name);
  2381. return responseJson;
  2382. }
  2383. /**
  2384. * 修改收费
  2385. * @param request
  2386. * @param informationInfo
  2387. * @return
  2388. */
  2389. @ResponseBody
  2390. @RequestMapping("/update_informationInfo")
  2391. public ResponseJson updateInformationInfo(HttpServletRequest request,InformationInfo informationInfo){
  2392. ResponseJson rj = new ResponseJson(200, "修改成功", 200);
  2393. if(informationInfo == null){
  2394. return new ResponseJson(500, "修改失败,请检查参数!", 500);
  2395. }
  2396. /*signTime*/
  2397. Integer msg = customerService.updateInformationInfo(informationInfo);
  2398. if(msg < 1){
  2399. return new ResponseJson(500, "修改失败", 500);
  2400. }
  2401. InformationInfo info = customerService.getInformationInfo(informationInfo.getFeeId());
  2402. rj.addResponseKeyValue("informationInfo",info);
  2403. return rj;
  2404. }
  2405. /**
  2406. * 删除单个收费信息
  2407. * @param request
  2408. * @param feeId
  2409. * @return
  2410. */
  2411. @ResponseBody
  2412. @RequestMapping("/delete_informationInfo")
  2413. public ResponseJson deleteInformationInfo(HttpServletRequest request,Integer feeId){
  2414. ResponseJson rj = new ResponseJson(200, "删除成功", 200);
  2415. if(feeId == null){
  2416. return new ResponseJson(500, "删除失败,请检查参数!", 500);
  2417. }
  2418. Integer msg = customerService.delInformationInfo(feeId);
  2419. if(msg < 1){
  2420. return new ResponseJson(500, "删除失败", 500);
  2421. }
  2422. return rj;
  2423. }
  2424. /**
  2425. * 查询单个收费信息
  2426. * @param request
  2427. * @param feeId
  2428. * @return
  2429. */
  2430. @ResponseBody
  2431. @RequestMapping("/get_informationInfo")
  2432. public ResponseJson getInformationInfo(HttpServletRequest request,Integer feeId){
  2433. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  2434. if(feeId == null){
  2435. return new ResponseJson(500, "查询失败,请检查参数!", 500);
  2436. }
  2437. InformationInfo informationInfo = customerService.getInformationInfo(feeId);
  2438. if(informationInfo == null){
  2439. return new ResponseJson(500, "查询失败", 500);
  2440. }
  2441. rj.addResponseKeyValue("informationInfo",informationInfo);
  2442. return rj;
  2443. }
  2444. /**
  2445. * 查询签收/检测数量
  2446. * @param request
  2447. * @param isOneself 1全部 2只看自己
  2448. * @return
  2449. */
  2450. @ResponseBody
  2451. @RequestMapping("/get_afterSalesNum")
  2452. public ResponseJson getAfterSalesNum(HttpServletRequest request,Integer isOneself){
  2453. ResponseJson rj = new ResponseJson(200, "查询成功", 200);
  2454. ComplaintAfterSalesNum complaintAfterSalesNum = new ComplaintAfterSalesNum();
  2455. //获取登录人id
  2456. Integer loginAdminId = AdminUtils.getLoginAdminId();
  2457. if(isOneself == null){
  2458. //查询缓存数据
  2459. String redisIsOneself = RedisUtils.get("CUSTOMER"+loginAdminId);
  2460. if(redisIsOneself == null){
  2461. RedisUtils.put("CUSTOMER"+loginAdminId,1);//新增缓存为查询全部
  2462. isOneself = 1;
  2463. }else{
  2464. isOneself = Integer.valueOf(redisIsOneself);
  2465. }
  2466. }else if(isOneself == 1){
  2467. RedisUtils.put("CUSTOMER"+loginAdminId,1);//更新缓存
  2468. }else if(isOneself == 2){
  2469. RedisUtils.put("CUSTOMER"+loginAdminId,2);//更新缓存
  2470. }
  2471. ComplaintDetectInfo detect = new ComplaintDetectInfo();
  2472. ComplaintSignclosedInfo signclosed = new ComplaintSignclosedInfo();
  2473. if (isOneself == 2) {
  2474. detect.setAdminId(loginAdminId);
  2475. signclosed.setAdminId(loginAdminId);
  2476. }
  2477. /*查询维修数据 state*/
  2478. ComplaintAfterSalesNum afterSalesNum = complaintDetectInfoService.getCustomerDetectNum(detect);
  2479. if(afterSalesNum == null){
  2480. complaintAfterSalesNum.setBeDetected(0);
  2481. complaintAfterSalesNum.setBeConfirmed(0);
  2482. complaintAfterSalesNum.setCompleteProcessing(0);
  2483. complaintAfterSalesNum.setPlaceOrderNum(0);
  2484. complaintAfterSalesNum.setDetectplaceOrderNum(0);
  2485. complaintAfterSalesNum.setMaintenanceCutTimeNum(0);
  2486. complaintAfterSalesNum.setCompleteCutTimeNum(0);
  2487. }else{
  2488. complaintAfterSalesNum.setBeDetected(afterSalesNum.getBeDetected());
  2489. complaintAfterSalesNum.setBeConfirmed(afterSalesNum.getBeConfirmed());
  2490. complaintAfterSalesNum.setCompleteProcessing(afterSalesNum.getCompleteProcessing());
  2491. complaintAfterSalesNum.setPlaceOrderNum(afterSalesNum.getPlaceOrderNum());
  2492. complaintAfterSalesNum.setDetectplaceOrderNum(afterSalesNum.getDetectplaceOrderNum());
  2493. complaintAfterSalesNum.setMaintenanceCutTimeNum(afterSalesNum.getMaintenanceCutTimeNum());
  2494. complaintAfterSalesNum.setCompleteCutTimeNum(afterSalesNum.getCompleteCutTimeNum());
  2495. }
  2496. /*查询维修数据 end*/
  2497. /*查询签收数据 state*/
  2498. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  2499. Calendar date = Calendar.getInstance();
  2500. date.setTime(new Date());
  2501. //今日签收
  2502. signclosed.setDate(sdf.format(date.getTime()));
  2503. Integer s1 = complaintSignclosedInfoService.getSignclosedDay(signclosed);
  2504. complaintAfterSalesNum.setTodaysignNum(complaintSignclosedInfoService.getSignclosedDay(signclosed));
  2505. //昨日签收
  2506. date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
  2507. signclosed.setDate(sdf.format(date.getTime()));
  2508. complaintAfterSalesNum.setYesterdaysignNum(complaintSignclosedInfoService.getSignclosedDay(signclosed));
  2509. //前日签收
  2510. date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
  2511. signclosed.setDate(sdf.format(date.getTime()));
  2512. complaintAfterSalesNum.setBeforedaysignNum(complaintSignclosedInfoService.getSignclosedDay(signclosed));
  2513. //待联系
  2514. signclosed.setIsBinding(1);
  2515. signclosed.setDate(null);
  2516. complaintAfterSalesNum.setContactNum(complaintSignclosedInfoService.getSignclosedDay(signclosed));
  2517. //待换货发出数量
  2518. ComplaintSignclosedInfo signcloseds = new ComplaintSignclosedInfo();
  2519. if (isOneself == 2) {
  2520. signcloseds.setAdminId(loginAdminId);
  2521. }
  2522. complaintAfterSalesNum.setCompleteSent(complaintSignclosedInfoService.getCompleteSent(signcloseds));
  2523. /*查询签收数据 end*/
  2524. //待打印邮费申请
  2525. complaintAfterSalesNum.setPostagePrintedNum(postageService.getPostagePrintedNum());
  2526. rj.addResponseKeyValue("complaintAfterSalesNum",complaintAfterSalesNum);
  2527. rj.addResponseKeyValue("isOneself",isOneself);
  2528. return rj;
  2529. }
  2530. /**
  2531. * 下载客诉统计信息 (2018-05-29)
  2532. *
  2533. * @param request
  2534. * @param res
  2535. * @param
  2536. * @throws Exception
  2537. */
  2538. @ResponseBody
  2539. @RequestMapping("/download_customer_statistics")
  2540. public ResponseJson downloadStatisticsExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
  2541. String path = request.getSession().getServletContext().getRealPath("/");
  2542. new Thread(new Mythread2(path,customerInfo)).start();
  2543. return new ResponseJson(200, "查询成功", 200);
  2544. }
  2545. class Mythread2 extends Thread{
  2546. private String path;
  2547. private CustomerInfo customerInfo;
  2548. public Mythread2(String path,CustomerInfo customerInfo) {
  2549. this.path=path;
  2550. this.customerInfo=customerInfo;
  2551. }
  2552. @Override
  2553. public void run(){
  2554. Admin admin = AdminUtils.getLoginAdmin();
  2555. //添加一条下载记录
  2556. DownloadProgressInfo downloadProgressInfo = new DownloadProgressInfo();
  2557. downloadProgressInfo.setDownloadAdminId(admin.getAdminId());
  2558. downloadProgressInfo.setDownloadProgress("00.00");
  2559. downloadProgressInfo.setDownloadStatus(1);
  2560. customerService.addDownloadProgressInfo(downloadProgressInfo);
  2561. //循环一次的时间(毫秒)
  2562. long cycleOne = 0;
  2563. long cycleOnes = 0;
  2564. int s = 0;
  2565. List<CustomerStatistics> customerList = new ArrayList<>();
  2566. //计算统计月份
  2567. List<String> listmonth = ExcelUtil.month(customerInfo.getStartTime(),customerInfo.getEndTime());
  2568. if(listmonth.size() > 0){
  2569. for(String month : listmonth){
  2570. List<CustomerStatistics> list = customerService.selectCustomerStatistics(month);
  2571. customerList.addAll(list);
  2572. }
  2573. }
  2574. String[] cells = {
  2575. "月份", "产品型号", "处理结果", "数量1", "处理方法",
  2576. "数量2", "购买月份", "数量3", "客诉问题", "数量4",
  2577. "数量5"
  2578. };
  2579. long startTime=System.currentTimeMillis(); //获取开始时间
  2580. s++;
  2581. long endTime=System.currentTimeMillis(); //获取结束时间
  2582. NumberFormat numberFormat = NumberFormat.getInstance();
  2583. float percentage = (float) s / (float) customerList.size() * 100;
  2584. String result = numberFormat.format(percentage);
  2585. if(s == 1){
  2586. cycleOne = endTime - startTime;
  2587. SimpleDateFormat sdf3=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2588. cycleOnes = cycleOne * customerList.size();
  2589. //修改预计下载完成时间
  2590. downloadProgressInfo.setDownloadDate(sdf3.format(new Date().getTime()+cycleOnes));
  2591. downloadProgressInfo.setDownloadProgress(result);
  2592. customerService.updateDownloadProgressInfo(downloadProgressInfo);
  2593. }
  2594. //导出订单Excel并下载
  2595. try {
  2596. customerExcel2(cells,customerList,downloadProgressInfo,path);
  2597. } catch (Exception e) {
  2598. e.printStackTrace();
  2599. }
  2600. }
  2601. }
  2602. /**
  2603. * 导出订单Excel并下载
  2604. * @param cells
  2605. * @throws Exception
  2606. */
  2607. public void customerExcel2(String[] cells,List<CustomerStatistics> customerList,
  2608. DownloadProgressInfo downloadProgressInfo,String path) throws Exception {
  2609. //创建一个workbook,对应一个Excel文件
  2610. HSSFWorkbook wb = new HSSFWorkbook();
  2611. //在workbook中添加一个sheet,对应Excel中的一个sheet
  2612. HSSFSheet sheet = wb.createSheet("导出客诉统计");
  2613. //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
  2614. HSSFRow row = sheet.createRow((int) 0);
  2615. //创建单元格,设置值表头,设置表头居中
  2616. HSSFCellStyle style = wb.createCellStyle();
  2617. //居中格式
  2618. style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  2619. style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);// 上下居中
  2620. //设置表头
  2621. if (cells == null || cells.length == 0) {
  2622. return;
  2623. }
  2624. //循环设置表头
  2625. HSSFCell cell = null;
  2626. for (int i = 0; i < cells.length; i++) {
  2627. String name = cells[i];
  2628. cell = row.createCell(i);
  2629. cell.setCellValue(name);
  2630. cell.setCellStyle(style);
  2631. }
  2632. if (customerList.size() > 0) {
  2633. int s1 = 0;
  2634. for (int i = 0; i < customerList.size() - 1; i++) {
  2635. if (i >= s1) {
  2636. for (int j = 0; j < customerList.size() - 1; j++) {
  2637. if (j >= s1) {
  2638. if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
  2639. && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
  2640. customerList.get(i).setNumberOne(customerList.get(i).getNumberOne() + customerList.get(j + 1).getNumberOne());
  2641. customerList.get(j + 1).setNumberOne(0);
  2642. s1 = j + 1;
  2643. } else {
  2644. s1 = j + 1;
  2645. break;
  2646. }
  2647. }
  2648. }
  2649. }
  2650. }
  2651. }
  2652. if (customerList.size() > 0) {
  2653. int s2 = 0;
  2654. for (int i = 0; i < customerList.size() - 1; i++) {
  2655. if (i >= s2) {
  2656. for (int j = 0; j < customerList.size() - 1; j++) {
  2657. if (j >= s2) {
  2658. if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
  2659. && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
  2660. && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())) {
  2661. customerList.get(i).setNumberTwo(customerList.get(i).getNumberTwo() + customerList.get(j + 1).getNumberTwo());
  2662. customerList.get(j + 1).setNumberTwo(0);
  2663. s2 = j + 1;
  2664. } else {
  2665. s2 = j + 1;
  2666. break;
  2667. }
  2668. }
  2669. }
  2670. }
  2671. }
  2672. }
  2673. if (customerList.size() > 0) {
  2674. int s2 = 0;
  2675. for (int i = 0; i < customerList.size() - 1; i++) {
  2676. if (i >= s2) {
  2677. for (int j = 0; j < customerList.size() - 1; j++) {
  2678. if (j >= s2) {
  2679. if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
  2680. && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
  2681. && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())
  2682. && customerList.get(i).getBuyMonth() != null && customerList.get(j + 1).getBuyMonth() != null
  2683. && customerList.get(i).getBuyMonth().equals(customerList.get(j + 1).getBuyMonth())) {
  2684. customerList.get(i).setNumberThree(customerList.get(i).getNumberThree() + customerList.get(j + 1).getNumberThree());
  2685. customerList.get(j + 1).setNumberThree(0);
  2686. customerList.get(j + 1).setBuyMonth("");
  2687. s2 = j + 1;
  2688. } else {
  2689. s2 = j + 1;
  2690. break;
  2691. }
  2692. }
  2693. }
  2694. }
  2695. }
  2696. }
  2697. if (customerList.size() > 0) {
  2698. int s2 = 0;
  2699. for (int i = 0; i < customerList.size() - 1; i++) {
  2700. if (i >= s2) {
  2701. for (int j = 0; j < customerList.size() - 1; j++) {
  2702. if (j >= s2) {
  2703. if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
  2704. && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
  2705. && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())) {
  2706. customerList.get(j + 1).setProcessingMethod("");
  2707. s2 = j + 1;
  2708. } else {
  2709. s2 = j + 1;
  2710. break;
  2711. }
  2712. }
  2713. }
  2714. }
  2715. }
  2716. }
  2717. if (customerList.size() > 0) {
  2718. int s2 = 0;
  2719. for (int i = 0; i < customerList.size() - 1; i++) {
  2720. if (i >= s2) {
  2721. for (int j = 0; j < customerList.size() - 1; j++) {
  2722. if (j >= s2) {
  2723. if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
  2724. && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
  2725. customerList.get(j + 1).setProcessingResults("");
  2726. s2 = j + 1;
  2727. } else {
  2728. s2 = j + 1;
  2729. break;
  2730. }
  2731. }
  2732. }
  2733. }
  2734. }
  2735. }
  2736. if (customerList.size() > 0) {
  2737. int s2 = 0;
  2738. for (int i = 0; i < customerList.size() - 1; i++) {
  2739. if (i >= s2) {
  2740. for (int j = 0; j < customerList.size() - 1; j++) {
  2741. if (j >= s2) {
  2742. if (customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
  2743. customerList.get(j + 1).setProductModel("");
  2744. s2 = j + 1;
  2745. } else {
  2746. s2 = j + 1;
  2747. break;
  2748. }
  2749. }
  2750. }
  2751. }
  2752. }
  2753. }
  2754. if (customerList.size() > 0) {
  2755. int s2 = 0;
  2756. for (int i = 0; i < customerList.size() - 1; i++) {
  2757. if (i >= s2) {
  2758. for (int j = 0; j < customerList.size() - 1; j++) {
  2759. if (j >= s2) {
  2760. if (customerList.get(i).getMonth().equals(customerList.get(j + 1).getMonth())) {
  2761. customerList.get(j + 1).setMonth("");
  2762. s2 = j + 1;
  2763. } else {
  2764. s2 = j + 1;
  2765. break;
  2766. }
  2767. }
  2768. }
  2769. }
  2770. }
  2771. }
  2772. for (int i = 0; i < customerList.size(); i++) {
  2773. row = sheet.createRow((int) i + 1);
  2774. CustomerStatistics customerStatisticalInfo = customerList.get(i);
  2775. // 创建单元格,设置值
  2776. row.createCell(0).setCellValue(customerStatisticalInfo.getMonth() == null ? "" : customerStatisticalInfo.getMonth());
  2777. if(customerStatisticalInfo.getProductModel() == null){
  2778. row.createCell(1).setCellValue("");
  2779. }else{
  2780. row.createCell(1).setCellValue( customerStatisticalInfo.getProductModel());
  2781. }
  2782. if(customerStatisticalInfo.getProcessingResults() == null){
  2783. row.createCell(2).setCellValue("");
  2784. }else{
  2785. row.createCell(2).setCellValue( customerStatisticalInfo.getProcessingResults());
  2786. }
  2787. if(customerStatisticalInfo.getNumberOne() == null || customerStatisticalInfo.getNumberOne() == 0){
  2788. row.createCell(3).setCellValue("");
  2789. }else{
  2790. row.createCell(3).setCellValue( customerStatisticalInfo.getNumberOne());
  2791. }
  2792. if(customerStatisticalInfo.getProcessingMethod() == null){
  2793. row.createCell(4).setCellValue("");
  2794. }else{
  2795. row.createCell(4).setCellValue( customerStatisticalInfo.getProcessingMethod());
  2796. }
  2797. if(customerStatisticalInfo.getNumberTwo() == null || customerStatisticalInfo.getNumberTwo() == 0){
  2798. row.createCell(5).setCellValue("");
  2799. }else{
  2800. row.createCell(5).setCellValue( customerStatisticalInfo.getNumberTwo());
  2801. }
  2802. if(customerStatisticalInfo.getBuyMonth() == null){
  2803. row.createCell(6).setCellValue("");
  2804. }else{
  2805. row.createCell(6).setCellValue( customerStatisticalInfo.getBuyMonth());
  2806. }
  2807. if(customerStatisticalInfo.getNumberThree() == null || customerStatisticalInfo.getNumberThree() == 0){
  2808. row.createCell(7).setCellValue("");
  2809. }else{
  2810. row.createCell(7).setCellValue( customerStatisticalInfo.getNumberThree());
  2811. }
  2812. if(customerStatisticalInfo.getAftersaleProblem() == null){
  2813. row.createCell(8).setCellValue("");
  2814. }else{
  2815. row.createCell(8).setCellValue( customerStatisticalInfo.getAftersaleProblem());
  2816. }
  2817. if(customerStatisticalInfo.getNumberFour() == null || customerStatisticalInfo.getNumberFour() == 0){
  2818. row.createCell(9).setCellValue("");
  2819. }else{
  2820. row.createCell(9).setCellValue( customerStatisticalInfo.getNumberFour());
  2821. }
  2822. if(customerStatisticalInfo.getNumberFive() == null || customerStatisticalInfo.getNumberFive() == 0){
  2823. row.createCell(10).setCellValue("");
  2824. }else{
  2825. row.createCell(10).setCellValue( customerStatisticalInfo.getNumberFive());
  2826. }
  2827. cell = row.getCell(0);
  2828. cell.setCellStyle(style);
  2829. cell = row.getCell(1);
  2830. cell.setCellStyle(style);
  2831. cell = row.getCell(2);
  2832. cell.setCellStyle(style);
  2833. cell = row.getCell(3);
  2834. cell.setCellStyle(style);
  2835. cell = row.getCell(4);
  2836. cell.setCellStyle(style);
  2837. cell = row.getCell(5);
  2838. cell.setCellStyle(style);
  2839. cell = row.getCell(6);
  2840. cell.setCellStyle(style);
  2841. cell = row.getCell(7);
  2842. cell.setCellStyle(style);
  2843. cell = row.getCell(8);
  2844. cell.setCellStyle(style);
  2845. cell = row.getCell(9);
  2846. cell.setCellStyle(style);
  2847. cell = row.getCell(10);
  2848. cell.setCellStyle(style);
  2849. }
  2850. HashMap<Integer,HashMap<Integer,Integer>> cellMaps = new HashMap<>();
  2851. HashMap<Integer,Integer> cellMap = new HashMap<>();
  2852. int c1 = 0;
  2853. //合并单元格
  2854. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2855. if(i >= c1){
  2856. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2857. if(j >= c1){
  2858. if(sheet.getRow(j+1).getCell(0).toString().equals("") || sheet.getRow(j+1).getCell(0) == null){
  2859. cellMap.put(i,j+1);
  2860. c1 = j+1;
  2861. }else{
  2862. c1 = j+1;
  2863. break;
  2864. }
  2865. }
  2866. }
  2867. }
  2868. }
  2869. cellMaps.put(0,cellMap);
  2870. HashMap<Integer,Integer> cellMap2 = new HashMap<>();
  2871. int c2 = 0;
  2872. //合并单元格
  2873. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2874. if(i >= c2){
  2875. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2876. if(j >= c2){
  2877. if(sheet.getRow(j+1).getCell(1).toString().equals("") || sheet.getRow(j+1).getCell(1) == null){
  2878. cellMap2.put(i,j+1);
  2879. c2 = j+1;
  2880. }else{
  2881. c2 = j+1;
  2882. break;
  2883. }
  2884. }
  2885. }
  2886. }
  2887. }
  2888. cellMaps.put(1,cellMap2);
  2889. HashMap<Integer,Integer> cellMap3 = new HashMap<>();
  2890. int c3 = 0;
  2891. //合并单元格
  2892. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2893. if(i >= c3){
  2894. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2895. if(j >= c3){
  2896. if(sheet.getRow(j+1).getCell(2).toString().equals("") || sheet.getRow(j+1).getCell(2) == null){
  2897. cellMap3.put(i,j+1);
  2898. c3 = j+1;
  2899. }else{
  2900. c3 = j+1;
  2901. break;
  2902. }
  2903. }
  2904. }
  2905. }
  2906. }
  2907. cellMaps.put(2,cellMap3);
  2908. HashMap<Integer,Integer> cellMap4 = new HashMap<>();
  2909. int c4 = 0;
  2910. //合并单元格
  2911. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2912. if(i >= c4){
  2913. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2914. if(j >= c4){
  2915. if(sheet.getRow(j+1).getCell(3).toString().equals("") || sheet.getRow(j+1).getCell(3) == null){
  2916. cellMap4.put(i,j+1);
  2917. c4 = j+1;
  2918. }else{
  2919. c4 = j+1;
  2920. break;
  2921. }
  2922. }
  2923. }
  2924. }
  2925. }
  2926. cellMaps.put(3,cellMap4);
  2927. HashMap<Integer,Integer> cellMap5 = new HashMap<>();
  2928. int c5 = 0;
  2929. //合并单元格
  2930. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2931. if(i >= c5){
  2932. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2933. if(j >= c5){
  2934. if(sheet.getRow(j+1).getCell(4).toString().equals("") || sheet.getRow(j+1).getCell(4) == null){
  2935. cellMap5.put(i,j+1);
  2936. c5 = j+1;
  2937. }else{
  2938. c5 = j+1;
  2939. break;
  2940. }
  2941. }
  2942. }
  2943. }
  2944. }
  2945. cellMaps.put(4,cellMap5);
  2946. HashMap<Integer,Integer> cellMap6 = new HashMap<>();
  2947. int c6 = 0;
  2948. //合并单元格
  2949. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2950. if(i >= c6){
  2951. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2952. if(j >= c6){
  2953. if(sheet.getRow(j+1).getCell(5).toString().equals("") || sheet.getRow(j+1).getCell(5) == null){
  2954. cellMap6.put(i,j+1);
  2955. c6 = j+1;
  2956. }else{
  2957. c6 = j+1;
  2958. break;
  2959. }
  2960. }
  2961. }
  2962. }
  2963. }
  2964. cellMaps.put(5,cellMap6);
  2965. HashMap<Integer,Integer> cellMap7 = new HashMap<>();
  2966. int c7 = 0;
  2967. //合并单元格
  2968. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2969. if(i >= c7){
  2970. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2971. if(j >= c7){
  2972. if((sheet.getRow(j+1).getCell(6).toString().equals("") || sheet.getRow(j+1).getCell(6) == null)
  2973. && (sheet.getRow(j+1).getCell(5).toString().equals("") || sheet.getRow(j+1).getCell(5) == null)){
  2974. cellMap7.put(i,j+1);
  2975. c7 = j+1;
  2976. }else{
  2977. c7 = j+1;
  2978. break;
  2979. }
  2980. }
  2981. }
  2982. }
  2983. }
  2984. cellMaps.put(6,cellMap7);
  2985. HashMap<Integer,Integer> cellMap8 = new HashMap<>();
  2986. int c8 = 0;
  2987. //合并单元格
  2988. for(int i=0;i < sheet.getPhysicalNumberOfRows() -1;i++){
  2989. if(i >= c7){
  2990. for(int j=0;j < sheet.getPhysicalNumberOfRows() -1;j++){
  2991. if(j >= c8){
  2992. if((sheet.getRow(j+1).getCell(7).toString().equals("") || sheet.getRow(j+1).getCell(7) == null)
  2993. && (sheet.getRow(j+1).getCell(6).toString().equals("") || sheet.getRow(j+1).getCell(6) == null)
  2994. && (sheet.getRow(j+1).getCell(5).toString().equals("") || sheet.getRow(j+1).getCell(5) == null)){
  2995. cellMap8.put(i,j+1);
  2996. c8 = j+1;
  2997. }else{
  2998. c8 = j+1;
  2999. break;
  3000. }
  3001. }
  3002. }
  3003. }
  3004. }
  3005. cellMaps.put(7,cellMap8);
  3006. for(Map.Entry<Integer,HashMap<Integer,Integer>> entry : cellMaps.entrySet())
  3007. {
  3008. HashMap<Integer,Integer> map = entry.getValue();
  3009. for(Integer key : map.keySet())
  3010. {
  3011. CellRangeAddress region = new CellRangeAddress(key, map.get(key), entry.getKey(), entry.getKey());
  3012. sheet.addMergedRegion(region);
  3013. }
  3014. }
  3015. NumberFormat numberFormat = NumberFormat.getInstance();
  3016. numberFormat.setMaximumFractionDigits(2);
  3017. downloadProgressInfo.setDownloadProgress("100");
  3018. customerService.updateDownloadProgressInfo(downloadProgressInfo);
  3019. //下载导出订单Excel
  3020. downloadCustomerExcel(wb, downloadProgressInfo,path,"统计报表");
  3021. }
  3022. /**
  3023. * 客诉标识列表
  3024. * @param request
  3025. * @param customerId
  3026. * @return
  3027. */
  3028. @RequestMapping("/to_tag_list")
  3029. public ModelAndView listTag(HttpServletRequest request,Integer customerId){
  3030. ModelAndView mv = new ModelAndView("cm/customer/tag_list");
  3031. if(customerId != null){
  3032. TagInfo tag = new TagInfo();
  3033. tag.setTagCustomerId(customerId);
  3034. List<TagInfo> listTag = customerService.listTag(tag);
  3035. mv.addObject("listTag",listTag);
  3036. }
  3037. return mv;
  3038. }
  3039. /**
  3040. * 进入添加客诉标识
  3041. * @param request
  3042. * @param customerId
  3043. * @return
  3044. */
  3045. @RequestMapping("/to_add_Tag")
  3046. public ModelAndView toAddTag(HttpServletRequest request,Integer customerId){
  3047. ModelAndView mv = new ModelAndView("cm/customer/add_tag");
  3048. TagInfo tag = new TagInfo();
  3049. tag.setTagCustomerId(customerId);
  3050. List<TagInfo> listTag = customerService.listTag(tag);
  3051. mv.addObject("listTag",listTag);
  3052. mv.addObject("customerId",customerId);
  3053. return mv;
  3054. }
  3055. /**
  3056. * 添加客诉标识
  3057. * @param request
  3058. * @param tagInfo
  3059. * @return
  3060. */
  3061. @ResponseBody
  3062. @RequestMapping("/add_Tag")
  3063. public ResponseJson addTag(HttpServletRequest request,TagInfo tagInfo){
  3064. if(tagInfo == null || tagInfo.getTagCustomerId() == null){
  3065. return new ResponseJson(500, "查询失败,请检查参数!", 500);
  3066. }
  3067. //获取登录人id
  3068. Integer loginAdminId = AdminUtils.getLoginAdminId();
  3069. tagInfo.setTagAdminId(loginAdminId);
  3070. if(customerService.addTag(tagInfo) > 0){
  3071. return new ResponseJson(200, "添加成功", 200);
  3072. }else{
  3073. return new ResponseJson(500, "查询失败,请检查参数!", 500);
  3074. }
  3075. }
  3076. }