Пример #1
0
/**
 * 根据账号id获取平台名称
 * @param int $id 账号id
 * @return string
 * @author yxd
 * */
function get_platnamebyaccountid($id)
{
    $platformId = get_platFromidbyaccountid($id);
    $platformName = get_platnamebyid($platformId);
    return $platformName;
}
Пример #2
0
 /**
  * 独立商城订单导入页面
  */
 public function act_insertDresslinkOrder()
 {
     //独立商城的扩展表尚未建立
     return false;
     if (isset($_FILES['cndlAccountListFile']['tmp_name'])) {
         $filePath = $_FILES['cndlAccountListFile']['tmp_name'];
         $PHPExcel = E('PHPExcel');
         $PHPReader = new PHPExcel_Reader_Excel2007();
         if (!$PHPReader->canRead($filePath)) {
             $PHPReader = new PHPExcel_Reader_Excel5();
             if (!$PHPReader->canRead($filePath)) {
                 self::$errMsg[] = get_promptmsg(10058);
                 return false;
             }
         }
         $PHPExcel = $PHPReader->load($filePath);
         $currentSheet = $PHPExcel->getSheet(0);
         $orderid = array();
         $orderData = array();
         F('order');
         //引入lib/funciond的order_functions
         $account = $_POST['cndlAccountId'];
         //accountId
         if (intval($account) <= 0) {
             self::$errMsg[] = get_promptmsg(10054);
             return false;
         }
         $platformId = get_platFromidbyaccountid($account);
         if (intval($platformId) <= 0) {
             self::$errMsg[] = get_promptmsg(10121);
             return false;
         }
         //            $carrierList = M('InterfaceTran')->getCarrierList(2);//获取所有的运输方式
         //            $carrierKV = array();
         //            foreach($carrierList as $key => $trans) {
         //                $carrierKV[$trans['id']] = $trans['carrierNameCn'];
         //            }
         $c = 2;
         $dresslinks = array();
         $ebay_fedex_remark = array();
         $ChineseDescs = array();
         while (true) {
             $aa = 'A' . $c;
             $bb = 'B' . $c;
             $cc = 'C' . $c;
             $dd = 'D' . $c;
             $ee = 'E' . $c;
             $ff = 'F' . $c;
             $gg = 'G' . $c;
             $hh = 'H' . $c;
             $ii = 'I' . $c;
             $jj = 'J' . $c;
             $kk = 'K' . $c;
             $ll = 'L' . $c;
             $mm = 'M' . $c;
             $nn = 'N' . $c;
             $oo = 'O' . $c;
             $pp = 'P' . $c;
             $qq = 'Q' . $c;
             $rr = 'R' . $c;
             $ss = 'S' . $c;
             $tt = 'T' . $c;
             $uu = 'U' . $c;
             $vv = 'V' . $c;
             $ww = 'W' . $c;
             $xx = 'X' . $c;
             $yy = 'Y' . $c;
             $zz = 'Z' . $c;
             $aaa = 'AA' . $c;
             $abb = 'AB' . $c;
             $acc = 'AC' . $c;
             $add = 'AD' . $c;
             $aee = 'AE' . $c;
             $aff = 'AF' . $c;
             $agg = 'AG' . $c;
             $ahh = 'AH' . $c;
             $aii = 'AI' . $c;
             $ajj = 'AJ' . $c;
             $akk = 'AK' . $c;
             $all = 'AL' . $c;
             $amm = 'AM' . $c;
             $ann = 'AN' . $c;
             $aww = 'AW' . $c;
             $recordNumber = trim($currentSheet->getCell($aa)->getValue());
             //订单号
             if (empty($recordNumber)) {
                 break;
             }
             /***************判断订单是否已存在***************/
             if (M('OrderAdd')->checkIsExists(array('recordNumber' => $recordNumber, 'accountId' => $account))) {
                 self::$errMsg[] = get_promptmsg(10043, $recordNumber);
                 //"该recordNumber已经存在<br/>";
                 continue;
             }
             /**************/
             $is_order = intval($currentSheet->getCell($bb)->getValue());
             //1代表为订单,0代表订单明细
             if ($is_order != 0) {
                 //为订单
                 //这个验证可以不用
                 //if($cndlAccounts[$account]=="dresslink.com"){
                 //					   $str = substr($recordNumber,0,2);
                 //					   if($str!=="DL"){
                 //						  $message .= "<font color=red> {$recordNumber}不在账号{$cndlAccounts[$account]}中!</font><br>";
                 //						  continue;
                 //					   }
                 //					}elseif($cndlAccounts[$account]=="cndirect.com"){
                 //					   $str = substr($recordNumber,0,2);
                 //					   if($str!=="CN"){
                 //						  $message .= "<font color=red> {$recordNumber}不在账号{$cndlAccounts[$account]}中!</font><br>";
                 //						  continue;
                 //					   }
                 //					}
                 $platformUsername = mysql_real_escape_string(trim($currentSheet->getCell($cc)->getValue()));
                 $email = mysql_real_escape_string(trim($currentSheet->getCell($dd)->getValue()));
                 $transId = mysql_real_escape_string(trim($currentSheet->getCell($ee)->getValue()));
                 $ordersTime = (array) PHPExcel_Shared_Date::ExcelToPHPObject(trim($currentSheet->getCell($ll)->getValue()));
                 $paymentTime = (array) PHPExcel_Shared_Date::ExcelToPHPObject(trim($currentSheet->getCell($mm)->getValue()));
                 $shippingFee = round_num(trim($currentSheet->getCell($oo)->getValue()), 2);
                 $calcWeight = round_num(trim($currentSheet->getCell($ahh)->getValue()), 3);
                 $actualTotal = round_num(trim($currentSheet->getCell($pp)->getValue()), 2);
                 $onlineTotal = round_num(trim($currentSheet->getCell($aff)->getValue()), 2);
                 $currency = mysql_real_escape_string(trim($currentSheet->getCell($qq)->getValue()));
                 //$orders['ebay_orderqk'] = round_num(trim($currentSheet->getCell($rr)->getValue()), 2);
                 $note = mysql_real_escape_string(trim($currentSheet->getCell($ss)->getValue()));
                 $username = mysql_real_escape_string(trim($currentSheet->getCell($tt)->getValue()));
                 $countryName = mysql_real_escape_string(trim($currentSheet->getCell($uu)->getValue()));
                 $state = mysql_real_escape_string(trim($currentSheet->getCell($vv)->getValue()));
                 $city = mysql_real_escape_string(trim($currentSheet->getCell($ww)->getValue()));
                 $street = mysql_real_escape_string(trim($currentSheet->getCell($xx)->getValue()));
                 $address2 = mysql_real_escape_string(trim($currentSheet->getCell($yy)->getValue()));
                 $zipCode = mysql_real_escape_string(trim($currentSheet->getCell($zz)->getValue()));
                 $phone = mysql_real_escape_string(trim($currentSheet->getCell($abb)->getValue()));
                 $landline = mysql_real_escape_string(trim($currentSheet->getCell($aaa)->getValue()));
                 //					if($account == 400){    //dresslink.com
                 //						$feedback 				= mysql_real_escape_string(trim($currentSheet->getCell($ann)->getValue()));
                 //					}elseif($account == 410){   //cndirect.com
                 //						$feedback 				= mysql_real_escape_string(trim($currentSheet->getCell($akk)->getValue()));
                 //					}
                 $carrierNameCn = strtolower(mysql_real_escape_string(trim($currentSheet->getCell($kk)->getValue())));
                 $payment_method = mysql_real_escape_string(trim($currentSheet->getCell($ff)->getValue()));
                 $payment_module = mysql_real_escape_string(trim($currentSheet->getCell($gg)->getValue()));
                 $bank_account = mysql_real_escape_string(trim($currentSheet->getCell($hh)->getValue()));
                 $bank_country = mysql_real_escape_string(trim($currentSheet->getCell($ii)->getValue()));
                 $shipping_method = mysql_real_escape_string(trim($currentSheet->getCell($jj)->getValue()));
                 $shipping_module = mysql_real_escape_string(trim($currentSheet->getCell($kk)->getValue()));
                 //这个dresslinks_info表在新系统已经废除了
                 //$dresslinks['payment_method'] = $payment_method;
                 //					$dresslinks['payment_module'] = $payment_module;
                 //					$dresslinks['bank_account'] = $bank_account;
                 //					$dresslinks['bank_country'] = $bank_country;
                 //					$dresslinks['shipping_method'] = $shipping_method;
                 //					$dresslinks['shipping_module'] = $shipping_module;
                 $PayPalPaymentId = $transId;
                 $ordersTime = strtotime($ordersTime['date']);
                 $paymentTime = strtotime($paymentTime['date']);
                 /***************BEGIN 订单表数据***************/
                 //order信息
                 $orderData[$recordNumber]['order']['recordNumber'] = $recordNumber;
                 $orderData[$recordNumber]['order']['platformId'] = $platformId;
                 //这里要根据accountId得到对应的platformId
                 $orderData[$recordNumber]['order']['accountId'] = $account;
                 $orderData[$recordNumber]['order']['orderStatus'] = 0;
                 $orderData[$recordNumber]['order']['ordersTime'] = $ordersTime;
                 $orderData[$recordNumber]['order']['paymentTime'] = $paymentTime;
                 $orderData[$recordNumber]['order']['onlineTotal'] = $onlineTotal;
                 $orderData[$recordNumber]['order']['actualTotal'] = $actualTotal;
                 //$actualTotal+$shippingFee
                 $orderData[$recordNumber]['order']['actualShipping'] = $shippingFee;
                 $orderData[$recordNumber]['order']['currency'] = $currency;
                 //取默认,待以后确认处理
                 $orderData[$recordNumber]['order']['transportId'] = 0;
                 //走拦截流程,取消默认
                 $orderData[$recordNumber]['order']['pmId'] = 0;
                 //包材ID,默认0
                 $orderData[$recordNumber]['order']['channelId'] = 0;
                 //渠道ID,默认0
                 $orderData[$recordNumber]['order']['orderAddTime'] = time();
                 $orderData[$recordNumber]['order']['calcShipping'] = $shippingFee;
                 $orderData[$recordNumber]['order']['orderType'] = 0;
                 $orderData[$recordNumber]['order']['completeTime'] = 0;
                 //完结时间,默认0
                 $orderData[$recordNumber]['order']['ORtransport'] = $carrierNameCn;
                 //order扩展信息
                 //user信息
                 $orderData[$recordNumber]['orderUserInfo']['platformUsername'] = $platformUsername;
                 $orderData[$recordNumber]['orderUserInfo']['username'] = $username;
                 $orderData[$recordNumber]['orderUserInfo']['email'] = $email;
                 $orderData[$recordNumber]['orderUserInfo']['countryName'] = $countryName;
                 $orderData[$recordNumber]['orderUserInfo']['currency'] = $currency;
                 //$currency;
                 $orderData[$recordNumber]['orderUserInfo']['state'] = $state;
                 $orderData[$recordNumber]['orderUserInfo']['city'] = $city;
                 $orderData[$recordNumber]['orderUserInfo']['county'] = ' ';
                 //区县默认空
                 $orderData[$recordNumber]['orderUserInfo']['address1'] = $street;
                 $orderData[$recordNumber]['orderUserInfo']['mobilePhone'] = $landline;
                 $orderData[$recordNumber]['orderUserInfo']['phone'] = $phone;
                 $orderData[$recordNumber]['orderUserInfo']['zipCode'] = $zipCode;
                 //detail信息
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['sku'] = $sku;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['amount'] = $amount;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['itemPrice'] = $itemPrice;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['createdTime'] = time();
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['shippingFee'] = $shippingFee;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetail']['recordNumber'] = $recordNumber;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtension']['itemTitle'] = $itemTitle;
                 /***************END 订单表数据***************/
                 /***************BEGIN 订单扩展表数据***************/
                 $orderData[$recordNumber]['orderExtension']['feedback'] = $note;
                 $orderData[$recordNumber]['orderExtension']['payPalPaymentId'] = $transId;
                 $orderData[$recordNumber]['orderExtension']['paymentStatus'] = "Complete";
                 $orderData[$recordNumber]['orderExtension']['transId'] = $transId;
                 $orderData[$recordNumber]['orderExtension']['PayPalPaymentId'] = $PayPalPaymentId;
                 $orderData[$recordNumber]['orderExtension']['paymentMethod'] = $payment_method;
                 $orderData[$recordNumber]['orderExtension']['paymentModule'] = $payment_module;
                 $orderData[$recordNumber]['orderExtension']['shippingMethod'] = $shipping_method;
                 $orderData[$recordNumber]['orderExtension']['ShippingModule'] = $shipping_module;
                 $orderData[$recordNumber]['orderExtension']['currency'] = $currency;
                 $orderData[$recordNumber]['orderExtension']['feedback'] = $feedback;
                 //客户留言
                 /***************END 订单扩展表数据***************/
                 /***************BEGIN 订单用户表数据***************/
                 $orderData[$recordNumber]['orderUserInfo']['username'] = $username;
                 $orderData[$recordNumber]['orderUserInfo']['platformUsername'] = $platformUsername;
                 $orderData[$recordNumber]['orderUserInfo']['email'] = $email;
                 $orderData[$recordNumber]['orderUserInfo']['countryName'] = $countryName;
                 $orderData[$recordNumber]['orderUserInfo']['currency'] = $currency;
                 $orderData[$recordNumber]['orderUserInfo']['state'] = $state;
                 // 省
                 $orderData[$recordNumber]['orderUserInfo']['city'] = $city;
                 // 市
                 $orderData[$recordNumber]['orderUserInfo']['street'] = $street;
                 $orderData[$recordNumber]['orderUserInfo']['address2'] = $address2;
                 $orderData[$recordNumber]['orderUserInfo']['landline'] = $landline;
                 // 座机电话
                 $orderData[$recordNumber]['orderUserInfo']['phone'] = $phone;
                 // 手机
                 $orderData[$recordNumber]['orderUserInfo']['zipCode'] = $zipCode;
                 // 邮编
                 /*************END 订单用户表数据***************/
                 //note信息
                 if (!empty($note)) {
                     $orderData[$recordNumber]['orderNote']['content'] = $note;
                 }
             } else {
                 $sku = mysql_real_escape_string(trim($currentSheet->getCell($acc)->getValue()));
                 $itemTitle = mysql_real_escape_string(trim($currentSheet->getCell($add)->getValue()));
                 $itemPrice = round_num(trim($currentSheet->getCell($aff)->getValue()), 2);
                 $amount = intval(trim($currentSheet->getCell($agg)->getValue()));
                 $shipingfee = round_num(trim($currentSheet->getCell($ahh)->getValue()), 2);
                 /***************BEGIN 订单详细数据***************/
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']['recordNumber'] = $recordnumber;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']['sku'] = $sku;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']['itemPrice'] = $itemPrice;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']['amount'] = $amount;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']["shippingFee"] = $shipingfee;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetail']['createdTime'] = time();
                 /*************END 订单详细数据***************/
                 /***************BEGIN 订单详细扩展表数据***************/
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetailExtension']['itemTitle'] = $itemTitle;
                 $orderData[$recordNumber]['orderDetail'][$c]['orderDetailExtension']['transId'] = $transId;
                 //$orderData['orderDetail']['orderDetailExtenData']['note'] = $value[10];
                 $categoryName = trim($currentSheet->getCell($ajj)->getValue());
                 $customCode = trim($currentSheet->getCell($akk)->getValue());
                 $material = trim($currentSheet->getCell($all)->getValue());
                 $ShenBaoQuantity = trim($currentSheet->getCell($amm)->getValue());
                 $ShenBaoUnitPrice = trim($currentSheet->getCell($ann)->getValue());
                 $ChineseDesc = trim($currentSheet->getCell($aww)->getValue());
                 //$salePrice						   =	round_num(mysql_real_escape_string(trim($detail['SalePrice'])), 2);	//实际SKU付款价
                 /*************END 订单详细扩展表数据***************/
                 $ebay_fedex_remark[$recordNumber][$categoryName][] = array('real_price' => $ShenBaoUnitPrice, 'qty' => $ShenBaoQuantity, 'hamcodes' => $customCode, 'detail' => $material);
                 $orderData[$recordNumber]['fedexRemark'] = $ebay_fedex_remark[$recordNumber];
             }
         }
         //fedexRemark 逻辑处理
         foreach ($orderData as $recordNumber => $tmpArr) {
             $fedexRemarkArr = $tmpArr['fedexRemark'];
             $transportId = $orderData['order']['transportId'];
             if (!empty($fedexRemarkArr)) {
                 $tmpArr1 = array();
                 foreach ($fedexRemarkArr as $k => $v) {
                     $tmpArr1['description'] = trim("[No Brand]" . $k . "{$v[0]['detail']}");
                     if (in_array($carrierKV[$transportId], array('FedEx'))) {
                         $tmpArr1['type'] = 1;
                     } elseif (in_array($carrierKV[$transportId], array('DHL', 'EMS', 'UPS美国专线'))) {
                         $tmpArr1['type'] = 2;
                     } else {
                         break;
                     }
                     $sku_price = 0;
                     $qty = 0;
                     foreach ($v as $v0) {
                         $sku_price += $v0['real_price'];
                         $qty += $v0['qty'];
                     }
                     $tmpArr1['price'] = round($sku_price / $qty, 2);
                     $tmpArr1['amount'] = $qty;
                     $tmpArr1['hamcodes'] = $v[0]['hamcodes'];
                     if (in_array($carrierKV[$transportId], array('DHL', 'EMS', 'UPS美国专线'))) {
                         $tmpArr1['price'] = round($sku_price, 2);
                     }
                 }
                 $orderData[$recordNumber]['fedexRemark'] = $tmpArr1;
             }
         }
         var_dump($orderData);
         exit;
         //return $this->act_insertOrder($orderData);
     } else {
         self::$errMsg[] = get_promptmsg(10053);
         return false;
     }
 }