|
@@ -1,9 +1,14 @@
|
|
|
package com.iamberry.rst.utils;
|
|
|
|
|
|
+import com.iamberry.rst.core.dm.DealerChannel;
|
|
|
+import com.iamberry.rst.core.dm.DealerProduct;
|
|
|
+import com.iamberry.rst.core.dm.DealerProductStore;
|
|
|
import com.iamberry.rst.core.order.EfastOrder;
|
|
|
import com.iamberry.rst.core.order.ProductColor;
|
|
|
import com.iamberry.rst.core.pts.PtsBomComponents;
|
|
|
import com.iamberry.rst.faces.cm.SalesOrderService;
|
|
|
+import com.iamberry.rst.faces.dm.DealerChannelService;
|
|
|
+import com.iamberry.rst.faces.dm.DealerProductService;
|
|
|
import com.iamberry.wechat.tools.AddrUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
@@ -36,6 +41,10 @@ public class ExcelUtil {
|
|
|
|
|
|
@Autowired
|
|
|
private SalesOrderService salesOrderService;
|
|
|
+ @Autowired
|
|
|
+ private DealerChannelService dealerChannelService;
|
|
|
+ @Autowired
|
|
|
+ private DealerProductService dealerProductService;
|
|
|
|
|
|
/**
|
|
|
* 读取Excel文件头
|
|
@@ -374,7 +383,7 @@ public class ExcelUtil {
|
|
|
|
|
|
public List<EfastOrder> readCell(String filePath, String productName, String[] maps,
|
|
|
String[] infos, String tel, String name,String platformOrder, String num, String discount,String remark,
|
|
|
- Map<String, ProductColor> price, String postType, String orderStoreInfoSt, Integer isOtherStore,String[] storeArray,Integer selfOperated)
|
|
|
+ Map<String, ProductColor> price, String postType, String orderStoreInfoSt, Integer isOtherStore,String[] storeArray)
|
|
|
throws IOException {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
for (String t : maps) {
|
|
@@ -552,34 +561,6 @@ public class ExcelUtil {
|
|
|
}
|
|
|
order.setOrderRemark(orderRemark);
|
|
|
|
|
|
- String colorDiscount = "0";
|
|
|
- if(selfOperated == 1){
|
|
|
- colorDiscount = getValue(temp.getCell(discountColumnIndex)).trim();
|
|
|
- if(colorDiscount != null && !"".equals(colorDiscount)){
|
|
|
- colorDiscount = colorDiscount.replaceAll("\\r|\\r|\\n","");
|
|
|
- }
|
|
|
- if(colorDiscount == null || "".equals(colorDiscount)){
|
|
|
- order.setReturnStatus("error");
|
|
|
- order.setReturnMsg("价格不正确");
|
|
|
- // 读取购买数量
|
|
|
- order.setOrderProductDiscount(0);
|
|
|
- order.setOrderProductPrice(0);
|
|
|
- }else{
|
|
|
- // 读取购买数量
|
|
|
- Double colorDiscountDou = Double.valueOf(colorDiscount);
|
|
|
- colorDiscountDou = colorDiscountDou*100/orderNumByInt;
|
|
|
- order.setOrderProductDiscount(colorDiscountDou.intValue());
|
|
|
- order.setOrderProductPrice(colorDiscountDou.intValue());
|
|
|
- Double orderTotal = Double.valueOf(colorDiscount);
|
|
|
- orderTotal = orderTotal*100;
|
|
|
- order.setOrderTotal(orderTotal.intValue());
|
|
|
- }
|
|
|
- }else{
|
|
|
- order.setOrderProductDiscount(0);
|
|
|
- order.setOrderProductPrice(0);
|
|
|
- order.setOrderTotal(0);
|
|
|
- }
|
|
|
-
|
|
|
try{
|
|
|
if (infoColumnIndex.length == 1){
|
|
|
// 如果infoColumnIndex = 1, 则表示需要截取(可能是-、“ ”)
|
|
@@ -646,6 +627,92 @@ public class ExcelUtil {
|
|
|
//店铺
|
|
|
order.setStoreId(Integer.valueOf(storeArray[0]));
|
|
|
}
|
|
|
+
|
|
|
+ //-- 获取价格 --
|
|
|
+ order.setOrderProductDiscount(-1);
|
|
|
+ order.setOrderProductPrice(-1);
|
|
|
+ order.setOrderTotal(-1);
|
|
|
+ DealerChannel dealerChannel = new DealerChannel();
|
|
|
+ boolean flag = true;
|
|
|
+ if(order.getStoreId() != null){
|
|
|
+ dealerChannel.setStoreId(order.getStoreId());
|
|
|
+ List<DealerChannel> dealerChannelList = dealerChannelService.getDealerChannelList(dealerChannel);
|
|
|
+ if(dealerChannelList!= null && dealerChannelList.size() > 0){
|
|
|
+ dealerChannel = dealerChannelList.get(0);
|
|
|
+ }else{
|
|
|
+ order.setReturnStatus("error");
|
|
|
+ order.setReturnMsg("订单导入失败-查询店铺对应客户信息失败,店铺ID:"+order.getStoreId()+"。");
|
|
|
+ order.setPlatformOrderId("1");
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(flag){
|
|
|
+ if(1 == dealerChannel.getDealerSelfOperated()){
|
|
|
+ //是否自营 1:自营 2:非自营
|
|
|
+ String colorDiscount = "-1";
|
|
|
+ colorDiscount = getValue(temp.getCell(discountColumnIndex)).trim();
|
|
|
+ if(colorDiscount != null && !"".equals(colorDiscount)){
|
|
|
+ colorDiscount = colorDiscount.replaceAll("\\r|\\r|\\n","");
|
|
|
+ }
|
|
|
+ if(colorDiscount == null || "".equals(colorDiscount)){
|
|
|
+ order.setReturnStatus("error");
|
|
|
+ order.setReturnMsg("价格不正确"+"。");
|
|
|
+ order.setPlatformOrderId("1");
|
|
|
+ }else{
|
|
|
+ // 计算单个价格
|
|
|
+ Double colorDiscountDou = Double.valueOf(colorDiscount);
|
|
|
+ colorDiscountDou = colorDiscountDou*100/orderNumByInt;
|
|
|
+ order.setOrderProductDiscount(colorDiscountDou.intValue());
|
|
|
+ order.setOrderProductPrice(colorDiscountDou.intValue());
|
|
|
+ //赋值小结
|
|
|
+ Double orderTotal = Double.valueOf(colorDiscount);
|
|
|
+ orderTotal = orderTotal*100;
|
|
|
+ order.setOrderTotal(orderTotal.intValue());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //2:非自营
|
|
|
+ DealerProduct dealerProduct = new DealerProduct();
|
|
|
+ dealerProduct.setDealerId(dealerChannel.getDealerId());
|
|
|
+ dealerProduct.setColorBar(OrderProductBarCodeValue);
|
|
|
+ List<DealerProduct> dealerProductList = dealerProductService.getDealerProductAndStoreList(dealerProduct);
|
|
|
+ if(dealerProductList != null && dealerProductList.size() > 0){
|
|
|
+ for (DealerProduct dp:dealerProductList) {
|
|
|
+ if(1 == dp.getDealProdStoreArea()){
|
|
|
+ // 1:全部店铺
|
|
|
+ order.setOrderProductDiscount(dp.getDealProdPrice());
|
|
|
+ order.setOrderProductPrice(dp.getDealProdPrice());
|
|
|
+ order.setOrderTotal(dp.getDealProdPrice()*orderNumByInt);
|
|
|
+ }else{
|
|
|
+ // 2:部分店铺
|
|
|
+ for (DealerProductStore dps:dp.getDealerProductStoreList()) {
|
|
|
+ if(order.getStoreId().equals(dps.getStoreId())){
|
|
|
+ order.setOrderProductDiscount(dp.getDealProdPrice());
|
|
|
+ order.setOrderProductPrice(dp.getDealProdPrice());
|
|
|
+ order.setOrderTotal(dp.getDealProdPrice()*orderNumByInt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ order.setReturnStatus("error");
|
|
|
+ order.setReturnMsg("订单导入-未能从该客户中获取到对应产品的信息,客户名称:"+dealerChannel.getDealerName()+",产品SKU:"+ OrderProductBarCodeValue+"。");
|
|
|
+ order.setPlatformOrderId("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ order.setReturnStatus("error");
|
|
|
+ order.setReturnMsg("订单导入-获取店铺ID失败,店铺ID:"+order.getStoreId()+"。");
|
|
|
+ order.setPlatformOrderId("1");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(order.getOrderTotal() == null || order.getOrderTotal() < 0){
|
|
|
+ order.setReturnStatus("error");
|
|
|
+ order.setReturnMsg("订单导入-未能从该客户中获取店铺对应的产品价格,客户名称:"+dealerChannel.getDealerName()+",产品SKU:"+ OrderProductBarCodeValue+"店铺ID:"+order.getStoreId()+"。");
|
|
|
+ order.setPlatformOrderId("1");
|
|
|
+ }
|
|
|
+
|
|
|
order.setOid(oid);
|
|
|
try{
|
|
|
if (postType.equals("ems")) {
|