Esempio n. 1
0
 function act_sureAddOrder()
 {
     $order_data = array();
     $detail_data = array();
     $exten_data = array();
     $userinfo_data = array();
     $buyer_data = array();
     $time = time();
     $platform_id = trim($_POST['platform']);
     $username = trim($_POST['fullname']);
     $account_id = trim($_POST['account']);
     $street1 = trim($_POST['street1']);
     $platformUsername = trim($_POST['userid']);
     $email = trim($_POST['ebay_usermail1']);
     $street2 = trim($_POST['street2']);
     $recordNumber = trim($_POST['orderid']);
     $city = trim($_POST['city']);
     $ordersTime = strtotime(trim($_POST['ebay_createdtime']));
     $state = trim($_POST['state']);
     $paymentTime = strtotime(trim($_POST['ebay_paidtime']));
     $countryname = trim($_POST['country']);
     $ebay_itemprice = trim($_POST['ebay_itemprice']);
     $zipCode = trim($_POST['zip']);
     $shippingFee = trim($_POST['ebay_shipfee']);
     $ebay_tel1 = trim($_POST['tel1']);
     $actualTotal = trim($_POST['ebay_total']);
     $ebay_tel2 = trim($_POST['tel2']);
     $ebay_tel3 = trim($_POST['tel3']);
     $currency = trim($_POST['ebay_currency']);
     $other_currency = trim($_POST['other_currency']);
     $isCheckOrder = self::act_checkOrder();
     $returnArr = array();
     //返回的数组信息
     if (!$isCheckOrder) {
         $returnArr['errCode'] = self::$errCode;
         $returnArr['errMsg'] = self::$errMsg;
         return $returnArr;
     }
     if ($currency == '其他') {
         $currency = $other_currency;
     }
     $phone = trim($_POST['tel1']);
     $transId = trim($_POST['ebay_ptid']);
     $other_ptid = trim($_POST['other_ptid']);
     if ($transId == 'paypal' || $transId == 'Escrow' || $transId == '其他') {
         $transId = $other_ptid;
     }
     $PayPalPaymentId = $transId;
     $orderweight = trim($_POST['orderweight']);
     $ebay_usermail2 = trim($_POST['ebay_usermail2']);
     $ebay_carrier = trim($_POST['ebay_carrier']);
     $ebay_usermail3 = trim($_POST['ebay_usermail3']);
     $ebay_tracknumber = trim($_POST['ebay_tracknumber']);
     $ebay_noteb = trim($_POST['ebay_noteb']);
     $orderStatus = 100;
     $orderType = 101;
     $tracknumber = trim($_POST['ebay_tracknumber']);
     //order信息
     $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber;
     $orderData[$recordNumber]['orderData']['ordersTime'] = $ordersTime;
     $orderData[$recordNumber]['orderData']['paymentTime'] = $paymentTime;
     $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal;
     $orderData[$recordNumber]['orderData']['onlineTotal'] = $actualTotal;
     //默认线上总价和实际总价一样
     $orderData[$recordNumber]['orderData']['orderAddTime'] = time();
     //$orderData[$recordNumber]['orderData']['calcWeight'] = $orderweight;//估算重量
     $orderData[$recordNumber]['orderData']['accountId'] = $account_id;
     $orderData[$recordNumber]['orderData']['platformId'] = $platform_id;
     //添加状态信息
     $orderData[$recordNumber]['orderData']['orderStatus'] = 100;
     $orderData[$recordNumber]['orderData']['orderType'] = 101;
     $SYS_ACCOUNTS = OmAvailableModel::getPlatformAccount();
     foreach ($SYS_ACCOUNTS as $platform => $accounts) {
         foreach ($accounts as $accountId => $accountname) {
             if ($account_id == $accountId) {
                 if ($platform == 'ebay') {
                     //为ebay平台
                     $orderData[$recordNumber]['orderData']['isFixed'] = 2;
                 } else {
                     $orderData[$recordNumber]['orderData']['isFixed'] = 1;
                 }
             }
         }
     }
     $transportation = CommonModel::getCarrierList();
     //所有的
     foreach ($transportation as $tranValue) {
         if ($tranValue['id'] == $ebay_carrier) {
             $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id'];
             break;
         }
     }
     //order扩展信息
     $orderData[$recordNumber]['orderExtenData']['currency'] = $currency;
     $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS";
     //$orderData[$recordNumber]['orderExtenData']['transId']			    =	$transId;
     $orderData[$recordNumber]['orderExtenData']['PayPalPaymentId'] = $PayPalPaymentId;
     $orderData[$recordNumber]['orderExtenData']['platformUsername'] = $platformUsername;
     //user信息
     $orderData[$recordNumber]['orderUserInfoData']['platformUsername'] = $platformUsername;
     $orderData[$recordNumber]['orderUserInfoData']['username'] = $username;
     $orderData[$recordNumber]['orderUserInfoData']['email'] = $email;
     $orderData[$recordNumber]['orderUserInfoData']['street'] = $street1;
     $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency;
     $orderData[$recordNumber]['orderUserInfoData']['address2'] = $street2;
     $orderData[$recordNumber]['orderUserInfoData']['city'] = $city;
     $orderData[$recordNumber]['orderUserInfoData']['state'] = $state;
     $orderData[$recordNumber]['orderUserInfoData']['zipCode'] = $zipCode;
     $orderData[$recordNumber]['orderUserInfoData']['countryName'] = $countryname;
     $orderData[$recordNumber]['orderUserInfoData']['landline'] = !empty($ebay_tel2) ? $ebay_tel2 : $ebay_tel3;
     $orderData[$recordNumber]['orderUserInfoData']['phone'] = $phone;
     //note信息
     if (!empty($ebay_noteb)) {
         $orderData[$recordNumber]['orderNote']['content'] = $ebay_noteb;
         $orderData[$recordNumber]['orderNote']['userId'] = $_SESSION['sysUserId'];
         $orderData[$recordNumber]['orderNote']['createdTime'] = time();
     }
     //tracknumer信息
     $orderData[$recordNumber]['orderTrack']['tracknumber'] = $tracknumber;
     $sku_list = $_POST['sku'];
     $sku_count = $_POST['qty'];
     $ebay_itemtitle = $_POST['name'];
     $count = count($sku_list);
     for ($i = 0; $i < $count; $i++) {
         //detail信息
         $sku = $sku_list[$i];
         $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku_list[$i];
         $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] += $sku_count[$i];
         //累加
         $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber;
         $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time();
         $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $ebay_itemtitle[$i];
     }
     foreach ($orderData as $id => $order) {
         //$orderData 中第一维只有一个元素,方便起见这里用foreach,虽然只循环一次
         $ret = commonModel::checkOrder($recordNumber);
         if ($ret) {
             $returnArr['errCode'] = 101;
             $returnArr['errMsg'] = "订单{$recordNumber}已存在!";
             return $returnArr;
         }
         //计算订单属性
         if (count($order['orderDetail']) == 1) {
             $detail = current($order['orderDetail']);
             if ($detail['orderDetailData']['amount'] == 1) {
                 $orderData[$id]['orderData']['orderAttribute'] = 1;
             } else {
                 $orderData[$id]['orderData']['orderAttribute'] = 2;
             }
         } else {
             $orderData[$id]['orderData']['orderAttribute'] = 3;
         }
         //计算订单重量及包材
         $obj_order_detail_data = array();
         foreach ($order['orderDetail'] as $sku => $detail) {
             $obj_order_detail_data[] = $detail['orderDetailData'];
         }
         $weightfee = commonModel::calcOrderWeight($obj_order_detail_data);
         $orderData[$id]['orderData']['calcWeight'] = $weightfee[0];
         $orderData[$id]['orderData']['pmId'] = $weightfee[1];
         $calcShippingInfo = CommonModel::calcAddOrderShippingFee($orderData[$id], $orderData[$id]['orderData']['isFixed']);
         //计算运费
         $orderData[$id]['orderData']['channelId'] = $calcShippingInfo['channelId'];
         $orderData[$id]['orderData']['calcShipping'] = $calcShippingInfo['fee'];
         //调用旧系统接口,先插入数据到旧系统
         $rtn = OldsystemModel::orderErpInsertorder($orderData[$id]);
         $insertData = array();
         if (empty($rtn)) {
             $returnArr['errCode'] = 102;
             $returnArr['errMsg'] = "接口返回异常,请重试!";
             return $returnArr;
         }
         if ($rtn['errcode'] == 200) {
             $rtn_data = $rtn['data'];
             $orderId = $rtn_data['orderId'];
             //echo "插入老系统成功,订单编号 [$orderId] \n";
             $pmId = $rtn_data['pmId'];
             $totalweight = $rtn_data['totalweight'];
             $shipfee = $rtn_data['shipfee'];
             $carrier = $rtn_data['carrier'];
             $carrierId = $rtn_data['carrierId'];
             $status = $rtn_data['status'];
             $orderData[$id]['orderData']['id'] = $orderId;
             //赋予新系统订单编号
             if ($orderData['orderData']['calcWeight'] != $totalweight) {
                 $insertData['old_totalweight'] = $totalweight;
                 $insertData['new_totalweight'] = $orderData[$id]['orderData']['calcWeight'];
                 $orderData[$id]['orderData']['calcWeight'] = $totalweight;
             }
             if ($orderData['orderData']['pmId'] != $pmId) {
                 $insertData['old_pmId'] = $pmId;
                 $insertData['new_pmId'] = $orderData[$id]['orderData']['pmId'];
                 $orderData[$id]['orderData']['pmId'] = $pmId;
             }
             if ($orderData['orderData']['calcShipping'] != $shipfee) {
                 $insertData['old_shippfee'] = $shipfee;
                 $insertData['new_shippfee'] = $orderData[$id]['orderData']['calcShipping'];
                 $orderData[$id]['orderData']['calcShipping'] = $shipfee;
             }
             if ($orderData['orderData']['transportId'] != $carrierId) {
                 $insertData['old_carrierId'] = $carrierId;
                 $insertData['new_carrierId'] = $orderData[$id]['orderData']['transportId'];
                 $orderData[$id]['orderData']['transportId'] = $carrierId;
             }
             if (!empty($insertData)) {
                 $insertData['ebay_id'] = $orderId;
                 $insertData['addtime'] = time();
                 //var_dump($insertData);
                 OldsystemModel::insertTempSyncRecords($insertData);
                 // 插入临时对比记录表
             }
             //缺货拦截
             $orderData[$id] = AutoModel::auto_contrast_intercept($orderData[$id]);
             //插入订单
             $info = OrderAddModel::insertAllOrderRowNoEvent($orderData[$id]);
             if ($info) {
                 $returnArr['errCode'] = 200;
                 $returnArr['errMsg'] = "订单{$id}上传成功!";
             } else {
                 $returnArr['errCode'] = 404;
                 $returnArr['errMsg'] = "订单{$id}上传失败!";
             }
         } else {
             $returnArr['errCode'] = 400;
             $returnArr['errMsg'] = "添加失败,原因为:{$rtn['msg']}!";
         }
     }
     return $returnArr;
 }
Esempio n. 2
0
     $obj_order_detail_data[] = array('orderDetailData' => $orderdata_detail, 'orderDetailExtenData' => $orderDetailExtDL);
     $ebay_fedex_remark[$categoryName][] = array('real_price' => $ShenBaoQuantity, 'qty' => $ShenBaoUnitPrice, 'hamcodes' => $customCode, 'detail' => $material);
 }
 $insertOrder = array('orderData' => $orderdata, 'orderExtenData' => $orderExtDL, 'orderUserInfoData' => $orderUserInfo, 'orderDetail' => $obj_order_detail_data, 'orderNote' => $orderNote);
 $calcInfo = CommonModel::calcAddOrderWeight($insertOrder['orderDetail']);
 //计算重量和包材
 //var_dump($calcInfo); exit;
 $insertOrder['orderData']['calcWeight'] = $calcInfo[0];
 $insertOrder['orderData']['pmId'] = $calcInfo[1];
 //$insertOrder['orderData']['transportId'] = $flip_transportList[get_carrier($insertOrder['orderData']['calcWeight'], $insertOrder['orderUserInfoData']['countryName'])];
 $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, 1);
 //计算运费
 //var_dump($calcShippingInfo); exit;
 //$insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
 $insertOrder['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
 $insertOrder = AutoModel::auto_contrast_intercept($insertOrder);
 $omOrderId = OrderAddModel::insertAllOrderRow($insertOrder, 'cndl');
 if ($omOrderId) {
     echo "订单 {$orderdata['recordnumber']} 信息添加成功!ERP订单号为{$omOrderId}--" . date("Y-M-d H:i:s", $mctime) . "--\n";
 }
 foreach ($ebay_fedex_remark as $k => $v) {
     $fedex_remark = array();
     if ($carrierList[$orderdata['transportId']] == 'FedEx') {
         $fedex_remark['description'] = "[No Brand]" . $k . "({$v[0]['detail']})";
         $fedex_remark['type'] = 1;
     } elseif ($carrierList[$orderdata['transportId']] == 'DHL' || $carrierList[$orderdata['transportId']] == 'EMS') {
         $fedex_remark['description'] = trim($k);
         $fedex_remark['type'] = 2;
     } else {
         continue;
     }
Esempio n. 3
0
 function __handle_ebay_orderxml(&$SellerOrderArray, $ebay_account)
 {
     global $FLIP_GLOBAL_EBAY_ACCOUNT;
     if (!isset($FLIP_GLOBAL_EBAY_ACCOUNT)) {
         $omAvailableAct = new OmAvailableAct();
         $GLOBAL_EBAY_ACCOUNT = $omAvailableAct->act_getTNameList2arrById('om_account', 'id', 'account', ' WHERE is_delete=0 ');
         $FLIP_GLOBAL_EBAY_ACCOUNT = array_flip($GLOBAL_EBAY_ACCOUNT);
     }
     global $mctime, $_allow_spide_itemid;
     $account_suffix = get_account_suffix($ebay_account);
     $message = "";
     foreach ($SellerOrderArray as $SellerOrder) {
         //每个订单号
         $oSellerOrderID = $SellerOrder->getElementsByTagName('OrderID')->item(0)->nodeValue;
         //oCreatingUserRole用于判断是否是 combined payments
         $oCreatingUserRole = @$SellerOrder->getElementsByTagName('CreatingUserRole')->item(0)->nodeValue;
         $oAmountPaid = $SellerOrder->getElementsByTagName('AmountPaid')->item(0)->nodeValue;
         $shippingDeatil = $SellerOrder->getElementsByTagName('ShippingDetails')->item(0);
         $oRecordNumber = $shippingDeatil->getElementsByTagName('SellingManagerSalesRecordNumber')->item(0)->nodeValue;
         $shippingDeatil = null;
         unset($shippingDeatil);
         //订单状态
         $CheckoutStatus = $SellerOrder->getElementsByTagName('CheckoutStatus')->item(0);
         $LastTimeModified = strtotime($CheckoutStatus->getElementsByTagName('LastModifiedTime')->item(0)->nodeValue);
         $oeBayPaymentStatus = $CheckoutStatus->getElementsByTagName('eBayPaymentStatus')->item(0)->nodeValue;
         $oCompleteStatus = $CheckoutStatus->getElementsByTagName('Status')->item(0)->nodeValue;
         $oCheckStatus = $CheckoutStatus->getElementsByTagName('Status')->item(0)->nodeValue;
         $CheckoutStatus = null;
         unset($CheckoutStatus);
         //该订单交易信息
         $osoTransArray = $SellerOrder->getElementsByTagName('Transaction');
         //其他交易信息比如payapl整合到ebay
         $oTid = 0;
         //兼容表结构,其实此时还没有交易号的概念
         $ExtTran = $SellerOrder->getElementsByTagName('ExternalTransaction')->item(0);
         $noptid_trans = false;
         if (!empty($ExtTran)) {
             $oPtid = $ExtTran->getElementsByTagName('ExternalTransactionID')->item(0)->nodeValue;
             $oFeeOrCreditAmount = $ExtTran->getElementsByTagName('FeeOrCreditAmount')->item(0)->nodeValue;
         } else {
             $oPtid = '0';
             $oFeeOrCreditAmount = 0.0;
             echo " Notice : [{$oSellerOrderID}]Not ebay offical paypal trans\n";
             $noptid_trans = true;
         }
         //以下信息强制以订单的transation数据中第一条交易为准而取
         if (is_object($osoTransArray->item(0)->getElementsByTagName('Buyer')->item(0))) {
             $oEmail = str_rep($osoTransArray->item(0)->getElementsByTagName('Buyer')->item(0)->getElementsByTagName('Email')->item(0)->nodeValue);
         } else {
             echo "\n同步订单未获取邮箱\n";
             $oEmail = "";
         }
         $oSite = str_rep($osoTransArray->item(0)->getElementsByTagName('Item')->item(0)->getElementsByTagName('Site')->item(0)->nodeValue);
         if (empty($oSite)) {
             $oSite = str_rep($osoTransArray->item(0)->getElementsByTagName('TransactionSiteID')->item(0)->nodeValue);
         }
         //货币类型
         $oCurrency = $osoTransArray->item(0)->getElementsByTagName('TransactionPrice')->item(0)->attributes->item(0)->nodeValue;
         //userid
         $oUserID = str_rep($SellerOrder->getElementsByTagName('BuyerUserID')->item(0)->nodeValue);
         $BuyerInfo = $SellerOrder->getElementsByTagName('ShippingAddress')->item(0);
         $oName = str_rep($BuyerInfo->getElementsByTagName('Name')->item(0)->nodeValue);
         $oName = mysql_real_escape_string($oName);
         $oStreet1 = str_rep($BuyerInfo->getElementsByTagName('Street1')->item(0)->nodeValue);
         $oStreet2 = str_rep($BuyerInfo->getElementsByTagName('Street2')->item(0)->nodeValue);
         $oCityName = str_rep($BuyerInfo->getElementsByTagName('CityName')->item(0)->nodeValue);
         $oStateOrProvince = str_rep($BuyerInfo->getElementsByTagName('StateOrProvince')->item(0)->nodeValue);
         $oCountry = str_rep($BuyerInfo->getElementsByTagName('Country')->item(0)->nodeValue);
         $oCountryName = str_rep($BuyerInfo->getElementsByTagName('CountryName')->item(0)->nodeValue);
         $oPostalCode = str_rep($BuyerInfo->getElementsByTagName('PostalCode')->item(0)->nodeValue);
         $oPhone = $BuyerInfo->getElementsByTagName('Phone')->item(0)->nodeValue;
         $BuyerInfo = null;
         unset($BuyerInfo);
         //顾客留言
         $oBuyerCheckoutMessage = @str_rep($SellerOrder->getElementsByTagName('BuyerCheckoutMessage')->item(0)->nodeValue);
         //顾客购买留言
         $oBuyerCheckoutMessage = str_replace('<![CDATA[', '', $oBuyerCheckoutMessage);
         $oBuyerCheckoutMessage = str_replace(']]>', '', $oBuyerCheckoutMessage);
         //付款时间
         $oPaidTime = strtotime($SellerOrder->getElementsByTagName('PaidTime')->item(0)->nodeValue);
         $oCreateTime = strtotime($SellerOrder->getElementsByTagName('CreatedTime')->item(0)->nodeValue);
         $oShippedTime = @strtotime($SellerOrder->getElementsByTagName('ShippedTime')->item(0)->nodeValue);
         $SSS = $SellerOrder->getElementsByTagName('ShippingServiceSelected')->item(0);
         $oShipingService = $SSS->getElementsByTagName('ShippingService')->item(0)->nodeValue;
         $oShipingFee = $SSS->getElementsByTagName('ShippingServiceCost')->item(0)->nodeValue;
         $SSS = null;
         unset($SSS);
         //店铺收款paypal account
         //$oPayPalEmailAddress = @$SellerOrder->getElementsByTagName('PayPalEmailAddress')->item(0)->nodeValue;
         $_itemid = $osoTransArray->item(0)->getElementsByTagName('ItemID')->item(0)->nodeValue;
         $oPayPalEmailAddress = $this->getPayPalEmailAddress($_itemid);
         //var_dump($Item_Elements);
         //$oPayPalEmailAddress = $Item_Elements->getElementsByTagName('PayPalEmailAddress')->nodeValue;
         //echo $oCompleteStatus."======".$oeBayPaymentStatus."======".$oPaidTime; echo "\n";
         if ($oCompleteStatus == "Complete" && $oeBayPaymentStatus == "NoPaymentFailure" && $oPaidTime > 0) {
             $oOrderStatus = 1;
         }
         if ($noptid_trans === true) {
             //不是通过ebay官方交易的paypal交易
             if ($oCompleteStatus == "Complete" && $oeBayPaymentStatus == "NoPaymentFailure" && $oPaidTime > 0) {
                 $oOrderStatus = 687;
             }
         }
         $is_allow_spide_itemid = false;
         if ($oPaidTime <= 0 || $oPaidTime == '' || empty($oPaidTime) && count($osoTransArray) == 1) {
             $_QuantityPurchased = $osoTransArray->item(0)->getElementsByTagName('QuantityPurchased')->item(0)->nodeValue;
             if (in_array($_itemid, $_allow_spide_itemid) && $_QuantityPurchased > 0) {
                 echo "未付款促销订单抓取--------";
                 $oOrderStatus = $_QuantityPurchased == 1 ? 687 : 688;
                 $oAmountPaid = 9999;
                 $oPaidTime = $oCreateTime;
                 $is_allow_spide_itemid = true;
                 $buyAddress = $this->getSellerTransactions($oSellerOrderID);
                 $oName = str_rep($buyAddress->getElementsByTagName('Name')->item(0)->nodeValue);
                 $oName = mysql_real_escape_string($oName);
                 $oStreet1 = str_rep($buyAddress->getElementsByTagName('Street1')->item(0)->nodeValue);
                 $oCityName = str_rep($buyAddress->getElementsByTagName('CityName')->item(0)->nodeValue);
                 $oStateOrProvince = str_rep($buyAddress->getElementsByTagName('StateOrProvince')->item(0)->nodeValue);
                 $oCountry = str_rep($buyAddress->getElementsByTagName('Country')->item(0)->nodeValue);
                 $oCountryName = str_rep($buyAddress->getElementsByTagName('CountryName')->item(0)->nodeValue);
                 $oPostalCode = str_rep($buyAddress->getElementsByTagName('PostalCode')->item(0)->nodeValue);
                 $oPhone = $buyAddress->getElementsByTagName('Phone')->item(0)->nodeValue;
             }
         }
         if ($oShippedTime > 0) {
             $oOrderStatus = 2;
         }
         //已经发货
         $oRefundAmount = 0;
         //表示未垦退款
         if ($oOrderStatus == 1 && $oShippedTime <= 0 && $oPaidTime > 0 || $oOrderStatus == 4 && $oShippedTime <= 0 || in_array($oOrderStatus, array(687, 688)) && $oShippedTime <= 0 && $is_allow_spide_itemid == true) {
             echo "eBay订单号[{$oSellerOrderID}]有效 ,订单类型[{$oOrderStatus}] ";
             $check_ebayorderid = true;
             //检查汇总表该 eBay 订单号是否已经存在
             //echo "===={$oSellerOrderID}==={$ebay_account}====";//检测重复抓单信息
             $where = " where orderid='" . $oSellerOrderID . "' and accountId='" . $FLIP_GLOBAL_EBAY_ACCOUNT[$ebay_account] . "' ";
             $check_ebayorderid = OrderidsModel::judgeOrderidsList('orderid', $where);
             //取消
             $check_ebayorderid == false;
             $new_ebay_id = true;
             if ($check_ebayorderid === false) {
                 //添加订单汇总
                 /* 生成一个本地系统订单号 */
                 //$our_sys_ordersn=date('Y-m-d-His').mt_rand(100,999).$oRecordNumber;
                 $oorder_no = '';
                 //已废弃
                 $isNote = 0;
                 if (!empty($oBuyerCheckoutMessage)) {
                     $isNote = 1;
                 }
                 $orderData = array();
                 $orderData = array('orderData' => array('recordNumber' => $oRecordNumber, 'platformId' => 1, 'accountId' => $FLIP_GLOBAL_EBAY_ACCOUNT[$ebay_account], 'ordersTime' => $oCreateTime, 'paymentTime' => $oPaidTime, 'onlineTotal' => $oAmountPaid, 'actualTotal' => $oAmountPaid, 'transportId' => '', 'actualShipping' => $oShipingFee, 'orderStatus' => C("STATEPENDING"), 'orderType' => C("STATEPENDING_CONV"), 'orderAttribute' => 1, 'channelId' => '', 'orderAddTime' => $mctime, 'isNote' => $isNote, 'storeId' => 1), 'orderExtenData' => array('declaredPrice' => 0.0, 'paymentStatus' => $oCompleteStatus, 'transId' => 1, 'PayPalPaymentId' => $oPtid, 'site' => $oSite, 'orderId' => $oSellerOrderID, 'platformUsername' => $oUserID, 'currency' => $oCurrency, 'feedback' => $oBuyerCheckoutMessage, 'PayPalEmailAddress' => $oPayPalEmailAddress, 'eBayPaymentStatus' => $oeBayPaymentStatus), 'orderUserInfoData' => array('username' => $oName, 'platformUsername' => $oUserID, 'email' => $oEmail, 'countryName' => $oCountryName, 'countrySn' => $oCountry, 'currency' => $oCurrency, 'state' => $oStateOrProvince, 'city' => $oCityName, 'street' => $oStreet1, 'address2' => $oStreet2, 'address3' => '', 'landline' => $oPhone, 'phone' => $ebay_state, 'zipCode' => $oPostalCode));
                 echo "\tUserID:{$oUserID}" . " AMT:{$oAmountPaid} recordNO:{$oRecordNumber} 付款状态:{$oCompleteStatus} 付款时间:" . date('Y-m-d H:i:s', $oPaidTime) . "\n";
                 //添加订单明细
                 $obj_order_detail_data = array();
                 foreach ($osoTransArray as $transaction) {
                     //该交易的销售编号
                     $tran_recordnumber = $transaction->getElementsByTagName('ShippingDetails')->item(0)->getElementsByTagName('SellingManagerSalesRecordNumber')->item(0)->nodeValue;
                     /* 多属性订单 */
                     $attribute = '';
                     $buy_with_attr = false;
                     $tran_varia = $transaction->getElementsByTagName('Variation')->item(0);
                     if (is_object($tran_varia)) {
                         //未添加明细的属性 20130301
                         if ($tran_varia->hasChildNodes()) {
                             $Variation = $tran_varia->getElementsByTagName('NameValueList')->item(0);
                             if (!empty($Variation) && $Variation->hasChildNodes()) {
                                 foreach ($Variation as $variate) {
                                     $aname = $variate->getElementsByTagName('Name')->item(0)->nodeValue;
                                     $avalue = $variate->getElementsByTagName('Value')->item(0)->nodeValue;
                                     $attribute .= $aname . ":" . $avalue . " ";
                                 }
                             }
                             $buy_with_attr = true;
                             $Variation = null;
                             unset($Variation);
                         }
                     }
                     $tran_id = $transaction->getElementsByTagName('TransactionID')->item(0)->nodeValue;
                     //该交易的物品信息
                     $odItem = $transaction->getElementsByTagName('Item')->item(0);
                     if ($buy_with_attr === true) {
                         $odItemTitle = @$tran_varia->getElementsByTagName('VariationTitle')->item(0)->nodeValue;
                         $odSKU = @$tran_varia->getElementsByTagName('SKU')->item(0)->nodeValue;
                     } else {
                         $odItemTitle = str_rep($odItem->getElementsByTagName('Title')->item(0)->nodeValue);
                         $odSKU = str_rep($odItem->getElementsByTagName('SKU')->item(0)->nodeValue);
                     }
                     $is_suffix = 0;
                     if (!empty($account_suffix)) {
                         list($truesku, $skusuffix) = explode(':', $odSKU);
                         if (!empty($skusuffix)) {
                             $odSKU = $truesku;
                             $is_suffix = 1;
                         }
                     }
                     ###########悲剧 目前getorder api 无法取得下面2个值#########
                     //ebay刊登物品的分类ID,备用字段
                     //$CategoryID 		= @$odItem->getElementsByTagName('PrimaryCategory')->item(0)->getElementsByTagName('CategoryID')->item(0)->nodeValue;
                     //$ListingType 		= @$odItem->getElementsByTagName('ListingType')->item(0)->nodeValue;
                     $CategoryID = 0;
                     $ListingType = '';
                     //购买数量
                     $QuantityPurchased = $transaction->getElementsByTagName('QuantityPurchased')->item(0)->nodeValue;
                     //交易创建时间
                     $CreatedDate = strtotime($transaction->getElementsByTagName('CreatedDate')->item(0)->nodeValue);
                     $FinalValueFee = $transaction->getElementsByTagName('FinalValueFee')->item(0)->nodeValue;
                     $tran_price = $transaction->getElementsByTagName('TransactionPrice')->item(0)->nodeValue;
                     $goodsshippingcost = $transaction->getElementsByTagName('ActualShippingCost')->item(0)->nodeValue;
                     $goodsshippingcost = empty($goodsshippingcost) ? '0.0' : $goodsshippingcost;
                     $tran_itemid = $odItem->getElementsByTagName('ItemID')->item(0)->nodeValue;
                     $tran_site = $odItem->getElementsByTagName('Site')->item(0)->nodeValue;
                     //$obj_order_detail	=new eBayOrderDetail();
                     $obj_order_detail_data[] = array('orderDetailData' => array('recordNumber' => $tran_recordnumber, 'itemPrice' => $tran_price, 'sku' => strtoupper($odSKU), 'amount' => $QuantityPurchased, 'shippingFee' => $goodsshippingcost, 'createdTime' => $mctime), 'orderDetailExtenData' => array('itemId' => $tran_itemid, 'transId' => $tran_id, 'itemTitle' => $odItemTitle, 'itemURL' => '', 'shippingType' => $oShipingService, 'FinalValueFee' => $FinalValueFee, 'FeeOrCreditAmount' => $oFeeOrCreditAmount, 'ListingType' => $ListingType, 'note' => $oBuyerCheckoutMessage));
                 }
                 $orderData['orderDetail'] = $obj_order_detail_data;
                 $rtn = OldsystemModel::orderErpInsertorder($orderData);
                 //var_dump($rtn);
                 $insertData = array();
                 if ($rtn['errcode'] == 200) {
                     var_dump($rtn);
                     $rtn_data = $rtn['data'];
                     $orderId = $rtn_data['orderId'];
                     echo "插入老系统成功,订单编号 [{$orderId}] \n";
                     $pmId = $rtn_data['pmId'];
                     $totalweight = $rtn_data['totalweight'];
                     $shipfee = $rtn_data['shipfee'];
                     $carrier = $rtn_data['carrier'];
                     $carrierId = $rtn_data['carrierId'];
                     $status = $rtn_data['status'];
                     $orderData['orderData']['id'] = $orderId;
                     //赋予新系统订单编号@20140501
                     $calcInfo = CommonModel::calcAddOrderWeight($obj_order_detail_data);
                     //计算重量和包材
                     //var_dump($calcInfo);
                     $orderData['orderData']['ORcalcWeight'] = $calcInfo[0];
                     $orderData['orderData']['calcWeight'] = $calcInfo[0];
                     $orderData['orderData']['pmId'] = $calcInfo[1];
                     if ($orderData['orderData']['calcWeight'] != $totalweight) {
                         $insertData['old_totalweight'] = $totalweight;
                         $insertData['new_totalweight'] = $orderData['orderData']['calcWeight'];
                     }
                     if ($orderData['orderData']['pmId'] != $pmId) {
                         $insertData['old_pmId'] = $pmId;
                         $insertData['new_pmId'] = $orderData['orderData']['pmId'];
                     }
                     if (count($orderData['orderDetail']) > 1) {
                         $orderData['orderData']['orderAttribute'] = 3;
                     } else {
                         if (isset($orderData['orderDetail'][0]['orderDetailData']['amount']) && $orderData['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                             $orderData['orderData']['orderAttribute'] = 2;
                         }
                     }
                     $calcShippingInfo = TransAPIModel::trans_carriers_best_get($orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName'], $ebay_account, $orderData['orderData']['actualTotal']);
                     //计算运费
                     //var_dump($calcShippingInfo);
                     $orderData['orderData']['calcShipping'] = $calcShippingInfo['fee'];
                     $orderData['orderData']['transportId'] = $calcShippingInfo['carrierId'];
                     $orderData['orderData']['ORtransportId'] = $calcShippingInfo['carrierId'];
                     $orderData['orderData']['channelId'] = $calcShippingInfo['channelId'];
                     $orderData['orderData']['ORchannelId'] = $calcShippingInfo['channelId'];
                     if ($orderData['orderData']['calcShipping'] != $shipfee) {
                         $insertData['old_shippfee'] = $shipfee;
                         $insertData['new_shippfee'] = $orderData['orderData']['calcShipping'];
                     }
                     if ($orderData['orderData']['transportId'] != $carrierId) {
                         $insertData['old_carrierId'] = $carrierId;
                         $insertData['new_carrierId'] = $orderData['orderData']['transportId'];
                     }
                     if (!empty($insertData)) {
                         $insertData['ebay_id'] = $orderId;
                         $insertData['addtime'] = time();
                         var_dump($insertData);
                         OldsystemModel::insertTempSyncRecords($insertData);
                         // 插入临时对比记录表
                     }
                     $orderData = AutoModel::auto_contrast_intercept($orderData);
                     $statusArr = StatusMenuModel::getStatusMenuByOldStatus($status);
                     if (empty($statusArr)) {
                         echo "未获取老系统状态{$status}转换新码\n";
                     } else {
                         $orderData['orderData']['ORorderStatus'] = $statusArr[0];
                         $orderData['orderData']['ORorderType'] = $statusArr[1];
                         $orderData['orderData']['orderStatus'] = $statusArr[0];
                         $orderData['orderData']['orderType'] = $statusArr[1];
                     }
                     if (OrderAddModel::insertAllOrderRow($orderData)) {
                         echo "本地 Record No. [{$oRecordNumber}] 入库成功\n";
                         $message .= "<font color='green'>本地订单号 [{$oRecordNumber}] 入库成功</font><br>";
                     } else {
                         echo OrderAddModel::$errMsg;
                         $message .= "<font color='red'>本地订单号 [{$oRecordNumber}] 入库失败</font><br>";
                     }
                 } else {
                     var_dump($rtn);
                 }
                 //exit;
             } else {
                 echo "本地订单号 [{$oRecordNumber}] 入库失败\n";
                 $message .= "<font color='red'>本地订单号 [{$oRecordNumber}] 入库失败</font><br>";
             }
         } else {
             echo "eBay订单号[{$oSellerOrderID}] 记录编号[{$oRecordNumber}] 无效 不入库...\t";
             $message .= "<font color='red'>{$oSellerOrderID}无效 不入库...</font><br>";
             if ($oShippedTime > 0 || $oOrderStatus == 2) {
                 echo "已经发货\t";
                 $message .= "<font color='red'>{$oSellerOrderID}已经发货</font><br>";
             }
             if ($oPaidTime <= 0 || $oPaidTime == '' || empty($oPaidTime)) {
                 echo "未付款\t";
                 $message .= "<font color='red'>{$oSellerOrderID}未付款</font><br>";
             }
             echo "\n";
             //pop_ebay_orderid_queue($oSellerOrderID,$ebay_account);
         }
     }
     return $message;
 }
Esempio n. 4
0
 function act_addDistributorOrder()
 {
     $orderArrJson = json_decode($_POST["orderArr"], true);
     $app_key = trim($_POST['app_key']);
     $account = $this->getOrderSystemAccount($app_key);
     $accountInfo = omAccountModel::getAccountInfoByName($account);
     $accountId = $accountInfo['id'];
     $orderAddAct = new OrderAddAct();
     $rtnArr = array();
     foreach ($orderArrJson as $val) {
         $itemRtn = array();
         $orderId = $val['orderId'];
         $check = $orderAddAct->checkDuplicateOrder($orderId, '16');
         if ($check) {
             $itemRtn["errcode"] = 80001;
             $itemRtn["orderId"] = $orderId;
             $itemRtn["msg"] = "系统已经存在[" . $orderId . "]这个订单";
             $rtnArr[] = $itemRtn;
             continue;
         }
         //return $rtnArr;
         $insertOrder = array();
         /***************BEGIN 订单表数据***************/
         //$unshipedOrder = array();
         $orderdata['recordNumber'] = $orderId;
         $orderdata['platformId'] = 16;
         //国内销售部
         $orderdata['accountId'] = $accountId;
         $orderdata['orderStatus'] = C('STATEPENDING');
         $orderdata['orderType'] = C('STATEPENDING');
         //daichu
         //$gmtCreate = time_shift($val['gmtCreate']);
         $orderdata['ordersTime'] = $val['gmtCreate'];
         $orderdata['paymentTime'] = "";
         //$pay_time[0];
         $orderdata['onlineTotal'] = "";
         //$order['initOderAmount']['amount'];  //线上总金额
         $orderdata['actualTotal'] = "";
         //$orderDetail2['payAmount']['amount'];//付款总金额
         $orderdata['calcShipping'] = $orderdata['orderAddTime'] = time();
         $orderdata['isFixed'] = 1;
         /***************END 订单表数据***************/
         /***************BEGIN 订单扩展表数据***************/
         $orderExtAli = array();
         //
         $orderExtAli['declaredPrice'] = $val['orderAmount']['amount'];
         $orderExtAli['paymentStatus'] = "";
         //$order['fundStatus'];
         $orderExtAli['transId'] = "";
         //$val['tradeID'];//$order['id'];//$orderdetail["id"]; // 交易id;;
         //$orderExtAli[PayPalPaymentId"]	=	'';
         //$orderExtAli["site"]			    =	'';
         $orderExtAli['orderId'] = $val['orderId'];
         $orderExtAli['platformUsername'] = "";
         //$order['buyerSignerFullname'];;
         $orderExtAli['currency'] = $val['orderAmount']['currencyCode'];
         $orderExtAli['PayPalEmailAddress'] = "";
         //$order['buyerInfo']['email'];;
         $orderExtAli['eBayPaymentStatus'] = "";
         //1?//$order['orderStatus']; //订单状态;
         /***************END 订单扩展表数据***************/
         /***************BEGIN 订单用户表数据***************/
         $orderUserInfo = array();
         $orderUserInfo['username'] = $val['receiptAddress']['contactPerson'];
         $orderUserInfo['platformUsername'] = "";
         //$order['buyerSignerFullname'];
         $orderUserInfo['email'] = "";
         //$order['buyerInfo']['email'];
         $orderUserInfo['countryName'] = get_country_name($val['receiptAddress']['country']);
         $orderUserInfo['countrySn'] = $val['receiptAddress']['country'];
         $orderUserInfo['currency'] = $val['orderAmount']['currencyCode'];
         $orderUserInfo['state'] = $val['receiptAddress']['province'];
         $orderUserInfo['city'] = $val['receiptAddress']['city'];
         $orderUserInfo['street'] = $val['receiptAddress']['address1'];
         //?//$val['receiptAddress']['detailAddress'];
         $orderUserInfo['address2'] = isset($val['receiptAddress']['address2']) ? $val['receiptAddress']['address2'] : "";
         $orderUserInfo['zipCode'] = $val['receiptAddress']['zip'];
         $orderUserInfo['phone'] = $val['receiptAddress']['phoneNumber'];
         /*************END 订单用户表数据***************/
         $carrier = array();
         $item_notes = array();
         $noteb = array();
         $insertOrder = array('orderData' => $orderdata, 'orderExtenData' => $orderExtAli, 'orderUserInfoData' => $orderUserInfo);
         $orderweight = "";
         $obj_order_detail_data = array();
         foreach ($val['childOrderList'] as $orderdetail) {
             //明细表
             $orderdata_detail = array();
             //$orderdata_detail['omOrderId']	    =	$insertId;//$order["id"];
             $orderdata_detail['recordNumber'] = $orderId;
             $orderdata_detail['sku'] = $orderdetail['productAttributes']['sku'];
             //substr($orderdetail['skuCode'],0,stripos($orderdetail['skuCode'],'#'));
             $orderdata_detail['itemPrice'] = $orderdetail['productAttributes']['itemPrice'];
             $orderdata_detail['amount'] = $orderdetail['lotNum'];
             //$orderdata_detail["shippingFee"]	=	'';
             //$orderdata_detail["reviews"]	    =	'';
             $orderdata_detail['createdTime'] = time();
             //明细扩展表
             $orderDetailExtAli = array();
             $orderDetailExtAli['itemTitle'] = $orderdetail['productAttributes']['itemTitle'];
             $orderDetailExtAli['itemURL'] = $orderdetail['productAttributes']['skuUrl'];
             $orderDetailExtAli['itemId'] = "";
             //$orderdetail['productId'];
             $orderDetailExtAli['transId'] = 0;
             //$orderId;//$orderdetail['orderId']; // 交易id;
             $orderDetailExtAli['note'] = "";
             //$item_notes[$orderdetail['orderId']];
             $obj_order_detail_data[] = array('orderDetailData' => $orderdata_detail, 'orderDetailExtenData' => $orderDetailExtAli);
         }
         $insertOrder['orderDetail'] = $obj_order_detail_data;
         $calcInfo = CommonModel::calcAddOrderWeight($obj_order_detail_data);
         //计算重量和包材
         $insertOrder['orderData']['calcWeight'] = $calcInfo[0];
         $insertOrder['orderData']['pmId'] = $calcInfo[1];
         if (count($insertOrder['orderDetail']) > 1) {
             $insertOrder['orderData']['orderAttribute'] = 3;
         } else {
             if (isset($insertOrder['orderDetail'][0]['orderDetailData']['amount']) && $insertOrder['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                 $insertOrder['orderData']['orderAttribute'] = 2;
             }
         }
         $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, 1);
         //计算运费
         $insertOrder['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
         $insertOrder = AutoModel::auto_contrast_intercept($insertOrder);
         $opflag = "false";
         if (OrderAddModel::insertAllOrderRow($insertOrder)) {
             $itemRtn["errcode"] = 0;
             $itemRtn["orderId"] = $orderId;
             $itemRtn["msg"] = "success";
             $rtnArr[] = $itemRtn;
             $opflag = "success";
         } else {
             $itemRtn["errcode"] = 80005;
             $itemRtn["orderId"] = $orderId;
             $itemRtn["msg"] = "添加订单失败";
             $rtnArr[] = $itemRtn;
         }
         $logfile = date("Y-m-d") . ".log";
         @file_put_contents("/home/ebay_order_cronjob_logs/auto_contrast_intercept/" . $account . "/" . $logfile, $_POST["orderArr"] . "==" . $opflag . "\r\n", FILE_APPEND);
     }
     $rtnStr = json_encode($rtnArr);
     echo $rtnStr;
 }
Esempio n. 5
0
 function act_invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request, $account, $site, $accountId, $flip_transportList, $message)
 {
     //		/global $account, $site, $accountId, $flip_transportList , $message;
     try {
         $response = $service->getOrder($request);
         //echo ("Service Response\n");
         //echo ("=============================================================================\n");
         if ($response->isSetGetOrderResult()) {
             //echo ("ListOrdersResult\n");
             $listOrdersResult = $response->getGetOrderResult();
             /*if ($listOrdersResult->isSetNextToken()) {
             			//echo ("	NextToken----");
             			//echo ($listOrdersResult->getNextToken() . "\n");
             		}
             		
             		if ($listOrdersResult->isSetCreatedBefore()) {
             			//echo ("CreatedBefore----");
             			//echo ($listOrdersResult->getCreatedBefore() . "\n");
             		}
             		if ($listOrdersResult->isSetLastUpdatedBefore()) {
             			//echo ("LastUpdatedBefore----");
             			//echo ($listOrdersResult->getLastUpdatedBefore() . "\n");
             		}*/
             if ($listOrdersResult->isSetOrders()) {
                 $orders = $listOrdersResult->getOrders();
                 $orderList = $orders->getOrder();
                 $orderIndex = 1;
                 $now = time();
                 //BaseModel :: begin(); //开始事务
                 foreach ($orderList as $order) {
                     //echo ("***********Orders $orderIndex************\n\n");
                     $orderIndex++;
                     $orderData = array();
                     //om_unshipped_order
                     $orderUserInfoData = array();
                     //om_unshipped_order_userInfo
                     $orderExtenData = array();
                     //om_unshipped_order_extension
                     $street2 = '';
                     //街道2
                     $street3 = '';
                     //街道3
                     if ($order->isSetAmazonOrderId() && $order->isSetOrderStatus() && $order->getOrderStatus() == 'Unshipped') {
                         //$orderData['ebay_status'] = 1; //同步进来的订单的状态
                         $orderData['recordNumber'] = $order->getAmazonOrderId();
                         //平台上的订单id
                         //echo "AmazonOrderId ==== {$orderData['recordNumber']}\n";
                     } else {
                         //echo 'getOrderStatus======' . $order->getOrderStatus() . "\n";
                         if ($order->getOrderStatus() == 'Shipped') {
                             //表示已经发货了的订单
                             $shippedRecordNum = $order->getAmazonOrderId();
                             $tName = 'om_shipped_order';
                             $where = "WHERE recordNumber='{$shippedRecordNum}' and accountId='{$accountId}' and ShippedTime=''";
                             $set = "SET ShippedTime='{$now}'";
                             //标记发货时间
                             $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where);
                             if ($affectRow) {
                                 $message .= "<font color='green'>update {$shippedRecordNum} ShippedTime success" . "</font><br>";
                             } else {
                                 $message .= "<font color='red'>update {$shippedRecordNum} ShippedTime fail may be has shippedTime or had no this recordNumber" . "</font><br>";
                             }
                         }
                         continue;
                     }
                     if ($order->isSetPurchaseDate()) {
                         //亚马逊平台上的下单时间
                         $orderData['ordersTime'] = strtotime($order->getPurchaseDate());
                         //echo ("addTime  ==== {$order->getPurchaseDate()}\n");
                     }
                     if ($order->isSetLastUpdateDate()) {
                         //支付时间
                         $orderData['paymentTime'] = strtotime($order->getLastUpdateDate());
                         //echo ("paidTime  ==== {$order->getLastUpdateDate()}\n");
                     }
                     $orderstatus = '';
                     //订单状态
                     //if ($order->isSetOrderStatus()) {
                     //                    	if($order->getOrderStatus() == 'Unshipped'){
                     //							$orderstatus				= 1;
                     //						}
                     //					}
                     if ($order->isSetFulfillmentChannel()) {
                         $orderExtenData['FulfillmentChannel'] = $order->getFulfillmentChannel();
                         //echo ("FulfillmentChannel  ==== "); //订单配送方式
                         //echo ($orderExtenData['FulfillmentChannel'] . "\n");
                     }
                     if ($order->isSetSalesChannel()) {
                         $orderExtenData['SalesChannel'] = $order->getSalesChannel();
                         //echo ("SalesChannel ==== ");
                         //echo ($orderExtenData['SalesChannel'] . "\n");
                     }
                     if ($order->isSetOrderChannel()) {
                         $orderExtenData['OrderChannel'] = $order->getOrderChannel();
                         //echo ("OrderChannel ====");
                         //echo ($orderExtenData['OrderChannel'] . "\n");
                     }
                     if ($order->isSetShipServiceLevel()) {
                         $orderExtenData['ShipServiceLevel'] = $order->getShipServiceLevel();
                         //echo ("ShipServiceLevel ==== ");
                         //echo ($orderExtenData['ShipServiceLevel'] . "\n");
                     }
                     if ($order->isSetShippingAddress()) {
                         //判断是否设置了地址
                         $shippingAddress = $order->getShippingAddress();
                         if ($shippingAddress->isSetName()) {
                             //获取收件人姓名
                             $orderUserInfoData['username'] = htmlentities($shippingAddress->getName(), ENT_QUOTES);
                             //echo ("username ==== ");
                             //echo ($orderUserInfoData['username'] . "\n");
                         }
                         if ($shippingAddress->isSetAddressLine1()) {
                             //街道1
                             $orderUserInfoData['street'] = htmlentities($shippingAddress->getAddressLine1(), ENT_QUOTES);
                             //echo ("street ==== ");
                             //echo ($orderUserInfoData['street'] . "\n");
                         }
                         if ($shippingAddress->isSetAddressLine2()) {
                             //街道2
                             $street2 = htmlentities($shippingAddress->getAddressLine2(), ENT_QUOTES);
                         }
                         if ($shippingAddress->isSetAddressLine3()) {
                             //街道3
                             $street3 = htmlentities($shippingAddress->getAddressLine3(), ENT_QUOTES);
                         }
                         if ($shippingAddress->isSetCity()) {
                             //城市
                             $orderUserInfoData['city'] = htmlentities($shippingAddress->getCity(), ENT_QUOTES);
                             //echo ("city ==== ");
                             //echo ($orderUserInfoData['city'] . "\n");
                         }
                         if ($shippingAddress->isSetCounty()) {
                             //郡,县
                             $orderUserInfoData['address2'] = htmlentities($shippingAddress->getCounty() . ' ' . $street2, ENT_QUOTES);
                             $orderUserInfoData['address3'] = htmlentities($shippingAddress->getCounty() . ' ' . $street3, ENT_QUOTES);
                             //echo ("address2 ==== ");
                             //echo ($orderUserInfoData['address2'] . "\n");
                             //echo ("address3 ==== ");
                             //echo ($orderUserInfoData['address3'] . "\n");
                         }
                         if ($shippingAddress->isSetDistrict()) {
                             //地方,区
                             //echo ("District ==== " . $shippingAddress->getDistrict() . "\n");
                         }
                         if ($shippingAddress->isSetStateOrRegion()) {
                             //州
                             $orderUserInfoData['state'] = htmlentities($shippingAddress->getStateOrRegion(), ENT_QUOTES);
                             //echo ("state ==== ");
                             //echo ($orderUserInfoData['state'] . "\n");
                         }
                         if ($shippingAddress->isSetPostalCode()) {
                             //邮编
                             $orderUserInfoData['zipCode'] = htmlentities($shippingAddress->getPostalCode(), ENT_QUOTES);
                             //echo ("zipCode ==== ");
                             //echo ($orderUserInfoData['zipCode'] . "\n");
                         }
                         if ($shippingAddress->isSetCountryCode()) {
                             //国家简称
                             /*$ebay_countrynames = array('US'=>'United States', "UK"=>"United Kingdom");
                             		$orderData['ebay_couny'] 	= 	$shippingAddress->getCountryCode() ;
                             		$orderData['ebay_site'] 	= 	$shippingAddress->getCountryCode() ;
                             		$orderData['ebay_countryname'] 	= 	$ebay_countrynames[$shippingAddress->getCountryCode()];*/
                             //$sql = "SELECT regions_en FROM  ebay_region WHERE  regions_jc =  '".$shippingAddress->getCountryCode()."'";
                             //                        	$sql	= $dbcon->execute($sql);
                             //							$amazon_countryname	= $dbcon->fetch_one($sql);
                             $orderUserInfoData['countrySn'] = $shippingAddress->getCountryCode();
                             //这里要调用运输方式管理系统的数据,获取国家简称对应的国家名称
                             $countryNameInfo = CommonModel::getCountrieInfoBySn($orderUserInfoData['countrySn']);
                             //根据国家简称获取该国家的信息
                             //$orderData['ebay_site'] = $shippingAddress->getCountryCode() ;
                             $orderUserInfoData['countryName'] = trim($countryNameInfo['regions_en']);
                             //获得国家名称
                             //echo ("getCountryCode==== " . $orderUserInfoData['countrySn'] . "\n");
                         }
                         if ($shippingAddress->isSetPhone()) {
                             //手机
                             $orderUserInfoData['phone'] = $shippingAddress->getPhone();
                             //echo ("phone ==== ");
                             //echo ($orderUserInfoData['phone'] . "\n");
                         }
                     }
                     if ($order->isSetOrderTotal()) {
                         $orderTotal = $order->getOrderTotal();
                         if ($orderTotal->isSetCurrencyCode()) {
                             //币种
                             $orderUserInfoData['currency'] = $orderTotal->getCurrencyCode();
                             //echo ("currency ==== ");
                             //echo ($orderUserInfoData['currency'] . "\n");
                         }
                         if ($orderTotal->isSetAmount()) {
                             //订单总价,线上总价
                             $orderData['onlineTotal'] = $orderTotal->getAmount();
                             $orderData['actualTotal'] = $orderTotal->getAmount();
                             //echo ("onlineTotal ==== ");
                             //echo ($orderData['onlineTotal'] . "\n");
                         }
                     }
                     if ($order->isSetNumberOfItemsShipped()) {
                         //echo ("ItemsShipped ==== " . $order->getNumberOfItemsShipped() . "\n");
                     }
                     if ($order->isSetNumberOfItemsUnshipped()) {
                         //echo ("NumberOfItemsUnshipped ==== " . $order->getNumberOfItemsUnshipped() . "\n");
                     }
                     if ($order->isSetPaymentExecutionDetail()) {
                         $paymentExecutionDetail = $order->getPaymentExecutionDetail();
                         $paymentExecutionDetailItemList = $paymentExecutionDetail->getPaymentExecutionDetailItem();
                         foreach ($paymentExecutionDetailItemList as $paymentExecutionDetailItem) {
                             echo "######PaymentExecutionDetailItem######\n";
                             if ($paymentExecutionDetailItem->isSetPayment()) {
                                 $payment = $paymentExecutionDetailItem->getPayment();
                                 if ($payment->isSetCurrencyCode()) {
                                     //echo ("CurrencyCode ==== ");
                                     //echo ($payment->getCurrencyCode() . "\n");
                                 }
                                 if ($payment->isSetAmount()) {
                                     //echo (" Amount ==== ");
                                     //echo ($payment->getAmount() . "\n");
                                 }
                             }
                             if ($paymentExecutionDetailItem->isSetSubPaymentMethod()) {
                                 //echo ("SubPaymentMethod ==== ");
                                 //echo ($paymentExecutionDetailItem->getSubPaymentMethod() . "\n");
                             }
                         }
                     }
                     if ($order->isSetPaymentMethod()) {
                         $orderExtenData['PaymentMethod'] = $order->getPaymentMethod();
                         //echo ("PaymentMethod ==== ");
                         //echo ($orderExtenData['PaymentMethod'] . "\n");
                     }
                     if ($order->isSetMarketplaceId()) {
                         $orderExtenData['MarketplaceId'] = $order->getMarketplaceId();
                         //echo ("MarketplaceId ==== ");
                         //echo ($orderExtenData['MarketplaceId'] . "\n");
                     }
                     if ($order->isSetBuyerName()) {
                         //买家ID
                         $orderUserInfoData['platformUsername'] = htmlentities($order->getBuyerName(), ENT_QUOTES);
                         //echo ("platformUsername ==== ");
                         //echo ($orderUserInfoData['platformUsername'] . "\n");
                     }
                     if ($order->isSetBuyerEmail()) {
                         //买家email
                         $orderUserInfoData['email'] = $order->getBuyerEmail();
                         //echo ("email ==== ");
                         //echo ($orderUserInfoData['email'] . "\n");
                     }
                     if ($order->isSetShipmentServiceLevelCategory()) {
                         $orderExtenData['ShipmentServiceLevelCategory'] = $order->getShipmentServiceLevelCategory();
                         //echo ("ShipmentServiceLevelCategory ==== ");
                         //echo ($orderExtenData['ShipmentServiceLevelCategory'] . "\n");
                     }
                     //$orderData['ebay_user']			=	$user;
                     $orderData['platformId'] = 11;
                     //amazon的平台ID为11
                     $orderData['accountId'] = $accountId;
                     //amazon的账号ID
                     //echo ("accountId ==== ");
                     //echo ($orderData['accountId'] . "\n");
                     $orderData['orderAddTime'] = time();
                     //添加到系统的时间
                     //echo ("orderAddTime ==== ");
                     //echo ($orderData['orderAddTime'] . "\n");
                     $orderData['orderStatus'] = C('STATEPENDING');
                     //默认订单状态
                     $orderData['orderType'] = C('STATEPENDING_INITIAL');
                     //默认订单类型
                     $orderData = array('orderData' => $orderData, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData);
                     $tName = 'om_unshipped_order';
                     $where = "WHERE recordNumber='{$orderData['orderData']['recordNumber']}' AND platformId={$orderData['orderData']['platformId']} and is_delete ='0'";
                     $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where);
                     $tName = 'om_shipped_order';
                     $flagCountshipped = OmAvailableModel::getTNameCount($tName, $where);
                     if (empty($flagCountUnshipped) && empty($flagCountshipped)) {
                         //判断订单是否已经在系统2个订单表(未发货和已发货)中存在
                         //$orderData['ebay_ordersn']	=	generateOrdersn();
                         $detailrequest = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest();
                         $detailrequest->setSellerId(MERCHANT_ID);
                         $detailrequest->setAmazonOrderId($orderData['orderData']['recordNumber']);
                         $orderDetailArr = self::act_invokeListOrderItems($service, $detailrequest);
                         //var_dump($orderDetailArr); exit;
                         for ($i = 0; $i < count($orderDetailArr); $i++) {
                             $orderDetailArr[$i]['orderDetailData']['recordNumber'] = $orderData['orderData']['recordNumber'];
                         }
                         //print_r($orderDetailArr);
                         if (!empty($orderDetailArr)) {
                             $orderData['orderDetail'] = $orderDetailArr;
                             $insertData = array();
                             //var_dump($obj_order_detail_data); echo "<br>";
                             $calcInfo = CommonModel::calcAddOrderWeight($orderDetailArr);
                             //计算重量和包材
                             //var_dump($calcInfo); exit;
                             $orderData['orderData']['ORcalcWeight'] = $calcInfo[0];
                             $orderData['orderData']['calcWeight'] = $calcInfo[0];
                             $orderData['orderData']['pmId'] = $calcInfo[1];
                             if ($orderData['orderData']['calcWeight'] != $totalweight) {
                                 $insertData['old_totalweight'] = $totalweight;
                                 $insertData['new_totalweight'] = $orderData['orderData']['calcWeight'];
                             }
                             if ($orderData['orderData']['pmId'] != $pmId) {
                                 $insertData['old_pmId'] = $pmId;
                                 $insertData['new_pmId'] = $orderData['orderData']['pmId'];
                             }
                             $newcarrier = get_carrier($orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName'], $account, $orderData['orderUserInfoData']['currency']);
                             $orderData['orderData']['transportId'] = $flip_transportList[$newcarrier];
                             $orderData['orderData']['ORtransportId'] = $flip_transportList[$newcarrier];
                             $rtn = OldsystemModel::orderErpInsertorder($orderData);
                             //var_dump($rtn);
                             if ($rtn['errcode'] == 200) {
                                 //var_dump($rtn);
                                 $rtn_data = $rtn['data'];
                                 $orderId = $rtn_data['orderId'];
                                 $message .= "<font color='green'>" . date("Y-m-d H:i:s") . " 插入老系统成功,订单编号 [{$orderId}] </font><br>";
                                 $pmId = $rtn_data['pmId'];
                                 $totalweight = $rtn_data['totalweight'];
                                 $shipfee = $rtn_data['shipfee'];
                                 $carrier = $rtn_data['carrier'];
                                 $carrierId = $rtn_data['carrierId'];
                                 $status = $rtn_data['status'];
                                 $orderData['orderData']['id'] = $orderId;
                                 //赋予新系统订单编号@20140501
                                 if (count($orderData['orderDetail']) > 1) {
                                     $orderData['orderData']['orderAttribute'] = 3;
                                 } else {
                                     if (isset($orderData['orderDetail'][0]['orderDetailData']['amount']) && $orderData['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                                         $orderData['orderData']['orderAttribute'] = 2;
                                     }
                                 }
                                 /*$calcShippingInfo = CommonModel :: calcAddOrderShippingFee($orderData,1);//计算运费
                                 		//var_dump($calcShippingInfo); exit;
                                 		//$insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
                                 		$orderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];*/
                                 $calcShippingInfo = TransAPIModel::trans_carriers_fix_get($orderData['orderData']['transportId'], $orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName']);
                                 //计算运费
                                 //var_dump($calcShippingInfo);
                                 $orderData['orderData']['calcShipping'] = $calcShippingInfo['fee'];
                                 //$orderData['orderData']['transportId'] = $calcShippingInfo['carrierId'];
                                 $orderData['orderData']['channelId'] = $calcShippingInfo['channelId'];
                                 $orderData['orderData']['ORchannelId'] = $calcShippingInfo['channelId'];
                                 if ($orderData['orderData']['calcShipping'] != $shipfee) {
                                     $insertData['old_shippfee'] = $shipfee;
                                     $insertData['new_shippfee'] = $orderData['orderData']['calcShipping'];
                                 }
                                 if ($orderData['orderData']['transportId'] != $carrierId) {
                                     $insertData['old_carrierId'] = $carrierId;
                                     $insertData['new_carrierId'] = $orderData['orderData']['transportId'];
                                 }
                                 if (!empty($insertData)) {
                                     $insertData['ebay_id'] = $orderId;
                                     $insertData['addtime'] = time();
                                     //var_dump($insertData);
                                     OldsystemModel::insertTempSyncRecords($insertData);
                                     // 插入临时对比记录表
                                 }
                                 $orderData = AutoModel::auto_contrast_intercept($orderData);
                                 //print_r($interceptInfo); exit;
                                 /*$orderData['orderData']['orderStatus'] = $interceptInfo['orderStatus'];
                                 		$orderData['orderData']['orderType'] = $interceptInfo['orderType'];*/
                                 //var_dump($orderData); exit;
                                 if (OrderAddModel::insertAllOrderRow($orderData)) {
                                     //echo 'insert success!' . "\n";
                                     $message .= "<font color='green'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}成功</font><br>";
                                 } else {
                                     $message .= "<font color='red'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}失败</font><br>";
                                     //echo OrderAddModel :: $errMsg;
                                 }
                             }
                         } else {
                             //echo "Amazon ID: ".$orderData['recordnumber']." 订单详情添加失败\n";
                             $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " has no detail </font><br>";
                         }
                     } else {
                         $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " had exist</font><br>";
                     }
                 }
             }
         }
     } catch (MarketplaceWebServiceOrders_Exception $ex) {
         $message .= "Caught Exception: " . $ex->getMessage() . "<br>";
         $message .= "Response Status Code: " . $ex->getStatusCode() . "<br>";
         $message .= "Error Code: " . $ex->getErrorCode() . "<br>";
         $message .= "Error Type: " . $ex->getErrorType() . "<br>";
         $message .= "Request ID: " . $ex->getRequestId() . "<br>";
         $message .= "XML: " . $ex->getXML() . "<br>";
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $message .= $e->getMessage() . "<br>";
     }
     return $message;
 }
 public function view_guoneiSaleImport()
 {
     //var_dump($_POST);//exit;
     include_once WEB_PATH . "lib/PHPExcel.php";
     //phpexcel
     include_once WEB_PATH . "conf/scripts/script.ebay.config.php";
     //global $SYSTEM_ACCOUNTS,$__liquid_items_fenmocsku,$__liquid_items_BuiltinBattery,$__liquid_items_SuperSpecific,$__liquid_items_Paste;
     $toptitle = '速卖通线下订单导入';
     //头部title
     $this->smarty->assign('toptitle', $toptitle);
     $this->smarty->assign('toplevel', 2);
     $this->smarty->assign('secondlevel', 220);
     $OmAccountAct = new OmAccountAct();
     $aliexpressAccountList = $OmAccountAct->act_getINNERAccountList();
     $this->smarty->assign("aliexpressAccountList", $aliexpressAccountList);
     if (isset($_FILES['aliexpressFile']['tmp_name'])) {
         $filePath = $_FILES['aliexpressFile']['tmp_name'];
         $PHPExcel = new PHPExcel();
         $PHPReader = new PHPExcel_Reader_Excel2007();
         if (!$PHPReader->canRead($filePath)) {
             $PHPReader = new PHPExcel_Reader_Excel5();
             if (!$PHPReader->canRead($filePath)) {
                 echo 'no Excel';
                 return;
             }
         }
         $PHPExcel = $PHPReader->load($filePath);
         $currentSheet = $PHPExcel->getSheet(0);
         //$excellists    = excel2array($PHPExcel, $filePath, 0, 0);
         //print_r($excellists);print_r($_SESSION);
         $orderid = array();
         $orderData = array();
         //$orderarr = OrderindexModel::showSearchOrderList("om_unshipped_order","where da.id=14448");
         //echo "<pre>";print_r($orderarr);
         $account = $_POST['aliexpressAccount'];
         $transportation = CommonModel::getCarrierList();
         //所有的
         $c = 2;
         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;
             $c++;
             $recordNumber = trim($currentSheet->getCell($aa)->getValue());
             $userId = trim($currentSheet->getCell($bb)->getValue());
             $skuStr = trim($currentSheet->getCell($cc)->getValue());
             $amount = trim($currentSheet->getCell($dd)->getValue());
             $countryName = trim($currentSheet->getCell($ee)->getValue());
             $actualTotal = trim($currentSheet->getCell($ff)->getValue());
             $currency = trim($currentSheet->getCell($gg)->getValue());
             $street1 = trim($currentSheet->getCell($hh)->getValue());
             $street2 = trim($currentSheet->getCell($ii)->getValue());
             $carrierNameCn = trim($currentSheet->getCell($jj)->getValue());
             $city = trim($currentSheet->getCell($kk)->getValue());
             $state = trim($currentSheet->getCell($ll)->getValue());
             $zipCode = trim($currentSheet->getCell($mm)->getValue());
             $phone = trim($currentSheet->getCell($nn)->getValue());
             $trackNumber = trim($currentSheet->getCell($oo)->getValue());
             $noteStr = trim($currentSheet->getCell($pp)->getValue());
             $ordersTime = time();
             $paymentTime = time();
             $email = '';
             $onlineTotal = '';
             $shippingFee = '';
             $transId = '';
             $note = '';
             $username = $userId;
             $platformUsername = $userId;
             $PayPalPaymentId = $transId;
             if (empty($recordNumber)) {
                 break;
             }
             $skuArrlist = explode(',', $skuStr);
             $noteArr = explode(',', $noteStr);
             $skuCount = count($skuArrlist);
             for ($i = 0; $i < $skuCount; $i++) {
                 list($sku, $amount) = explode('*', $skuArrlist[$i]);
                 //echo "--sku=$sku---amount=$amount-------";
                 //detail信息
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time();
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $noteArr[$i];
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId;
                 if (!empty($note)) {
                     $orderData[$recordNumber]['orderNote'][$c]['content'] = $note;
                     $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId'];
                 }
             }
             //order信息
             $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber;
             $orderData[$recordNumber]['orderData']['ordersTime'] = $ordersTime;
             $orderData[$recordNumber]['orderData']['paymentTime'] = $paymentTime;
             $orderData[$recordNumber]['orderData']['onlineTotal'] = $onlineTotal;
             $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal;
             $orderData[$recordNumber]['orderData']['actualShipping'] = $shippingFee;
             $orderData[$recordNumber]['orderData']['calcShipping'] = $shippingFee;
             $orderData[$recordNumber]['orderData']['orderAddTime'] = time();
             $orderData[$recordNumber]['orderData']['orderStatus'] = 100;
             $orderData[$recordNumber]['orderData']['orderType'] = 101;
             $SYS_ACCOUNTS = OmAvailableModel::getTNameList("om_account", "*", " where account='{$account}'");
             $orderData[$recordNumber]['orderData']['accountId'] = $SYS_ACCOUNTS[0]['id'];
             $orderData[$recordNumber]['orderData']['platformId'] = $SYS_ACCOUNTS[0]['platformId'];
             $plataccountId = $SYS_ACCOUNTS[0]['id'];
             $platformId = $SYS_ACCOUNTS[0]['platformId'];
             $SYS_ACCOUNTS = OmAvailableModel::getPlatformAccount();
             foreach ($SYS_ACCOUNTS as $platform => $accounts) {
                 foreach ($accounts as $accountId => $accountname) {
                     if ($account == $accountname) {
                         if ($platform == "ebay") {
                             $orderData[$recordNumber]['orderData']['isFixed'] = 2;
                         } else {
                             $orderData[$recordNumber]['orderData']['isFixed'] = 1;
                         }
                     }
                 }
             }
             foreach ($transportation as $tranValue) {
                 if ($tranValue['carrierNameCn'] == $carrierNameCn) {
                     $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id'];
                     break;
                 }
             }
             if ($trackNumber != '') {
                 $orderData[$recordNumber]['orderTrack']['tracknumber'] = $trackNumber;
                 $orderData[$recordNumber]['orderTrack']['addUser'] = $_SESSION['sysUserId'];
                 $orderData[$recordNumber]['orderTrack']['createdTime'] = time();
             }
             //order扩展信息
             $orderData[$recordNumber]['orderExtenData']['currency'] = $currency;
             $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS";
             $orderData[$recordNumber]['orderExtenData']['transId'] = $recordNumber;
             // 交易id;;
             $orderData[$recordNumber]['orderExtenData']['PayPalPaymentId'] = $PayPalPaymentId;
             $orderData[$recordNumber]['orderExtenData']['platformUsername'] = $platformUsername;
             $orderData[$recordNumber]['orderExtenData']['currency'] = $currency;
             //user信息
             $orderData[$recordNumber]['orderUserInfoData']['platformUsername'] = $platformUsername;
             $orderData[$recordNumber]['orderUserInfoData']['username'] = $username;
             $orderData[$recordNumber]['orderUserInfoData']['email'] = $email;
             $orderData[$recordNumber]['orderUserInfoData']['street'] = $street1;
             $orderData[$recordNumber]['orderUserInfoData']['address2'] = ${$street2};
             $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency;
             //$orderData[$recordNumber]['orderUserInfoData']['address3'] = $address3;
             $orderData[$recordNumber]['orderUserInfoData']['city'] = $city;
             $orderData[$recordNumber]['orderUserInfoData']['state'] = $state;
             $orderData[$recordNumber]['orderUserInfoData']['zipCode'] = $zipCode;
             $orderData[$recordNumber]['orderUserInfoData']['countryName'] = $countryName;
             $orderData[$recordNumber]['orderUserInfoData']['landline'] = $phone;
             $orderData[$recordNumber]['orderUserInfoData']['phone'] = $phone;
             //note信息
             if (!empty($note)) {
                 $orderData[$recordNumber]['orderNote'][$c]['content'] = $note;
                 $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId'];
             }
         }
         //print_r($orderData);
         //echo "<pre>";print_r($orderData);//exit;
         $message = "";
         foreach ($orderData as $id => $order) {
             //echo $id;
             //$msg = commonModel::checkOrder($id);
             $msg = commonModel::checkRecordNumber($id, $platformId, $plataccountId);
             if ($msg) {
                 $message .= "<font color='red'>订单{$id}已存在!</font><br>";
                 continue;
             }
             //计算订单属性
             if (count($order['orderDetail']) == 1) {
                 $detail = current($order['orderDetail']);
                 if ($detail['orderDetailData']['amount'] == 1) {
                     $orderData[id]['orderData']['orderAttribute'] = 1;
                 } else {
                     $orderData[id]['orderData']['orderAttribute'] = 2;
                 }
             } else {
                 $orderData[id]['orderData']['orderAttribute'] = 3;
             }
             //计算订单重量及包材
             $obj_order_detail_data = array();
             foreach ($order['orderDetail'] as $sku => $detail) {
                 $obj_order_detail_data[] = $detail['orderDetailData'];
             }
             $weightfee = commonModel::calcOrderWeight($obj_order_detail_data);
             $orderData[$id]['orderData']['calcWeight'] = $weightfee[0];
             //$orderData[$value[0]]['orderData']['calcShipping'] = $weightfee[3];
             $orderData[$id]['orderData']['pmId'] = $weightfee[1];
             //计算运费
             $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, $orderData[$id]['orderData']['isFixed']);
             //计算运费
             $orderData[$id]['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
             //$orderData[$id]['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
             //缺货拦截
             $orderData[$id] = AutoModel::auto_contrast_intercept($orderData[$id]);
             /*$orderData[$id]['orderData']['orderStatus'] = $status['orderStatus'];
             		$orderData[$id]['orderData']['orderType'] = $status['orderType'];*/
             //echo "<pre>";print_r($orderData[$id]);
             //print_r($orderData);
             //exit;
             //插入订单
             $info = OrderAddModel::insertAllOrderRowNoEvent($orderData[$id]);
             if ($info) {
                 $message .= "<font color='green'>订单{$id}上传成功!</font><br>";
             } else {
                 $message .= "<font color='red'>订单{$id}上传失败!</font><br>";
             }
         }
         $this->smarty->assign("showerrorinfo", $message);
         //header("location:index.php?mod=underLineOrderImport&act=importOrder");
     }
     $this->smarty->display('guoneiSaleImport.htm');
 }