123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172 |
- package com.iamberry.rst.controllers.cm;
- import com.iamberry.rst.core.cm.*;
- import com.iamberry.rst.core.order.Product;
- import com.iamberry.rst.core.order.ProductColor;
- import com.iamberry.rst.core.order.ProductType;
- import com.iamberry.rst.core.page.PagedResult;
- import com.iamberry.rst.core.sys.Admin;
- import com.iamberry.rst.faces.address.AddressService;
- import com.iamberry.rst.faces.cm.*;
- import com.iamberry.rst.faces.order.EfastOrderService;
- import com.iamberry.rst.faces.product.ProductService;
- import com.iamberry.rst.faces.sms.SmsService;
- import com.iamberry.rst.faces.sys.SysService;
- import com.iamberry.rst.util.CustomerCommonUtil;
- import com.iamberry.rst.util.SmsConfig;
- import com.iamberry.rst.utils.AdminUtils;
- import com.iamberry.rst.utils.OrderNoUtil;
- import com.iamberry.rst.utils.ResultMsg;
- import com.iamberry.rst.utils.StitchAttrUtil;
- import com.iamberry.wechat.tools.NameUtils;
- import com.iamberry.wechat.tools.ResponseJson;
- import com.iamberry.wechat.tools.ResultInfo;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import org.apache.commons.codec.binary.Base64;
- import org.apache.commons.lang.StringUtils;
- import org.apache.poi.hssf.usermodel.*;
- import org.apache.shiro.authz.annotation.RequiresPermissions;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.*;
- import java.text.MessageFormat;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * Created by wxm
- */
- @Controller
- @RequestMapping("/admin/customer")
- public class AdminCustomerController {
- private Logger logger = LoggerFactory.getLogger(AdminCustomerController.class);
- @Autowired
- private CompanyInfoService companyInfoService;
- @Autowired
- private StoreInfoService storeInfoService;
- @Autowired
- private SalesOrderService salesOrderService;
- @Autowired
- private CustomerService customerService;
- @Autowired
- private ProductService productService;
- @Autowired
- private SysService sysService;
- @Autowired
- private ComplaintTypeInfoService complaintTypeInfoService;
- @Autowired
- private VisitService visitService;
- @Autowired
- private QuestionDescribeService questionDescribeService;
- @Autowired
- private RenewedService renewedService;
- @Autowired
- private RepairService repairService;
- @Autowired
- private BackGoodsService backGoodsService;
- @Autowired
- private FittingsInfoService fittingsInfoService;
- @Autowired
- private ReissueService reissueService;
- @Autowired
- private NoreasonBackService noreasonBackService;
- @Autowired
- private ComplaintQuestionInfoService complaintQuestionInfoService;
- @Autowired
- private SmsService smsService;
- @Autowired
- private ComplaintSignclosedInfoService complaintSignclosedInfoService;
- @Autowired
- private ComplaintSmallClassInfoService complaintSmallClassInfoService;
- @Autowired
- private CustomerCommonService customerCommonService;
- @Autowired
- private AddressService addressService;
- @Autowired
- private PostageService postageService;
- @Autowired
- private EfastOrderService efastOrderService;
- @Autowired
- private RelationOrderService relationOrderService;
- /**
- * 获取客诉列表
- *
- * @param request
- * @return
- */
- @RequiresPermissions("customer:list:customer")
- @RequestMapping("/_customer_list")
- public ModelAndView getCustomer(HttpServletRequest request, CustomerInfo customer,
- @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
- @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
- @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
- ModelAndView mv = new ModelAndView("cm/customer/custome_list");
- // PagedResult<Customer> pagedResult = ptsBomService.listCustomer(pageNO, pageSize, ptsBom, totalNum == 0);
- // if (totalNum != 0) {
- // pagedResult.setTotal(totalNum);
- // }
- // //获取产品集合,用于页面选择产品
- // List<Produce> list = produceService.getProduceList();
- // mv.addObject("produceList", list);
- // StitchAttrUtil.getSa().setModelAndView(customer, mv, "/admin/bom/_bom_list", pagedResult);
- return mv;
- }
- /**
- * 跳转到添加客诉页面
- *
- * @return
- */
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/to_add_customer")
- public ModelAndView toAddCustomer(HttpServletRequest request) {
- ModelAndView mv = new ModelAndView("cm/customer/add_customer");
- //获取产品集合,用于页面选择产品
- // List<Produce> produceList = produceService.getProduceList();
- // mv.addObject("produceList", produceList);
- return mv;
- }
- /**
- * 跳转到修改客诉页面
- *
- * @return
- */
- @RequiresPermissions("customer:update:customer")
- @RequestMapping(value = "/to_update_customer")
- public ModelAndView toUpdateCustomer(HttpServletRequest request,Integer customerId) {
- ModelAndView mv = new ModelAndView("cm/customer/update_customer");
- ProductType productType = new ProductType();
- //查询产品类型集合
- List<ProductType> typeList = productService.listProductType(productType);
- //查询客诉类型集合
- List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
- //查询跟进客服集合
- Admin admin = new Admin();
- admin.setAdminDept(3);
- admin.setAdminStatus(1);
- List<Admin> adminList = sysService.listSelectAdmin(admin);
- //获取登录人id
- Integer loginAdminId = AdminUtils.getLoginAdminId();
- //查询客诉基本信息
- CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
- /*客诉信息处理-stast*/
- //对于区域处理
- if(customerInfo!=null && customerInfo.getCustomerArea() != null){
- // String[] customerAreaAndCity = customerInfo.getCustomerArea().split("-");
- // customerInfo.setProvinceName(customerAreaAndCity[0]);
- // City city
- // addressService.listCity(customerAreaAndCity[0]);
- // customerInfo.setCityName(customerAreaAndCity[0]);
- }
- /*客诉信息处理-end*/
- CustomerCommon customerCommon = new CustomerCommon();
- if(customerInfo.getCustomerIsSolve() != null){
- switch (customerInfo.getCustomerIsSolve()){ //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
- case 3://获取换新
- Renewed renewed = new Renewed();
- renewed.setCustomerId(customerInfo.getCustomerId());
- renewed = renewedService.getRenewed(renewed);
- customerCommon = CustomerCommonUtil.getCustomerCommon(3,renewed);
- break;
- case 4://维修
- Repair repair = new Repair();
- repair.setCustomerId(customerInfo.getCustomerId());
- repair = repairService.getRepair(repair);
- customerCommon = CustomerCommonUtil.getCustomerCommon(4,repair);
- break;
- case 5:
- Reissue reissue = new Reissue();
- reissue.setCustomerId(customerInfo.getCustomerId());
- reissue = reissueService.getReissue(reissue);
- customerCommon = CustomerCommonUtil.getCustomerCommon(5,reissue);
- break;
- case 6:
- BackGoods backGoods = new BackGoods();
- backGoods.setCustomerId(customerInfo.getCustomerId());
- backGoods = backGoodsService.getBackGoods(backGoods);
- customerCommon = CustomerCommonUtil.getCustomerCommon(6,backGoods);
- break;
- case 7:
- NoreasonBack noreasonBack = new NoreasonBack();
- noreasonBack.setCustomerId(customerInfo.getCustomerId());
- noreasonBack = noreasonBackService.getNoreasonBack(noreasonBack);
- customerCommon = CustomerCommonUtil.getCustomerCommon(7,noreasonBack);
- break;
- }
- /*查询所有需要寄入寄出的产品*/
- customerCommon.setCustomerIsSolve(customerInfo.getCustomerIsSolve());
- customerCommon = customerCommonService.getListProduceAndFitting(customerCommon);
- // 2018/4/18 页面只会给寄回的赋值,在处理方式为补发的情况下,寄出需要赋值到寄回当中
- if(customerInfo.getCustomerIsSolve() == 5){
- //售后寄回产品表
- List<ClosedProdcue> closedProdcues = new ArrayList<ClosedProdcue>();
- for (SendProdcue sendProdcue : customerCommon.getSendProdcues()) {
- ClosedProdcue closedProdcue = new ClosedProdcue();
- closedProdcue.setRelationId(sendProdcue.getRelationId());
- closedProdcue.setProductType(sendProdcue.getProductType());
- closedProdcue.setProductId(sendProdcue.getProductId());
- closedProdcue.setColorId(sendProdcue.getColorId());
- closedProdcue.setClosedProductName(sendProdcue.getSendProduceName());
- closedProdcue.setClosedColorName(sendProdcue.getSendColorName());
- closedProdcue.setClosedProdcueNumber(sendProdcue.getSendProdcueNumber());
- closedProdcue.setColorBar(sendProdcue.getColorBar());
- closedProdcues.add(closedProdcue);
- }
- //售后寄回产品配件表
- List<ClosedFitting> closedFittings = new ArrayList<ClosedFitting>();
- for (SendFitting sendFitting : customerCommon.getSendFittings()) {
- ClosedFitting closedFitting = new ClosedFitting();
- closedFitting.setRelationId(sendFitting.getRelationId());
- closedFitting.setClosedFittingType(sendFitting.getSendFittingType());
- closedFitting.setProductId(sendFitting.getProductId());
- closedFitting.setFittingsId(sendFitting.getFittingsId());
- closedFitting.setClosedProductName(sendFitting.getSendProductName());
- closedFitting.setClosedFittingsName(sendFitting.getSendFittingsName());
- closedFitting.setClosedFittingNumber(sendFitting.getSendFittingNumber());
- closedFitting.setColorBar(sendFitting.getColorBar());
- closedFittings.add(closedFitting);
- }
- customerCommon.setClosedProdcues(closedProdcues);
- customerCommon.setClosedFittings(closedFittings);
- }
- mv.addObject("customerCommon", customerCommon);
- if(customerInfo.getTypeId() == 1){
- customerInfo.setIsNeedSelectOrder(2); //不需要订单
- }else{
- customerInfo.setIsNeedSelectOrder(1);
- }
- /*查询所有的产品,颜色和配件信息*/
- // List<Product> productList = productService.listProduce(new Product());
- // for(Product product : productList){
- // ProductColor productColor = new ProductColor();
- // productColor.setColorProductId(product.getProductId());
- // List<ProductColor> productColorList = productService.listProduceColor(productColor);
- // product.setColorList(productColorList);
- //
- // FittingsInfo fittingsInfo = new FittingsInfo();
- // fittingsInfo.setProductId(product.getProductId());
- // List<FittingsInfo> fittingsInfoList = fittingsInfoService.listFittings(fittingsInfo);
- // product.setFittingsList(fittingsInfoList);
- // }
- // mv.addObject("productList", productList);
- if(customerInfo.getTypeId() != 1 && (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5 ||
- customerInfo.getCustomerIsSolve() == 6 || customerInfo.getCustomerIsSolve() == 7)){
- RelationOrder relationOrder = new RelationOrder();
- relationOrder.setRelationType(customerCommon.getCustomerIsSolve());
- relationOrder.setRelationId(customerCommon.getRelationId());
- List<RelationOrder> relationOrderList = relationOrderService.getRelationOrderList(relationOrder);
- String[] salesIds = new String[relationOrderList.size()];
- for (int k=0; k<relationOrderList.size();k++){
- salesIds[k] = String.valueOf(relationOrderList.get(k).getSalesId());
- }
- SalesOrder so = new SalesOrder();
- so.setSalesIds(salesIds);
- List<SalesOrder> orderList = salesOrderService.listSalesOrder(so);
- for (SalesOrder sor: orderList) {
- SalesOrderItem salesOrderItem = new SalesOrderItem();
- salesOrderItem.setItemOrderId(sor.getSalesId());
- List<SalesOrderItem> salesOrderItemList = salesOrderService.listSalesOrderItem(salesOrderItem);
- sor.setSalesOrderItemList(salesOrderItemList);
- }
- mv.addObject("salesOrderList", orderList);
- }else{
- mv.addObject("salesOrderList", null);
- }
- }
- if ("2".equals(customerInfo.getCustomerIsVisit())){ //1:不需要回访 2:需要回访
- Visit visit = new Visit();
- visit.setCustomerId(customerInfo.getCustomerId());
- visit = visitService.getVisit(visit);
- mv.addObject("visit", visit);
- }
- //查询关联问题
- ComplaintQuestionInfo complaintQuestionInfo = complaintQuestionInfoService.getQuestionById(customerInfo.getQuestionId());
- //查询问题小类
- ComplaintSmallClassInfo complaintSmallClassInfo = new ComplaintSmallClassInfo();
- complaintSmallClassInfo.setComplaintId(complaintQuestionInfo.getComplaintId());
- List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(complaintSmallClassInfo);
- //查询问题大类
- ComplaintTypeInfo complaintTypeInfo = new ComplaintTypeInfo();
- List<ComplaintTypeInfo> complaintTypeInfoList = complaintTypeInfoService.listComplaintTypeInfo(complaintTypeInfo);
- mv.addObject("customerInfo", customerInfo);
- mv.addObject("typeList", typeList);
- mv.addObject("complaintTypeList", complaintTypeList);
- mv.addObject("complaintTypeList", complaintTypeList);
- mv.addObject("adminList", adminList);
- mv.addObject("loginAdminId", loginAdminId);
- mv.addObject("complaintQuestionInfo", complaintQuestionInfo);
- mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
- mv.addObject("complaintTypeInfoList", complaintTypeInfoList);
- //mv.addObject("questionDescribe", questionDescribe);
- return mv;
- }
- /**
- * 查询问题描述
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/select_question_describe")
- public ResponseJson selectQuestionDescribe(HttpServletRequest request, Integer customerId) throws Exception {
- if(customerId == null || customerId == 0){
- return new ResponseJson(500, "未获取到问题描述", 500);
- }
- //查询问题描述表
- QuestionDescribe questionDescribe = new QuestionDescribe();
- questionDescribe.setCustomerId(customerId);
- questionDescribe = questionDescribeService.listQuestionDescribe(questionDescribe).get(0);
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("questionDescribe", questionDescribe);
- return rj;
- }
- /**
- * 查询问题描述
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/select_company")
- public ResponseJson getCompany(HttpServletRequest request) throws Exception {
- //获取销售公司
- List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("companyInfoList", companyInfoList);
- return rj;
- }
- /**
- * 搜索订单列表弹出框
- *
- * @return
- */
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/select_order")
- public ModelAndView selectOrder(HttpServletRequest request) {
- ModelAndView mv = new ModelAndView("cm/customer/order_list");
- //获取销售公司
- List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
- mv.addObject("companyInfoList", companyInfoList);
- return mv;
- }
- /**
- * 添加订单列表弹出框
- *
- * @return
- */
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/add_order")
- public ModelAndView addOder(HttpServletRequest request) {
- ModelAndView mv = new ModelAndView("cm/customer/order_add");
- return mv;
- }
- /**
- * 添加订单
- *
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/add_order_info")
- public ResponseJson addOrderInfo(HttpServletRequest request, SalesOrder salesOrder, String itemJson) throws Exception {
- List<SalesOrderItem> list = new ArrayList<>();
- JSONArray jsonArray = JSONArray.fromObject(itemJson);
- list = (List) JSONArray.toCollection(jsonArray, SalesOrderItem.class);
- Integer salesAmount = 0;
- for (int i = 0; i < list.size(); i++) {
- SalesOrderItem salesOrderItem = list.get(i);
- if (salesOrderItem.getItemIsSource() == 1) { //产品来源 1:产品颜色表,2:配件表
- Product product = productService.getProductById(salesOrderItem.getItemColorId());
- ProductColor productColor = productService.getProduceColor(salesOrderItem.getItemColorId());
- salesOrderItem.setItemProductType(product.getProductType());
- salesOrderItem.setItemProductName(product.getProductName());
- salesOrderItem.setItemProductPic(productColor.getColorPicture());
- salesOrderItem.setItemProductColor(productColor.getColorName());
- salesOrderItem.setItemColorBar(productColor.getColorBar());
- salesOrderItem.setItemProductPrice(productColor.getColorPrice());
- salesOrderItem.setItemProductDiscount(productColor.getColorDiscount());
- salesOrderItem.setItemIsSource(1);
- salesAmount += productColor.getColorDiscount();
- } else if (salesOrderItem.getItemIsSource() == 2) {
- Product product = productService.getProductByFittingsId(salesOrderItem.getItemColorId());
- FittingsInfo fittingsInfo = fittingsInfoService.getFittingsById(salesOrderItem.getItemColorId());
- salesOrderItem.setItemProductType(product.getProductType());
- salesOrderItem.setItemProductName(product.getProductName());
- salesOrderItem.setItemProductColor(fittingsInfo.getFittingsName());
- salesOrderItem.setItemColorBar(fittingsInfo.getFittingsBar());
- salesOrderItem.setItemProductPrice(fittingsInfo.getFittingsPrice());
- salesOrderItem.setItemProductDiscount(fittingsInfo.getFittingsDiscount());
- salesOrderItem.setItemIsSource(2);
- salesAmount += fittingsInfo.getFittingsDiscount();
- }
- }
- salesOrder.setSalesOpenId("0");
- salesOrder.setSalesAmount(salesAmount);
- salesOrder.setSalesPayMoney(salesAmount);
- salesOrder.setSalesOrderStatus(1);
- salesOrder.setSalesCreateTime(new Date());
- //salesOrder.setSalesPayTime(new Date());
- salesOrder.setSalesLastMoney(salesAmount);
- salesOrder.setSalesWaitMoney(0);
- salesOrder.setSalesPayMoney(salesAmount);
- salesOrder.setSalesSalesTime(new Date());
- salesOrder.setSalesDiscountMoney(salesAmount);
- salesOrder.setSalesPledgeMoney(0);
- salesOrder.setSalesRemainDeposit(0);
- salesOrder.setSalesType(1);
- salesOrder.setSalesStatus(1);//确认状态:0(未确认)1(确认)2(挂起)3(作废)
- salesOrder.setSalesShippingStatus(1); //发货状态: 0(未发货)1(已发货,即已扫描出库)3(备货中)*****+++
- salesOrder.setSalesPayStatus(2); //已付款
- salesOrder.setSalesProcessStatus(0); //单据状态:0(正常单)1(问题单)
- salesOrder.setSalesIsSend(0); //0:否 1:是 是否通知配货
- salesOrder.setSalesIsLocked(0); //是否锁定 0:否 1:是
- salesOrder.setSalesIsSeparate(0); //是否缺货 0:否 1:是
- salesOrder.setSalesShippingFee(0); //邮费
- Integer adminId = AdminUtils.getLoginAdminId();
- String orderCode = OrderNoUtil.createOrderCode(adminId);
- salesOrder.setSalesDealCode(orderCode);
- salesOrder.setSalesOrderId(orderCode);
- //salesOrder = salesOrderService.addOrderAndIteminfo(salesOrder,list);
- salesOrder.setSalesOrderItemList(list);
- try {
- Integer flag = customerService.addOrder(salesOrder);
- } catch (RuntimeException e) {
- return new ResponseJson(500, "添加订单失败--"+ e.getMessage(), 500);
- }
- Integer orderId = salesOrder.getSalesId();
- ResponseJson rj = new ResponseJson(200, "添加订单成功", 200);
- rj.addResponseKeyValue("orderId", orderId);
- return rj;
- }
- /**
- * 获取店铺集合
- *
- * @param request
- * @param storeInfo
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/select_storeInfo")
- public ResponseJson listStoreInfo(HttpServletRequest request, StoreInfo storeInfo) {
- storeInfo.setStoreStatus(1);
- List<StoreInfo> storeInfoList = storeInfoService.listStore(storeInfo);
- if (storeInfoList == null || storeInfoList.size() < 1) {
- return new ResponseJson(500, "查询失败", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("storeInfoList", storeInfoList);
- return rj;
- }
- }
- /**
- * 获取订单集合
- *
- * @param request
- * @param salesOrder
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping(value = "/select_salesOrder")
- public ResponseJson listOrder(HttpServletRequest request, SalesOrder salesOrder,String ids,
- @RequestParam(value = "pageSize", defaultValue = "20", required = false) Integer pageSize,
- @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
- @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
- if(ids!= null && ids.indexOf("_") > -1){
- String[] salesIds = ids.split("_");
- salesOrder.setSalesIds(salesIds);
- }
- //分页获取订单信息
- PagedResult<SalesOrder> pagedResult = salesOrderService.listSalesOrderPage(pageNO, pageSize, salesOrder, totalNum == 0);
- List<SalesOrder> salesOrderList = pagedResult.getDataList();
- for (SalesOrder order : salesOrderList) {
- SalesOrderItem salesOrderItem = new SalesOrderItem();
- salesOrderItem.setItemOrderId(order.getSalesId());
- List<SalesOrderItem> salesOrderItemList = salesOrderService.listSalesOrderItem(salesOrderItem);
- order.setSalesOrderItemList(salesOrderItemList);
- }
- if (salesOrderList == null || salesOrderList.size() < 1) {
- return new ResponseJson(500, "查询失败", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("salesOrderList", salesOrderList);
- return rj;
- }
- }
- /**
- * 分页查询客诉列表信息
- *
- * @param request
- * @param customerInfo
- * @param pageSize
- * @param pageNO
- * @param totalNum
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:select:customer")
- @RequestMapping("/select_customer_list")
- public ModelAndView selectCustomerList(HttpServletRequest request, CustomerInfo customerInfo,
- @RequestParam(value = "isFirst", defaultValue = "2", required = false) Integer isFirst,
- @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
- @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
- @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) throws Exception {
- long x = new Date().getTime();
- ModelAndView mv = new ModelAndView("cm/customer/custome_list");
- if(customerInfo.getAdminId() == null && isFirst == 1){
- //获取登录员工id
- Integer adminId = AdminUtils.getLoginAdminId();
- customerInfo.setAdminId(adminId);
- }
- PagedResult<CustomerInfo> pagedResult = customerService.listCustomer(pageNO, pageSize, customerInfo, totalNum == 0);
- if (totalNum != 0) {
- pagedResult.setTotal(totalNum);
- }
- ProductType productType = new ProductType();
- //查询产品类型集合
- List<ProductType> typeList = productService.listProductType(productType);
- //查询客诉类型集合
- List<ComplaintTypeInfo> complaintTypeList = complaintTypeInfoService.listComplaintTypeInfo(new ComplaintTypeInfo());
- //查询客诉类型集合
- List<ComplaintSmallClassInfo> complaintSmallClassInfoList = complaintSmallClassInfoService.listComplaintSmallClassInfo(new ComplaintSmallClassInfo());
- //查询问题集合 第 30 条bug
- // List<QuestionDescribe> questionDescribeList = questionDescribeService.listQuestionDescribe(new QuestionDescribe());
- //查询跟进客服集合
- Admin admin = new Admin();
- admin.setAdminDept(3);
- admin.setAdminStatus(1);
- List<Admin> adminList = sysService.listSelectAdmin(admin);
- //获取登录人id
- Integer loginAdminId = AdminUtils.getLoginAdminId();
- mv.addObject("complaintSmallClassInfoList", complaintSmallClassInfoList);
- mv.addObject("loginAdminId", loginAdminId);
- mv.addObject("typeList", typeList);
- mv.addObject("complaintTypeList", complaintTypeList);
- mv.addObject("adminList", adminList);
- customerInfo.setVisit(null);
- customerInfo.setCustomerCommon(null);
- customerInfo.setComplaintDetectList(null);
- StitchAttrUtil sa = StitchAttrUtil.getSa();
- sa.addDatePro("yyyy-MM-dd","startTime","endTime");
- sa.setModelAndView(customerInfo, mv, "/admin/customer/select_customer_list", pagedResult);
- long y = new Date().getTime();
- System.out.println("使用时间:"+(y-x));
- return mv;
- }
- /**
- * 进入客诉基本信息页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:select:customer")
- @RequestMapping("/_customer_info")
- public ModelAndView toCustomerInfo(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/custome_detail");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 查询客诉基本信息
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:select:customer")
- @RequestMapping("/get_customer_info")
- public ResponseJson getCustomerInfo(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- CustomerInfo customerInfo = new CustomerInfo();
- customerInfo.setCustomerId(Integer.parseInt(customerId));
- Map<String, Object> map = customerService.getCustomerInfo(customerInfo);
- ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
- rj.addResponseKeyValue("customerCommon", map.get("customerCommon"));
- rj.addResponseKeyValue("customer", map.get("customer"));
- rj.addResponseKeyValue("orderList", map.get("orderList"));
- return rj;
- }
- /**
- * 进入添加回访页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:select:customer")
- @RequestMapping("/_add_visit")
- public ModelAndView toAddVisit(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/add_visit");
- String customerId = request.getParameter("customerId");
- //查询跟进客服集合
- Admin admin = new Admin();
- admin.setAdminDept(3);
- admin.setAdminStatus(1);
- List<Admin> adminList = sysService.listSelectAdmin(admin);
- //获取登录人id
- Integer loginAdminId = AdminUtils.getLoginAdminId();
- mv.addObject("loginAdminId", loginAdminId);
- mv.addObject("customerId", customerId);
- mv.addObject("adminList", adminList);
- return mv;
- }
- /**
- * 添加回访信息
- *
- * @param request
- * @param visit
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:visit")
- @RequestMapping("/add_visit_info")
- public ResponseJson addVisitInfo(HttpServletRequest request, Visit visit) throws Exception {
- String visitAdminId = request.getParameter("visitAdminId");
- if (!StringUtils.isNotEmpty(visitAdminId)) {
- return new ResponseJson(500, "请选择回访人!", 500);
- }
- Integer loginAdminId = AdminUtils.getLoginAdminId();
- visit.setAdminId(loginAdminId);
- visit.setDesignatedAdminId(Integer.parseInt(visitAdminId));
- visit.setVisitStatus(1);
- visit.setVisitCreateTime(new Date());
- int num = visitService.addVisitInfo(visit, visit.getCustomerId());
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 修改客诉状态为已解决
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:update:customerIsSolve")
- @RequestMapping("/update_customerIsSolve")
- public ResponseJson updateCustomerIsSolve(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- //根据id获取客诉信息
- CustomerInfo customer = customerService.getCustomerInfo(Integer.parseInt(customerId));
- if (customer == null) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- if (customer.getCustomerIsSolve().intValue() != 2) {
- return new ResponseJson(500, "该客诉信息不能修改为已解决状态!", 500);
- }
- CustomerInfo customerInfo = new CustomerInfo();
- customerInfo.setCustomerId(Integer.parseInt(customerId));
- customerInfo.setCustomerIsSolve(1);
- //修改客诉信息
- int num = customerService.updateCustomerInfo(customerInfo);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 查询客服
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/select_sys_admin")
- public ResponseJson selectSysAdmin(HttpServletRequest request) throws Exception {
- ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
- Integer adminId = AdminUtils.getLoginAdminId();
- Admin admin = new Admin();
- admin.setAdminDept(3);
- admin.setAdminStatus(1);
- List<Admin> adminList = sysService.listSelectAdmin(admin);
- if (adminList.size() > 0) {
- rj.addResponseKeyValue("adminList", adminList);
- rj.addResponseKeyValue("adminId", adminId);
- return rj;
- } else {
- return new ResponseJson(500, "查询失败!", 500);
- }
- }
- /**
- * 查询产品类型
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/select_produce_type")
- public ResponseJson selectProduceType(HttpServletRequest request) throws Exception {
- ResponseJson rj = new ResponseJson(200, "修改成功!", 200);
- ProductType productType = new ProductType();
- productType.setTypeStatus(1);
- List<ProductType> productTypeList = productService.listProductType(productType);
- if (productTypeList != null && productTypeList.size() > 0) {
- rj.addResponseKeyValue("productTypeList", productTypeList);
- return rj;
- } else {
- return new ResponseJson(500, "查询失败!", 500);
- }
- }
- /**
- * 查询产品
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/select_produce")
- public ResponseJson selectProduce(HttpServletRequest request) {
- ResponseJson rj = new ResponseJson(200, "查询成功!", 200);
- Product product = new Product();
- List<Product> productList = productService.listProduce(product);
- for (Product pro : productList) {
- ProductColor productColor = new ProductColor();
- productColor.setColorProductId(pro.getProductId());
- List<ProductColor> productColorList = productService.listProduceColor(productColor);
- pro.setColorList(productColorList);
- }
- if (productList != null && productList.size() > 0) {
- rj.addResponseKeyValue("productList", productList);
- return rj;
- } else {
- return new ResponseJson(500, "查询失败!", 500);
- }
- }
- /**
- * 查询产品
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/select_produce_fittings")
- public ResponseJson selectProduceFittings(HttpServletRequest request, FittingsInfo fittingsInfo) {
- ResponseJson rj = new ResponseJson(200, "查询成功!", 200);
- List<FittingsInfo> produceFittingsList = fittingsInfoService.listFittings(fittingsInfo);
- if (produceFittingsList != null && produceFittingsList.size() > 0) {
- rj.addResponseKeyValue("produceFittingsList", produceFittingsList);
- return rj;
- } else {
- return new ResponseJson(500, "查询失败!", 500);
- }
- }
- /**
- * 添加客诉
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/save_customer")
- public ResponseJson addCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CustomerCommon customerCommon,
- String sendProdcuesJson, String sendFittingsJson, String closedProdcuesJson, String closedFittingsJson) throws Exception {
- ResponseJson rjx = this.isValiData(customerInfo);
- if(rjx.getResultCode() == 500){
- return rjx;
- }
- Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
- String phone = customerInfo.getCustomerTel(); //手机号码
- Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
- Integer flag = 0;
- if(customerInfo.getIsNeedSelectOrder() == 1){ ////1:需要有订单 2:不需要有订单
- JSONArray jsonArray;
- List<SendProdcue> sendProdcueList;
- List<SendFitting> sendFittingList;
- List<ClosedProdcue> closedProdcueList;
- List<ClosedFitting> closedFittingList;
- jsonArray = JSONArray.fromObject(sendProdcuesJson);
- sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
- jsonArray = JSONArray.fromObject(sendFittingsJson);
- sendFittingList = (List) JSONArray.toCollection(jsonArray, SendFitting.class);
- jsonArray = JSONArray.fromObject(closedProdcuesJson);
- closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
- jsonArray = JSONArray.fromObject(closedFittingsJson);
- closedFittingList = (List) JSONArray.toCollection(jsonArray, ClosedFitting.class);
- customerCommon.setSendProdcues(sendProdcueList);
- customerCommon.setSendFittings(sendFittingList);
- customerCommon.setClosedProdcues(closedProdcueList);
- customerCommon.setClosedFittings(closedFittingList);
- }
- customerInfo.setCustomerCommon(customerCommon);
- String orderId = "";
- if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
- Integer adminId = AdminUtils.getLoginAdminId();
- orderId = OrderNoUtil.createOrderCode(adminId);
- }
- customerInfo.setTransactionNumber(orderId);
- Integer customerId = customerInfo.getCustomerId();
- logger.info("-----------------添加客诉开始----------------------");
- try {
- flag = customerService.saveCustomerInfo(customerInfo, salesOrder);
- } catch (RuntimeException e) {
- e.printStackTrace();
- return new ResponseJson(500, e.getMessage(), 500);
- }catch (Exception e){
- e.printStackTrace();
- return new ResponseJson(500,"添加失败", 500);
- }
- customerId = customerInfo.getCustomerId();
- logger.info("-----------------添加客诉结束----------------------");
- if (flag < 1) {
- return new ResponseJson(500, "添加客诉失败!", 500);
- }
- String msg = "";
- //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
- if (customerIsSolve == 3 || customerIsSolve == 4 || customerIsSolve == 5 || customerIsSolve == 6 || customerIsSolve == 7) {
- String solveMsg = "";
- switch (customerIsSolve) {
- case 3:
- solveMsg = "为您更换新机";
- break;
- case 4:
- solveMsg = "为您维修机器";
- break;
- case 5:
- solveMsg = "为您补发产品";
- break;
- case 6:
- solveMsg = "为您办理退货";
- break;
- case 7:
- solveMsg = "为您办理退货";
- break;
- }
- String addCustomerSuccessMsg = "";
- String typeMsg = "";
- switch (typeCompany) {
- case 1:
- addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_WATERO;
- typeMsg = "美国WaterO售后";
- break;
- case 2:
- addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_SHANGDUO;
- typeMsg = "上朵售后";
- break;
- case 3:
- addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_YULIA;
- typeMsg = "YULIA售后";
- break;
- case 4:
- addCustomerSuccessMsg = SmsConfig.ADD_CUSTOMER_SUCCESS_AIBERLE;
- typeMsg = "爱贝源售后";
- break;
- }
- // Object [] msg = new Object[]{solveMsg,typeMsg};
- // String text = MessageFormat.format(addCustomerSuccessMsg, msg);
- // logger.info("添加客诉成功后,给 "+ phone +" 手机用户发送短信:" + text );
- // String result = smsService.sendOtherCMS(phone, text);
- //
- // if (!"SUCCESS".equals(result)) {
- // return new ResponseJson(505, "添加客诉发送短信失败,失败原因:" + result + "<br>客诉信息发送失败并不影响客诉添加。客诉编号为:"+ customerId, 505);
- // }
- msg = ",请前往Efast进行换货/退货操作。";
- }
- return new ResponseJson(200, "录入客诉成功!客诉编号:" + customerId + msg, 200);
- }
- /**
- * 修改客诉
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:update:customer")
- @RequestMapping("/update_customer")
- public ResponseJson updateCustomer(HttpServletRequest request, CustomerInfo customerInfo, SalesOrder salesOrder, CustomerCommon customerCommon,
- String sendProdcuesJson, String sendFittingsJson, String closedProdcuesJson, String closedFittingsJson) throws Exception {
- ResponseJson rjx = this.isValiData(customerInfo);
- if(rjx.getResultCode() == 500){
- return rjx;
- }
- Integer flag = 0;
- Integer customerIsSolve = customerInfo.getCustomerIsSolve(); //处理类型
- String phone = customerInfo.getCustomerTel(); //手机号码
- Integer typeCompany = customerInfo.getTypeCompany(); // 所属商城 1:美国watero; 2:上朵电动牙刷 3:优尼雅净水机
- if(customerInfo.getIsNeedSelectOrder() == 1){
- JSONArray jsonArray;
- List<SendProdcue> sendProdcueList;
- List<SendFitting> sendFittingList;
- List<ClosedProdcue> closedProdcueList;
- List<ClosedFitting> closedFittingList;
- jsonArray = JSONArray.fromObject(sendProdcuesJson);
- sendProdcueList = (List) JSONArray.toCollection(jsonArray, SendProdcue.class);
- jsonArray = JSONArray.fromObject(sendFittingsJson);
- sendFittingList = (List) JSONArray.toCollection(jsonArray, SendFitting.class);
- jsonArray = JSONArray.fromObject(closedProdcuesJson);
- closedProdcueList = (List) JSONArray.toCollection(jsonArray, ClosedProdcue.class);
- jsonArray = JSONArray.fromObject(closedFittingsJson);
- closedFittingList = (List) JSONArray.toCollection(jsonArray, ClosedFitting.class);
- customerCommon.setSendProdcues(sendProdcueList);
- customerCommon.setSendFittings(sendFittingList);
- customerCommon.setClosedProdcues(closedProdcueList);
- customerCommon.setClosedFittings(closedFittingList);
- }
- customerInfo.setCustomerCommon(customerCommon);
- String orderId = "";
- if (customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5) {
- Integer adminId = AdminUtils.getLoginAdminId();
- orderId = OrderNoUtil.createOrderCode(adminId);
- }
- customerInfo.setTransactionNumber(orderId);
- Integer customerId = customerInfo.getCustomerId();
- logger.info("-----------------修改客诉开始----------------------");
- try {
- flag = customerService.updateCustomerInfo(customerInfo, salesOrder);
- } catch (RuntimeException e) {
- e.printStackTrace();
- return new ResponseJson(500, e.getMessage(), 500);
- }catch (Exception e){
- e.printStackTrace();
- return new ResponseJson(500,"修改失败", 500);
- }
- customerId = customerInfo.getCustomerId();
- logger.info("-----------------修改客诉结束----------------------");
- if (flag < 1) {
- return new ResponseJson(500, "修改客诉失败!", 500);
- }
- return new ResponseJson(200, "修改客诉成功!客诉编号为:" + customerId, 200);
- }
- /**
- * 验证方法
- *
- * @param customerInfo
- * @return
- */
- public ResponseJson isValiData(CustomerInfo customerInfo) {
- ResponseJson rj = new ResponseJson();
- if(customerInfo.getAdminId() == null){
- return new ResponseJson(500, "未填写客诉id", 500);
- }
- return rj;
- }
- /**
- * 发送短信
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:add:customer")
- @RequestMapping("/send_phone_sms")
- public ResponseJson sendPhoneSms(HttpServletRequest request, String type, String phone, Integer typeCompany, ComplaintQuestionInfo complaintQuestionInfo) throws Exception {
- String url = NameUtils.getConfig("website");
- Integer flag = 1;
- if (typeCompany == null || typeCompany == 0) {
- return new ResponseJson(500, "未获取到产品类型!", 500);
- }
- String con = "";
- if (type != null && !"".equals(type)) {
- if ("p".equals(type)) { //problem" 问题处理; mailAddress:邮寄地址;
- if (complaintQuestionInfo.getQuestionId() == null || "".equals(complaintQuestionInfo.getQuestionId())) {
- complaintQuestionInfo.setQuestionState(1);
- complaintQuestionInfo.setQuestionIsQcDetect(0);
- complaintQuestionInfo = complaintQuestionInfoService.insertBackInfo(complaintQuestionInfo);
- } else {
- complaintQuestionInfo.setSmallClassId(null); //不能修改小类类型
- flag = complaintQuestionInfoService.updateQuestionById(complaintQuestionInfo);
- if (flag < 1) {
- return new ResponseJson(500, "问题修改失败!", 500);
- }
- }
- url += "/" + complaintQuestionInfo.getQuestionId()+"/"+typeCompany;
- switch (typeCompany) {
- case 1:
- con = SmsConfig.SEND_PRODUCT_SEND_WATERO;
- break;
- case 2:
- con = SmsConfig.SEND_PRODUCT_SEND_SHANGDUO;
- break;
- case 3:
- con = SmsConfig.SEND_PRODUCT_SEND_YULIA;
- break;
- case 4:
- con = SmsConfig.SEND_PRODUCT_SEND_AIBERLE;
- break;
- }
- } else if ("m".equals(type)) {
- if (complaintQuestionInfo.getQuestionId() == null) {
- return new ResponseJson(500, "未获取到邮寄信息!", 500);
- }
- complaintQuestionInfo.setQuestionName(null);
- complaintQuestionInfo.setSmallClassId(null);
- url += "/5";
- switch (typeCompany) {
- case 1:
- con = SmsConfig.SEND_PRODUCT_SMS_WATERO;
- break;
- case 2:
- con = SmsConfig.SEND_PRODUCT_SMS_SHANGDUO;
- break;
- case 3:
- con = SmsConfig.SEND_PRODUCT_SMS_YULIA;
- break;
- case 4:
- con = SmsConfig.SEND_PRODUCT_SMS_AIBERLE;
- break;
- }
- }
- }
- String userPhone = encodePhoneNumber(phone);
- String text = MessageFormat.format(con, url);
- logger.info("给 " + phone + " 手机用户发送短信:" + text);
- String result = smsService.sendOtherCMS(phone, text);
- if ("SUCCESS".equals(result)) {
- return new ResponseJson(200, "发送短信成功!", 200);
- } else {
- return new ResponseJson(500, "发送短信失败,失败原因:" + result, 500);
- }
- }
- String encodePhoneNumber(String number)
- {
- int encnum = Integer.parseInt(number.substring(2));
- int prefix = (number.charAt(1) - '2') /2; // '3'=>0, '5'=>1, '[67]'=>2, '8'=>3
- encnum |= (prefix <<= 30);
- final byte[] raw = new byte[4];
- raw[0] = (byte)(encnum >>> 24);
- raw[1] = (byte)(encnum >>> 16);
- raw[2] = (byte)(encnum >>> 8);
- raw[3] = (byte) encnum;
- return Base64.encodeBase64URLSafeString(raw);
- }
- /**
- * 进入回访完成页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:visit")
- @RequestMapping("/_update_visit_info")
- public ModelAndView toUpdateVisitFinish(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/visit_finish");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 添加回访完成内容
- *
- * @param request
- * @param visit
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:update:visit")
- @RequestMapping("/update_visit_finish")
- public ResponseJson updateVisitFinish(HttpServletRequest request, Visit visit) throws Exception {
- String customerId = request.getParameter("finish_customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- visit.setCustomerId(Integer.parseInt(customerId));
- visit.setVisitStatus(2);
- //修改回访信息内容
- int num = visitService.updateVisit(visit);
- if (num > 0) {
- return new ResponseJson(200, "添加成功!", 200);
- } else {
- return new ResponseJson(500, "添加失败!", 500);
- }
- }
- /**
- * 进入回访信息详情
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:get:visit")
- @RequestMapping("/_visit_info")
- public ModelAndView toVisitInfo(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/visit_detail");
- String customerId = request.getParameter("customerId");
- // 1:未回访,2:已回访
- String num = request.getParameter("num");
- if (!StringUtils.isNotEmpty(num)) {
- num = "2";
- }
- mv.addObject("customerId", customerId);
- mv.addObject("num", num);
- return mv;
- }
- /**
- * 获取回访信息详情
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:get:visit")
- @RequestMapping("/get_visit_info")
- public ResponseJson getVisitInfo(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- Visit visit = new Visit();
- visit.setCustomerId(Integer.parseInt(customerId));
- //查询回访信息集合
- List<Visit> visitList = visitService.listVisit(visit);
- if (visitList == null || visitList.size() == 0) {
- return new ResponseJson(500, "该客诉没有回访信息!", 500);
- }
- visit = visitList.get(0);
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("visit", visit);
- return rj;
- }
- /**
- * 进入问题描述页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:get:describe")
- @RequestMapping("/_question_describe")
- public ModelAndView toQuestionDescribe(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/describe_detail");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 获取问题描述信息
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:get:describe")
- @RequestMapping("/get_describe_info")
- public ResponseJson getDescribeInfo(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- QuestionDescribe describe = new QuestionDescribe();
- describe.setCustomerId(Integer.parseInt(customerId));
- //查询问题集合
- List<QuestionDescribe> questionList = questionDescribeService.listQuestionDescribe(describe);
- if (questionList == null || questionList.size() == 0) {
- return new ResponseJson(500, "该客诉信息没有问题描述!", 500);
- }
- describe = questionList.get(0);
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("describe", describe);
- return rj;
- }
- /**
- * 进入修改换新页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:renewed")
- @RequestMapping("/_update_renewed")
- public ModelAndView toUpdateRenewed(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/update_renewed");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 获取换新详情
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:get:renewed")
- @RequestMapping("/get_renewed_info")
- public ResponseJson getRenewedInfo(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- Renewed renewed = new Renewed();
- renewed.setCustomerId(Integer.parseInt(customerId));
- renewed.setRenewedState(1);
- //获取换新详情和检测信息
- renewed = customerService.getRenewedInfo(renewed);
- if (renewed == null) {
- return new ResponseJson(500, "该客诉没有换新信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("renewed", renewed);
- return rj;
- }
- }
- /**
- * 修改换新信息
- *
- * @param request
- * @param renewed
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:renewed")
- @RequestMapping("/update_renewed_info")
- public ResponseJson updateRenewedInfo(HttpServletRequest request, Renewed renewed) throws Exception {
- /*String closedProducts = request.getParameter("closed_products");
- String closedFittings = request.getParameter("closed_fittings");*/
- String mergeAddress = request.getParameter("merge_address");
- if (!StringUtils.isNotEmpty(renewed.getRenewedId().toString())) {
- return new ResponseJson(500, "该换新信息不能修改!", 500);
- }
- // if (StringUtils.isNotEmpty(renewed.getRenewedBackPostage().toString())) {
- // renewed.setRenewedBackPostage(renewed.getRenewedBackPostage().intValue() * 100);
- // }
- /*if (!StringUtils.isNotEmpty(renewed.getRenewedBackEfastOrderId())) {
- return new ResponseJson(500, "请输入efast订单号!", 500);
- }*/
- if (StringUtils.isNotEmpty(mergeAddress)) {
- renewed.setRenewedSendMergeAddress(mergeAddress);
- }
- if(renewed.getRenewedBackStatus() != null){
- if(renewed.getRenewedBackStatus() != 1){
- ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
- cs.setSignclosedCustomerId(renewed.getCustomerId());
- cs.setSignclosedLogistics(renewed.getRenewedBackLogisticsCompany());
- cs.setSignclosedLogisticsNumber(renewed.getRenewedBackLogisticsNo());
- complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
- }
- }
- //修改换新信息
- int num = renewedService.updateRenewedInfo(renewed, null, null);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 进入修改维修页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:repair")
- @RequestMapping("/_to_update_repair")
- public ModelAndView toUpdateRepair(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/update_repair");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 进入修改维修页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:repair")
- @RequestMapping("/_update_repair")
- public ResponseJson updateRepairUI(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- Repair repair = new Repair();
- repair.setCustomerId(Integer.parseInt(customerId));
- repair.setRepairState(1);
- //获取维修详情和品质检测信息
- repair = customerService.getRepairInfo(repair);
- if (repair == null) {
- return new ResponseJson(500, "该客诉没有维修信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("repair", repair);
- return rj;
- }
- }
- /**
- * 修改维修处理信息
- *
- * @param request
- * @param repair
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:repair")
- @RequestMapping("/update_repair_info")
- public ResponseJson updateRepairInfo(HttpServletRequest request, Repair repair) throws Exception {
- if (!StringUtils.isNotEmpty(repair.getRepairId().toString())) {
- return new ResponseJson(500, "该换新信息不能修改!", 500);
- }
- /* String closedProducts = request.getParameter("closed_products");
- String closedFittings = request.getParameter("closed_fittings");*/
- String provinceNumber = request.getParameter("repairProvinceNumber");
- String cityNumber = request.getParameter("repairCityNumber");
- String areaNumber = request.getParameter("repairAreaNumber");
- String mergeAddress = request.getParameter("merge_address");
- if (StringUtils.isNotEmpty(provinceNumber)) {
- repair.setProvinceNumber(Integer.parseInt(provinceNumber));
- }
- if (StringUtils.isNotEmpty(cityNumber)) {
- repair.setCityNumber(Integer.parseInt(cityNumber));
- }
- if (StringUtils.isNotEmpty(areaNumber)) {
- repair.setAreaNumber(Integer.parseInt(areaNumber));
- }
- if (StringUtils.isNotEmpty(mergeAddress)) {
- repair.setRepairSendMergeAddress(mergeAddress);
- }
- // if (StringUtils.isNotEmpty(repair.getRepairBackPostage().toString())) {
- // repair.setRepairBackPostage(repair.getRepairBackPostage().intValue() * 100);
- // }
- /*if (!StringUtils.isNotEmpty(repair.getRepairBackEfastOrderId())) {
- return new ResponseJson(500, "请输入efast订单号!", 500);
- }*/
- if (StringUtils.isNotEmpty(mergeAddress)) {
- repair.setRepairSendMergeAddress(mergeAddress);
- }
- /*SalesOrder order = new SalesOrder();
- order.setSalesOrderStatus(1);
- order.setSalesOrderId(repair.getRepairBackEfastOrderId());
- int count = salesOrderService.getOrderInfoCount(order);
- //判断efast订单是否可查出有效数据
- if (count == 0) {
- return new ResponseJson(500, "该efast订单号无效,请重新输入!", 500);
- }*/
- if(repair.getRepairBackStatus() != null){
- if(repair.getRepairBackStatus() != 1){
- ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
- cs.setSignclosedCustomerId(repair.getCustomerId());
- cs.setSignclosedLogistics(repair.getRepairBackLogisticsCompany());
- cs.setSignclosedLogisticsNumber(repair.getRepairBackLogisticsNo());
- complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
- }
- }
- //修改维修信息
- int num = repairService.updateRepairInfo(repair, null, null);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 进入修改退货页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:backGoods")
- @RequestMapping("/_to_update_book_goods")
- public ModelAndView toUpdateBookGoods(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/update_back_goods");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 进入修改售后退货页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:backGoods")
- @RequestMapping("/_update_back_goods")
- public ResponseJson updateBackGoodsUI(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- BackGoods backGoods = new BackGoods();
- backGoods.setCustomerId(Integer.parseInt(customerId));
- //获取售后退货信息
- backGoods = customerService.getBackGoods(backGoods);
- if (backGoods == null) {
- return new ResponseJson(500, "该客诉没有售后退货信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("backGoods", backGoods);
- return rj;
- }
- }
- /**
- * 修改售后退货信息
- *
- * @param request
- * @param backGoods
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:backGoods")
- @RequestMapping("/update_back_goods")
- public ResponseJson updateBackGoods(HttpServletRequest request, BackGoods backGoods) throws Exception {
- String closedProducts = request.getParameter("closed_products");
- String closedFittings = request.getParameter("closed_fittings");
- if (!StringUtils.isNotEmpty(backGoods.getBackGoodsId().toString())) {
- return new ResponseJson(500, "该售后退货信息不能修改!", 500);
- }
- // if (StringUtils.isNotEmpty(backGoods.getBackGoodsBackPostage().toString())) {
- // backGoods.setBackGoodsBackPostage(backGoods.getBackGoodsBackPostage().intValue() * 100);
- // }
- // if(backGoods.getBackGoodsBackStatus() != 1){
- // ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
- // cs.setSignclosedCustomerId(backGoods.getCustomerId());
- // cs.setSignclosedLogistics(backGoods.getBackGoodsBackLogisticsCompany());
- // cs.setSignclosedLogisticsNumber(backGoods.getBackGoodsBackLogisticsNo());
- // complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
- // }
- int num = backGoodsService.updateBackGoods(backGoods, closedProducts, closedFittings);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 进入修改补寄页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:reissue")
- @RequestMapping("/_to_update_reissue")
- public ModelAndView toUpdateReissue(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/update_reissue");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 进入修改补寄信息页面
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:update:reissue")
- @RequestMapping("/get_reissue_info")
- public ResponseJson getReissueInfo(HttpServletRequest request) {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- Reissue reissue = new Reissue();
- reissue.setCustomerId(Integer.parseInt(customerId));
- //获取售后补寄信息
- reissue = customerService.getReissue(reissue);
- if (reissue == null) {
- return new ResponseJson(500, "该客诉没有售后退货信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("reissue", reissue);
- return rj;
- }
- }
- /**
- * 修改售后补寄信息
- *
- * @param request
- * @param reissue
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:reissue")
- @RequestMapping("/update_reissue_info")
- public ResponseJson updateReissueInfo(HttpServletRequest request, Reissue reissue) throws Exception {
- String provinceNumber = request.getParameter("reissueProvinceNumber");
- String cityNumber = request.getParameter("reissueCityNumber");
- String areaNumber = request.getParameter("reissueAreaNumber");
- String mergeAddress = request.getParameter("merge_address");
- if (!StringUtils.isNotEmpty(reissue.getReissueId().toString())) {
- return new ResponseJson(500, "该售后补寄信息不能修改!", 500);
- }
- if (StringUtils.isNotEmpty(provinceNumber)) {
- reissue.setProvinceNumber(Integer.parseInt(provinceNumber));
- }
- if (StringUtils.isNotEmpty(cityNumber)) {
- reissue.setCityNumber(Integer.parseInt(cityNumber));
- }
- if (StringUtils.isNotEmpty(areaNumber)) {
- reissue.setAreaNumber(Integer.parseInt(areaNumber));
- }
- if (StringUtils.isNotEmpty(mergeAddress)) {
- reissue.setReissueSendMergeAddress(mergeAddress);
- }
- //修改售后补寄信息
- int num = reissueService.updateReissueInfo(reissue);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 进入修改退货页面
- *
- * @param request
- * @return
- * @throws Exception
- */
- @RequiresPermissions("customer:update:noreason")
- @RequestMapping("/_update_noreason_back")
- public ModelAndView toUpdateNoreasonBack(HttpServletRequest request) throws Exception {
- ModelAndView mv = new ModelAndView("cm/customer/update_noreason_back");
- String customerId = request.getParameter("customerId");
- mv.addObject("customerId", customerId);
- return mv;
- }
- /**
- * 获取无理由退货信息
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:noreason")
- @RequestMapping("/get_noreason_back")
- public ResponseJson getNoreasonBack(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "该客诉信息不存在!", 500);
- }
- NoreasonBack noreasonBack = new NoreasonBack();
- noreasonBack.setCustomerId(Integer.parseInt(customerId));
- noreasonBack.setNoreasonBackState(1);
- //获取无理由退货信息
- noreasonBack = customerService.getNoreasonBack(noreasonBack);
- if (noreasonBack == null) {
- return new ResponseJson(500, "该客诉没有无理由售后退货信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("noreasonBack", noreasonBack);
- return rj;
- }
- }
- /**
- * 修改售后无理由退货信息
- *
- * @param request
- * @param noreasonBack
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequiresPermissions("customer:update:noreason")
- @RequestMapping("/update_noreason")
- public ResponseJson updateNoreason(HttpServletRequest request, NoreasonBack noreasonBack) throws Exception {
- String closedProducts = request.getParameter("closed_products");
- String closedFittings = request.getParameter("closed_fittings");
- if (!StringUtils.isNotEmpty(noreasonBack.getNoreasonBackId().toString())) {
- return new ResponseJson(500, "该售后无理由退货信息不能修改!", 500);
- }
- // if (StringUtils.isNotEmpty(noreasonBack.getNoreasonBackBackPostage().toString())) {
- // noreasonBack.setNoreasonBackBackPostage(noreasonBack.getNoreasonBackBackPostage().intValue() * 100);
- // }
- // if(noreasonBack.getNoreasonBackBackStatus() != 1){
- // ComplaintSignclosedInfo cs = new ComplaintSignclosedInfo();
- // cs.setSignclosedCustomerId(noreasonBack.getCustomerId());
- // cs.setSignclosedLogistics(noreasonBack.getNoreasonBackBackLogisticsCompany());
- // cs.setSignclosedLogisticsNumber(noreasonBack.getNoreasonBackBackLogisticsNo());
- // complaintSignclosedInfoService.updateSignclosedByCustomerId(cs);
- // }
- int num = noreasonBackService.updateNoreasonBack(noreasonBack, closedProducts, closedFittings);
- if (num > 0) {
- return new ResponseJson(200, "修改成功!", 200);
- } else {
- return new ResponseJson(500, "修改失败!", 500);
- }
- }
- /**
- * 查询未解决客诉数量
- */
- @ResponseBody
- @RequestMapping(value = "/selectNumberBacklog")
- public ResultMsg selectTodo(HttpServletRequest request){
- ResultMsg msg = new ResultMsg();
- CustomerInfo customerInfo = new CustomerInfo();
- //获取登录员工id
- Admin admin = AdminUtils.getLoginAdmin();
- customerInfo.setAdminId(admin.getAdminId());
- customerInfo.setCustomerIsSolve(2);
- //未解决客诉数量
- Integer notSolvedCustomer = customerService.selectNotSolvedCustomer(customerInfo);
- //需要向工厂确认所有已签收的产品数量
- CustomerCommon customerCommon = new CustomerCommon();
- customerCommon.setAdminId(admin.getAdminId());
- customerCommon.setRelationBackStatus(4);
- Integer amountReceivedCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
- //需要填写Efast订单号的客诉数量
- customerCommon.setRelationBackStatus(3);
- Integer noEntryCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
- //客诉录入后,三天后未寄回的客诉数量
- customerCommon.setRelationBackStatus(1);
- customerCommon.setRelationCreateTime(new Date());
- Integer notSendCustomer = customerCommonService.listCustomerCommonByStatus(customerCommon);
- Map<String,Integer> numberMap = new HashMap<>();
- numberMap.put("notSolvedCustomer",notSolvedCustomer);
- numberMap.put("amountReceivedCustomer",amountReceivedCustomer);
- numberMap.put("noEntryCustomer",noEntryCustomer);
- numberMap.put("notSendCustomer",notSendCustomer);
- numberMap.put("adminDept",admin.getAdminDept());
- msg.setResultCode(ResultInfo.SUCCESSCODE);
- msg.setStatus(true);
- msg.setData(numberMap);
- return msg;
- }
- /**
- * 根据微信昵称/姓名/电话查询客诉
- *
- * @param request
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:list:customer")
- @RequestMapping("/get_custoner_info")
- public ResponseJson getCustonerInfo(HttpServletRequest request,CustomerCommon customerCommon) throws Exception {
- if (customerCommon == null) {
- return new ResponseJson(500, "参数错误!", 500);
- }
- List<CustomerCommon> customerCommonList = customerCommonService.listCustomerCommon(customerCommon);
- if(customerCommonList.size() < 1){
- return new ResponseJson(500, "不存在相关客诉信息!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("customer", customerCommonList.get(0));
- return rj;
- }
- }
- /**
- * 申请邮费
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:applyPostage:customer")
- @RequestMapping(value = "/apply_postage")
- public ResponseJson applyPostage(HttpServletRequest request, Integer customerId) throws Exception {
- CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
- if(customerInfo == null){
- return new ResponseJson(500, "未获取到客诉", 500);
- }
- CustomerCommon customerCommon = new CustomerCommon();
- customerCommon.setCustomerId(customerId);
- List<CustomerCommon> customerCommonList = customerCommonService.listCustomerCommon(customerCommon);
- customerCommon = customerCommonList.get(0);
- if(customerCommon.getRelationBackStatus() == 1){ //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
- return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
- }
- if(customerCommon.getRelationBackStatus() == 2){ //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
- return new ResponseJson(500, "产品正在寄回中!", 500);
- }
- if(customerCommon.getRelationIsTransfer() == 0){ //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
- return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
- }
- if(customerCommon.getRelationBackPostage() == null || customerCommon.getRelationBackPostage() == 0 //relationBackPostage
- || customerCommon.getRelationAlipay() == null || customerCommon.getRelationAlipayName() == null ){
- return new ResponseJson(500, "请填写邮费信息", 500);
- }
- if(customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0 ){
- return new ResponseJson(500, "未正确选择销售公司", 500);
- }
- Postage age = new Postage();
- age.setCustomerId(customerInfo.getCustomerId()); //客诉id
- List<Postage> postageList = postageService.listPostage(age);
- if(postageList != null && postageList.size() > 0){
- return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
- }
- ResponseJson rj = new ResponseJson(200, "可以申请邮费", 200);
- rj.addResponseKeyValue("customerCommon",customerCommon);
- rj.addResponseKeyValue("customerInfo",customerInfo);
- return rj;
- }
- /**
- * 申请邮费
- * @return
- */
- @ResponseBody
- @RequiresPermissions("customer:applyPostage:customer")
- @RequestMapping(value = "/add_postage")
- public ResponseJson addPostage(HttpServletRequest request, Integer customerId,String postageLogisticsImg) throws Exception {
- CustomerInfo customerInfo = customerService.getCustomerInfo(customerId);
- if(customerInfo == null){
- return new ResponseJson(500, "未获取到客诉", 500);
- }
- CustomerCommon customerCommon = new CustomerCommon();
- customerCommon.setCustomerId(customerId);
- List<CustomerCommon> customerCommonList = customerCommonService.listCustomerCommon(customerCommon);
- customerCommon = customerCommonList.get(0);
- if(customerCommon.getRelationBackStatus() == 1){ //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
- return new ResponseJson(500, "请修改寄回状态,并填写寄回信息", 500);
- }
- if(customerCommon.getRelationBackStatus() == 2){ //1:未寄回 2:已寄回 3:已收货 4:已签收待确认
- return new ResponseJson(500, "产品正在寄回中!", 500);
- }
- if(customerCommon.getRelationIsTransfer() == 0){ //relationIsTransfer 是否需要转账邮费 0:不需要 10:需要转账
- return new ResponseJson(500, "请修改邮费转账状态,并填写邮费信息", 500);
- }
- if(customerCommon.getRelationBackPostage() == null || customerCommon.getRelationBackPostage() == 0 //relationBackPostage
- || customerCommon.getRelationAlipay() == null || customerCommon.getRelationAlipayName() == null ){
- return new ResponseJson(500, "请填写邮费信息", 500);
- }
- if(customerInfo.getCompanyId() == null || customerInfo.getCompanyId() == 0 ){
- return new ResponseJson(500, "未正确选择销售公司", 500);
- }
- Postage age = new Postage();
- age.setCustomerId(customerInfo.getCustomerId()); //客诉id
- List<Postage> postageList = postageService.listPostage(age);
- if(postageList != null && postageList.size() > 0){
- return new ResponseJson(500, "该条客诉已在申请邮费中了", 500);
- }
- String orderId = "";
- for (SalesOrder salesOrder : customerCommon.getSalesOrderList()){
- if("".equals(orderId)){
- orderId = salesOrder.getSalesOrderId();
- }else{
- orderId += ","+salesOrder.getSalesOrderId();
- }
- }
- Integer flag = 0;
- Postage postage = new Postage();
- postage.setCompanyId(customerInfo.getCompanyId()); //销售公司
- postage.setAdminId(customerInfo.getAdminId()); //客服
- postage.setCustomerId(customerInfo.getCustomerId()); //客诉id
- postage.setPostageCustomerStatus(2); //------考虑手动点, 直接变为申请中
- postage.setPostageManagerStatus(1); //------考虑手动点, 直接变为申请中
- postage.setPostageOrderSource(customerInfo.getStoreId()); //店铺id
- postage.setPostageTreatmentMethod(customerCommon.getCustomerIsSolve()); //处理方式
- postage.setSalesOrderId(orderId); //efast订单号
- postage.setPostageClientName(customerCommon.getRelationBackName());
- postage.setPostageClientTel(customerCommon.getRelationBackTel());
- postage.setPostageClientAddress(customerCommon.getRelationSendAddress());
- postage.setPostageLogisticsCompany(customerCommon.getRelationBackLogisticsCompany());
- postage.setPostageLogisticsNo(customerCommon.getRelationBackLogisticsNo());
- postage.setPostageAmount(customerCommon.getRelationBackPostage()); //寄回邮费
- postage.setPostageAlipay(customerCommon.getRelationAlipay()); //支付宝账户
- postage.setPostageAlipayName(customerCommon.getRelationAlipayName()); //支付宝账号名称
- postage.setPostageLogisticsImg(postageLogisticsImg);
- flag = postageService.savePostage(postage);
- if(flag < 1){
- return new ResponseJson(500, "申请失败", 500);
- }
- ResponseJson rj = new ResponseJson(200, "申请成功,请前往邮费转账列表查看", 200);
- return rj;
- }
- /**
- * 根据客诉id查询产品类型
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/getProductType")
- public ResponseJson getProductType(HttpServletRequest request) throws Exception {
- String customerId = request.getParameter("customerId");
- if (!StringUtils.isNotEmpty(customerId)) {
- return new ResponseJson(500, "查询产品类型失败!", 500);
- }
- //查询客诉产品类型
- ProductType productType = productService.getProductType(Integer.valueOf(customerId));
- if (productType == null) {
- return new ResponseJson(500, "未找到产品类型!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("productType", productType);
- return rj;
- }
- }
- /**
- * 根据客户信息查询旧的客诉信息
- *
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/selectOnCustomer")
- public ResponseJson listOnCustomer(HttpServletRequest request,CustomerInfo customerInfo) throws Exception {
- if (customerInfo == null) {
- return new ResponseJson(500, "查询客诉失败!", 500);
- }
- List<CustomerInfo> onCustomerList = customerService.listOnCustomer(customerInfo);
- if (onCustomerList.size() == 0) {
- return new ResponseJson(500, "未找到客诉!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("onCustomerList", onCustomerList);
- return rj;
- }
- }
- /**
- * 根据efast订单号查询efast订单物流信息
- * @param request
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/getefastOrder")
- public ResponseJson getEfastOrderInfo(HttpServletRequest request,String efastOrderId) throws Exception {
- if (efastOrderId == null) {
- return new ResponseJson(500, "查询失败!", 500);
- }
- JSONObject orderInfo = efastOrderService.getOrderFormEfastByOrderId(efastOrderId);
- if (orderInfo == null) {
- return new ResponseJson(500, "查询失败!", 500);
- } else if (!orderInfo.has("orders")) {
- return new ResponseJson(500, "查询失败!", 500);
- } else {
- ResponseJson rj = new ResponseJson(200, "查询成功", 200);
- rj.addResponseKeyValue("orderInfo", orderInfo.toString());
- return rj;
- }
- }
- /**
- * 下载客诉信息 (2018-05-29)
- * @param request
- * @param res
- * @param
- * @throws Exception
- */
- @RequestMapping("/download_customer_excel")
- public void downloadEfastOrderExcel(HttpServletRequest request,HttpServletResponse res) throws Exception{
- List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer();
- String[] cells = {
- "日期","姓名","联系电话","类别","来源入口",
- "问题类别","小类名称","客诉问题","处理过程","购买日期",
- "处理结果","销售公司","销售渠道","产品型号","产品颜色",
- "产品数量","寄回快递","寄回单号","签收日期",
- "状态","寄出快递","寄出快递","开箱损","二次客诉"
- };
- //导出订单Excel并下载
- customerExcel(request,res,cells,customerList);
- }
- /**
- * 导出订单Excel并下载
- * @param request
- * @param res
- * @param cells
- * @throws Exception
- */
- public void customerExcel(HttpServletRequest request,HttpServletResponse res,
- String[] cells,List<CustomerStatisticalInfo> customerList) throws Exception {
- //创建一个workbook,对应一个Excel文件
- HSSFWorkbook wb = new HSSFWorkbook();
- //在workbook中添加一个sheet,对应Excel中的一个sheet
- HSSFSheet sheet = wb.createSheet("导出订单");
- //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
- HSSFRow row = sheet.createRow((int) 0);
- //创建单元格,设置值表头,设置表头居中
- HSSFCellStyle style = wb.createCellStyle();
- //居中格式
- style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- //设置表头
- if (cells == null || cells.length == 0) {
- return;
- }
- //循环设置表头
- HSSFCell cell = null;
- for (int i = 0;i < cells.length;i++) {
- String name = cells[i];
- cell = row.createCell(i);
- cell.setCellValue(name);
- cell.setCellStyle(style);
- }
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- for (int i = 0; i < customerList.size(); i++) {
- row = sheet.createRow((int) i + 1);
- CustomerStatisticalInfo customerStatisticalInfo = customerList.get(i);
- String createTime = "";
- if(customerStatisticalInfo.getCreateTime() != null){
- createTime = format.format(customerStatisticalInfo.getCreateTime());
- }
- String salesPayTime = "";
- if(customerStatisticalInfo.getSalesPayTime() != null ){
- salesPayTime = format.format(customerStatisticalInfo.getSalesPayTime());
- }
- // 创建单元格,设置值
- row.createCell(0).setCellValue(createTime);
- row.createCell(1).setCellValue(customerStatisticalInfo.getCustomerName() == null ? null : customerStatisticalInfo.getCustomerName());
- row.createCell(2).setCellValue(customerStatisticalInfo.getCustomerTel() == null ? null : customerStatisticalInfo.getCustomerTel());
- row.createCell(3).setCellValue(customerStatisticalInfo.getCounselType() == null ? null : customerStatisticalInfo.getCounselType());
- row.createCell(4).setCellValue(customerStatisticalInfo.getSourceType() == null ? null : customerStatisticalInfo.getSourceType());
- row.createCell(5).setCellValue(customerStatisticalInfo.getComplaintClassName() == null ? null : customerStatisticalInfo.getComplaintClassName());
- row.createCell(6).setCellValue(customerStatisticalInfo.getSmallClassName() == null ? null : customerStatisticalInfo.getSmallClassName());
- row.createCell(7).setCellValue(customerStatisticalInfo.getDescribeTitle() == null ? null : customerStatisticalInfo.getDescribeTitle());
- row.createCell(8).setCellValue(customerStatisticalInfo.getDescribeHandleDesc() == null ? null : customerStatisticalInfo.getDescribeHandleDesc());
- row.createCell(9).setCellValue(customerStatisticalInfo.getCustomerIsSolve() == null ? null : customerStatisticalInfo.getCustomerIsSolve());
- row.createCell(10).setCellValue(salesPayTime);
- row.createCell(11).setCellValue(customerStatisticalInfo.getCompanyName() == null ? null : customerStatisticalInfo.getCompanyName());
- row.createCell(12).setCellValue(customerStatisticalInfo.getStoreName() == null ? null : customerStatisticalInfo.getStoreName());
- row.createCell(13).setCellValue(customerStatisticalInfo.getItemProductName() == null ? null : customerStatisticalInfo.getItemProductName());
- row.createCell(14).setCellValue(customerStatisticalInfo.getItemProductColor() == null ? null : customerStatisticalInfo.getItemProductColor());
- row.createCell(15).setCellValue(customerStatisticalInfo.getItemNum() == null ? null : customerStatisticalInfo.getItemNum());
- row.createCell(16).setCellValue(customerStatisticalInfo.getRelationBackLogisticsCompany() == null ? null : customerStatisticalInfo.getRelationBackLogisticsCompany());
- row.createCell(17).setCellValue(customerStatisticalInfo.getRelationBackLogisticsNo() == null ? null : customerStatisticalInfo.getRelationBackLogisticsNo());
- row.createCell(18).setCellValue(customerStatisticalInfo.getRelationBackReceiptDate() == null ? null : customerStatisticalInfo.getRelationBackReceiptDate());
- row.createCell(19).setCellValue(customerStatisticalInfo.getRelationBackStatus() == null ? null : customerStatisticalInfo.getRelationBackStatus());
- row.createCell(20).setCellValue(customerStatisticalInfo.getRelationSendLogisticsCompany() == null ? null : customerStatisticalInfo.getRelationSendLogisticsCompany());
- row.createCell(21).setCellValue(customerStatisticalInfo.getRelationSendLogisticsNo() == null ? null : customerStatisticalInfo.getRelationSendLogisticsNo());
- row.createCell(22).setCellValue(customerStatisticalInfo.getCustomerOutDamaged() == null ? null : customerStatisticalInfo.getCustomerOutDamaged());
- row.createCell(23).setCellValue(customerStatisticalInfo.getCustomerSecondaryCustomer() == null ? null : customerStatisticalInfo.getCustomerSecondaryCustomer());
- }
- //下载导出订单Excel
- downloadCustomerExcel(res,wb);
- }
- /**
- * 下载导出客诉到Excel
- * @param res
- * @param wb
- * @throws Exception
- */
- public void downloadCustomerExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- String fileName = format.format(new Date()) + "客诉报表";
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- wb.write(os);
- byte[] content = os.toByteArray();
- InputStream is = new ByteArrayInputStream(content);
- // 设置response参数,可以打开下载页面
- res.reset();
- res.setContentType("application/vnd.ms-excel;charset=utf-8");
- res.setHeader("Content-Disposition", "attachment;filename="
- + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
- ServletOutputStream out = res.getOutputStream();
- BufferedInputStream bis = null;
- BufferedOutputStream bos = null;
- try {
- bis = new BufferedInputStream(is);
- bos = new BufferedOutputStream(out);
- byte[] buff = new byte[2048];
- int bytesRead;
- // Simple read/write loop.
- while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
- bos.write(buff, 0, bytesRead);
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- } finally {
- if (bis != null)
- bis.close();
- if (bos != null)
- bos.close();
- }
- }
- }
|