package com.iamberry.rst.service.cm; import com.github.pagehelper.PageHelper; import com.iamberry.rst.core.cm.*; import com.iamberry.rst.core.fm.AwaitingSignclosedProductInfo; import com.iamberry.rst.core.fm.ComplaintDetectInfo; import com.iamberry.rst.core.fm.ComplaintSignclosedInfo; import com.iamberry.rst.core.order.*; import com.iamberry.rst.core.page.PagedResult; import com.iamberry.rst.faces.cm.*; import com.iamberry.rst.faces.order.EfastOrderService; import com.iamberry.rst.service.address.mapper.AddressMapper; import com.iamberry.rst.service.cm.mapper.*; import com.iamberry.rst.service.fm.mapper.ComplaintDetectInfoMapper; import com.iamberry.rst.service.fm.mapper.ComplaintSignclosedInfoMapper; import com.iamberry.rst.service.fm.mapper.ComplaintSignclosedProductInfoMapper; import com.iamberry.rst.service.product.mapper.ProductMapper; import com.iamberry.rst.util.CustomerCommonUtil; import com.iamberry.rst.util.PageUtil; import com.iamberry.wechat.tools.ResponseJson; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; @Service public class CustomerServiceImpl implements CustomerService { private static Logger logger = LoggerFactory.getLogger(CustomerServiceImpl.class); @Autowired private CustomerInfoMapper customerInfoMapper; @Autowired private RepairMapper repairMapper; @Autowired private BackGoodsMapper backGoodsMapper; @Autowired private NoreasonBackMapper noreasonBackMapper; @Autowired private ReissueMapper reissueMapper; @Autowired private RenewedMapper renewedMapper; @Autowired private ClosedFittingMapper closedFittingMapper; @Autowired private ClosedProdcueMapper closedProdcueMapper; @Autowired private SendProdcueMapper sendProdcueMapper; @Autowired private SendFittingMapper sendFittingMapper; @Autowired private SalesOrderMapper salesOrderMapper; @Autowired private CustomerService customerService; @Autowired private VisitMapper visitMapper; //回访 @Autowired private ComplaintSignclosedInfoMapper complaintSignclosedInfoMapper; //仓储 @Autowired private ComplaintDetectInfoMapper complaintDetectInfoMapper; //品检 @Autowired private QuestionDescribeMapper questionDescribeMapper; //客诉问题 @Autowired private AddressMapper addressMapper; //地址 @Autowired private ProductMapper productMapper; //产品 @Autowired private ComplaintSignclosedProductInfoMapper complaintSignclosedProductInfoMapper; @Autowired private FittingsInfoMapper fittingsInfoMapper; @Autowired private EfastOrderService efastOrderService; @Autowired private StoreInfoMapper storeInfoMapper; @Autowired private RelationOrderService relationOrderService; @Autowired private ProcMethodService procMethodService; @Autowired private CmRelationMapper cmRelationMapper; @Autowired private RelationOrderMapper relationOrderMapper; @Override public CustomerInfo getCustomerInfo(Integer customerId) { return customerInfoMapper.getCustomerInfo(customerId); } @Override @Transactional public Integer saveCustomerInfo(CustomerInfo customerInfo,SalesOrder salesOrder){ Integer isNeedSelectOrder = customerInfo.getIsNeedSelectOrder(); List orderList = new ArrayList<>(); //添加客诉基本信息 Integer flag = 0; flag = customerInfoMapper.insert(customerInfo); if(flag < 1){ throw new RuntimeException("添加客诉失败"); } logger.info("-----------添加客诉-添加客诉基本信息---------------"); QuestionDescribe questionDescribe = new QuestionDescribe(); questionDescribe.setCustomerId(customerInfo.getCustomerId()); questionDescribe.setDescribeTitle(customerInfo.getDescribeTitle()); //客诉问题标题 questionDescribe.setDescribeContent(customerInfo.getDescribeContent()); //客诉问题描述 questionDescribe.setDescribeHandleDesc(customerInfo.getDescribeHandleDesc()); //处理描述 flag = questionDescribeMapper.insert(questionDescribe); if(flag < 1){ throw new RuntimeException("添加客诉问题失败"); } logger.info("-----------添加客诉-添加客诉问题---------------"); if ("2".equals(customerInfo.getCustomerIsVisit())) { Visit visit = new Visit(); visit.setCustomerId(customerInfo.getCustomerId()); visit.setAdminId(customerInfo.getAdminId()); visit.setDesignatedAdminId(customerInfo.getVisitAdminId()); visit.setVisitName(customerInfo.getVisitName()); visit.setVisitTel(customerInfo.getVisitTel()); visit.setVisitDate(customerInfo.getVisitDate()); visit.setVisitTimeSelect(customerInfo.getVisitTimeSelect()); visit.setVisitStatus(1); //回访状态 flag = visitMapper.addVisitInfo(visit); if(flag < 1){ throw new RuntimeException("添加客诉回访信息失败"); } logger.info("-----------添加客诉-添加客诉回访信息---------------"); } ProcMethod procMethod = procMethodService.getProcMethodById(customerInfo.getProcMethodId()); if (2 == customerInfo.getCustomerCounselType() && (procMethod.getProcMethodIsBack()==1||procMethod.getProcMethodIsSend()==1)){ if(isNeedSelectOrder == 1){ SalesOrder so = new SalesOrder(); if(salesOrder.getIds()!= null && salesOrder.getIds().indexOf("_") > -1){ String[] salesIds = salesOrder.getIds().split("_"); so.setSalesIds(salesIds); orderList = salesOrderMapper.listSalesOrder(so); if(orderList == null || orderList.size() < 1){ throw new RuntimeException("添加客诉-订单为空-请重新添加订单"); } }else{ throw new RuntimeException("添加客诉-订单为空-请重新添加订单"); } } logger.info("-----------添加客诉-添加订单校验 --------------"); } CmRelation cmRelation = customerInfo.getCmRelation(); cmRelation.setCustomerId(customerInfo.getCustomerId()); cmRelation.setRelationBackStatus(1); //寄回状态 1:未寄回 cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送x cmRelation.setRelationState(1); //状态 默认使用中 //cmRelation.setTransactionNumber(customerInfo.getTransactionNumber()); //外部交易号 // TODO: 2018/3/27 是否转账邮费,默认为不需要转账 : 0 cmRelation.setRelationIsTransfer(0); //是否已转账邮费 cmRelation.setRelationBackPostage(0); //邮费默认为0 cmRelation.setRelationBackName(cmRelation.getRelationSendName()); //姓名 cmRelation.setRelationBackTel(cmRelation.getRelationSendTel()); //电话号码 /* 初始化产品类型,名称,配件名称 */ customerService.setName(cmRelation); logger.info("-----------添加客诉-初始化产品,配件信息--------------"); /*添加处理方式*/ flag = cmRelationMapper.save(cmRelation); if (flag < 1) { throw new RuntimeException("添加客诉处理结果失败"); } logger.info("-----------添加客诉-添加客诉处理成功--------------"); /*添加客诉-添加处理与订单关联表*/ List relationOrderList = new ArrayList<>(); for (SalesOrder sor : orderList) { RelationOrder ro = new RelationOrder(); ro.setRelationId(cmRelation.getRelationId()); ro.setSalesId(sor.getSalesId()); ro.setRelationCustomerId(customerInfo.getCustomerId()); relationOrderList.add(ro); } if(relationOrderList != null && relationOrderList.size() > 0){ flag = relationOrderService.saveList(relationOrderList); if(flag < 1){ throw new RuntimeException("添加客诉,关联订单失败"); } } logger.info("-----------添加客诉-添加处理与订单关联表--------------"); for (SalesOrder sor : orderList) { SalesOrder newOrder = new SalesOrder(); //salesOrderStatus newOrder.setSalesId(sor.getSalesId()); newOrder.setSalesOrderStatus(procMethod.getProcTypeId()); flag = salesOrderMapper.updateSalesOrder(newOrder); if(flag < 1){ throw new RuntimeException("添加客诉,修改订单失败"); } } logger.info("-----------添加客诉-修改订单--------------"); CustomerCommonUtil.setProduce(cmRelation); if(cmRelation.getClosedProdcues() != null && cmRelation.getClosedProdcues().size()>0){ closedProdcueMapper.insert(cmRelation.getClosedProdcues()); } if(cmRelation.getSendProdcues() != null && cmRelation.getSendProdcues().size() > 0){ sendProdcueMapper.insert(cmRelation.getSendProdcues()); } logger.info("-----------添加客诉-寄回寄出产品配件成功--------------"); return flag; } @Override @Transactional public Integer updateCustomerInfo(CustomerInfo customerInfo,SalesOrder salesOrder){ Integer isNeedSelectOrder = customerInfo.getIsNeedSelectOrder(); //当前处理信息 CmRelation cr = customerInfo.getCmRelation(); if(customerInfo == null || customerInfo.getCustomerId()==null || customerInfo.getCmRelation()==null || cr == null || cr.getRelationId() == null ){ throw new RuntimeException("修改客诉失败-未获取到客诉ID与处理方式ID"); } //删除旧的售后数据 customerService.deleteCustomerAfterSales(customerInfo,cr); List orderList = new ArrayList(); //修改客诉基本信息 Integer flag = 0; flag = customerInfoMapper.updateCustomerInfo(customerInfo); if(flag < 1){ throw new RuntimeException("修改客诉失败-修改客诉基本信息失败"); } logger.info("-----------修改客诉-修改客诉基本信息---------------"); QuestionDescribe questionDescribe = new QuestionDescribe(); // questionDescribe.setCustomerId(customerInfo.getCustomerId()); questionDescribe.setDescribeId(customerInfo.getDescribeId());//客诉问题主键 questionDescribe.setDescribeTitle(customerInfo.getDescribeTitle()); //客诉问题标题 questionDescribe.setDescribeContent(customerInfo.getDescribeContent()); //客诉问题描述 questionDescribe.setDescribeHandleDesc(customerInfo.getDescribeHandleDesc()); //处理描述 flag = questionDescribeMapper.updateByPrimaryKeySelective(questionDescribe); if(flag < 1){ throw new RuntimeException("修改客诉失败-修改客诉问题信息失败"); } logger.info("-----------修改客诉-修改客诉问题---------------"); if ("2".equals(customerInfo.getCustomerIsVisit())) { Visit visit = new Visit(); visit.setCustomerId(customerInfo.getCustomerId()); visit.setAdminId(customerInfo.getAdminId()); visit.setDesignatedAdminId(customerInfo.getVisitAdminId()); visit.setVisitName(customerInfo.getVisitName()); visit.setVisitTel(customerInfo.getVisitTel()); visit.setVisitDate(customerInfo.getVisitDate()); visit.setVisitTimeSelect(customerInfo.getVisitTimeSelect()); visit.setVisitStatus(1); //回访状态 flag = visitMapper.addVisitInfo(visit); if(flag < 1){ throw new RuntimeException("修改客诉失败-修改客诉回访失败"); } logger.info("-----------修改客诉-修改客诉回访信息---------------"); } ProcMethod procMethod = procMethodService.getProcMethodById(customerInfo.getProcMethodId()); if (2 == customerInfo.getCustomerCounselType() && (procMethod.getProcMethodIsBack()==1||procMethod.getProcMethodIsSend()==1)){ if(isNeedSelectOrder == 1){ SalesOrder so = new SalesOrder(); if(salesOrder.getIds()!= null && salesOrder.getIds().indexOf("_") > -1){ String[] salesIds = salesOrder.getIds().split("_"); so.setSalesIds(salesIds); orderList = salesOrderMapper.listSalesOrder(so); if(orderList == null || orderList.size() < 1){ throw new RuntimeException("添加客诉-订单为空-请重新添加订单"); } }else{ throw new RuntimeException("添加客诉-订单查询出错-请重新添加订单"); } } logger.info("-----------添加客诉-添加订单 --------------"); } if (procMethod.getProcMethodIsBack()==2) { cr.setRelationBackStatus(1); //寄回状态 1:未寄回 cr.setRelationIsTransfer(0); //是否已转账邮费 cr.setRelationBackPostage(0); //邮费 cr.setRelationBackLogisticsCompany("");//寄回物流公司 cr.setRelationBackLogisticsNo("");//寄回物流单号 cr.setRelationAlipay("");//转账账户 cr.setRelationAlipayName("");//转账账户 (账户姓名) } if (procMethod.getProcMethodIsSend()==2) { cr.setRelationSendStatus(1); //寄送状态 1:未寄送 cr.setRelationSendLogisticsCompany("");//寄送物流公司 cr.setRelationSendLogisticsNo("");//寄送物流单号 } /* 初始化产品类型,名称,配件名称 */ customerService.setName(cr); logger.info("-----------修改客诉-初始化产品,配件信息--------------"); // ComplaintDetectInfo complaintDetectInfo = new ComplaintDetectInfo(); //品质检测 // ComplaintSignclosedInfo complaintSignclosedInfo = new ComplaintSignclosedInfo(); //客诉-签收表 // Map map; // boolean isReturn = false; logger.info("-----------修改客诉-创建仓储/品检成功--------------"); flag = cmRelationMapper.update(cr); if(flag < 1){ throw new RuntimeException("修改客诉-修改处理信息失败"); } logger.info("-----------修改客诉-修改处理信息失败--------------"); /*添加客诉-添加处理与订单关联表*/ List relationOrderList = new ArrayList<>(); for (SalesOrder sor : orderList) { RelationOrder ro = new RelationOrder(); ro.setRelationId(cr.getRelationId()); ro.setSalesId(sor.getSalesId()); ro.setRelationCustomerId(customerInfo.getCustomerId()); relationOrderList.add(ro); } if(relationOrderList != null && relationOrderList.size() > 0){ flag = relationOrderService.saveList(relationOrderList); if(flag < 1){ throw new RuntimeException("添加客诉,关联订单失败"); } } for (SalesOrder sor : orderList) { SalesOrder newOrder = new SalesOrder(); //salesOrderStatus newOrder.setSalesId(sor.getSalesId()); newOrder.setSalesOrderStatus(procMethod.getProcTypeId()); flag = salesOrderMapper.updateSalesOrder(newOrder); if(flag < 1){ throw new RuntimeException("添加客诉,修改订单状态失败"); } } logger.info("-----------添加客诉-添加处理与订单关联表--------------"); logger.info("-----------添加客诉-修改订单--------------"); CustomerCommonUtil.setProduce(cr); if(cr.getClosedProdcues() != null && cr.getClosedProdcues().size()>0){ closedProdcueMapper.insert(cr.getClosedProdcues()); } if(cr.getSendProdcues() != null && cr.getSendProdcues().size() > 0){ sendProdcueMapper.insert(cr.getSendProdcues()); } logger.info("-----------添加客诉-寄回寄出产品配件成功--------------"); return flag; } /** * 删除旧的售后数据 * @param customer */ @Override @Transactional public void deleteCustomerAfterSales(CustomerInfo customer,CmRelation cmRelation){ Integer flag = 0; CustomerInfo customerInfo = customerInfoMapper.getCustomerInfo(customer.getCustomerId()); //删除回访信息 if ("2".equals(customerInfo.getCustomerIsVisit())){ flag = visitMapper.deleteByPrimaryKey(customer.getCustomerId()); if(flag < 1){ throw new RuntimeException("修改客诉-删除回访,删除回访失败"); } } //删除寄出寄回产品 ClosedProdcue closedrecord = new ClosedProdcue(); SendProdcue sendProdcue = new SendProdcue(); closedrecord.setRelationId(cmRelation.getRelationId()); closedProdcueMapper.deleteByPrimaryKey(closedrecord); sendProdcue.setRelationId(cmRelation.getRelationId()); sendProdcueMapper.deleteByPrimaryKey(sendProdcue); /*恢复订单状态*/ RelationOrder relationOrder = new RelationOrder(); relationOrder.setRelationId(cmRelation.getRelationId()); List relationOrderList = relationOrderService.getRelationOrderList(relationOrder); for (int k=0; k listCustomer = customerInfoMapper.listCustomer(customerInfo); return listCustomer.size(); } @Override public List listOnCustomer(CustomerInfo customerInfo) { List customerList = customerInfoMapper.listOnCustomer(customerInfo); //查询售后维修集合 // Repair repairInfo = new Repair(); // repairInfo.setRepairState(1); // List repairList = repairMapper.listRepair(repairInfo); // //查询售后退货集合 // BackGoods backGoodsInfo = new BackGoods(); // backGoodsInfo.setBackGoodsState(1); // List backGoodsList = backGoodsMapper.listBackGoods(backGoodsInfo); // //查询售后无理由退货集合 // NoreasonBack noreasonBackInfo = new NoreasonBack(); // noreasonBackInfo.setNoreasonBackState(1); // List noreasonBackList = noreasonBackMapper.listNoreasonBack(noreasonBackInfo); // //查询售后补发集合 // Reissue reissueInfo = new Reissue(); // reissueInfo.setReissueState(1); // List reissueList = reissueMapper.listReissue(reissueInfo); // //查询售后换新集合 // Renewed renewedInfo = new Renewed(); // renewedInfo.setRenewedState(1); // List renewedList = renewedMapper.listRenewed(renewedInfo); // // if (customerList != null && customerList.size() > 0) { // for (CustomerInfo customer : customerList) { // switch (customer.getCustomerIsSolve().intValue()) { // case 3: //换新 // for (Renewed renewed : renewedList) { // if (renewed.getCustomerId().intValue() == customer.getCustomerId()) { // customer.setBackStatus(renewed.getRenewedBackStatus()); // customer.setSendStatus(renewed.getRenewedSendStatus()); // customer.setSalesTime(renewed.getSalesPayTime()); // customer.setSendLogisticsNo(renewed.getRenewedSendLogisticsNo()); // customer.setSendLogisticsCompany(renewed.getRenewedSendLogisticsCompany()); // customer.setBackLogisticsNo(renewed.getRenewedBackLogisticsNo()); // customer.setBackLogisticsCompany(renewed.getRenewedBackLogisticsCompany()); // break; // } // } // break; // case 4: //维修 // for (Repair repair : repairList) { // if (repair.getCustomerId().intValue() == customer.getCustomerId()) { // customer.setBackStatus(repair.getRepairBackStatus()); // customer.setSendStatus(repair.getRepairSendStatus()); // customer.setSalesTime(repair.getSalesPayTime()); // customer.setSendLogisticsNo(repair.getRepairSendLogisticsNo()); // customer.setSendLogisticsCompany(repair.getRepairSendLogisticsCompany()); // customer.setBackLogisticsNo(repair.getRepairBackLogisticsNo()); // customer.setBackLogisticsCompany(repair.getRepairBackLogisticsCompany()); // break; // } // } // break; // case 5: //补发 // for (Reissue reissue : reissueList) { // if (reissue.getCustomerId().intValue() == customer.getCustomerId()) { // customer.setSendStatus(reissue.getReissueSendStatus()); // customer.setSalesTime(reissue.getSalesPayTime()); // customer.setBackLogisticsNo(reissue.getReissueSendLogisticsNo()); // customer.setBackLogisticsCompany(reissue.getReissueSendLogisticsCompany()); // break; // } // } // break; // case 6: //退货 // for (BackGoods backGoods : backGoodsList) { // if (backGoods.getCustomerId().intValue() == customer.getCustomerId()) { // customer.setBackStatus(backGoods.getBackGoodsBackStatus()); // customer.setSalesTime(backGoods.getSalesPayTime()); // customer.setSendLogisticsNo(backGoods.getBackGoodsBackLogisticsNo()); // break; // } // } // break; // case 7: //无理由退货 // for (NoreasonBack noreasonBack : noreasonBackList) { // if (noreasonBack.getCustomerId().intValue() == customer.getCustomerId()) { // customer.setBackStatus(noreasonBack.getNoreasonBackBackStatus()); // customer.setSalesTime(noreasonBack.getSalesPayTime()); // customer.setSendLogisticsNo(noreasonBack.getNoreasonBackBackLogisticsNo()); // customer.setSendLogisticsCompany(noreasonBack.getNoreasonBackBackLogisticsCompany()); // break; // } // } // break; // } // } // } return customerList; } /** * 产品配件初始化 * @param cr */ @Override @Transactional public void setName(CmRelation cr) { for (int i=0;i complaintDetectInfoList = new ArrayList(); for(int i=0 ;i< customerCommon.getClosedProdcues().size();i++){ ClosedProdcue closedProdcue = customerCommon.getClosedProdcues().get(i); for(int j=0; j 0){ flag = complaintDetectInfoMapper.insertList(complaintDetectInfoList); } if(flag < 1){ throw new RuntimeException("添加品检失败"); }*/ } /** * 添加仓储 * @param customerCommon * @return */ @Override @Transactional public void saveComplaintSignclosedInfo(ComplaintSignclosedInfo complaintSignclosedInfo,CustomerCommon customerCommon){ if(customerCommon.getIsNeedSelectOrder() == 2){ return; } Integer flag; complaintSignclosedInfo.setSignclosedType(1); //客诉寄回 complaintSignclosedInfo.setSignclosedCustomerId(customerCommon.getCustomerId()); //客诉id complaintSignclosedInfo.setSignclosedSendName(customerCommon.getRelationBackName()); //签收姓名 complaintSignclosedInfo.setSignclosedSendTel(customerCommon.getRelationBackTel()); //签收手机 flag = complaintSignclosedInfoMapper.insert(complaintSignclosedInfo); if(flag < 1){ throw new RuntimeException("添加签收失败"); } //添加代签收表 List awaitingSignclosedProductInfoArrayList = new ArrayList<>(); for(int i=0 ;i< customerCommon.getClosedProdcues().size();i++){ ClosedProdcue closedProdcue = customerCommon.getClosedProdcues().get(i); for(int k=0;k sendEfastOrder(CustomerCommon customerCommon,SalesOrder salesOrder){ Map map = new HashMap(); List orderList = new ArrayList(); List itemList = new ArrayList(); Integer num = 0; //产品数量 Integer amout = 0; //商品总价 String orderProductBarCode = ""; //产品sku String productName = ""; //产品名称 for(int i=0;i orderMap = new HashMap(); try { orderMap = efastOrderService.sendOrder(orderList,itemList); } catch (Exception e) { status = 0; } List oList = (List) orderMap.get("efastOrderList"); if(oList == null || oList.size() < 1){ status = 0; } map.put("status",status); if(oList != null && oList.size() > 0){ map.put("EfastOrderId",oList.get(0).getOrderId()); logger.info("换新,维修 ,补发向Efast 推送订单成功,订单号为:" + oList.get(0).getOrderId()); }else{ logger.info("换新,维修 ,补发向Efast 推送订单,推送失败,交易号为:" + customerCommon.getTransactionNumber()); } return map; } @Override public Integer getQuestionNumber(CustomerInfo customerInfo) { return customerInfoMapper.getQuestionNumber(customerInfo); } /** * 添加订单 * @return */ @Transactional public Integer addOrder(SalesOrder salesOrder) { //添加订单数据 int orderNum = salesOrderMapper.addSalesOrder(salesOrder); if (orderNum <= 0) { throw new RuntimeException("系统添加订单失败"); } for (SalesOrderItem item : salesOrder.getSalesOrderItemList()) { item.setItemOrderId(salesOrder.getSalesId()); } //批量添加订单项数据 int itemNum = salesOrderMapper.addOrderItemList(salesOrder.getSalesOrderItemList()); if (itemNum <= 0) { throw new RuntimeException("系统添加订单项失败"); } return orderNum; } @Override public List listStatisticalCustomer() { return customerInfoMapper.listStatisticalCustomer(); } @Override public List salesTotalSales(SalesOrder salesOrder) { return customerInfoMapper.salesTotalSales(salesOrder); } @Override public List salesTotalExchange(SalesOrder salesOrder) { return customerInfoMapper.salesTotalExchange(salesOrder); } @Override public List salesTotalReturn(SalesOrder salesOrder) { return customerInfoMapper.salesTotalReturn(salesOrder); } @Override public List salesSecondaryChangeNew(SalesOrder salesOrder) { return customerInfoMapper.salesSecondaryChangeNew(salesOrder); } @Override public List salesReturnForSecond(SalesOrder salesOrder) { return customerInfoMapper.salesReturnForSecond(salesOrder); } @Override public List listProcType() { return customerInfoMapper.listProcType(); } @Override public List listProcMethod(Integer procTypeId) { return customerInfoMapper.listProcMethod(procTypeId); } @Override public ProcMethod getProcMethod(Integer procMethodId) { return customerInfoMapper.getProcMethod(procMethodId); } @Override public Integer updateCmRelation(CmRelation cmRelation) { return customerInfoMapper.updateCmRelation(cmRelation); } @Override public CmRelation getCmRelationInfo(CmRelation cmRelation) { return customerInfoMapper.getCmRelationInfo(cmRelation); } /** * 向Efast推送订单--添加订单 * @return */ @Transactional public Map sendEfastOrder(SalesOrder salesOrder){ //添加订单数据 int orderNum = salesOrderMapper.addSalesOrder(salesOrder); if (orderNum <= 0) { throw new RuntimeException("系统添加订单失败"); } for (SalesOrderItem item : salesOrder.getSalesOrderItemList()) { item.setItemOrderId(salesOrder.getSalesId()); } //批量添加订单项数据 int itemNum = salesOrderMapper.addOrderItemList(salesOrder.getSalesOrderItemList()); if (itemNum <= 0) { throw new RuntimeException("系统添加订单项失败"); } Map map = new HashMap(); List orderList = new ArrayList(); List itemList = new ArrayList(); Integer num = 0; //产品数量 Integer amout = 0; //商品总价 String orderProductBarCode = ""; //产品sku String productName = ""; //产品名称 for(int i=0;i 4){ myAddress = address[3] + address[4]; }else{ myAddress = address[3]; } efastOrder.setOrderAddress(myAddress); efastOrder.setOrderStatus(1); efastOrder.setOrderNum(num); //产品数量 efastOrder.setOrderAmount(amout); //商品总价 efastOrder.setOrderPayMoney(amout); //已付款 //支付方式 switch (salesOrder.getSalesPayType()){ case 1: //微信支付 efastOrder.setOrderPayType(1); break; case 2: //现金支付 efastOrder.setOrderPayType(2); break; case 3: break; case 4: //刷卡支付 efastOrder.setOrderPayType(4); break; case 5: //支付宝支付 efastOrder.setOrderPayType(5); break; default: efastOrder.setOrderPayType(2); //默认现金 break; } efastOrder.setOrderProductBarCode(orderProductBarCode); //产品sku efastOrder.setOrderProductName(productName); //产品名称 efastOrder.setOrderId(salesOrder.getSalesDealCode()); //外部交易号 StoreInfo storeInfo = new StoreInfo(); storeInfo = storeInfoMapper.getStoreInfoById(salesOrder.getSalesStoreId()); efastOrder.setOrderStoreId(storeInfo.getStoreEfast()); efastOrder.setOid(1); orderList.add(efastOrder); Integer status = 1; Map orderMap = new HashMap(); try { orderMap = efastOrderService.sendOrder(orderList,itemList); } catch (Exception e) { status = 0; } List oList = (List) orderMap.get("efastOrderList"); if(oList == null || oList.size() < 1){ status = 0; } if(oList != null && oList.size() > 0){ map.put("EfastOrderId",oList.get(0).getOrderId()); SalesOrder sa = new SalesOrder(); sa.setSalesId(salesOrder.getSalesId()); sa.setSalesOrderId(oList.get(0).getOrderId()); orderNum = salesOrderMapper.updateSalesOrder(sa); if (orderNum <= 0) { throw new RuntimeException("系统修改订单失败,订单回滚,Efast交易号:"+salesOrder.getSalesDealCode()); } }else{ throw new RuntimeException("添加Efast订单失败"); } map.put("status",status); return map; } /** * 将原订单生成退货单 * @param customerCommon * @param salesOrder * @return * @throws RuntimeException */ @Transactional public void chargebackEfastOrder(CustomerCommon customerCommon, SalesOrder salesOrder,Integer status,Integer returnType){ SalesOrder order = new SalesOrder(); order.setSalesId(salesOrder.getSalesId()); order.setSalesOrderStatus(status); //换货状态 Integer flag = salesOrderMapper.updateSalesOrder(order); if(flag < 0){ throw new RuntimeException("系统生成退单失败"); } EfastOrder efastOrder = new EfastOrder(); List itemList = new ArrayList<>(); /*for(int i=0;i salesOrderItemList = salesOrderMapper.listSalesOrderItem(salesOrderItem); for(SalesOrderItem item : salesOrderItemList){ EfastOrderItem efastOrderItem = new EfastOrderItem(); efastOrderItem.setItemColorBar(item.getItemColorBar()); efastOrderItem.setItemNum(item.getItemNum()); efastOrderItem.setItemDiscount(item.getItemProductPrice()); itemList.add(efastOrderItem); } efastOrder.setOrderDealCode(salesOrder.getSalesDealCode()); //交易号 efastOrder.setOrderPostFirm(salesOrder.getSalesPostFirm()); //物流代码 efastOrder.setOrderPostNum(salesOrder.getSalesPostNum()); //物流单号 efastOrder.setOrderId(salesOrder.getSalesOrderId()); //订单编号 efastOrder.setItemList(itemList); efastOrder.setReturnOrderType(returnType);//退单类型 JSONObject jsonObject = new JSONObject(); try{ jsonObject = efastOrderService.returnOrderFormEfast(efastOrder); logger.info("------将原订单生成退货订单返回数据:" + jsonObject + "------"); /*if(jsonObject != null){ Object obj; obj = jsonObject.get("return_sn"); if(obj != null && !"".equals(obj)){ fg = true; }else{ obj = jsonObject.get("msg"); if("系统订单 已作废".equals(obj)){ fg = true; } } }*/ }catch (Exception e){ logger.info("------将原订单生成退货订单报错------"); } } @Override public Integer updateCustomerInfo(CustomerInfo record) { return customerInfoMapper.updateCustomerInfo(record); } @Override public PagedResult listCustomer(int pageNO, int pageSize, CustomerInfo customerInfo, boolean isTotalNum) { PageHelper.startPage(pageNO, pageSize, isTotalNum); //查询客诉列表 List customerList = customerInfoMapper.listCustomer(customerInfo); return PageUtil.getPage(customerList); } @Override public Map getCustomerInfo(CustomerInfo customerInfo) { Map map = new HashMap(); CustomerCommon customerCommon = new CustomerCommon(); //查询客诉列表 List customerList = customerInfoMapper.listCustomer(customerInfo); if (customerList == null || customerList.size() == 0) { return null; } CustomerInfo customer = customerList.get(0); map.put("customer",customer); CmRelation cmRelation = new CmRelation(); cmRelation.setCustomerId(customer.getCustomerId()); cmRelation = customerInfoMapper.getCmRelationInfo(cmRelation); RelationOrder relationOrder = new RelationOrder(); relationOrder.setRelationId(cmRelation.getRelationId()); relationOrder.setRelationCustomerId(customer.getCustomerId()); List relationOrderList = relationOrderService.getRelationOrderList(relationOrder); if(relationOrderList != null && relationOrderList.size() > 0){ String[] salesIds = new String[relationOrderList.size()]; for (int k=0; k orderList = salesOrderMapper.listSalesOrder(so); if (orderList != null && orderList.size() > 0) { SalesOrder order = orderList.get(0); SalesOrderItem salesOrderItem = new SalesOrderItem(); salesOrderItem.setItemOrderId(order.getSalesId()); order.setSalesOrderItemList(salesOrderMapper.listSalesOrderItem(salesOrderItem)); } else { map.put("orderList",null); } map.put("orderList",orderList); } //查询寄回寄出产品 ClosedProdcue record = new ClosedProdcue(); record.setRelationId(cmRelation.getRelationId()); customerCommon.setClosedProdcues(closedProdcueMapper.listclosedProdcue(record)); SendProdcue sendrecord = new SendProdcue(); sendrecord.setRelationId(cmRelation.getRelationId()); customerCommon.setSendProdcues(sendProdcueMapper.listSendProdcue(sendrecord)); map.put("customerCommon",customerCommon); return map; } @Override public CustomerCommon selectProdcueAndFitting(CustomerCommon customerCommon, int isSolve) { if (customerCommon == null || customerCommon.getRelationId() == null) { return customerCommon; } List sendProdcues = null; List sendFittings = null; List closedfittings = null; List closedProdcues = null; SendProdcue sendProdcue = new SendProdcue(); SendFitting sendFitting = new SendFitting(); ClosedFitting fitting = new ClosedFitting(); ClosedProdcue closedProdcue = new ClosedProdcue(); // switch (isSolve) { // case 3://换新 // sendProdcue.setRelationId(customerCommon.getRelationId()); // sendProdcue.setSendProduceType(3); // //查询寄出产品集合 // sendProdcues = sendProdcueMapper.listSendProdcue(sendProdcue); // sendFitting.setRelationId(customerCommon.getRelationId()); // sendFitting.setSendFittingType(3); // //查询寄出配件集合 // sendFittings = sendFittingMapper.listSendFitting(sendFitting); // fitting.setRelationId(customerCommon.getRelationId()); // fitting.setClosedFittingType(3); // //查询寄回配件集合 // closedfittings = closedFittingMapper.listClosedFitting(fitting); // closedProdcue.setRelationId(customerCommon.getRelationId()); // closedProdcue.setClosedProdcueType(3); // //查询寄回产品集合 // closedProdcues = closedProdcueMapper.listclosedProdcue(closedProdcue); // break; // case 4://维修 // sendProdcue.setRelationId(customerCommon.getRelationId()); // sendProdcue.setSendProduceType(4); // //查询寄出产品集合 // sendProdcues = sendProdcueMapper.listSendProdcue(sendProdcue); // sendFitting.setRelationId(customerCommon.getRelationId()); // sendFitting.setSendFittingType(4); // //查询寄出配件集合 // sendFittings = sendFittingMapper.listSendFitting(sendFitting); // fitting.setRelationId(customerCommon.getRelationId()); // fitting.setClosedFittingType(4); // //查询寄回配件集合 // closedfittings = closedFittingMapper.listClosedFitting(fitting); // closedProdcue.setRelationId(customerCommon.getRelationId()); // closedProdcue.setClosedProdcueType(4); // //查询寄回产品集合 // closedProdcues = closedProdcueMapper.listclosedProdcue(closedProdcue); // break; // case 5://补发 // sendProdcue.setRelationId(customerCommon.getRelationId()); // sendProdcue.setSendProduceType(5); // //查询寄出产品集合 // sendProdcues = sendProdcueMapper.listSendProdcue(sendProdcue); // sendFitting.setRelationId(customerCommon.getRelationId()); // sendFitting.setSendFittingType(5); // //查询寄出配件集合 // sendFittings = sendFittingMapper.listSendFitting(sendFitting); // break; // case 6://退货 // fitting.setRelationId(customerCommon.getRelationId()); // fitting.setClosedFittingType(6); // //查询寄回配件集合 // closedfittings = closedFittingMapper.listClosedFitting(fitting); // closedProdcue.setRelationId(customerCommon.getRelationId()); // closedProdcue.setClosedProdcueType(6); // //查询寄回产品集合 // closedProdcues = closedProdcueMapper.listclosedProdcue(closedProdcue); // break; // case 7://无理由退货 // fitting.setRelationId(customerCommon.getRelationId()); // fitting.setClosedFittingType(7); // //查询寄回配件集合 // closedfittings = closedFittingMapper.listClosedFitting(fitting); // closedProdcue.setRelationId(customerCommon.getRelationId()); // closedProdcue.setClosedProdcueType(7); // //查询寄回产品集合 // closedProdcues = closedProdcueMapper.listclosedProdcue(closedProdcue); // break; // } customerCommon.setClosedFittings(closedfittings); customerCommon.setClosedProdcues(closedProdcues); customerCommon.setSendProdcues(sendProdcues); customerCommon.setSendFittings(sendFittings); return customerCommon; } @Override public ProductType getcompanyAffiliation(Integer customerId) { return customerInfoMapper.getcompanyAffiliation(customerId); } @Override public BackGoods getBackGoods(BackGoods backGoods) { //获取退货集合 // List backList = backGoodsMapper.listBackGoods(backGoods); // if (backList == null || backList.size() == 0) { // return null; // } // BackGoods goods = backList.get(0); // ClosedProdcue closedProdcue = new ClosedProdcue(); // closedProdcue.setRelationId(goods.getBackGoodsId()); // closedProdcue.setClosedProdcueType(6); // //查询寄回产品集合 // List prodcueList = closedProdcueMapper.listclosedProdcue(closedProdcue); // ClosedFitting fitting = new ClosedFitting(); // fitting.setRelationId(goods.getBackGoodsId()); // fitting.setClosedFittingType(6); // //查询寄回配件集合 // List fittingList = closedFittingMapper.listClosedFitting(fitting); // if (prodcueList != null && prodcueList.size() > 0) { // goods.setClosedProdcues(prodcueList); // } // if (fittingList != null && fittingList.size() > 0) { // goods.setClosedFittings(fittingList); // } // return goods; return null; } @Override public NoreasonBack getNoreasonBack(NoreasonBack noreasonBack) { //获取无理由退货 List backList = noreasonBackMapper.listNoreasonBack(noreasonBack); if (backList == null || backList.size() == 0) { return null; } NoreasonBack noreasonBackInfo = backList.get(0); ClosedProdcue closedProdcue = new ClosedProdcue(); closedProdcue.setRelationId(noreasonBackInfo.getNoreasonBackId()); closedProdcue.setClosedProdcueType(7); //查询寄回产品集合 List prodcueList = closedProdcueMapper.listclosedProdcue(closedProdcue); ClosedFitting fitting = new ClosedFitting(); fitting.setRelationId(noreasonBackInfo.getNoreasonBackId()); fitting.setClosedFittingType(7); //查询寄回配件集合 if (prodcueList != null && prodcueList.size() > 0) { noreasonBackInfo.setClosedProdcues(prodcueList); } return noreasonBackInfo; } @Override public Reissue getReissue(Reissue reissue) { //查询售后补发信息 // List reissueList = reissueMapper.listReissue(reissue); // if (reissueList == null || reissueList.size() == 0) { // return null; // } // Reissue reissueInfo = reissueList.get(0); // SendProdcue sendProdcue = new SendProdcue(); // sendProdcue.setRelationId(reissueInfo.getReissueId()); // sendProdcue.setSendProduceType(5); // //查询寄送产品集合 // List sendProdcueList = sendProdcueMapper.listSendProdcue(sendProdcue); // SendFitting sendFitting = new SendFitting(); // sendFitting.setRelationId(reissueInfo.getReissueId()); // sendFitting.setSendFittingType(5); // //查询寄送配件集合 // List sendFittingList = sendFittingMapper.listSendFitting(sendFitting); // // if (sendProdcueList != null && sendProdcueList.size() > 0) { // reissueInfo.setSendProdcues(sendProdcueList); // } // if (sendFittingList != null && sendFittingList.size() > 0) { // reissueInfo.setSendFittings(sendFittingList); // } // return reissueInfo; return null; } @Override public Renewed getRenewedInfo(Renewed renewed) { // renewed = renewedMapper.getRenewedInfo(renewed); // if (renewed == null){ // return null; // } // ClosedProdcue closedProdcue = new ClosedProdcue(); // closedProdcue.setRelationId(renewed.getRenewedId()); // closedProdcue.setClosedProdcueType(3); // //查询寄回产品集合 // List prodcueList = closedProdcueMapper.listclosedProdcue(closedProdcue); // ClosedFitting fitting = new ClosedFitting(); // fitting.setRelationId(renewed.getRenewedId()); // fitting.setClosedFittingType(3); // //查询寄回配件集合 // List fittingList = closedFittingMapper.listClosedFitting(fitting); // SendProdcue sendProdcue = new SendProdcue(); // sendProdcue.setRelationId(renewed.getRenewedId()); // sendProdcue.setSendProduceType(3); // //查询寄送产品集合 // List sendProdcueList = sendProdcueMapper.listSendProdcue(sendProdcue); // SendFitting sendFitting = new SendFitting(); // sendFitting.setRelationId(renewed.getRenewedId()); // sendFitting.setSendFittingType(3); // //查询寄送配件集合 // List sendFittingList = sendFittingMapper.listSendFitting(sendFitting); // // if (prodcueList != null && prodcueList.size() > 0) { // renewed.setClosedProdcues(prodcueList); // } // if (fittingList != null && fittingList.size() > 0) { // renewed.setClosedFittings(fittingList); // } // if (sendProdcueList != null && sendProdcueList.size() > 0) { // renewed.setSendProdcues(sendProdcueList); // } // if (sendFittingList != null && sendFittingList.size() > 0) { // renewed.setSendFittings(sendFittingList); // } return null; } @Override public Repair getRepairInfo(Repair repair) { // repair = repairMapper.getRepairInfo(repair); // if (repair == null) { // return null; // } // ClosedProdcue closedProdcue = new ClosedProdcue(); // closedProdcue.setRelationId(repair.getRepairId()); // closedProdcue.setClosedProdcueType(4); // //查询寄回产品集合 // List prodcueList = closedProdcueMapper.listclosedProdcue(closedProdcue); // ClosedFitting fitting = new ClosedFitting(); // fitting.setRelationId(repair.getRepairId()); // fitting.setClosedFittingType(4); // //查询寄回配件集合 // List fittingList = closedFittingMapper.listClosedFitting(fitting); // SendProdcue sendProdcue = new SendProdcue(); // sendProdcue.setRelationId(repair.getRepairId()); // sendProdcue.setSendProduceType(4); // //查询寄送产品集合 // List sendProdcueList = sendProdcueMapper.listSendProdcue(sendProdcue); // SendFitting sendFitting = new SendFitting(); // sendFitting.setRelationId(repair.getRepairId()); // sendFitting.setSendFittingType(4); // //查询寄送配件集合 // List sendFittingList = sendFittingMapper.listSendFitting(sendFitting); // // if (prodcueList != null && prodcueList.size() > 0) { // repair.setClosedProdcues(prodcueList); // } // if (fittingList != null && fittingList.size() > 0) { // repair.setClosedFittings(fittingList); // } // if (sendProdcueList != null && sendProdcueList.size() > 0) { // repair.setSendProdcues(sendProdcueList); // } // if (sendFittingList != null && sendFittingList.size() > 0) { // repair.setSendFittings(sendFittingList); // } // return repair; return null; } @Override @Transactional public Integer updateRelation(CustomerInfo customerInfo) { /* * 查询客诉 * 查询处理方式 * 查询订单 * 查询寄入寄出 * * 删除订单 * 删除寄入寄出 * * 添加处理方式 * * 添加订单 * 添加寄入寄出 * */ // Integer flag = 0; // CmRelation cmRelation = new CmRelation(); // cmRelation.setCustomerId(customerInfo.getCustomerId()); // // /*判断是否是新加的客诉*/ // CmRelation crold = cmRelationMapper.getCmRelationByCustomerId(customerInfo.getCustomerId()); // if(crold != null ){ // return 1; // } // // CustomerCommon customerCommon = new CustomerCommon(); // customerCommon.setCustomerId(customerInfo.getCustomerId()); // List customerCommonList = customerCommonService.listCustomerCommon(customerCommon); // if(customerCommonList != null && customerCommonList.size() > 0){ // customerCommon = customerCommonList.get(0); // cmRelation.setRelationBackStatus(customerCommon.getRelationBackStatus()); //寄回状态 1:未寄回 2:已寄回 3:已收货 4: 已签收待确认 // cmRelation.setRelationBackName(customerCommon.getRelationBackName()); //寄回人姓名 // cmRelation.setRelationBackTel(customerCommon.getRelationBackTel()); //寄回人电话 // cmRelation.setRelationBackLogisticsCompany(customerCommon.getRelationBackLogisticsCompany()); //寄回物流公司 // cmRelation.setRelationBackLogisticsNo(customerCommon.getRelationBackLogisticsNo()); //寄回物流单号 // cmRelation.setRelationBackPostage(customerCommon.getRelationBackPostage()); //寄回邮费 单位为分 // cmRelation.setRelationSendStatus(customerCommon.getRelationSendStatus()); //寄送状态 1:未寄送 2:已寄送 3:已收货 // cmRelation.setRelationSendName(customerCommon.getRelationSendName());//寄送人姓名 // cmRelation.setRelationSendTel(customerCommon.getRelationSendTel()); // cmRelation.setProvinceNumber(customerCommon.getProvinceNumber()); //寄送地址-省 // cmRelation.setCityNumber(customerCommon.getCityNumber()); //寄送地址-市 // cmRelation.setAreaNumber(customerCommon.getAreaNumber()); //寄送地址-区 // cmRelation.setRelationSendMergeAddress(customerCommon.getRelationSendMergeAddress()); //寄送地址-省市区 // cmRelation.setRelationSendAddress(customerCommon.getRelationSendAddress()); //寄送地址-详细地址 // cmRelation.setRelationSendLogisticsCompany(customerCommon.getRelationSendLogisticsCompany()); //寄送物流公司 // cmRelation.setRelationSendLogisticsNo(customerCommon.getRelationSendLogisticsNo()); //寄送物流单号 // cmRelation.setRelationDesc(customerCommon.getRelationDesc()); //备注 // cmRelation.setRelationState(1);//状态 1:使用中 2:停用中 // cmRelation.setRelationAlipay(customerCommon.getRelationAlipay()); //转账账户 // cmRelation.setRelationAlipayName(customerCommon.getRelationAlipayName()); //转账账户姓名 // cmRelation.setRelationIsTransfer(customerCommon.getRelationIsTransfer()); //是否已转账邮费 0:不需要 1:已转 2:已申请待转 3:未申请 // cmRelation.setRelationBackReceiptDate(customerCommon.getRelationBackReceiptDate()); //签收日期 // cmRelation.setRelationFactoryCosts(customerCommon.getRelationFactoryCosts());//工厂维修报价 // cmRelation.setRelationCustomerCosts(customerCommon.getRelationCustomerCosts()); //客户报价 // cmRelation.setRelationCreateTime(customerCommon.getRelationCreateTime()); // cmRelation.setRelationUpdateTime(customerCommon.getRelationUpdateTime()); // // cmRelation.setSendProdcues(customerCommon.getSendProdcues()); // cmRelation.setClosedProdcues(customerCommon.getClosedProdcues()); // } // // Integer procMethodId; // switch (customerInfo.getCustomerIsSolve()){ //1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货 客诉修改 // case 1: // procMethodId = 1; // cmRelation.setRelationBackStatus(1); //寄回状态 1:未寄回 2:已寄回 3:已收货 4: 已签收待确认 // cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送 2:已寄送 3:已收货 // cmRelation.setRelationSendName(customerInfo.getCustomerName()); // cmRelation.setRelationBackName(customerInfo.getCustomerName()); // cmRelation.setRelationSendTel(customerInfo.getCustomerTel()); // cmRelation.setRelationBackTel(customerInfo.getCustomerTel()); // cmRelation.setRelationIsTransfer(0); // cmRelation.setRelationBackPostage(0); // break; // case 2: // procMethodId = 2; // cmRelation.setRelationBackStatus(1); //寄回状态 1:未寄回 2:已寄回 3:已收货 4: 已签收待确认 // cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送 2:已寄送 3:已收货 // cmRelation.setRelationSendName(customerInfo.getCustomerName()); // cmRelation.setRelationBackName(customerInfo.getCustomerName()); // cmRelation.setRelationSendTel(customerInfo.getCustomerTel()); // cmRelation.setRelationBackTel(customerInfo.getCustomerTel()); // cmRelation.setRelationIsTransfer(0); // cmRelation.setRelationBackPostage(0); // break; // case 3: // procMethodId = 3; // break; // case 4: // procMethodId = 6; // break; // case 5: // procMethodId = 13; // cmRelation.setRelationBackStatus(1); //寄回状态 1:未寄回 2:已寄回 3:已收货 4: 已签收待确认 // break; // case 6: // procMethodId = 10; // cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送 2:已寄送 3:已收货 // break; // case 7: // procMethodId = 8; // cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送 2:已寄送 3:已收货 // break; // default: // procMethodId = 2; // cmRelation.setRelationBackStatus(1); //寄回状态 1:未寄回 2:已寄回 3:已收货 4: 已签收待确认 // cmRelation.setRelationSendStatus(1); //寄送状态 1:未寄送 2:已寄送 3:已收货 // break; // } // cmRelation.setProcMethodId(procMethodId); // cmRelation.setRelationState(1); // // flag = cmRelationMapper.save(cmRelation); // if (flag < 1) { // throw new RuntimeException("添加处理方式失败"); // } // // if(customerInfo.getCustomerIsSolve() == 3 || customerInfo.getCustomerIsSolve() == 4 || customerInfo.getCustomerIsSolve() == 5 || // customerInfo.getCustomerIsSolve() == 6 ||customerInfo.getCustomerIsSolve() == 7 ){ // // //删除寄出寄回产品 ----- // ClosedProdcue closedrecord = new ClosedProdcue(); // SendProdcue sendProdcue = new SendProdcue(); // closedrecord.setRelationId(customerCommon.getRelationId()); // closedrecord.setClosedProdcueType(customerCommon.getCustomerIsSolve()); // closedProdcueMapper.deleteProduce(closedrecord); // sendProdcue.setRelationId(customerCommon.getRelationId()); // sendProdcue.setSendProduceType(customerCommon.getCustomerIsSolve()); // sendProdcueMapper.deleteByPrimaryKey(sendProdcue); // // /*恢复订单状态 ------------ */ // RelationOrder relationOrder = new RelationOrder(); // relationOrder.setRelationType(customerCommon.getCustomerIsSolve()); // relationOrder.setRelationId(customerCommon.getRelationId()); // List relationOrderList = relationOrderService.getRelationOrderList(relationOrder); // for (int k=0; k relationAndOrderList = new ArrayList<>(); // for (RelationOrder sokk : relationOrderList) { // RelationOrder ro = new RelationOrder(); // ro.setRelationId(cmRelation.getRelationId()); // ro.setSalesId(sokk.getSalesId()); // ro.setRelationCustomerId(customerInfo.getCustomerId()); // relationAndOrderList.add(ro); // } // if(relationAndOrderList != null && relationAndOrderList.size() > 0){ // relationOrderService.saveList(relationAndOrderList); // } // // Integer fl = 0; // /*产品整理*/ // try{ // customerService.setName(cmRelation); // fl = 1; // }catch (Exception e){ // e.printStackTrace(); // } // // if(fl == 1){ // CustomerCommonUtil.setProduce(cmRelation); // if(cmRelation.getClosedProdcues() != null && cmRelation.getClosedProdcues().size()>0){ // closedProdcueMapper.insert(cmRelation.getClosedProdcues()); // } // if(cmRelation.getSendProdcues() != null && cmRelation.getSendProdcues().size() > 0){ // sendProdcueMapper.insert(cmRelation.getSendProdcues()); // } // } // } // return flag; return 0; } @Override public List listCustomerCommons(CustomerCommon customerCommon) { List customerCommonList = new ArrayList<>(); customerCommonList.add(customerCommon); for (CustomerCommon c : customerCommonList) { RelationOrder relationOrder = new RelationOrder(); relationOrder.setRelationId(c.getRelationId()); List relationOrderList = relationOrderMapper.getRelationOrderList(relationOrder); List orderList = new ArrayList<>(); for (RelationOrder ro : relationOrderList) { SalesOrder salesOrder = salesOrderMapper.getSalesOrderById(ro.getSalesId()); if(salesOrder != null ){ SalesOrderItem salesOrderItem = new SalesOrderItem(); salesOrderItem.setItemOrderId(salesOrder.getSalesId()); salesOrder.setSalesOrderItemList(salesOrderMapper.listSalesOrderItem(salesOrderItem)); orderList.add(salesOrder); } } c.setSalesOrderList(orderList); SendProdcue sendProdcue = new SendProdcue(); sendProdcue.setRelationId(c.getRelationId()); List sendProdcueList = sendProdcueMapper.listSendProdcue(sendProdcue); c.setSendProdcues(sendProdcueList); ClosedProdcue closedProdcue = new ClosedProdcue(); closedProdcue.setRelationId(c.getRelationId()); List closedProdcueList = closedProdcueMapper.listclosedProdcue(closedProdcue); c.setClosedProdcues(closedProdcueList); } return customerCommonList; } @Override public PostageInfo getPostageInfo(Integer postageId) { return customerInfoMapper.getPostageInfo(postageId); } @Override public List listPostageInfo(Integer relationId) { return customerInfoMapper.listPostageInfo(relationId); } @Override public Integer addPostageInfo(PostageInfo postageInfo) { return customerInfoMapper.addPostageInfo(postageInfo); } @Override public Integer updatePostageInfo(PostageInfo postageInfo) { return customerInfoMapper.updatePostageInfo(postageInfo); } @Override public Integer deletePostageInfo(Integer postageId) { return customerInfoMapper.deletePostageInfo(postageId); } @Override @Transactional public String synchronizePostageInfo() { List cmRelationlist = cmRelationMapper.getCmRelationList(new CmRelation()); Integer num = 0;//成功个数 Integer oum = 0;//失败个数 try { for (CmRelation cmRelation : cmRelationlist){ PostageInfo postageInfo = new PostageInfo(); postageInfo.setRelationId(cmRelation.getRelationId()); postageInfo.setPostageAlipay(cmRelation.getRelationAlipay() == null ? "" : cmRelation.getRelationAlipay()); postageInfo.setPostageAlipayName(cmRelation.getRelationAlipayName() == null ? "" : cmRelation.getRelationAlipayName()); if(cmRelation.getRelationBackPostage() == null){ postageInfo.setPostageAmount(0); }else{ postageInfo.setPostageAmount(cmRelation.getRelationBackPostage()); } if(cmRelation.getRelationIsTransfer() == null){ postageInfo.setPostageStatus(1); }else{ if(cmRelation.getRelationIsTransfer() == 1){ postageInfo.setPostageStatus(3); }else if (cmRelation.getRelationIsTransfer() == 3){ postageInfo.setPostageStatus(1); }else if (cmRelation.getRelationIsTransfer() == 10){ postageInfo.setPostageStatus(4); }else{ postageInfo.setPostageStatus(cmRelation.getRelationIsTransfer()); } } if(cmRelation.getRelationIsTransfer() != null){ int msg = customerService.addPostageInfo(postageInfo); if(msg < 1){ oum++; }else{ num++; } } } } catch (Exception e) { throw new RuntimeException("同步邮费信息失败"); } return "同步成功:"+num+"个,失败:"+oum+"个"; } @Override @Transactional public String synchronizeSendbackInfo() { List cmRelationlist = cmRelationMapper.getCmRelationList(new CmRelation()); Integer num = 0;//成功个数 Integer oum = 0;//失败个数 try { for (CmRelation cmRelation : cmRelationlist){ SendbackInfo sendbackInfo = new SendbackInfo(); sendbackInfo.setRelationId(cmRelation.getRelationId()); sendbackInfo.setSendbackLogisticsCompany(cmRelation.getRelationBackLogisticsCompany()); sendbackInfo.setSendbackLogisticsNo(cmRelation.getRelationBackLogisticsNo()); sendbackInfo.setSendbackName(cmRelation.getRelationBackName()); sendbackInfo.setSendbackTel(cmRelation.getRelationBackTel()); sendbackInfo.setSendbackStatus(cmRelation.getRelationBackStatus()); sendbackInfo.setSendbackSignTime(cmRelation.getRelationBackReceiptDate()); int s = customerInfoMapper.addSendbackInfo(sendbackInfo); if(s > 0){ num++; ClosedProdcue closedProdcue = new ClosedProdcue(); closedProdcue.setRelationId(cmRelation.getRelationId()); List listClosedProdcue = closedProdcueMapper.listclosedProdcue(closedProdcue); List listSendbackItem = new ArrayList<>(); for(ClosedProdcue prodcue : listClosedProdcue){ SendbackItem sendbackItem = new SendbackItem(); sendbackItem.setSendbackId(sendbackInfo.getSendbackId()); sendbackItem.setSendbackProductId(prodcue.getProductId()); sendbackItem.setSendbackColorId(prodcue.getColorId()); sendbackItem.setSendbackProdcueNumber(prodcue.getClosedProdcueNumber()); sendbackItem.setSendbackProdcueNumber(prodcue.getClosedProdcueNumber()); listSendbackItem.add(sendbackItem); } if(listSendbackItem.size() > 0){ customerInfoMapper.addSendbackItemList(listSendbackItem); } }else{ oum++; } } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("同步寄回信息失败"); } return "同步成功:"+num+"个,失败:"+oum+"个"; } @Override @Transactional public SendbackInfo addSendbackInfo(SendbackInfo sendbackInfo) { JSONArray jsonArray; List sendbackItemList; Integer msg = customerInfoMapper.addSendbackInfo(sendbackInfo); jsonArray = JSONArray.fromObject(sendbackInfo.getSendProdcues()); sendbackItemList = (List) JSONArray.toCollection(jsonArray, SendbackItem.class); if(msg < 1){ return null; } List sendbackItemLists = new ArrayList<>(); for (SendbackItem info : sendbackItemList){ info.setSendbackId(sendbackInfo.getSendbackId()); if(info.getSendbackProdcueNumber() > 0){ sendbackItemLists.add(info); } } Integer msgs = customerService.addSendbackItemList(sendbackItemLists); if(msgs < 1){ throw new RuntimeException("添加寄回产品项信息失败"); } return sendbackInfo; } @Override public Integer addSendbackItemList(List list) { return customerInfoMapper.addSendbackItemList(list); } @Override public SendbackInfo getSendbackInfo(Integer sendbackId) { return customerInfoMapper.getSendbackInfo(sendbackId); } @Override public List listSendbackInfo(Integer relationId) { return customerInfoMapper.listSendbackInfo(relationId); } @Override public List sendbackItemList(Integer sendbackId) { return customerInfoMapper.sendbackItemList(sendbackId); } @Override public SendbackInfo updateSendbackInfo(SendbackInfo sendbackInfo) { JSONArray jsonArray; List sendbackItemList; Integer msg = customerInfoMapper.updateSendbackInfo(sendbackInfo); jsonArray = JSONArray.fromObject(sendbackInfo.getSendProdcues()); sendbackItemList = (List) JSONArray.toCollection(jsonArray, SendbackItem.class); if(msg < 1){ return null; } //删除原寄回产品项 if(customerInfoMapper.deleteSendbackItemBySendbackId(sendbackInfo.getSendbackId()) < 1){ throw new RuntimeException("删除寄回产品项信息失败"); } List sendbackItemLists = new ArrayList<>(); for (SendbackItem info : sendbackItemList){ info.setSendbackId(sendbackInfo.getSendbackId()); if(info.getSendbackProdcueNumber() > 0){ sendbackItemLists.add(info); } } Integer msgs = customerService.addSendbackItemList(sendbackItemLists); if(msgs < 1){ throw new RuntimeException("修改寄回产品项信息失败"); } return sendbackInfo; } @Override public Integer updateSendbackStatus(SendbackInfo sendbackInfo) { return customerInfoMapper.updateSendbackInfo(sendbackInfo); } @Override public Integer updateSendbackItem(SendbackItem sendbackItem) { return customerInfoMapper.updateSendbackItem(sendbackItem); } @Override public Integer deleteSendbackInfo(Integer sendbackId) { return customerInfoMapper.deleteSendbackInfo(sendbackId); } @Override public Integer deleteSendbackItemById(Integer sendbackItemId) { return customerInfoMapper.deleteSendbackItemById(sendbackItemId); } @Override public Integer deleteSendbackItemBySendbackId(Integer sendbackId) { return customerInfoMapper.deleteSendbackItemBySendbackId(sendbackId); } @Override public List listclosedProdcue(ClosedProdcue closedProdcue) { return closedProdcueMapper.listclosedProdcue(closedProdcue); } }