예제 #1
0
     $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;
     }
     $sku_price = 0;
예제 #2
0
 public function act_ApplicationException($omOrderId, $content)
 {
     $tableName = "om_unshipped_order";
     $storeId = 1;
     if (!$omOrderId || !$content) {
         self::$errCode = '5806';
         self::$errMsg = 'param is error';
         return array();
     }
     $where = " WHERE id = " . $omOrderId . " AND orderStatus = " . C('STATESHIPPED');
     $returnStatus0 = array('orderStatus' => C('STATEINTERCEPTSHIP'), 'orderType' => C('STATEPENDING_APPEXC'));
     if (!OrderindexModel::updateOrder($tableName, $returnStatus0, $where)) {
         self::$errCode = '5807';
         self::$errMsg = 'update error';
         return false;
     }
     $insertOrderNoteDada = array('omOrderId' => $omOrderId, 'content' => $content, 'userId' => 0, 'createdTime' => time());
     if ($insertOrderNoteids = OrderAddModel::insertOrderNotesRow($insertOrderNoteDada)) {
         self::$errCode = '5808';
         self::$errMsg = 'insert Note error';
         return false;
     }
     self::$errCode = '200';
     self::$errMsg = 'sync success';
     return true;
 }
예제 #3
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;
 }
예제 #4
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;
 }
예제 #5
0
 public function act_operateAbOrderAPI()
 {
     if (!isset($_POST['omData'])) {
         self::$errCode = 500;
         self::$errMsg = '未成功接收数据!';
         return false;
     }
     $ostatus = 770;
     $otype = 0;
     $storeId = 1;
     $orderstr = $_POST['omData'];
     $orderstr2 = $_POST['omData2'];
     $orderids = array_unique(explode(',', $orderstr));
     $invoiceids = array_unique(explode(',', $orderstr2));
     if (!$orderids) {
         self::$errCode = 400;
         self::$errMsg = '未获取订单编号信息!';
         return false;
     }
     //var_dump($orderids); exit;
     $OrderindexAct = new OrderindexAct();
     $WarehouseAPIAct = new WarehouseAPIAct();
     foreach ($orderids as $k => $orderId) {
         BaseModel::begin();
         //开始事务
         $insertOrderData = array();
         $AbOrderInfo = $WarehouseAPIAct->act_getAbOrderInfo($invoiceids[$k]);
         //var_dump($AbOrderInfo); echo "<br>";
         //exit;
         $where = ' WHERE id = ' . $orderId . ' and is_delete = 0 AND storeId = ' . $storeId . ' LIMIT 1';
         $orderList = $OrderindexAct->act_showOrderList($ostatus, $otype, $where);
         //var_dump($orderList);exit;
         $order = $orderList[$orderId];
         $orderData = $order['orderData'];
         $insert_orderData = $orderData;
         unset($insert_orderData['id']);
         $insert_orderData['orderStatus'] = C('STATEOUTOFSTOCK');
         $insert_orderData['orderType'] = C('STATEOUTOFSTOCK_ABNORMAL');
         $orderExtenData = $order['orderExtenData'];
         $insert_orderExtenData = $orderExtenData;
         unset($insert_orderExtenData['omOrderId']);
         $orderUserInfoData = $order['orderUserInfoData'];
         $insert_orderUserInfoData = $orderUserInfoData;
         unset($insert_orderUserInfoData['omOrderId']);
         //$orderTracknumber = $order['orderTracknumber'];
         //$orderAudit = $order['orderAudit'];
         $orderDetail = $order['orderDetail'];
         $insertOrderData['orderData'] = $insert_orderData;
         $insertOrderData['orderExtenData'] = $insert_orderExtenData;
         $insertOrderData['orderUserInfoData'] = $insert_orderUserInfoData;
         $insert_orderDetail = array();
         $need_delete_ids = array();
         foreach ($orderDetail as $dkey => $detailValue) {
             $orderDetailData = $detailValue['orderDetailData'];
             $orderDetailExtenData = $detailValue['orderDetailExtenData'];
             if (!isset($AbOrderInfo[$orderDetailData['sku']]) || $AbOrderInfo[$orderDetailData['sku']] == 0) {
                 $insert_orderDetailData = $orderDetailData;
                 unset($insert_orderDetailData['id']);
                 unset($insert_orderDetailData['omOrderId']);
                 $insert_orderDetailExtenData = $orderDetailExtenData;
                 unset($insert_orderDetailExtenData['omOrderdetailId']);
                 $insert_orderDetail[$dkey]['orderDetailData'] = $insert_orderDetailData;
                 $insert_orderDetail[$dkey]['orderDetailExtenData'] = $insert_orderDetailExtenData;
                 $need_delete_ids[] = $orderDetailData['id'];
             }
         }
         $insertOrderData['orderDetail'] = $insert_orderDetail;
         $count_insert_orderDetail = count($insert_orderDetail);
         $count_orderDetail = count($orderDetail);
         $tableName = "om_unshipped_order";
         if ($count_insert_orderDetail > 0 && $count_insert_orderDetail < $count_orderDetail) {
             $calcWeight = CommonModel::calcNowOrderWeight($orderId);
             //重新计算原来订单的重量
             if (!OrderindexModel::deleteOrderDetail(array('is_delete' => 1), ' where id in(' . join(',', $need_delete_ids) . ')')) {
                 BaseModel::rollback();
                 self::$errCode = '005';
                 self::$errMsg = "删除原订单明细失败!";
                 return false;
             }
             $insertOrderData['orderData']['isCopy'] = 2;
             $insertOrderData['orderData']['actualTotal'] = 0.0;
             //var_dump($orderData);exit;
             $calcInfo = CommonModel::calcAddOrderWeight($insert_orderDetail);
             //计算重量和包材
             //var_dump($calcInfo); exit;
             $insertOrderData['orderData']['calcWeight'] = $calcInfo[0];
             $insertOrderData['orderData']['pmId'] = $calcInfo[1];
             if (count($insertOrderData['orderDetail']) > 1) {
                 $insertOrderData['orderData']['orderAttribute'] = 3;
             } else {
                 if (isset($insertOrderData['orderDetail'][0]['orderDetailData']['amount']) && $insertOrderData['orderDetail'][0]['orderDetailData']['amount'] > 1) {
                     $insertOrderData['orderData']['orderAttribute'] = 2;
                 }
             }
             $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insertOrder, 1);
             //计算运费
             $insertOrderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
             $insertOrderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
             //print_r($insertOrderData); exit;
             if ($_spitId = OrderAddModel::insertAllOrderRowNoEvent($insertOrderData)) {
                 if (!OrderLogModel::insertOrderLog($_spitId, 'INSERT ORDER')) {
                     BaseModel::rollback();
                     self::$errCode = '001';
                     self::$errMsg = "插入订单日志失败!";
                     return false;
                 }
                 if (!OrderRecordModel::insertSpitRecords($orderId, $_spitId)) {
                     BaseModel::rollback();
                     self::$errCode = '002';
                     self::$errMsg = "插入拆分日志失败!";
                     return false;
                 }
             } else {
                 BaseModel::rollback();
                 self::$errCode = '010';
                 self::$errMsg = "插入订单信息失败!";
                 return false;
             }
             $returnStatus0 = array('isCopy' => 1, 'calcWeight' => $calcWeight);
             $rtn = $WarehouseAPIAct->act_operateAbOrder($invoiceids[$k], $calcWeight);
             if (!$rtn) {
                 BaseModel::rollback();
                 self::$errCode = '011';
                 self::$errMsg = "调用仓库系统拆分功能失败!";
                 return false;
             }
         } else {
             $returnStatus0 = array('orderStatus' => $insert_orderData['orderStatus'], 'orderType' => $insert_orderData['orderType']);
         }
         if (!OrderindexModel::updateOrder($tableName, $returnStatus0, $where)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "订单移动到缺货异常失败!";
             return false;
         }
         BaseModel::commit();
         BaseModel::autoCommit();
     }
     self::$errCode = 200;
     self::$errMsg = '缺货拆分完成!';
     return true;
 }
예제 #6
0
 public static function overWeightSplitB2B($omOrderId)
 {
     !self::$dbConn ? self::initDB() : null;
     global $memc_obj;
     //调用memcache获取sku信息
     $mctime = time();
     //var_dump($moOrderIdArr);
     $tableName = 'om_unshipped_order';
     $where = ' WHERE id = ' . $omOrderId . ' and is_delete = 0 and storeId = 1';
     $orderData = OrderindexModel::showOrderList($tableName, $where);
     $orderDetail = $orderData[$omOrderId]['orderDetail'];
     $obj_order_data = $orderData[$omOrderId]['orderData'];
     $orderExtenData = $orderData[$omOrderId]['orderExtenData'];
     $orderUserInfoData = $orderData[$omOrderId]['orderUserInfoData'];
     $_actualTotal = $obj_order_data['actualTotal'];
     $_actualShipping = $obj_order_data['actualShipping'];
     $_platformId = $obj_order_data['platformId'];
     $_mainId = $obj_order_data['id'];
     $_transportId = $obj_order_data['transportId'];
     //var_dump($orderDetail); exit;
     $omAvailableAct = new OmAvailableAct();
     $GLOBAL_EBAY_ACCOUNT = $omAvailableAct->act_getTNameList2arrById('om_account', 'id', 'account', ' WHERE is_delete=0 AND platformId in(1,5) ');
     $weightlists = array();
     $skuinfo = array();
     $goods_sn_nums = 0;
     $shippfee_arr = array();
     $ebay_total_be = 0;
     foreach ($orderDetail as $k => $f) {
         $sku = trim($f['orderDetailData']['sku']);
         $amount = $f['orderDetailData']['amount'];
         $shippingFee = $f['orderDetailData']['shippingFee'];
         $goods_sn_nums += $amount;
         $ebay_total_be += $f['orderDetailData']['amount'] * $f['orderDetailData']['itemPrice'];
         $shippfee_arr[$sku] = round($shippingFee / $amount, 3);
         //单个料号的运费
         $skuinfo[$sku] = $f;
         for ($i = 1; $i <= $amount; $i++) {
             $var = $sku;
             $oneskuweight = CommonModel::calcOnlySkuWeight($var, 1);
             //一个sku的重量
             $weightlists[$var][] = $oneskuweight[0];
         }
     }
     $rate = $_actualTotal / $ebay_total_be;
     //var_dump($weightlists); exit;
     if ($goods_sn_nums <= 1) {
         self::$errCode = '0020';
         self::$errMsg = "只有一个料号组成,不允许超重拆分";
         return false;
     }
     //echo "==========="; exit;
     $keyarray = array();
     $keyarrays = array();
     $checkweight = 0;
     $arrinfo = CommonModel::calcNowOrderWeight($omOrderId);
     //var_dump($arrinfo); exit;
     $realweight = $arrinfo[0];
     $realcosts = $arrinfo[2];
     $itemprices = $arrinfo[3];
     foreach ($weightlists as $wk => $wv) {
         foreach ($wv as $weightlist) {
             $checkweight += $weightlist;
             if ($checkweight > 1.85) {
                 $keyarrays[] = $keyarray;
                 $keyarray = array();
                 $checkweight = $weightlist;
                 $keyarray[$wk][] = $wk;
             } else {
                 $keyarray[$wk][] = $wk;
             }
         }
     }
     if (!empty($keyarray)) {
         $keyarrays[] = $keyarray;
     }
     //var_dump($keyarrays); exit;
     BaseModel::begin();
     //开始事务
     $insert_orderData = array();
     foreach ($keyarrays as $keyarray) {
         $ebay_total = 0;
         $totalweight = 0;
         $insert_ebay_ids = array();
         //var_dump($skuinfo); echo "<br>";
         foreach ($keyarray as $k => $kav) {
             //var_dump($skuinfo[$k]['orderDetailData']['itemPrice'], count($kav));
             //$ebay_total += ($skuinfo[$k]['orderDetailData']['itemPrice'] + $shippfee_arr[$k]) * count($kav);
             $ebay_total += $skuinfo[$k]['orderDetailData']['itemPrice'] * count($kav);
         }
         $ebay_total = $rate * $ebay_total;
         $shipfee = 0;
         //$val = generateOrdersn();
         $insert_obj_order_data = $obj_order_data;
         unset($insert_obj_order_data['id']);
         $insert_obj_order_data['actualTotal'] = $ebay_total;
         $insert_obj_order_data['orderType'] = C('STATEPENDING_OWDONE');
         $insert_obj_order_data['orderAddTime'] = $mctime;
         $insert_obj_order_data['isSplit'] = 2;
         $insert_orderExtenData = $orderExtenData;
         unset($insert_orderExtenData['id']);
         $insert_orderUserInfoData = $orderUserInfoData;
         unset($insert_orderUserInfoData['id']);
         $insert_orderData = array('orderData' => $insert_obj_order_data, 'orderExtenData' => $insert_orderExtenData, 'orderUserInfoData' => $insert_orderUserInfoData);
         /*$sql = "insert into ebay_splitorder (recordnumber, main_order_id, split_order_id, create_date) values ('$recordnumber', '$ebay_id', '$insert_ebay_id', '".date("Y-m-d H:i:s")."')";
         		$split_log .= "添加主定单和拆分订单到关系表中\r\n".$sql ."\r\n";
         		$dbcon->execute($sql) or die("Fail : $sql");*/
         $obj_order_detail_data = array();
         foreach ($keyarray as $k => $kav) {
             $sku = $k;
             $amount = count($kav);
             $insert_orderDetailData = $skuinfo[$k]['orderDetailData'];
             unset($insert_orderDetailData['id']);
             $insert_orderDetailData['sku'] = strtoupper($sku);
             $insert_orderDetailData['amount'] = $amount;
             $insert_orderDetailData['createdTime'] = $mctime;
             if (isset($shippfee_arr[$sku])) {
                 $insert_orderDetailData['shippingFee'] = $shippfee_arr[$sku] * $amount;
                 //相同料号运费拆分
             }
             $insert_orderDetailExtenData = $skuinfo[$k]['orderDetailExtenData'];
             unset($insert_orderDetailExtenData['id']);
             $obj_order_detail_data[] = array('orderDetailData' => $insert_orderDetailData, 'orderDetailExtenData' => $insert_orderDetailExtenData);
         }
         $insert_orderData['orderDetail'] = $obj_order_detail_data;
         //echo "<pre>";
         //var_dump($obj_order_detail_data); exit;
         $calcInfo = CommonModel::calcAddOrderWeight($obj_order_detail_data);
         //计算重量和包材
         //var_dump($calcInfo); exit;
         $insert_orderData['orderData']['calcWeight'] = $calcInfo[0];
         $insert_orderData['orderData']['pmId'] = $calcInfo[1];
         //var_dump($insert_orderData); exit;
         $calcShippingInfo = CommonModel::calcAddOrderShippingFee($insert_orderData, 1);
         //计算运费
         //var_dump($calcShippingInfo); exit;
         $insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
         $insert_orderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
         /*$interceptInfo = CommonModel :: auto_contrast_intercept($orderData);
         		//print_r($interceptInfo); exit;
         		$orderData['orderData']['orderStatus'] = $interceptInfo['orderStatus'];
         		$orderData['orderData']['orderType'] = $interceptInfo['orderType'];*/
         if ($_spitId = OrderAddModel::insertAllOrderRowNoEvent($insert_orderData)) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($_spitId, 'INSERT ORDER')) {
                 BaseModel::rollback();
                 self::$errCode = '0021';
                 self::$errMsg = "split error!";
                 return false;
             }
             if (!OrderRecordModel::insertSpitRecords($_mainId, $_spitId)) {
                 BaseModel::rollback();
                 self::$errCode = '0022';
                 self::$errMsg = "split error!";
                 return false;
             }
         } else {
             $split_log .= 'insert error!' . "\n";
             BaseModel::rollback();
             self::$errCode = '0023';
             self::$errMsg = "split error!";
             return false;
         }
         if (!OrderindexModel::deleteOrderData($tableName, $where)) {
             self::$errCode = '0024';
             self::$errMsg = "split error!";
             return false;
         }
         if (!OrderLogModel::insertOrderLog($_mainId, 'DELETE ORDER')) {
             BaseModel::rollback();
             self::$errCode = '0025';
             self::$errMsg = "split error!";
             return false;
         }
         BaseModel::commit();
         BaseModel::autoCommit();
     }
     self::$errCode = '200';
     self::$errMsg = "split success!";
     return true;
 }
예제 #7
0
 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');
 }
예제 #8
0
            echo "\n=====同步的订单{$orderid}状态成功======\n";
        }
        $msg = CommonModel::updateWarehouseInfo($orderid, 2, $operateUserId, $operateTime, $actualWeight);
        if ($msg) {
            $where = ' WHERE id in (' . join(",", $orderids) . ') AND orderStatus= ' . C('STATESHIPPED') . ' AND orderType= ' . C('STATEHASSHIPPED_CONV') . ' AND is_delete = 0 ';
            if (OrderindexModel::shiftOrderList($where)) {
                echo "转移成功\n";
            } else {
                echo "转移失败\n";
            }
        }
    } else {
        $where = " WHERE id in (" . join(',', $orderids) . ") AND orderStatus = " . C('STATESHIPPED');
        $returnStatus0 = array('orderType' => C($orderStatus));
        if (OrderindexModel::updateOrder($tableName, $returnStatus0, $where)) {
            echo "\n=====同步的订单{$orderid}状态成功======\n";
        }
        $msg = commonModel::updateWarehouseInfo($orderid, C($orderStatus), $operateUserId, $operateTime);
        if ($tracknumber) {
            $updateArr = array('omOrderId' => $orderid, 'tracknumber' => $tracknumber, 'createdTime' => time());
            $msg = OrderAddModel::insertOrderTrackRow($updateArr);
        }
    }
};
$channel->basic_consume($queue_name, '', false, true, false, false, $callback);
while (count($channel->callbacks)) {
    $channel->wait();
}
$channel->close();
$connection->close();
//$dbConn->close();
예제 #9
0
                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);
                //计算运费
                //var_dump($calcShippingInfo); exit;
                //$insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee'];
                $insertOrder['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];
                $insertOrder = AutoModel::auto_contrast_intercept($insertOrder);
                //print_r($interceptInfo); exit;
                /*$insertOrder['orderData']['orderStatus'] = $interceptInfo['orderStatus'];
                		$insertOrder['orderData']['orderType'] = $interceptInfo['orderType'];*/
                //print_r($orderData); exit;
                if (OrderAddModel::insertAllOrderRow($insertOrder)) {
                    echo "-----" . date("Y-m-d H:i:s") . ", 新增订单{$orderdata["recordNumber"]}成功\r\n";
                } else {
                    echo "-----" . date("Y-m-d H:i:s") . ", 新增订单{$orderdata["recordNumber"]}失败\r\n";
                }
                $total++;
            }
        }
    }
}
echo "DATE: " . date("Y-m-d H:i:s") . "-----------------------------------\n";
echo "\n" . implode("\n", $error_data);
echo "\n订单导入完成, 共导入" . $total . "条订单\n";
exit;
예제 #10
0
 public function view_aliexpressimport()
 {
     $this->smarty->assign('toplevel', 2);
     $this->smarty->assign('secondlevel', 24);
     $OmAccountAct = new OmAccountAct();
     //$aliexpressAccountList = $OmAccountAct->act_getAccountListByPid(2);
     $aliexpressAccountList = $OmAccountAct->act_getAccountListAliexpress();
     var_dump($aliexpressAccountList);
     $aliexpressAccountList = json_decode($aliexpressAccountList, true);
     $this->smarty->assign("aliexpressAccountList", $aliexpressAccountList);
     $this->smarty->display('aliexpressImport.htm');
     include_once WEB_PATH . "lib/PHPExcel.php";
     //phpexcel
     $toptitle = 'underLineOrderImport';
     //头部title
     $this->smarty->assign('toptitle', $toptitle);
     $this->smarty->assign('toplevel', 2);
     $this->smarty->assign('secondlevel', 22);
     if (isset($_FILES['orderUpfile']['tmp_name'])) {
         $filePath = $_FILES['orderUpfile']['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);
         $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++;
             $account = trim($currentSheet->getCell($aa)->getValue());
             $recordNumber = trim($currentSheet->getCell($bb)->getValue());
             $platformUsername = trim($currentSheet->getCell($cc)->getValue());
             $email = trim($currentSheet->getCell($dd)->getValue());
             $ordersTime = trim($currentSheet->getCell($ee)->getValue());
             $paymentTime = trim($currentSheet->getCell($ff)->getValue());
             $sku = trim($currentSheet->getCell($gg)->getValue());
             $amount = trim($currentSheet->getCell($hh)->getValue());
             $itemTitle = trim($currentSheet->getCell($ii)->getValue());
             $note = trim($currentSheet->getCell($jj)->getValue());
             $itemPrice = trim($currentSheet->getCell($kk)->getValue());
             $shippingFee = trim($currentSheet->getCell($ll)->getValue());
             $actualTotal = trim($currentSheet->getCell($mm)->getValue());
             $currency = trim($currentSheet->getCell($nn)->getValue());
             $transId = trim($currentSheet->getCell($oo)->getValue());
             $username = trim($currentSheet->getCell($pp)->getValue());
             $street = trim($currentSheet->getCell($qq)->getValue());
             $address2 = trim($currentSheet->getCell($rr)->getValue());
             $address3 = trim($currentSheet->getCell($ss)->getValue());
             $city = trim($currentSheet->getCell($tt)->getValue());
             $state = trim($currentSheet->getCell($uu)->getValue());
             $zipCode = trim($currentSheet->getCell($vv)->getValue());
             $countryName = trim($currentSheet->getCell($ww)->getValue());
             $landline = trim($currentSheet->getCell($xx)->getValue());
             $carrierNameCn = trim($currentSheet->getCell($yy)->getValue());
             if (empty($account)) {
                 break;
             }
             if (in_array($recordNumber, $orderid)) {
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['itemPrice'] = $itemPrice;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['shippingFee'] = $shippingFee;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $itemTitle;
                 //$orderData['orderDetail']['orderDetailExtenData']['note'] = $value[10];
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId;
                 if (!empty($note)) {
                     $orderData[$recordNumber]['orderNote'][$c]['content'] = $note;
                     $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId'];
                 }
             } else {
                 $orderid[] = $recordNumber;
                 //order信息
                 $orderData[$recordNumber]['orderData']['recordNumber'] = $recordNumber;
                 $orderData[$recordNumber]['orderData']['ordersTime'] = strtotime($ordersTime);
                 $orderData[$recordNumber]['orderData']['paymentTime'] = strtotime($paymentTime);
                 $orderData[$recordNumber]['orderData']['actualTotal'] = $actualTotal;
                 $orderData[$recordNumber]['orderData']['orderAddTime'] = time();
                 $SYSTEM_ACCOUNTS = OmAvailableModel::getTNameList("om_account", "*", " where account='{$account}'");
                 $orderData[$recordNumber]['orderData']['accountId'] = $SYSTEM_ACCOUNTS[0]['id'];
                 $orderData[$recordNumber]['orderData']['platformId'] = $SYSTEM_ACCOUNTS[0]['platformId'];
                 $SYSTEM_ACCOUNTS = OmAvailableModel::getPlatformAccount();
                 foreach ($SYSTEM_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;
                             }
                         }
                     }
                 }
                 $transportation = CommonModel::getCarrierList();
                 //所有的
                 foreach ($transportation as $tranValue) {
                     if ($tranValue['carrierNameCn'] == $carrierNameCn) {
                         $orderData[$recordNumber]['orderData']['transportId'] = $tranValue['id'];
                         break;
                     }
                     //$transportationList[$tranValue['id']] = $tranValue['carrierNameCn'];
                 }
                 //order扩展信息
                 $orderData[$recordNumber]['orderExtenData']['currency'] = $currency;
                 $orderData[$recordNumber]['orderExtenData']['paymentStatus'] = "PAY_SUCCESS";
                 $orderData[$recordNumber]['orderExtenData']['transId'] = $recordNumber;
                 // 交易id;;
                 $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'] = $street;
                 $orderData[$recordNumber]['orderUserInfoData']['currency'] = $currency;
                 $orderData[$recordNumber]['orderUserInfoData']['address2'] = $address2;
                 $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'] = $landline;
                 //detail信息
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['sku'] = $sku;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['amount'] = $amount;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['itemPrice'] = $itemPrice;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['shippingFee'] = $shippingFee;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['recordNumber'] = $recordNumber;
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailData']['createdTime'] = time();
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['itemTitle'] = $itemTitle;
                 //$orderData['orderDetail']['orderDetailExtenData']['note'] = $value[10];
                 $orderData[$recordNumber]['orderDetail'][$sku]['orderDetailExtenData']['transId'] = $transId;
                 //note信息
                 if (!empty($note)) {
                     $orderData[$recordNumber]['orderNote'][$c]['content'] = $note;
                     $orderData[$recordNumber]['orderNote'][$c]['userId'] = $_SESSION['sysUserId'];
                 }
             }
         }
         //echo "<pre>";print_r($orderData);
         $message = "";
         foreach ($orderData as $id => $order) {
             $msg = commonModel::checkOrder($id);
             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'];
             //缺货拦截
             $status = commonModel::auto_contrast_intercept($orderData[$id]);
             $orderData[$id]['orderData']['orderStatus'] = $status['orderStatus'];
             $orderData[$id]['orderData']['orderType'] = $status['orderType'];
             //print_r($order);
             //插入订单
             $info = OrderAddModel::insertAllOrderRowNoEvent($order);
             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('underLineOrderImport.htm');
 }
예제 #11
0
 public static function shiftOrderList($where)
 {
     BaseModel::begin();
     //开始事务
     $unshipped_tableName = 'om_unshipped_order';
     $shipped_tableName = 'om_shipped_order';
     $orderList = self::showOrderList($unshipped_tableName, $where);
     //echo "<pre>"; print_r($orderList); exit;
     if (empty($orderList)) {
         self::$errCode = '000';
         self::$errMsg = "无操作数据!";
         return false;
     }
     foreach ($orderList as $omOrderId => $orderData) {
         $obj_order_data = $orderData['orderData'];
         $orderDetail = $orderData['orderDetail'];
         $insert_orderDetail = array();
         foreach ($orderDetail as $detail) {
             $insert_orderDetailData = $detail['orderDetailData'];
             //unset ($insert_orderDetailData['id']);
             $insert_orderDetailExtenData = $detail['orderDetailExtenData'];
             //unset ($insert_orderDetailExtenData['omOrderdetailId']);
             $insert_orderDetail[] = array('orderDetailData' => $insert_orderDetailData, 'orderDetailExtenData' => $insert_orderDetailExtenData);
         }
         //BaseModel :: rollback();\
         //self :: $dbConn->query('SET AUTOCOMMIT=1');
         //return FALSE;
         //unset ($obj_order_data['id']);
         $orderExtenData = $orderData['orderExtenData'];
         //unset ($orderExtenData['omOrderId']);
         $orderUserInfoData = $orderData['orderUserInfoData'];
         //unset ($orderExtenData['omOrderId']);
         $orderWhInfoData = $orderData['orderWhInfoData'];
         //unset ($orderWhInfoData['omOrderId']);
         //$obj_order_data['orderStatus'] = C('STATEBUJI');
         //$obj_order_data['orderType'] = C('STATEBUJI_DONE');
         $insert_orderData = array();
         $insert_orderData = array('orderData' => $obj_order_data, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData, 'orderDetail' => $insert_orderDetail, 'orderWhInfoData' => $orderWhInfoData);
         //var_dump($insert_orderData); exit;
         if ($insertId = OrderAddModel::shiftAllOrderRowNoEvent($insert_orderData)) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($insertId, '从unshipped表转移数据到shipped表中,第一步:添加shipped表数据')) {
                 BaseModel::rollback();
                 self::$errCode = '001';
                 self::$errMsg = "转移数据添加日志失败,第一步:添加shipped表数据失败!";
                 return false;
             }
         } else {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "INSERT数据失败!";
             return false;
         }
         if (self::killAllOrderRowNoEvent($omOrderId, $obj_order_data['platformId'])) {
             //echo $split_log .= 'insert success!' . "\n"; exit;
             //var_dump($_mainId,$_spitId); exit;
             if (!OrderLogModel::insertOrderLog($omOrderId, '从unshipped表转移数据到shipped表中,第二步:删除unshipped表中数据')) {
                 BaseModel::rollback();
                 self::$errCode = '003';
                 self::$errMsg = "转移数据添加日志失败,第二步:删除unshipped表中数据失败!";
                 return false;
             }
         } else {
             BaseModel::rollback();
             self::$errCode = '004';
             self::$errMsg = "KILL数据失败!";
             return false;
         }
     }
     BaseModel::commit();
     BaseModel::autoCommit();
     self::$errCode = '200';
     self::$errMsg = "转移数据成功!";
     return TRUE;
 }
예제 #12
0
 /**
  * 临时插入订单数据对比关系
  * @para $data as array
  * return true
  */
 public static function insertTempOrderRelation($data)
 {
     self::initDB();
     $string = array2sql_extral($data);
     $sql = "INSERT INTO `om_temp_orderRelation` SET " . $string;
     $query = self::$dbConn->query($sql);
     if ($query) {
         //$orderid = $data['omOrderId'];
         return true;
     } else {
         self::$errCode = "003";
         self::$errMsg = "error";
         return false;
     }
 }
예제 #13
0
 /**
  * 插入订单快递描述的方法,key为fedexRemark,现在只有独立商城会用到
  * 以下为demo
  * @param array $data 为一个二维数组,至少是一条快递描述记录
  * @return bool
  * @author zqt
  * @modify 20140807 修改方法名,同时订单大数组键改为了declarationContent,表也换了
  */
 public function insertOrderDeclarationContent($data)
 {
     $data = array_filter($data);
     if (empty($data)) {
         //如果$data为空,则不支持操作,直接返回,因为订单跟踪号是非必须的
         return true;
     }
     //检测订单号是否插入成功
     if ($this->_orderid == 0) {
         return false;
     } else {
         foreach ($data as $key => $value) {
             $data[$key]['omOrderId'] = $this->_orderid;
             $data[$key]['datetime'] = time();
         }
     }
     $table = C('DB_PREFIX') . 'declaration_content';
     foreach ($data as $value) {
         $fdata = $this->formatInsertField($table, $value);
         if ($fdata === false) {
             self::$errMsg = $this->validatemsg;
             return false;
         }
         if (!$this->sql("INSERT INTO {$table} SET " . array2sql($fdata))->insert()) {
             return false;
         }
     }
     return true;
 }
예제 #14
0
 public function view_modifyOrderList()
 {
     global $memc_obj;
     $sysUserId = $_SESSION['sysUserId'];
     $modify_showerrorinfo = '';
     $OrderModifyAct = new OrderModifyAct();
     $OrderindexAct = new OrderindexAct();
     $UserCompetenceAct = new UserCompetenceAct();
     //var_dump($_GET); exit;
     if (isset($_GET) && !empty($_GET)) {
         $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
         $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
         $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
     }
     if (isset($_POST) && !empty($_POST)) {
         //var_dump($_POST); echo "<br>"; exit;
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if ($_POST['action'] == 'addDetail') {
             //var_dump($_GET); echo "<br>"; exit;
             $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
             $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
             $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
             if ($OrderModifyAct->act_batchAdd($orderid, $_POST)) {
                 $modify_showerrorinfo = "<font color='green'>添加成功</font>";
             } else {
                 $modify_showerrorinfo = "<font color='red'>添加失败</font>";
             }
         } else {
             if ($_POST['action'] == 'addNote') {
                 //var_dump($_GET); echo "<br>"; exit;
                 $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : '';
                 $ostatus = isset($_GET['edit_ostatus']) ? $_GET['edit_ostatus'] : $_GET['ostatus'];
                 $otype = isset($_GET['edit_otype']) ? $_GET['edit_otype'] : $_GET['otype'];
                 if ($OrderModifyAct->act_addNote($orderid, $_POST)) {
                     $modify_showerrorinfo = "<font color='green'>添加成功</font>";
                 } else {
                     $modify_showerrorinfo = "<font color='red'>添加失败</font>";
                 }
             } else {
                 $visible_movefolder = $UserCompetenceAct->act_getInStatusIds($_POST['otype'], $sysUserId);
                 if (!in_array($_POST['edit_otype'], $visible_movefolder)) {
                     $modify_showerrorinfo = "<font color='red'>您没有改变订单状态的权限</font>";
                 } else {
                     if ($_POST['username'] != $_POST['edit_username']) {
                         $update_userinfo['username'] = $_POST['edit_username'];
                     }
                     if ($_POST['ostatus'] != $_POST['edit_ostatus']) {
                         $update_order['orderStatus'] = $_POST['edit_ostatus'];
                     }
                     if ($_POST['otype'] != $_POST['edit_otype']) {
                         $update_order['orderType'] = $_POST['edit_otype'];
                         $updatestatus = true;
                     }
                     if ($_POST['street'] != $_POST['edit_street']) {
                         $update_userinfo['street'] = $_POST['edit_street'];
                     }
                     if ($_POST['platformUsername'] != $_POST['edit_platformUsername']) {
                         $update_userinfo['platformUsername'] = $_POST['edit_platformUsername'];
                     }
                     if ($_POST['address2'] != $_POST['edit_address2']) {
                         $update_userinfo['address2'] = $_POST['edit_address2'];
                     }
                     if ($_POST['actualShipping'] != $_POST['edit_actualShipping']) {
                         $update_order['actualShipping'] = $_POST['edit_actualShipping'];
                     }
                     if ($_POST['city'] != $_POST['edit_city']) {
                         $update_userinfo['city'] = $_POST['edit_city'];
                     }
                     if ($_POST['state'] != $_POST['edit_state']) {
                         $update_userinfo['state'] = $_POST['edit_state'];
                     }
                     if ($_POST['countryName'] != $_POST['edit_countryName']) {
                         $update_userinfo['countryName'] = $_POST['edit_countryName'];
                     }
                     if ($_POST['zipCode'] != $_POST['edit_zipCode']) {
                         $update_userinfo['zipCode'] = $_POST['edit_zipCode'];
                     }
                     if ($_POST['landline'] != $_POST['edit_landline']) {
                         $update_userinfo['landline'] = $_POST['edit_landline'];
                     }
                     if ($_POST['phone'] != $_POST['edit_phone']) {
                         $update_userinfo['phone'] = $_POST['edit_phone'];
                     }
                     if ($_POST['transportId'] != $_POST['edit_transportId']) {
                         $update_order['transportId'] = $_POST['edit_transportId'];
                     }
                     if ($_POST['edit_tracknumber']) {
                         $update_tracknumber['omOrderId'] = $orderid;
                         $update_tracknumber['tracknumber'] = $_POST['edit_tracknumber'];
                         $update_tracknumber['addUser'] = $sysUserId;
                         $update_tracknumber['createdTime'] = time();
                         //var_dump($update_tracknumber); exit;
                     }
                     BaseModel::begin();
                     //开始事务
                     if ($update_order) {
                         //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
                         //$msg = OrderLogModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
                         if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                             if ($updatestatus) {
                                 $ProductStatus = new ProductStatus();
                                 if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                                     BaseModel::rollback();
                                 }
                             }
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_userinfo) {
                         //var_dump($update_userinfo);
                         if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                             $modify_showerrorinfo = "<font color='green'>更新成功</font>";
                         } else {
                             $modify_showerrorinfo = "<font color='red'>更新失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     if ($update_tracknumber) {
                         //echo $msg;
                         if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                             /*self :: $errCode = "001";
                             		self :: $errMsg =  "跟踪号插入失败";
                             		return false;*/
                             $modify_showerrorinfo = "<font color='red'>跟踪号插入失败</font>";
                             BaseModel::rollback();
                         }
                     }
                     BaseModel::commit();
                     BaseModel::autoCommit();
                 }
             }
         }
     }
     $this->smarty->assign('modify_showerrorinfo', $modify_showerrorinfo);
     $omAvailableAct = new OmAvailableAct();
     //平台信息
     $platform = $omAvailableAct->act_getTNameList('om_platform', 'id,platform', 'WHERE is_delete=0');
     //var_dump($platform);
     $platformList = array();
     foreach ($platform as $v) {
         $platformList[$v['id']] = $v['platform'];
     }
     $this->smarty->assign('platformList', $platformList);
     /**导航 start**/
     $this->smarty->assign('ostatus', $ostatus);
     $this->smarty->assign('otype', $otype);
     //二级目录
     $StatusMenuAct = new StatusMenuAct();
     $ostatusList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = 0 AND is_delete=0');
     //var_dump($ostatusList);
     $this->smarty->assign('ostatusList', $ostatusList);
     $otypeList = $StatusMenuAct->act_getStatusMenuList('statusCode,statusName', 'WHERE groupId = "' . $ostatus . '" AND is_delete=0');
     //var_dump($otypeList);
     $this->smarty->assign('otypeList', $otypeList);
     /*$o_secondlevel =  $omAvailableAct->act_getTNameList('om_status_menu','*','WHERE is_delete=0 and groupId=0 order by sort asc');
     		$this->smarty->assign('o_secondlevel', $o_secondlevel);*/
     $second_count = array();
     $second_type = array();
     foreach ($ostatusList as $o_secondinfo) {
         $orderStatus = $o_secondinfo['statusCode'];
         /*$accountacc = $_SESSION['accountacc'];
         		$oc_where = " where orderStatus='$orderStatus' ";
         		if($accountacc){
         			$oc_where .= ' AND ('.$accountacc.') ';
         		}*/
         $s_total = $OrderindexAct->act_showSearchOrderNum($orderStatus);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order", $oc_where);
         $second_count[$o_secondinfo['statusCode']] = $s_total;
         $s_type = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$orderStatus}' order by sort asc");
         $second_type[$o_secondinfo['statusCode']] = $s_type[0]['statusCode'];
     }
     //var_dump($second_count);
     $this->smarty->assign('second_count', $second_count);
     $this->smarty->assign('second_type', $second_type);
     //退款数量
     $refund_total = $omAvailableAct->act_getTNameCount("om_order_refund", " where is_delete=0");
     $this->smarty->assign('refund_total', $refund_total);
     //三级目录
     $o_threelevel = $omAvailableAct->act_getTNameList("om_status_menu", "*", "WHERE is_delete=0 and groupId='{$ostatus}' order by sort asc");
     $this->smarty->assign('o_threelevel', $o_threelevel);
     $three_count = array();
     foreach ($o_threelevel as $o_threeinfo) {
         $orderType = $o_threeinfo['statusCode'];
         $s_total = $OrderindexAct->act_showSearchOrderNum($ostatus, $orderType);
         //$s_total = $omAvailableAct->act_getTNameCount("om_unshipped_order"," where orderStatus='$ostatus' and orderType='$orderType' and storeId=1 and is_delete=0");
         $three_count[$o_threeinfo['statusCode']] = $s_total;
     }
     $this->smarty->assign('three_count', $three_count);
     $toptitle = '订单显示页面';
     //头部title
     $this->smarty->assign('toptitle', $toptitle);
     $this->smarty->assign('toplevel', 0);
     $threelevel = '1';
     //当前的三级菜单
     $this->smarty->assign('threelevel', $threelevel);
     $statusMenu = $omAvailableAct->act_getTNameList('om_status_menu', ' * ', 'WHERE is_delete=0 ');
     $this->smarty->assign('statusMenu', $statusMenu);
     $value = '';
     $where = '';
     switch ($searchTransportationType) {
         case '1':
             $transportation = CommonModel::getCarrierList(1);
             //快递
             break;
         case '2':
             $transportation = CommonModel::getCarrierList(0);
             //平邮
             break;
         default:
             $transportation = CommonModel::getCarrierList();
             //所有的
             break;
     }
     //var_dump($transportation); exit;
     $transportationList = array();
     foreach ($transportation as $tranValue) {
         $transportationList[$tranValue['id']] = $tranValue['carrierNameCn'];
     }
     //var_dump($transportationList); exit;
     $this->smarty->assign('transportation', $transportation);
     $this->smarty->assign('transportationList', $transportationList);
     //var_dump($orderid, $ostatus,$otype);
     $omOrderList = $OrderModifyAct->act_getModifyOrderList($orderid, $ostatus, $otype, $storeId = 1);
     //var_dump($omOrderList);
     //$sku	=	array();
     $account_where = ' WHERE is_delete = 0 ';
     if ($searchPlatformId) {
         $account_where .= ' AND platformId = ' . $searchPlatformId;
     }
     $accountList = $UserCompetenceAct->act_showGlobalUser();
     if ($accountList) {
         $account_where .= ' AND id in ( ' . join(',', $accountList) . ' ) ';
     }
     //帐号信息
     $accountList = $omAvailableAct->act_getTNameList('om_account', '*', $account_where);
     //var_dump($accountList); exit;
     $account = array();
     foreach ($accountList as $v) {
         $account[$v['id']] = $v['account'];
     }
     //包材信息
     $pm = GoodsModel::getMaterInfoByList();
     //获取系统所有状态
     $statusList = copyOrderModel::selectStatusList();
     $CurrencyAct = new CurrencyAct();
     $currencyList = $CurrencyAct->act_getCurrencyListById();
     //echo "<pre>"; print_r($currencyList); exit;
     $this->smarty->assign('currencyList', $currencyList);
     $this->smarty->assign('statusList', $statusList);
     $this->smarty->assign('show_page', $show_page);
     $this->smarty->assign('account', $account);
     $this->smarty->assign('accountList', $accountList);
     $this->smarty->assign('pm', $pm);
     $this->smarty->assign('omOrderList', $omOrderList);
     $this->smarty->display('orderModify.htm');
 }
예제 #15
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;
 }
예제 #16
0
 public static function combineOrder($orderIdArr)
 {
     self::initDB();
     BaseModel::begin();
     //开始事务
     $serchSql = "SELECT * FROM om_unshipped_order WHERE id in ('" . join("','", $orderIdArr) . "') and is_delete = 0 and storeId = 1 ";
     $querySql = self::$dbConn->query($serchSql);
     $serchSqlArr = self::$dbConn->fetch_array_all($querySql);
     //判断一:订单数量统计
     if (count($serchSqlArr) < 2) {
         self::$errCode = "1111";
         self::$errMsg = "合并订单最少需要选择两个或两个以上的订单!";
         return false;
     }
     $platfrom = omAccountModel::getPlatformSuffixById($serchSqlArr[0]['platformId']);
     $extension = $platfrom['suffix'];
     //获取后缀名称
     $temporderStatus = "";
     //相同状态一
     $temporderStatus2 = "";
     //相同状态二
     $userinfo = array();
     //订单相同条件
     $orderSn = array();
     //订单编号
     $onlineTotal = 0;
     //线上总价
     $actualTotal = 0;
     //实际收款总价
     $calcWeight = 0;
     //估算重量,单位是kg
     $calcShipping = 0;
     //估算运费
     foreach ($serchSqlArr as $selectArr) {
         $orderSn[] = $selectArr['id'];
         $onlineTotal += $selectArr['onlineTotal'];
         $actualTotal += $selectArr['actualTotal'];
         $calcWeight += $selectArr['calcWeight'];
         $calcShipping += $selectArr['calcShipping'];
         //判断二:订单被其他人 <锁定> 订单判断
         if ($selectArr['isLock'] == 1) {
             self::$errCode = "2222";
             self::$errMsg = "订单[" . $selectArr['id'] . "]已经被 [" . UserModel::getUsernameById($selectArr['lockUser']) . "] 锁定,不能合并操作。";
             return false;
         }
         //判断三:已合并订单,无法再次合并判断
         if (in_array($selectArr['combineOrder'], array(1, 2))) {
             self::$errCode = "3333";
             self::$errMsg = "订单[" . $selectArr['id'] . "]已经有订单合并操作,不能重复订单合并。";
             return false;
         }
         //判断四:已合并包裹订单,无法合并判断
         if (in_array($selectArr['combinePackage'], array(1, 2))) {
             self::$errCode = "4444";
             self::$errMsg = "订单[" . $selectArr['id'] . "]是合并包裹订单,不能订单合并操作。";
             return false;
         }
         //判断五:订单信息不相同判断
         $userinfsql = "SELECT * FROM om_unshipped_order_userInfo WHERE omOrderId = {$selectArr['id']}";
         $userinfsql = self::$dbConn->fetch_first($userinfsql);
         $tempArr = array();
         $tempArr['accountId'] = trim($selectArr['accountId']);
         $tempArr['platformUsername'] = trim($userinfsql['platformUsername']);
         $tempArr['username'] = trim($userinfsql['username']);
         $tempArr['countryName'] = trim($userinfsql['countryName']);
         $tempArr['state'] = trim($userinfsql['state']);
         $tempArr['city'] = trim($userinfsql['city']);
         $tempArr['street'] = trim($userinfsql['street']);
         $tempArr['currency'] = trim($userinfsql['currency']);
         //币种判断
         if (!empty($userinfo) && $userinfo != $tempArr) {
             self::$errCode = "5555";
             self::$errMsg = "订单信息不相同,无法合并订单操作。";
             return false;
         }
         $userinfo = $tempArr;
         //订单信息相同,进入下次比较。
         //判断六:同状态判断
         $orderStatus = "";
         //订单状态一
         $orderType = "";
         //订单状态二
         $orderStatus = $selectArr['orderStatus'];
         $orderType = $selectArr['orderType'];
         if (!empty($temporderStatus) && $temporderStatus != $orderStatus) {
             self::$errCode = "6666";
             self::$errMsg = "订单不在同一文件夹,无法合并订单操作。";
             return false;
         }
         $temporderStatus = $orderStatus;
         if (!empty($temporderStatus2) && $temporderStatus2 != $orderType) {
             self::$errCode = "6666";
             self::$errMsg = "订单不在同一文件夹,无法合并订单操作。";
             return false;
         }
         $orderExtensql = "SELECT * FROM om_unshipped_order_extension_" . $extension . " WHERE omOrderId = {$selectArr['id']}";
         $orderExtensql = self::$dbConn->fetch_first($orderExtensql);
         $temporderStatus2 = $orderType;
     }
     $insertOrder = array();
     $insertOrder['orderData'] = $serchSqlArr[0];
     $insert_userinfo = $userinfsql;
     unset($insert_userinfo['omOrderId']);
     $insertOrder['orderUserInfoData'] = $insert_userinfo;
     $insert_orderExtensql = $orderExtensql;
     unset($insert_orderExtensql['omOrderId']);
     $insertOrder['orderExtenData'] = $insert_orderExtensql;
     //$insertOrder['orderNote'] = $userinfsql;
     unset($insertOrder['orderData']['id']);
     $insertOrder['orderData']['onlineTotal'] = $onlineTotal;
     $insertOrder['orderData']['actualTotal'] = $actualTotal;
     $insertOrder['orderData']['calcWeight'] = $calcWeight;
     $insertOrder['orderData']['calcShipping'] = $calcShipping;
     $insertOrder['orderData']['orderAddTime'] = time();
     $insertOrder['orderData']['combineOrder'] = 2;
     $insertOrder['orderData']['orderAttribute'] = 3;
     //$insertOrder['orderDetail'] = array();
     $detailSql = "SELECT * FROM om_unshipped_order_detail WHERE omOrderId in ('" . join("','", $orderIdArr) . "') and is_delete = 0 and storeId = 1 ";
     $detailSql = self::$dbConn->query($detailSql);
     $detailSqlArr = self::$dbConn->fetch_array_all($detailSql);
     $orderDetail = array();
     foreach ($detailSqlArr as $value) {
         //$orderDetailData = array();
         //$orderDetailExtenData = array();
         $obj_orderDetail = $value;
         unset($obj_orderDetail['id']);
         unset($obj_orderDetail['omOrderId']);
         $orderDetailData = $obj_orderDetail;
         $detailExtenSql = "SELECT * FROM om_unshipped_order_detail_extension_" . $extension . " WHERE omOrderdetailId = '" . $value['id'] . "' ";
         $detailExtenSql = self::$dbConn->query($detailExtenSql);
         $detailExtenSqlArr = self::$dbConn->fetch_array($detailExtenSql);
         $obj_orderDetailExten = $detailExtenSqlArr;
         unset($obj_orderDetailExten['omOrderdetailId']);
         $orderDetailExtenData = $obj_orderDetailExten;
         $orderDetail[] = array('orderDetailData' => $orderDetailData, 'orderDetailExtenData' => $orderDetailExtenData);
     }
     $insertOrder['orderDetail'] = $orderDetail;
     //var_dump($insertOrder); exit;
     if ($insertId = OrderAddModel::insertAllOrderRowNoEvent($insertOrder)) {
         //echo $split_log .= 'insert success!' . "\n"; exit;
         //var_dump($_mainId,$_spitId); exit;
         if (!OrderLogModel::insertOrderLog($insertId, '合并产生新订单')) {
             BaseModel::rollback();
             self::$errCode = '001';
             self::$errMsg = "合并失败!";
             return false;
         }
         if (!OrderRecordModel::insertCombineRecord($serchSqlArr[0]['id'], $insertId)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "合并订单失败添加记录失败!";
             return false;
         }
         $updateOrder = array();
         $updateOrder['is_delete'] = 1;
         $updateOrder['combineOrder'] = 1;
         if (!OrderindexModel::updateOrder("om_unshipped_order", $updateOrder, " WHERE id in ('" . join("','", $orderSn) . "')")) {
             BaseModel::rollback();
             //事物回滚
             self::$errCode = "0012";
             self::$errMsg = "合并更新原始订单失败!";
             return false;
         }
     } else {
         //$split_log .= '补寄新订单产生失败!' . "\n";
         BaseModel::rollback();
         self::$errCode = '003';
         self::$errMsg = "合并新订单产生失败";
         return false;
     }
     BaseModel::commit();
     self::$errCode = '200';
     self::$errMsg = "合并新订单成功!";
     return TRUE;
 }
예제 #17
0
 public function act_modifyOrder()
 {
     if (isset($_POST) && !empty($_POST)) {
         //$OrderModifyAct->act_modifyOrder();
         $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : '';
         $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus'];
         $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype'];
         $update_order = array();
         $update_userinfo = array();
         $update_tracknumber = array();
         //$orderid = $_POST['orderid'];
         //var_dump($_POST); exit;
         $updatestatus = false;
         if (!empty($_POST['data'])) {
             $data = $_POST['data'];
         }
         if (isset($data['username'])) {
             $update_userinfo['username'] = $data['username'];
         }
         if (isset($data['orderStatus'])) {
             $update_order['orderStatus'] = $data['orderStatus'];
         }
         if (isset($data['orderType'])) {
             $update_order['orderType'] = $data['orderType'];
             $updatestatus = true;
         }
         if (isset($data['street'])) {
             $update_userinfo['street'] = $data['street'];
         }
         if (isset($data['platformUsername'])) {
             $update_userinfo['platformUsername'] = $data['platformUsername'];
         }
         if (isset($data['address2'])) {
             $update_userinfo['address2'] = $data['address2'];
         }
         if (isset($data['actualShipping'])) {
             $update_order['actualShipping'] = $data['actualShipping'];
         }
         if (isset($data['city'])) {
             $update_userinfo['city'] = $data['city'];
         }
         if (isset($data['state'])) {
             $update_userinfo['state'] = $data['state'];
         }
         if (isset($data['countryName'])) {
             $update_userinfo['countryName'] = $data['countryName'];
         }
         if (isset($data['zipCode'])) {
             $update_userinfo['zipCode'] = $data['zipCode'];
         }
         if (isset($data['landline'])) {
             $update_userinfo['landline'] = $data['landline'];
         }
         if (isset($data['phone'])) {
             $update_userinfo['phone'] = $data['phone'];
         }
         if (isset($data['transportId'])) {
             $update_order['transportId'] = $data['transportId'];
         }
         if (isset($data['update_notes'])) {
             $update_note = $data['update_notes'];
         }
         if (isset($data['note_new'])) {
             $add_note = $data['note_new'];
         }
         if ($data['edit_tracknumber']) {
             $update_tracknumber['omOrderId'] = $orderid;
             $update_tracknumber['tracknumber'] = $data['edit_tracknumber'];
             $update_tracknumber['addUser'] = $_SESSION['sysUserId'];
             $update_tracknumber['createdTime'] = time();
             //var_dump($update_tracknumber); exit;
         }
         BaseModel::begin();
         //开始事务
         if ($update_order) {
             //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid;
             //$msg = commonModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql);
             if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) {
                 if ($updatestatus) {
                     $ProductStatus = new ProductStatus();
                     if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) {
                         BaseModel::rollback();
                     }
                 }
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "001";
                 self::$errMsg = "更新订单信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_userinfo) {
             //var_dump($update_userinfo);
             if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) {
                 $modify_showerrorinfo = "<font color='green'>更新成功</font>";
             } else {
                 self::$errCode = "002";
                 self::$errMsg = "更新订单用户信息失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_tracknumber) {
             //echo $msg;
             if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) {
                 self::$errCode = "003";
                 self::$errMsg = "更新订单跟踪号插入失败!";
                 BaseModel::rollback();
                 return false;
             }
         }
         if ($update_note) {
             foreach ($update_note as $key => $value) {
                 $notes = explode("###", $value);
                 $where = " where content='{$notes[0]}' and omOrderId={$orderid}";
                 $set = "set content='{$notes[1]}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::updateTNameRow("om_order_notes", $set, $where);
                 if (!$msg) {
                     self::$errCode = "004";
                     self::$errMsg = "更新订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         if ($add_note) {
             foreach ($add_note as $key => $value) {
                 $set = "set omOrderId={$orderid},content='{$value}',userId={$_SESSION['sysUserId']},createdTime=" . time();
                 $msg = OmAvailableModel::insertRow("om_order_notes", $set);
                 if (!$msg) {
                     self::$errCode = "005";
                     self::$errMsg = "插入订单备注失败!";
                     BaseModel::rollback();
                     return false;
                 }
             }
         }
         self::$errCode = "200";
         self::$errMsg = "整个订单信息更新成功!";
         BaseModel::commit();
         BaseModel::autoCommit();
     }
 }
예제 #18
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;
 }
예제 #19
0
 public static function resendOrder($orderid, $note, $type, $old_ostatus, $old_otype)
 {
     !self::$dbConn ? self::initDB() : NULL;
     BaseModel::begin();
     //开始事务
     //$tableName = 'om_unshipped_order';
     //echo $old_ostatus; echo "<br>";
     //echo $old_otype; echo "<br>";
     $StatusMenuAct = new StatusMenuAct();
     $tableName = $StatusMenuAct->act_getOrderNameByStatus($old_ostatus, $old_otype);
     //echo $tableName;
     if ($type == 1) {
         $updatesql = 'update ' . $tableName . ' set isBuji=1,isCopy=1 where id=' . $orderid . ' and is_delete = 0 and storeId = 1';
     } else {
         $updatesql = 'update ' . $tableName . ' set isCopy=1 where id=' . $orderid . ' and is_delete = 0 and storeId = 1';
     }
     if (!self::$dbConn->query($updatesql)) {
         //更新状态失败
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         self::$errCode = '003';
         self::$errMsg = '订单信息不存在,无法复制!';
         return FALSE;
     }
     //产生新订单
     $where = ' WHERE id = ' . $orderid . ' and is_delete = 0 and storeId = 1';
     $orderData = OrderindexModel::showOrderList($tableName, $where);
     $orderDetail = $orderData[$orderid]['orderDetail'];
     if (!$orderDetail) {
         //更新状态失败
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     $insert_orderDetail = array();
     foreach ($orderDetail as $detail) {
         $insert_orderDetailData = $detail['orderDetailData'];
         unset($insert_orderDetailData['id']);
         $insert_orderDetailExtenData = $detail['orderDetailExtenData'];
         unset($insert_orderDetailExtenData['omOrderdetailId']);
         $insert_orderDetail[] = array('orderDetailData' => $insert_orderDetailData, 'orderDetailExtenData' => $insert_orderDetailExtenData);
     }
     $obj_order_data = $orderData[$orderid]['orderData'];
     if ($obj_order_data['isBuji'] == 2) {
         self::$errCode = '003';
         self::$errMsg = "补寄产生订单不能补寄!";
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     if ($obj_order_data['isCopy'] == 2) {
         self::$errCode = '003';
         self::$errMsg = "复制产生订单不能复制!";
         BaseModel::rollback();
         self::$dbConn->query('SET AUTOCOMMIT=1');
         return FALSE;
     }
     unset($obj_order_data['id']);
     $orderExtenData = $orderData[$orderid]['orderExtenData'];
     unset($orderExtenData['omOrderId']);
     $orderUserInfoData = $orderData[$orderid]['orderUserInfoData'];
     unset($orderExtenData['omOrderId']);
     if ($type == 1) {
         $obj_order_data['isCopy'] = 2;
         $obj_order_data['actualTotal'] = 0.0;
     } else {
         $obj_order_data['isCopy'] = 2;
         $obj_order_data['isBuji'] = 2;
         $obj_order_data['actualTotal'] = 0.0;
         $obj_order_data['orderStatus'] = C('STATEBUJI');
         $obj_order_data['orderType'] = C('STATEBUJI_DONE');
     }
     $orderNote = array('content ' => $note, 'userId' => $_SESSION['sysUserId'], 'createdTime' => time());
     $insert_orderData = array();
     $insert_orderData = array('orderData' => $obj_order_data, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData, 'orderDetail' => $insert_orderDetail, 'orderNote' => $orderNote);
     //$orderNote = $orderData['orderNote'];
     //echo $insertsql;
     //var_dump($insert_orderData); exit;
     if ($insertId = OrderAddModel::insertAllOrderRowNoEvent($insert_orderData)) {
         //echo $split_log .= 'insert success!' . "\n"; exit;
         //var_dump($_mainId,$_spitId); exit;
         if (!OrderLogModel::insertOrderLog($insertId, '补寄产生订单')) {
             BaseModel::rollback();
             self::$errCode = '001';
             self::$errMsg = "补寄失败!";
             return false;
         }
         if (!OrderRecordModel::insertSendRecords($orderid, $insertId)) {
             BaseModel::rollback();
             self::$errCode = '002';
             self::$errMsg = "补寄失败添加记录失败!";
             return false;
         }
     } else {
         //$split_log .= '补寄新订单产生失败!' . "\n";
         BaseModel::rollback();
         self::$errCode = '003';
         self::$errMsg = "补寄新订单产生失败";
         return false;
     }
     BaseModel::commit();
     self::$errCode = '200';
     self::$errMsg = "补寄新订单成功!";
     return TRUE;
 }