|
@@ -2,16 +2,22 @@ package com.iamberry.rst.service.cm;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.iamberry.rst.core.cm.*;
|
|
|
+import com.iamberry.rst.core.order.EfastOrder;
|
|
|
+import com.iamberry.rst.core.order.OrderItem;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
-import com.iamberry.rst.core.pts.PtsSupplier;
|
|
|
import com.iamberry.rst.faces.cm.CustomerService;
|
|
|
import com.iamberry.rst.service.cm.mapper.*;
|
|
|
+import com.iamberry.rst.service.order.EfastOrderServiceImpl;
|
|
|
import com.iamberry.rst.util.PageUtil;
|
|
|
+import freemarker.ext.beans.HashAdapter;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class CustomerServiceImpl implements CustomerService {
|
|
@@ -33,32 +39,193 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
@Autowired
|
|
|
private ClosedProdcueMapper closedProdcueMapper;
|
|
|
@Autowired
|
|
|
- private VisitMapper visitMapper;
|
|
|
+ private VisitMapper visitMapper; //回访
|
|
|
+ @Autowired
|
|
|
+ private ComplaintSignclosedInfoMapper complaintSignclosedInfoMapper; //仓储
|
|
|
+ @Autowired
|
|
|
+ private ComplaintDetectInfoMapper complaintDetectInfoMapper; //品检
|
|
|
+ @Autowired
|
|
|
+ private SalesOrderMapper salesOrderMapper; //订单
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Integer saveCustomerInfo(CustomerInfo customerInfo) {
|
|
|
+ public Integer saveCustomerInfo(CustomerInfo customerInfo,SalesOrder salesOrder) {
|
|
|
+
|
|
|
+ salesOrder = salesOrderMapper.getSalesOrderById(salesOrder.getSalesId());
|
|
|
+
|
|
|
//添加客诉基本信息
|
|
|
Integer flag = 0;
|
|
|
flag = customerInfoMapper.insert(customerInfo);
|
|
|
|
|
|
- Visit visit = customerInfo.getVisit();
|
|
|
- flag = visitMapper.addVisitInfo(visit);
|
|
|
+ if ("2".equals(customerInfo.getCustomerIsVisit())) {
|
|
|
+ Visit visit = customerInfo.getVisit();
|
|
|
+ flag = visitMapper.addVisitInfo(visit);
|
|
|
+ }
|
|
|
|
|
|
-// if(2 == customerInfo.getCustomerCounselType()){
|
|
|
-// switch (customerInfo.getCustomerIsSolve()){
|
|
|
-// case 3: //换新
|
|
|
-// // CustomerCommon
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if (2 == customerInfo.getCustomerCounselType()) {
|
|
|
+ CustomerCommon customerCommon = customerInfo.getCustomerCommon();
|
|
|
+ customerCommon.setCustomerId(customerInfo.getCustomerId()); //设置客诉id
|
|
|
+ customerCommon.setRelationBackStatus(1); //寄回状态 1:未寄回
|
|
|
+ customerCommon.setRelationSendStatus(1); //寄送状态 1:未寄送
|
|
|
+ customerCommon.setRelationState(1); //状态 默认使用中
|
|
|
+ customerCommon.setOrderId(salesOrder.getSalesId()); //订单id
|
|
|
|
|
|
+ ComplaintDetectInfo complaintDetectInfo = new ComplaintDetectInfo();
|
|
|
+ ComplaintSignclosedInfo complaintSignclosedInfo = new ComplaintSignclosedInfo();
|
|
|
+ Map<String,Object> map;
|
|
|
+ switch (customerInfo.getCustomerIsSolve()) { //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
|
|
|
+ case 3: //换新
|
|
|
+ map = this.sendEfastOrder(); //换新需要向Efast推送一条换新发货的订单
|
|
|
+ if(map.get("status") == 1){
|
|
|
+ customerCommon.setRelationBackEfastOrderId(String.valueOf(map.get("EfastOrderId"))); //存放Efast订单编号
|
|
|
+ complaintSignclosedInfo.setNewEfastId(String.valueOf(map.get("EfastOrderId"))); //仓储签收表添加 发货的Efast订单id
|
|
|
+ }else{
|
|
|
|
|
|
+ }
|
|
|
+ complaintSignclosedInfo.setOldEfastId(salesOrder.getSalesOrderId()); //原有订单的Efast的订单编号
|
|
|
+ this.saveComplaintSignclosedInfo(complaintSignclosedInfo,customerCommon);//创建仓储任务
|
|
|
+ complaintDetectInfo.setSignclosedId(complaintSignclosedInfo.getSignclosedId()); //设置仓储签收id
|
|
|
+ this.saveComplaintDetectInfo(complaintDetectInfo,customerCommon); //创建品检
|
|
|
+ break;
|
|
|
+ case 4: //维修
|
|
|
+ map = this.sendEfastOrder(); //维修需要向Efast推送一条维修发货的订单
|
|
|
+ if(map.get("status") == 1){
|
|
|
+ customerCommon.setRelationBackEfastOrderId(String.valueOf(map.get("EfastOrderId"))); //存放Efast订单编号
|
|
|
+ complaintSignclosedInfo.setNewEfastId(String.valueOf(map.get("EfastOrderId"))); //仓储签收表添加 发货的Efast订单id
|
|
|
+ }else{
|
|
|
|
|
|
+ }
|
|
|
+ complaintSignclosedInfo.setOldEfastId(salesOrder.getSalesOrderId()); //原有订单的Efast的订单编号
|
|
|
+ this.saveComplaintSignclosedInfo(complaintSignclosedInfo,customerCommon);//创建仓储任务
|
|
|
+ complaintDetectInfo.setSignclosedId(complaintSignclosedInfo.getSignclosedId()); //设置仓储签收id
|
|
|
+ this.saveComplaintDetectInfo(complaintDetectInfo,customerCommon); //创建品检
|
|
|
+ break;
|
|
|
+ case 5: //补发 不用创建仓储签收任务
|
|
|
+ map = this.sendEfastOrder(); //补发需要向Efast推送一条发货的订单
|
|
|
+ if(map.get("status") == 1){
|
|
|
+ customerCommon.setRelationBackEfastOrderId(String.valueOf(map.get("EfastOrderId"))); //存放Efast订单编号
|
|
|
+ complaintSignclosedInfo.setNewEfastId(String.valueOf(map.get("EfastOrderId"))); //仓储签收表添加 发货的Efast订单id
|
|
|
+ }else{
|
|
|
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6: //退货
|
|
|
+ complaintSignclosedInfo.setOldEfastId(salesOrder.getSalesOrderId()); //原有订单的Efast的订单编号
|
|
|
+ this.saveComplaintSignclosedInfo(complaintSignclosedInfo,customerCommon);//创建仓储任务
|
|
|
+ complaintDetectInfo.setSignclosedId(complaintSignclosedInfo.getSignclosedId()); //设置仓储签收id
|
|
|
+ this.saveComplaintDetectInfo(complaintDetectInfo,customerCommon); //创建品检
|
|
|
+ break;
|
|
|
+ case 7: //无理由退货
|
|
|
+ complaintSignclosedInfo.setOldEfastId(salesOrder.getSalesOrderId()); //原有订单的Efast的订单编号
|
|
|
+ this.saveComplaintSignclosedInfo(complaintSignclosedInfo,customerCommon);//创建仓储任务
|
|
|
+ complaintDetectInfo.setSignclosedId(complaintSignclosedInfo.getSignclosedId()); //设置仓储签收id
|
|
|
+ this.saveComplaintDetectInfo(complaintDetectInfo,customerCommon); //创建品检
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ customerCommon.setSignclosedId(complaintSignclosedInfo.getSignclosedId()); //设置仓储id
|
|
|
+
|
|
|
+ //新建仓储任务, 补发不用生成
|
|
|
+ //
|
|
|
+
|
|
|
+
|
|
|
+ Object object = CustomerCommon.getRelation(customerInfo.getCustomerIsSolve(), customerCommon);
|
|
|
+ Integer relationId;
|
|
|
+ switch (customerInfo.getCustomerIsSolve()) { //处理结果: 1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
|
|
|
+ case 3: //换新
|
|
|
+ Renewed renewed = (Renewed) object;
|
|
|
+ flag = renewedMapper.insert(renewed);
|
|
|
+ relationId = renewed.getRenewedId();
|
|
|
+ break;
|
|
|
+ case 4: //维修
|
|
|
+ Repair repair = (Repair) object;
|
|
|
+ flag = repairMapper.insert(repair);
|
|
|
+ relationId = repair.getRepairId();
|
|
|
+ break;
|
|
|
+ case 5: //补发
|
|
|
+ Reissue reissue = (Reissue) object;
|
|
|
+ flag = reissueMapper.insert(reissue);
|
|
|
+ relationId = reissue.getReissueId();
|
|
|
+ break;
|
|
|
+ case 6: //退货
|
|
|
+ BackGoods backGoods = (BackGoods) object;
|
|
|
+ flag = backGoodsMapper.insert(backGoods);
|
|
|
+ relationId = backGoods.getBackGoodsId();
|
|
|
+ break;
|
|
|
+ case 7: //无理由退货
|
|
|
+ NoreasonBack noreasonBack = (NoreasonBack) object;
|
|
|
+ flag = noreasonBackMapper.insert(noreasonBack);
|
|
|
+ relationId = noreasonBack.getNoreasonBackId();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (flag < 1) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加品检
|
|
|
+ * @param complaintDetectInfo
|
|
|
+ * @param customerCommon
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void saveComplaintDetectInfo(ComplaintDetectInfo complaintDetectInfo,CustomerCommon customerCommon){
|
|
|
+ Integer flag;
|
|
|
+ complaintDetectInfo.setCustomerId(customerCommon.getCustomerId()); //添加客诉
|
|
|
+// complaintDetectInfo.setProductId(); //品检产品id
|
|
|
+// complaintDetectInfo.setDetectProductNumber(); //产品型号
|
|
|
+ complaintDetectInfo.setDetectState(1); //状态 1待仓库转入
|
|
|
+ complaintDetectInfo.setDetectRevolutionProduced(1); //是否转入生产部门 1待转入
|
|
|
+ flag = complaintDetectInfoMapper.insert(complaintDetectInfo);
|
|
|
+ if(flag < 1){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加仓储
|
|
|
+ * @param customerCommon
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public void saveComplaintSignclosedInfo(ComplaintSignclosedInfo complaintSignclosedInfo,CustomerCommon customerCommon){
|
|
|
+ Integer flag;
|
|
|
+ complaintSignclosedInfo.setSignclosedId(1); //签收类型 : 客诉寄回
|
|
|
+ complaintSignclosedInfo.setSignclosedIsQuality(1); //是否平品检 1:需要品检
|
|
|
+ complaintSignclosedInfo.setSignclosedIsInto(2); //是否已转入品检 2:未转入品检
|
|
|
+ complaintSignclosedInfo.setSignclosedState(2); //处理状态 2:未签收
|
|
|
+ complaintSignclosedInfo.setSignclosedObjectsState(3); //物件状态 3:暂未签收
|
|
|
+ complaintSignclosedInfo.setSignclosedCustomerId(customerCommon.getCustomerId()); //客诉id
|
|
|
+ flag = complaintSignclosedInfoMapper.insert(complaintSignclosedInfo);
|
|
|
+ if(flag < 1){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加代签收表
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 像Efast推送订单 仅换新,维修
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> sendEfastOrder(){
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ EfastOrderServiceImpl efastOrderService = new EfastOrderServiceImpl();
|
|
|
+ List<EfastOrder> orderList = new ArrayList<EfastOrder>();
|
|
|
+ List<OrderItem > itemList = new ArrayList<OrderItem>();
|
|
|
+// try {
|
|
|
+// efastOrderService.sendOrderInfoToEfast(orderList,itemList);
|
|
|
+// } catch (Exception e) {
|
|
|
+// flag = 0;
|
|
|
+// }
|
|
|
+ map.put("status",1);
|
|
|
+ map.put("EfastOrderId","xxxxxxxxxxxxxxxxx");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public CustomerInfo getCustomerInfo(Integer customerId) {
|
|
|
return customerInfoMapper.getCustomerInfo(customerId);
|
|
@@ -166,7 +333,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
return null;
|
|
|
}
|
|
|
renewedInfo = renewedList.get(0);
|
|
|
- customerCommon = CustomerCommon.getCustomerCommon(3,renewedInfo);
|
|
|
+ customerCommon = CustomerCommon.getCustomerCommon(3, renewedInfo);
|
|
|
break;
|
|
|
case 4://维修
|
|
|
//查询售后维修集合
|
|
@@ -178,7 +345,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
return null;
|
|
|
}
|
|
|
repairInfo = repairList.get(0);
|
|
|
- customerCommon = CustomerCommon.getCustomerCommon(4,repairInfo);
|
|
|
+ customerCommon = CustomerCommon.getCustomerCommon(4, repairInfo);
|
|
|
break;
|
|
|
case 5://补发
|
|
|
//查询售后补发集合
|
|
@@ -190,7 +357,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
return null;
|
|
|
}
|
|
|
reissueInfo = reissueList.get(0);
|
|
|
- customerCommon = CustomerCommon.getCustomerCommon(5,reissueInfo);
|
|
|
+ customerCommon = CustomerCommon.getCustomerCommon(5, reissueInfo);
|
|
|
break;
|
|
|
case 6://退货
|
|
|
//查询售后退货集合
|
|
@@ -202,7 +369,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
return null;
|
|
|
}
|
|
|
backGoodsInfo = backGoodsList.get(0);
|
|
|
- customerCommon = CustomerCommon.getCustomerCommon(6,backGoodsInfo);
|
|
|
+ customerCommon = CustomerCommon.getCustomerCommon(6, backGoodsInfo);
|
|
|
break;
|
|
|
case 7://无理由退货
|
|
|
//查询售后无理由退货集合
|
|
@@ -214,7 +381,7 @@ public class CustomerServiceImpl implements CustomerService {
|
|
|
return null;
|
|
|
}
|
|
|
noreasonBackInfo = noreasonBackList.get(0);
|
|
|
- customerCommon = CustomerCommon.getCustomerCommon(7,noreasonBackInfo);
|
|
|
+ customerCommon = CustomerCommon.getCustomerCommon(7, noreasonBackInfo);
|
|
|
break;
|
|
|
}
|
|
|
return customerCommon;
|