|
@@ -7,28 +7,35 @@ import com.iamberry.rst.core.page.PagedResult;
|
|
|
import com.iamberry.rst.faces.cm.SalesOrderService;
|
|
|
import com.iamberry.rst.faces.cm.StoreInfoService;
|
|
|
import com.iamberry.rst.faces.order.EfastOrderService;
|
|
|
+import com.iamberry.rst.utils.ExcelUtil;
|
|
|
import com.iamberry.rst.utils.StitchAttrUtil;
|
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
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.multipart.MultipartFile;
|
|
|
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.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static com.iamberry.rst.util.SmsConfig.SEND_NOTICE;
|
|
|
+
|
|
|
/**
|
|
|
* 订单信息
|
|
|
* Created by liuzhiwei on 2017/12/4.
|
|
@@ -298,6 +305,35 @@ public class AdminSalesOrderController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取快递公司
|
|
|
+ * @param firm
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getPostCode(String firm) {
|
|
|
+ String postCode = "";
|
|
|
+ switch (firm) {
|
|
|
+ case "申通快递":postCode = "sto";break;
|
|
|
+ case "圆通快递":postCode = "yto";break;
|
|
|
+ case "顺丰快递":postCode = "sf";break;
|
|
|
+ case "邮政EMS":postCode = "ems";break;
|
|
|
+ case "省外EMS":postCode = "ems";break;
|
|
|
+ case "中通快递":postCode = "zto";break;
|
|
|
+ case "宅急送":postCode = "zjs";break;
|
|
|
+ case "韵达快递":postCode = "yunda";break;
|
|
|
+ case "cces快递":postCode = "cces";break;
|
|
|
+ case "上门提货":postCode = "pick";break;
|
|
|
+ case "汇通快递":postCode = "htky";break;
|
|
|
+ case "天天快递":postCode = "ttkdex";break;
|
|
|
+ case "星晨急便":postCode = "stars";break;
|
|
|
+ case "京东快递":postCode = "jd";break;
|
|
|
+ case "其他":postCode = "01";break;
|
|
|
+ case "上门送货":postCode = "02";break;
|
|
|
+ default:postCode = "sto";break;
|
|
|
+ }
|
|
|
+ return postCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 同步百胜订单
|
|
|
*
|
|
|
* @return
|
|
@@ -453,4 +489,62 @@ public class AdminSalesOrderController {
|
|
|
//下载导出订单Excel
|
|
|
downloadOrderExcel(res,wb);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传efast物流信息excel到系统订单
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/uploadLogisticsExcel")
|
|
|
+ @ResponseBody
|
|
|
+ public String uploadLogisticsExcel(HttpServletResponse response,HttpServletRequest request,@RequestParam("file") String file)throws IOException {
|
|
|
+ Integer maxNumber = 100;
|
|
|
+ String path = request.getServletContext().getRealPath(file);
|
|
|
+ boolean flag = ExcelUtil.readExcelNumber(path,maxNumber);
|
|
|
+ if(!flag){
|
|
|
+ return "最大上传数量为一百条,请检查文档内的数据是否正常!";
|
|
|
+ }
|
|
|
+ List<String> listString = ExcelUtil.readExcelHead(path);
|
|
|
+ if(listString == null){
|
|
|
+ return "数据不合格,请检查文档内的数据是否正常!";
|
|
|
+ }
|
|
|
+ List<String> tradings = ExcelUtil.readCell2(path,listString.get(2));//外部交易号
|
|
|
+ List<String> oderIds = ExcelUtil.readCell2(path,listString.get(4));//efast订单号
|
|
|
+ List<String> kuyaidi = ExcelUtil.readCell2(path,listString.get(12));//快递公司
|
|
|
+ List<String> danhao = ExcelUtil.readCell2(path,listString.get(15));//快递单号
|
|
|
+ if(oderIds == null || tradings == null || kuyaidi == null || danhao == null){
|
|
|
+ return "数据不合格,请检查文档内的数据是否正常!";
|
|
|
+ }
|
|
|
+ if(oderIds.size() != kuyaidi.size() || oderIds.size() != danhao.size()|| oderIds.size() != tradings.size()){
|
|
|
+ return "数据不合格,请检查文档内的数据是否正常!";
|
|
|
+ }
|
|
|
+ SalesOrder salesOrder = new SalesOrder();
|
|
|
+ Integer success = 0,error = 0;
|
|
|
+ List<String> errorOrders = new ArrayList();
|
|
|
+ for (int i = 0;i< tradings.size();i++){
|
|
|
+ if( tradings.get(i) != null && !tradings.get(i).equals("") &&
|
|
|
+ oderIds.get(i) != null && !oderIds.get(i).equals("") &&
|
|
|
+ kuyaidi.get(i) != null && !kuyaidi.get(i).equals("") &&
|
|
|
+ danhao.get(i) != null && !danhao.get(i).equals("")){
|
|
|
+ String code = getPostCode(kuyaidi.get(i));
|
|
|
+ salesOrder.setSalesDealCode(tradings.get(i));
|
|
|
+ salesOrder.setSalesOrderId(oderIds.get(i));
|
|
|
+ salesOrder.setSalesPostFirm(code);
|
|
|
+ salesOrder.setSalesPostNum(danhao.get(i));
|
|
|
+ Integer msg = salesOrderService.updateSalesOrderByDealCode(salesOrder);
|
|
|
+ if(msg > 0){
|
|
|
+ success++;
|
|
|
+ }else{
|
|
|
+ errorOrders.add(tradings.get(i));
|
|
|
+ error++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String data = "上传完成,成功:"+success+"条,失败:"+error+"条";
|
|
|
+ if(error > 0){
|
|
|
+ data = data+errorOrders.toString();
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|