Procházet zdrojové kódy

提交文风导入的订单还有paypal 其中paypal和orderinfo一直

lvhao před 3 měsíci
rodič
revize
e75670dddf
1 změnil soubory, kde provedl 263 přidání a 1 odebrání
  1. 263 1
      core/CoreApp/controllers/Customer.php

+ 263 - 1
core/CoreApp/controllers/Customer.php

@@ -1739,7 +1739,7 @@ class Customer extends Start_Controller {
 				$ddpost['issku'] = $sku;
 				$ddpost['quantity'] = rtrim($value['3'],';');
 				$ddpost['clientremarks'] = '';//客户备注
-				$ddpost['paypal'] = '';//交易号
+				//$ddpost['paypal'] = '';//交易号
 				$ddpost['guarantee'] = '';//卖家保障
 				$ddpost['parameter'] = '';//属性
 				$ddpost['shippingmethod'] = '';//用户选择快递方式及运费金额
@@ -1755,6 +1755,7 @@ class Customer extends Start_Controller {
 					$i++;
 					continue;
 				}
+				$ddpost['paypal'] = $ddpost['orderinfo'];
 				$ddpost['insurance'] = 0;//运输保险费用
 				$ddpost['baddress'] = '';
 				$ddpost['saddress'] = '';
@@ -1823,6 +1824,267 @@ class Customer extends Start_Controller {
 		}
     }
 	
+	//代发客户导入
+	public function _dafakehuexcel()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				@$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				@$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;
+			$gethl = $this->hl->get_hl();//获取即时汇率
+			$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
+			$dtc = array();
+			foreach ($dictionaries as $v) 
+			{
+				if(stripos($v['spare'],'|') !== false)//如果有多个值
+				{
+					$v['spare'] = explode('|',$v['spare']);
+					foreach ($v['spare'] as $k=>$vs) 
+		        	{
+						if(stripos($v['zh'],'|') !== false)
+						{
+							$vzh = explode('|',$v['zh']);
+							$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
+						}
+						else
+						{
+					   	 $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
+						}
+					}
+				}
+				else
+				{
+					$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
+				}
+			
+			}
+			$dk = array();
+			$dictionaries2 = $this->typeclass->find_all();
+			foreach ($dictionaries2 as $v)
+			{
+				$dtctitle[$v['id']] = $v['title'];
+				$dk[$v['id']] = $v['bqsku'];
+			}
+			/*  匹配结束  */    
+			/*  价格加入  */  
+			$money = array();
+			$productdescribe = $this->productdescribe->find_all('1=1');
+			foreach ($productdescribe as $v) 
+			{
+				$money[$v['number']] = array();
+			}
+			/*  价格加入  */
+			/*  匹配ID加入  */
+			$int = array();
+			$intdata = $this->typeclass->find_all('classid=14','id,spare');
+			foreach ($intdata as $v) 
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				$int[$v['id']] = $v['spare'][0];
+			}	
+			/*  匹配ID加入  */
+			$zjsku = array();
+			$shopsku = $this->shopsku->find_all();
+			foreach ($shopsku as $val) 
+			{
+				$ss = explode(',',trim($val['shop'],','));
+				foreach ($ss as $v) 
+			    {
+					if(isset($zjsku[$v]))
+					{
+						$zjsku[$v] .= ','.trim($val['sku'],',');
+					}
+					else
+					{
+						$zjsku[$v] = trim($val['sku'],',');
+					}
+				}
+			}	
+			
+			/*  匹配ID结束  */
+		    $this->db->trans_begin();
+		    foreach ($list as $key=>$value)
+		    {
+				$addtess = ($value['15']!='--'?$value['15'].' ':'').($value['14']!='--'?$value['14'].' ':'').$value['13'];
+				$addtess = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$addtess);
+				$repeat = $this->customer->find_all('phone = "'.$value[11].'" and address = "'.($value['15']!='--'?$value['15'].' ':'').($value['14']!='--'?$value['14'].' ':'').$value['13'].'" and shop = 19');//判断电话地址
+				$sku = $value['8'];
+				$je = (isset($value['28']))?$value['28']:0;
+				$value['29'] = str_replace('/','-',$value['29']);
+				$dtime = strtotime($value['29']);
+				$post['name'] = ($value['10'] && $value['10'] != 'NULL')?str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['10']):'';
+				$post['email'] = $value['12'];
+				if($value['20'] != '')
+				{
+					$country = $this->country->get_ename(str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['20']));
+					$post['country'] = $country['id'];
+				}
+				$post['level'] = 4;
+				$post['phone'] = $value['11']?$value['11']:'';
+				$post['province'] = $value['18']?$value['18']:'';
+				$post['city'] = $value['17']?$value['17']:'';
+				$post['address'] = $addtess;
+				$post['zipcode'] = $value['19']?$value['19']:'';
+				$post['shop'] = 19;
+				$post['source'] = 2;
+				$post['type'] = 1;
+				$post['count'] = '';
+				$post['time'] = $dtime;
+				$str = $post['phone'];
+				preg_match_all('/[0-9]/u',$str,$result);
+				$numphone = join('',$result[0]);
+				$post['numphone'] = $numphone;
+				if(!isset($repeat[0]))
+				{
+		    	    $this->customer->insert($post);
+                }
+				else
+				{
+					$this->customer->save(array('num'=>$repeat[0]['num']+1),$repeat[0]['id']);
+				}
+				$sbsku = '';
+				$whlabel = $this->whlabel->get_sku($sku);
+				if($whlabel)
+				{
+					$w = explode('-',trim($whlabel['features'],'-'));
+					foreach ($w as $v)
+		            {
+						if(isset($dk[$v]))
+						{
+							$sbsku .= $dk[$v].'-';
+						}
+					}
+				}
+				$sbsku = trim($sbsku,'-');
+				$time = time();
+				$shop = $this->shop->read(19);
+				$ddpost['orderremarks'] = isset($value['30'])?$value['30']:'';
+				$ddpost['shop'] = $shop['id'];//店铺ID
+				$ddpost['user'] = $shop['shopuser'];//店铺负责人
+				$orderid = 0;
+				$ddpost['orderid'] = 0;
+				$ddpost['product'] = '';//产品名称
+				$ddpost['link'] = '';//产品链接
+				$ddpost['issku'] = $sku;
+				$ddpost['quantity'] = rtrim($value['3'],';');
+				$ddpost['clientremarks'] = '';//客户备注
+				$ddpost['paypal'] = '';//交易号
+				$ddpost['guarantee'] = '';//卖家保障
+				$ddpost['parameter'] = '';//属性
+				$ddpost['shippingmethod'] = '';//用户选择快递方式及运费金额
+				$ddpost['source'] = 2;//订单类型
+				$ddpost['type'] = 1;//发货仓库
+				$ddpost['capital'] = 3;//资金支付状况,全部付款
+				$num = $this->fullorder->find_count('gtime = "'.date('Ymd',$dtime).'" and shop = 19');
+				$ddpost['number'] = $shop['shortname'].'-'.substr(date('ymd',$dtime),1).'-'.(substr(strval($num+1+1000),1,3));//编号
+				$ddpost['orderinfo'] =  preg_replace('/[^0-9]/', '', $value['0']);//订单号
+				$d = $this->fullorder->get_orderinfo($ddpost['orderinfo']);
+				if(isset($d['id']))
+				{
+					$i++;
+					continue;
+				}
+				$ddpost['insurance'] = 0;//运输保险费用
+				$ddpost['baddress'] = '';
+				$ddpost['saddress'] = '';
+				$ddpost['country'] = $country['id'];//此国家的ID
+				$ddpost['al'] = $country['lb'];//联邦名称
+				$ddpost['bname'] = $post['name'];//名称
+				$ddpost['sname'] = $post['name'];//名称
+				$ddpost['client'] = $post['name'];//公司名称
+				$ddpost['name'] = $post['name'];//收件人名称
+				$ddpost['phone'] = $post['phone'];//收件人电话
+				$ddpost['email'] = $post['email'];//客户邮箱
+				$ddpost['zipcode'] = $post['zipcode'];//收件人邮编
+				$ddpost['province'] = $post['province'];//收件人省份
+				$ddpost['city'] = $post['city'];//收件人城市
+				$ddpost['address'] = $post['address'];//收件人地址
+				$ddpost['shouldmoney'] = $je;//应收金额
+				$ddpost['skje'] = $je;//收款金额
+				$ddpost['ismoney'] = '';//支付币种金额
+				$ddpost['shouldmoney'] = $je;//金额
+			    $ddpost['budget'] = $je;//预估到帐金额
+				$ddpost['buytime'] = $dtime;//格式化付款时间
+				$ddpost['dtime'] = $dtime;//订单时间
+				$ddpost['gtime'] = date('Ymd',$dtime);//格式化订单时间
+				$ddpost['currencytitle'] = 'USD';//结算币种名称
+				$ddpost['currency'] = 219;//钱币ID
+				$ddpost['time'] = time();//同步时间
+				$ddpost['shopify'] = 0;//同步时间
+				$ddpost['hl'] = '6.4';//汇率
+				$matching = $this->api->matching($ddpost['quantity'],$sbsku,$dtc,$money,$int,$dtctitle,$shop);
+				$ddpost['shipremarks'] = $matching['title'];
+				$ddpost['cost'] = $matching['cost'];
+				$ddpost['purchase'] = $matching['purchase'];
+				$ddpost['fpdata'] = $matching['product'];
+				$ddpost['whlabel'] = $matching['whlabel'];
+				$ddpost['slpx'] = $matching['wcslpx'];
+				$ddpost['state'] = 207;
+				$ddpost['type'] = 17;
+				$this->fullorder->insert($ddpost);
+			}
+			if ($this->db->trans_status() === FALSE)
+            {
+				$this->db->trans_commit();
+				echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+            }
+            else
+            {
+				if(count($list) == $i)
+				{
+					$til = '导入全部失败!请检查导入信息';
+				}
+				else if(count($list) > $i && $i != 0)
+				{
+					$til = '部分导入成功!'.$i.'条信息有问题,请排查';
+				}
+				else  if($i < 1)
+				{
+					$til = '导入成功!';
+				}
+                $this->db->trans_commit();
+				echo json_encode(array('msg'=>$til,'success'=>true));exit;
+            }
+        }
+		else
+		{
+			echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
+		}
+    }
+
+
 	public function _indexexcel()//通过计数,2020/02/21已校准
 	{
 		$user = $this->user->get_api($_SESSION['api']);