public function view_reculculateShippingWay()
 {
     $ids = isset($_GET['ids']) ? trim($_GET['ids']) : '';
     $ids = explode(',', $ids);
     $ids = array_map('intval', $ids);
     $succesResult = array();
     //存储处理成功的结果集
     $failureResult = array();
     //处理存储失败的结果集
     $owOrderMG = new OwOrderManageModel();
     $owShipfeeCul = new OwShippingWayDesisionModel();
     $oderIndex = new OrderindexAct();
     $exApply = new ExpressLabelApplyModel();
     foreach ($ids as $orderId) {
         $orderInfo = $owOrderMG->getOrderInfoById($orderId, array('id', 'recordNumber', 'calcWeight'));
         if (FALSE == $orderInfo) {
             $failureResult[] = array('oderid' => $orderId, 'recordNumber' => '', 'calcWeight' => 0, 'errMsg' => '订单不存在');
             continue;
         }
         if (0 == $orderInfo['calcWeight']) {
             //重量未0 不予打印
             $failureResult[] = array('oderid' => $orderId, 'recordNumber' => $orderInfo['recordNumber'], 'calcWeight' => 0, 'errMsg' => '订单重量为0! 请确认重量!');
             continue;
         }
         $userInfo = $owOrderMG->getBuyerInfoById($orderId);
         if (FALSE == $userInfo) {
             $failureResult[] = array('oderid' => $orderId, 'recordNumber' => $orderInfo['recordNumber'], 'calcWeight' => $orderInfo['calcWeight'], 'errMsg' => '不能获取买家信息!');
             continue;
         }
         $shipInfo = $owOrderMG->getShippingInfo($orderId);
         if ($shipInfo) {
             if ($shipInfo['isCanceled'] == 0) {
                 //之前已经申请过跟踪号 如果未取消则不予重复申请
                 $failureResult[] = array('oderid' => $orderId, 'recordNumber' => $orderInfo['recordNumber'], 'calcWeight' => $orderInfo['calcWeight'], 'shippingWay' => $shipInfo['shippingWay'], 'errMsg' => '原有跟踪号未取消!', 'trackNumber' => $shipInfo['trackNumber']);
                 continue;
             }
         }
         $skuList = $oderIndex->act_getRealskulist($orderId);
         $outSide = $owShipfeeCul->culPackageLWH($skuList);
         $zone = $exApply->getZoneCode($userInfo['zipCode']);
         $shipingWay = $owShipfeeCul->chooseShippingWay($skuList, $orderInfo['calcWeight'], $outSide, $zone);
         if (FALSE == $shipingWay) {
             $failureResult[] = array('oderid' => $orderId, 'recordNumber' => $orderInfo['recordNumber'], 'calcWeight' => $orderInfo['calcWeight'], 'errMsg' => '未找到合适的运输方式!', 'trackNumber' => '');
             continue;
         } else {
             //执行成功 更新运输方式
             $transId = $exApply->reflectCodeToId($shipingWay['shippingCode']);
             $owOrderMG->updateFeildData(array('transportId' => $transId), $orderId);
             $owOrderMG->changeOrderStatus(911, 916, $orderId);
             //移动到待打印
             $succesResult[] = array('oderid' => $orderId, 'recordNumber' => $orderInfo['recordNumber'], 'calcWeight' => $orderInfo['calcWeight'], 'errMsg' => '成功!', 'trackNumber' => $shipingWay['shippingCode']);
             continue;
         }
     }
     //         print_r($failureResult);
     //         print_r($succesResult);
     $this->smarty->assign('success', $succesResult);
     $this->smarty->assign('failure', $failureResult);
     $this->smarty->display('owReculShipping.htm');
 }
Beispiel #2
0
 public function view_applyLabel()
 {
     $returnData = array('code' => 0, 'msg' => '');
     $orderId = isset($_GET['oid']) ? intval($_GET['oid']) : 0;
     if (!$orderId) {
         $returnData['msg'] = '未指定订单号';
         echo json_encode($returnData);
         return FALSE;
     }
     $orderInfo = OrderInfoModel::getOrderInfo($orderId);
     if (FALSE === $orderInfo) {
         //不存在的订单号
         $returnData['msg'] = '不存在的订单号!';
         echo json_encode($returnData);
         return FALSE;
     }
     if ($orderInfo['orderStatus'] != 911 || $orderInfo['orderType'] != 916) {
         //订单状态不合法
         $returnData['msg'] = '该订单不是海外仓待打印订单!';
         echo json_encode($returnData);
         return FALSE;
     }
     if ($orderInfo['transportId'] == 0) {
         //订单未设置运输方式
         $returnData['msg'] = '该订单还未设定运输方式!';
         echo json_encode($returnData);
         return FALSE;
     }
     $orderActObj = new OrderindexAct();
     $skuList = $orderActObj->act_getRealskulist($orderId);
     //获得全部的sku列表
     if (FALSE == $skuList) {
         $returnData['msg'] = '获取料号信息出错!';
         echo json_encode($returnData);
         return FALSE;
     }
     $owOrderMg = new OwOrderManageModel();
     $owShipDes = new OwShippingWayDesisionModel();
     $outside = $owShipDes->culPackageLWH($skuList);
     $buyerInfo = $owOrderMg->getUnshippedOrderBuyerInfo($orderId);
     //买家信息
     if (FALSE === $buyerInfo) {
         $returnData['msg'] = '获取买家信息失败!';
         echo json_encode($returnData);
         return FALSE;
     }
     $zipCode = $buyerInfo['zipCode'];
     //邮编
     $weight = $orderInfo['calcWeight'];
     //订单重量
     if ($weight == 0) {
         //重量为0 则无法处理
         $returnData['msg'] = '订单重量为0,请先确认重量!';
         echo json_encode($returnData);
         return FALSE;
     }
     $owOrderMG = new OwOrderManageModel();
     $transInfo = $owOrderMG->getShippingInfo($orderId);
     if (!empty($transInfo) && $transInfo['shippingWay'] == 'USPS' && $transInfo['isCanceled'] == 0) {
         /* 当之前有申请过usps 并且申请的usps还没有退款的时 则 不予申请*/
         $returnData['msg'] = '请先退款已申请的USPS!';
         echo json_encode($returnData);
         return FALSE;
     }
     $shipping = new ExpressLabelApplyModel();
     $zone = $shipping->getZoneCode($zipCode);
     $zone = FALSE !== $zone ? $zone : 6;
     //如果没找到分区则默认为6区
     $shippingInfo = $owShipDes->chooseShippingWay($skuList, $weight, $outside, $zone);
     if ($shippingInfo) {
         $transId = $shipping->reflectCodeToId($shippingInfo['shippingCode']);
     } else {
         $transId = 0;
     }
     if ($transId != $orderInfo['transportId']) {
         //计算出的运输方式和系统的不符合
         $returnData['msg'] = "计算的运输方式和初始运输方式不符合! 请重新生成运输方式 ! 计算运输方式为 " . $shippingInfo['shippingCode'];
         echo json_encode($returnData);
         return FALSE;
     }
     if (0 == $transId) {
         //没找到正确的运输方式
         $returnData['msg'] = OwShippingWayDesisionModel::$errMsg;
         echo json_encode($returnData);
         return FALSE;
     }
     $data = array();
     $data['recipients'] = $buyerInfo['username'];
     //收件人
     $data['re_phone'] = $buyerInfo['landline'] . '/' . $buyerInfo['phone'];
     //电话
     $data['re_address1'] = $buyerInfo['street'];
     //街道地址一
     $data['re_address2'] = $buyerInfo['address2'];
     //街道地址二
     $data['re_city'] = $buyerInfo['city'];
     //市
     $data['re_post_code'] = $zipCode;
     //邮编
     $data['re_country_code'] = 'US';
     //国家简称
     $data['weight'] = $weight;
     //重量
     $data['orderId'] = $orderId;
     //订单号
     $owSkuMG = new OwSkuInfoManageModel();
     //生成料号仓位数据
     $skuLocation = $owSkuMG->getAsetOfSkusLocation(array_keys($skuList));
     $positionStr = '';
     $skuDetailStr = '';
     foreach ($skuList as $k => $_num) {
         $position = $skuLocation[$k];
         $positionStr .= " {$k} [{$position}] ";
         $skuDetailStr .= " {$k} * {$_num} ";
     }
     $data['sku_position'] = $positionStr;
     $data['show_detail'] = $skuDetailStr;
     $handResult = FALSE;
     $errMsg = '';
     //         print_r($shippingInfo['shippingCode']);exit;
     if ('UPS Ground' == $shippingInfo['shippingCode']) {
         //申请 UPS Label
         $upsApplyObj = new ApplyUpsLabelModel();
         $data['re_state_code'] = $upsApplyObj->getStateAbbreviationName($buyerInfo['state']);
         //州简称
         if (FALSE == $data['re_state_code']) {
             //没找到则使用原始值
             $data['re_state_code'] = $buyerInfo['state'];
         }
         //         	print_r($data);exit;
         $applyResult = $upsApplyObj->applyUPSLabel($data);
         if (FALSE === $applyResult) {
             //申请标签失败
             $errMsg = ApplyUpsLabelModel::$errMsg;
         } else {
             $handResult = TRUE;
             $this->deal_img_ups($applyResult['imagePath'], $applyResult['imagePath']);
         }
     } else {
         if ('USPS' == $shippingInfo['shippingCode']) {
             //申请usps label
             $uspsApplyObj = new ApplyUSPSLabelModel();
             $data['re_state_code'] = $uspsApplyObj->getStateAbbreviationName($buyerInfo['state']);
             //州简称
             if (FALSE == $data['re_state_code']) {
                 //没找到则使用原始值
                 $data['re_state_code'] = $buyerInfo['state'];
             }
             $mailClass = $shippingInfo['extensionInfo']['mailclass'];
             //运输类型
             $packageType = $shippingInfo['extensionInfo']['packageType'];
             $typeInfo = array('mailClass' => $mailClass, 'packageType' => $packageType);
             $applyResult = $uspsApplyObj->aplyUSPSLabel($data, $typeInfo);
             if (FALSE === $applyResult) {
                 //申请标签失败
                 $errMsg = ApplyUSPSLabelModel::$errMsg;
             } else {
                 $handResult = TRUE;
                 if ($packageType == 'Letter' || $packageType == 'Flat') {
                     $this->deal_img_usps($applyResult['imagePath'], $applyResult['imagePath']);
                     //后期处理图片
                 }
             }
         }
     }
     if (FALSE == $handResult) {
         $returnData['msg'] = $errMsg;
     } else {
         $returnData['code'] = 1;
         //               array('trackNumber'=>$trackNumber, 'shippFee'=>$totalMoney, 'imagePath'=>$labelSavePath
         $result = $owOrderMG->insertNewTrackNumber($orderId, $applyResult['trackNumber'], $shippingInfo['shippingCode'], $_SESSION['sysUserId'], 0);
         //更新跟踪号信息
         $result2 = $owOrderMG->changeOrderStatus(911, 910, $orderId);
     }
     echo json_encode($returnData);
     return FALSE;
 }
Beispiel #3
0
 public static function auto_contrast_intercept($orderData)
 {
     global $SYSTEM_ACCOUNTS, $__liquid_items_fenmocsku, $__liquid_items_BuiltinBattery, $__liquid_items_SuperSpecific, $__liquid_items_Paste;
     global $GLOBAL_EBAY_ACCOUNT;
     global $express_delivery, $no_express_delivery;
     if (!$SYSTEM_ACCOUNTS) {
         if (!defined('WEB_PATH')) {
             define("WEB_PATH", "/data/web/order.valsun.cn/");
             //define("WEB_PATH","/data/web/framework.valsun.cn/");
         }
         include WEB_PATH . "conf/scripts/script.ebay.config.php";
     }
     if (!$GLOBAL_EBAY_ACCOUNT) {
         $GLOBAL_EBAY_ACCOUNT = array();
         foreach ($SYSTEM_ACCOUNTS as $acct) {
             foreach ($acct as $key => $value) {
                 $GLOBAL_EBAY_ACCOUNT[$key] = $value;
             }
         }
     }
     //var_dump($GLOBAL_EBAY_ACCOUNT);
     self::initDB();
     //var_dump($orderData); echo "\n";
     $log_data = "";
     $actualTotal0 = 0;
     //该订单实际总数
     //$ebay_id = $orderData['orderData']['id'];
     $orderStatus = empty($orderData['orderData']['orderStatus']) ? C('STATEPENDING') : $orderData['orderData']['orderStatus'];
     $orderType = empty($orderData['orderData']['orderType']) ? C('STATEPENDING_CONV') : $orderData['orderData']['orderType'];
     $returnStatus = array('orderStatus' => $orderStatus, 'orderType' => $orderType);
     $isNote = $orderData['orderData']['isNote'];
     if ($isNote) {
         $orderType = C('STATEPENDING_MSG');
     }
     $calcWeight = $orderData['orderData']['calcWeight'];
     $pmId = $orderData['orderData']['pmId'];
     //var_dump($calcWeight); echo "\n";
     $orderdetaillist = $orderData['orderDetail'];
     if (empty($calcWeight)) {
         $calcInfo = CommonModel::calcAddOrderWeight($orderdetaillist);
         //计算重量和包材
         $calcWeight = $calcInfo[0];
         $pmId = $calcInfo[1];
         $orderData['orderData']['calcWeight'] = $calcWeight;
         $orderData['orderData']['pmId'] = $pmId;
     }
     //var_dump($calcWeight); echo "\n";
     $transportId = @$orderData['orderData']['transportId'];
     $countryName = $orderData['orderUserInfoData']['countryName'];
     $accountId = $orderData['orderData']['accountId'];
     $actualTotal = $orderData['orderData']['actualTotal'];
     $ebay_username = $orderData['orderUserInfoData']['username'];
     $orderDataid = $orderData['orderExtenData']['orderId'];
     $ebay_usermail = $orderData['orderUserInfoData']['email'];
     $PayPalEmailAddress = @$orderData['orderExtenData']['PayPalEmailAddress'];
     //echo "------$countryName-----\n";
     //echo "订单计算重量:$calcWeight\t\n";
     $contain_special_item = false;
     $contain_os_item = false;
     $ow_status = array();
     $all_splited_sku = array();
     //汇总改订单的sku
     //foreach ($orderdetaillist AS $orderdetail){
     for ($i = 0; $i < count($orderdetaillist); $i++) {
         $sku = $orderdetaillist[$i]['orderDetailData']['sku'];
         $itemPrice = $orderdetaillist[$i]['orderDetailData']['itemPrice'];
         $amount = $orderdetaillist[$i]['orderDetailData']['amount'];
         $shippingFee = $orderdetaillist[$i]['orderDetailData']['shippingFee'];
         //var_dump($sku);
         $sku_arr = GoodsModel::get_realskuinfo($sku);
         //将sku的信息汇总到汇总sku列表中
         foreach ($sku_arr as $f_sku => $f_num) {
             if (array_key_exists($f_sku, $all_splited_sku)) {
                 $all_splited_sku[$f_sku] = $all_splited_sku[$f_sku] + $f_num;
             } else {
                 $all_splited_sku[$f_sku] = $f_num;
             }
         }
         //var_dump($sku_arr); exit;
         $actualTotal0 += $itemPrice * $amount + $shippingFee;
         foreach ($sku_arr as $or_sku => $or_nums) {
             if (in_array($or_sku, $__liquid_items_fenmocsku) || in_array($or_sku, $__liquid_items_SuperSpecific) || in_array($or_sku, $__liquid_items_BuiltinBattery)) {
                 //粉末状,超规格产品 走福建邮局
                 $contain_special_item = true;
             }
             if (preg_match("/^US01\\+.*/", $or_sku, $matchArr) || preg_match("/^US1\\+.*/", $or_sku, $matchArr)) {
                 //$log_data .= "[".date("Y-m-d H:i:s")."]\t包含海外仓料号订单---{$ebay_id}-----料号:{$or_sku}--!\n\n";
                 $contain_os_item = true;
                 if (strpos($or_sku, "US01+") !== false) {
                     $matchStr = substr($matchArr[0], 5);
                     //去除前面
                     //$matchStr = str_replace("US1+", "", $or_sku);
                 } else {
                     //$matchStr=substr($matchArr[0],5);//去除前面
                     $matchStr = str_replace("US1+", "", $or_sku);
                 }
                 $n = strpos($matchStr, ':');
                 //寻找位置
                 if ($n) {
                     $matchStr = substr($matchStr, 0, $n);
                 }
                 //删除后面
                 if (preg_match("/^0+(\\w+)/", $matchStr, $matchArr)) {
                     $matchStr = $matchArr[1];
                 }
                 $orderData['orderDetail'][$i]['orderDetailData']['sku'] = $matchStr;
                 //OrderAddModel::updateDetailExtension(array('sku'=>$matchStr), " id = {$orderdetail['ebay_id']} ");
                 //$virtualnum = check_oversea_stock($matchStr); //检查海外仓虚拟库存
                 $virtualnum = self::checkHasRepertoryOs($matchStr, $or_nums);
                 //预留获取海外仓虚拟库存接口 20131225
                 if ($virtualnum >= 0) {
                     $ow_status[] = C('STATEPENDING_OVERSEA');
                     //海外仓待处理
                 } else {
                     $ow_status[] = C('STATEOUTOFSTOCK_OVERSEA');
                     //海外仓缺货
                 }
             }
         }
     }
     if ($contain_special_item) {
         /*$sql = "update ebay_order set ebay_carrierstyle ='1' where ebay_id ={$ebay_id}"; //add by Herman.Xi 记录该订单含有特殊料号
         		$dbConnn->query($sql);
         		$log_data .= "[".date("Y-m-d H:i:s")."]\t包含粉末状超规格产品---{$ebay_id}---!\n\n";*/
     }
     if ($contain_os_item) {
         if (in_array(C('STATEOUTOFSTOCK_OVERSEA'), $ow_status)) {
             $orderData['orderData']['orderStatus'] = C('STATEPENDING_OS');
             $orderData['orderData']['orderType'] = C('STATEOUTOFSTOCK_OVERSEA');
         } else {
             $orderData['orderData']['orderStatus'] = C('STATEPENDING_OS');
             $orderData['orderData']['orderType'] = C('STATEPENDING_OVERSEA');
         }
         //$log_data .= "[".date("Y-m-d H:i:s")."]\t更新海外仓料号订单状态为{$final_status}---{$ebay_id}--{$sql}-!\n\n";
         /*if($final_status == C('STATEPENDING_OVERSEA')){
         
         				$calcWeight = calcWeight($ebay_id);
         				$skunums	 = checkSkuNum($ebay_id);
         				if($skunums === true){
         					continue;
         				}else if ($calcWeight>20) {
         					if($skunums==1){
         						usCalcShipCost($ebay_id);
         					}
         				} else {
         					 usCalcShipCost($ebay_id);
         				}
         			}*/
         //$calcWeight = recalcorderweight($order_sn, $ebay_packingmaterial); //modified by Herman.Xi 2012-10-17
         $owShipDes = new OwShippingWayDesisionModel();
         $outside = $owShipDes->culPackageLWH($all_splited_sku);
         $zipCode = $orderData['orderData']['userInfo']['zipCode'];
         $shipping = new ExpressLabelApplyModel();
         $zone = $shipping->getZoneCode($zipCode);
         $zone = FALSE !== $zone ? $zone : 6;
         //如果没找到分区则默认为6区
         $shippingInfo = $owShipDes->chooseShippingWay($all_splited_sku, $calcWeight, $outside, $zone);
         if ($shippingInfo) {
             $transId = $shipping->reflectCodeToId($shipping['shippingCode']);
         } else {
             $transId = 0;
         }
         $orderData['orderData']['transportId'] = $transId;
         if ($transId) {
             //找到运输方 则放到待处理
             $orderData['orderData']['orderStatus'] = 911;
             $orderData['orderData']['orderType'] = 115;
         }
         $orderStatus = empty($orderData['orderData']['orderStatus']) ? C('STATEPENDING') : $orderData['orderData']['orderStatus'];
         $orderType = empty($orderData['orderData']['orderType']) ? C('STATEPENDING_CONV') : $orderData['orderData']['orderType'];
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t包含海外仓料号---自动跳转---的状态为---{$final_status}!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
         //continue;
     }
     $interceptrtn = self::intercept_exception_orders($orderData);
     //var_dump($interceptrtn);
     if ($interceptrtn) {
         $orderData['orderData']['orderStatus'] = $interceptrtn['orderStatus'];
         $orderData['orderData']['orderType'] = $interceptrtn['orderType'];
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     }
     $record_details = array();
     $is_640 = false;
     //var_dump($orderdetaillist); exit;
     foreach ($orderdetaillist as $orderdetail) {
         //var_dump($orderdetail['sku']);
         $sku = $orderdetail['orderDetailData']['sku'];
         //$itemPrice = $orderdetail['orderDetailData']['itemPrice'];
         $amount = $orderdetail['orderDetailData']['amount'];
         //$shippingFee = $orderdetail['orderDetailData']['shippingFee'];
         $sku_arr = GoodsModel::get_realskuinfo($sku);
         //var_dump($sku_arr); exit;
         $hava_goodscount = true;
         foreach ($sku_arr as $or_sku => $or_nums) {
             $allnums = $or_nums * $amount;
             if (!CommonModel::check_sku($or_sku, $allnums)) {
                 //超大订单状态
                 $orderStatus = C('STATEOVERSIZEDORDERS');
                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['aliexpress']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['DHgate']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['出口通']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['线下结算客户'])) {
                     $orderType = C('STATEOVERSIZEDORDERS_CONFIRM');
                 } else {
                     $orderType = C('STATEOVERSIZEDORDERS_PEND');
                 }
                 //self::insert_mark_shipping($ebay_id);
                 $is_640 = true;
                 break;
             } else {
                 $skuinfo = CommonModel::get_sku_info($or_sku);
                 $salensend = CommonModel::getpartsaleandnosendall($or_sku);
                 //$log_data .= "[".date("Y-m-d H:i:s")."]\t---{$sql}\n\n";
                 $log_data .= "订单==={$ebay_id}===料号=={$or_sku}===实际库存为{$skuinfo['realnums']}===需求量为{$allnums}===待发货数量为{$salensend}===\n";
                 if (!isset($skuinfo['realnums']) || empty($skuinfo['realnums']) || $skuinfo['realnums'] - $salensend - $allnums < 0) {
                     $hava_goodscount = false;
                     break;
                 }
             }
         }
         if ($hava_goodscount) {
             $record_details[] = $orderdetail;
         }
     }
     if ($is_640) {
         $orderData['orderData']['orderStatus'] = $orderStatus;
         $orderData['orderData']['orderType'] = $orderType;
         //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     }
     $count_record_details = count($record_details);
     $count_orderdetaillist = count($orderdetaillist);
     $final_status = $orderStatus;
     //原始状态
     if ($count_record_details == 0) {
         //更新至自动拦截发货状态
         /*if (!in_array($ebay_carrier, $no_express_delivery)){
         			$final_status = 658;
         		}else {
         			$final_status = 661;
         		}*/
         //$sql = "UPDATE ebay_order SET ebay_status='$final_status' WHERE ebay_id ='$ebay_id' and ebay_status = '{$orderStatus}' ";
         $orderStatus = C('STATEOUTOFSTOCK');
         $orderType = C('STATEOUTOFSTOCK_AO');
         //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为---".C('STATEOUTOFSTOCK_AO')."!\n\n";
         //self::insert_mark_shipping($ebay_id);
         //self::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
         $orderData['orderData']['orderStatus'] = $orderStatus;
         $orderData['orderData']['orderType'] = $orderType;
         $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
         CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
         return $orderData;
     } else {
         if ($count_record_details < $count_orderdetaillist) {
             //更新至自动部分发货状态
             /*if (!in_array($ebay_carrier, $no_express_delivery)){
             			//$final_status = 659;
             			$final_status = 640;
             		}else {
             			$final_status = 660;
             		}*/
             $orderStatus = C('STATEOUTOFSTOCK');
             $orderType = C('STATEOUTOFSTOCK_PO');
             //$log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转的状态为---".C('STATEOUTOFSTOCK_PO')."!\n\n";
             //self::insert_mark_shipping($ebay_id);
             //$returnStatus = array('orderStatus'=>C('STATEOUTOFSTOCK'), 'orderType'=>C('STATEOUTOFSTOCK_PO'));
             //self::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
             //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
             $orderData['orderData']['orderStatus'] = $orderStatus;
             $orderData['orderData']['orderType'] = $orderType;
             $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
             CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
             return $orderData;
         } else {
             if ($count_record_details == $count_orderdetaillist) {
                 //正常发货状态
                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['ebay'])) {
                     if (in_array($orderStatus, array(C('STATEOUTOFSTOCK_PO'), C('STATEOUTOFSTOCK_PO')))) {
                         //$final_status = 618;//ebay订单自动拦截有货不能移动到待处理和有留言 modified by Herman.Xi @ 20130325(移动到缺货需打印中)
                         $orderStatus = C('STATEPENDING');
                         if ($isNote == 1) {
                             echo "有留言\t";
                             $orderType = C('STATEPENDING_MSG');
                         } else {
                             $orderType = C('STATEPENDING_HASARRIVED');
                         }
                     } else {
                         $orderStatus = C('STATEPENDING');
                         if ($isNote == 1) {
                             echo "有留言\t";
                             $orderType = C('STATEPENDING_MSG');
                         } else {
                             $orderType = C('STATEPENDING_CONV');
                         }
                     }
                 } else {
                     if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['aliexpress'])) {
                         if (in_array($countryName, array('Russian Federation', 'Russia')) && strpos($ebay_carrier, '中国邮政') !== false && str_word_count($ebay_username) < 2) {
                             $orderStatus = C('STATESYNCINTERCEPT');
                             $orderType = C('STATESYNCINTERCEPT_AB');
                             $orderData['orderData']['orderStatus'] = $orderStatus;
                             $orderData['orderData']['orderType'] = $orderType;
                             $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
                             CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
                             return $orderData;
                         }
                     } else {
                         if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['DHgate'])) {
                             $orderStatus = C('STATEPENDING');
                             $orderType = C('STATEPENDING_CONV');
                         } else {
                             if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['dresslink.com'])) {
                                 $orderStatus = C('STATEPENDING');
                                 $orderType = C('STATEPENDING_CONV');
                             } else {
                                 if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['cndirect.com'])) {
                                     $orderStatus = C('STATEPENDING');
                                     $orderType = C('STATEPENDING_CONV');
                                 } else {
                                     if (in_array($GLOBAL_EBAY_ACCOUNT[$accountId], $SYSTEM_ACCOUNTS['Amazon'])) {
                                         $orderStatus = C('STATEPENDING');
                                         $orderType = C('STATEPENDING_CONV');
                                     } else {
                                         $orderStatus = C('STATEPENDING');
                                         $orderType = C('STATEPENDING_CONV');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($isNote == 1) {
                     echo "有留言\t";
                     $orderType = C('STATEPENDING_MSG');
                 }
                 /*if(self::judge_contain_combinesku_new($orderdetaillist)){
                 			$final_status = 606;
                 		}*/
                 if ($calcWeight > 2) {
                     echo "\t 超重订单";
                     $orderStatus = C('STATEPENDING');
                     $orderType = C('STATEPENDING_OW');
                 }
                 $expressArr = CommonModel::getCarrierInfoById(1);
                 if (in_array($transportId, $expressArr)) {
                     $orderType = C('STATEPENDING_HASARRIVED');
                 }
                 /*if (!in_array($ebay_carrier, $no_express_delivery) && !empty($ebay_carrier)){
                 			if(in_array($GLOBAL_EBAY_ACCOUNT[$accountId],$SYSTEM_ACCOUNTS['ebay']) || in_array($GLOBAL_EBAY_ACCOUNT[$accountId],$SYSTEM_ACCOUNTS['海外销售平台'])){
                 				$final_status = 641;//ebay和海外都跳转到 待打印线下和异常订单
                 			}else{
                 				$final_status = 639;
                 			}
                 		}*/
             } else {
                 $log_data .= "[" . date("Y-m-d H:i:s") . "]\t订单同步状态有误,请联系IT解决!";
             }
         }
     }
     //$returnStatus = array('orderStatus'=>$orderStatus, 'orderType'=>$orderType);
     $orderData['orderData']['orderStatus'] = $orderStatus;
     $orderData['orderData']['orderType'] = $orderType;
     $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转的状态为--" . $orderStatus . "--" . $orderType . "!\n\n";
     CommonModel::write_scripts_log('auto_contrast_intercept', $GLOBAL_EBAY_ACCOUNT[$accountId], $log_data);
     return $orderData;
 }
 public function chooseShippingWay($skuList, $weightP, $outside, $zone)
 {
     $culModel = new OwShippingFeeCulModel();
     $weight = $weightP;
     //重量 KG
     $L = $outside['L'];
     //长 CM
     $W = $outside['W'];
     //宽 CM
     $H = $outside['H'];
     //高 CM
     $shipsetting = $culModel->getShipSettings();
     $rate = $shipsetting['firerate'];
     //燃油附加费
     $home = $shipsetting['homeshipfee'];
     //住宅运输费
     $exchange = $shipsetting['usdexchange'];
     //美元rmb汇率
     $result = array();
     //可成立的运输方式列表    格式 array(运输方式名称=>运费)
     /*
      $usps_fix   = $culModel->uspsShipfee_fix($length,$width, $hight, 'fix', 'inside');                     //usps 固定运费
     if ($usps_fix) {
     $result['usps_fix']    = $usps_fix;
     }
     
     $usps_A     = $culModel->usps_serviceA($length,$width, $hight,$weight);
     if ($usps_A) {                                                                                         //usps 套餐A
     $result['usps_A']    = $usps_A;
     }
     
     $usps_B     = $culModel->usps_serviceB($length,$width, $hight, $weight);                               //usps 套餐B
     if ($usps_B) {
     $result['usps_B']    = $usps_B;
     }
     
     $usps_C     = $culModel->usps_serviceC($length,$width, $hight, $weight);
     if ($usps_C) {
     $result['usps_C']    = $usps_C;
     }
     */
     $ground_re = $culModel->ground_re($weight, $zone);
     //GROUND RESIDENTIAL
     if ($ground_re) {
         $result['ground_re'] = $ground_re + $ground_re * $rate;
         //运费加燃油附加费 + 住宅运送费
     }
     $ground_co = $culModel->ground_co($weight, $zone);
     //GROUND COMMERCIAL
     if ($ground_co) {
         $result['ground_co'] = $ground_co + $ground_co * $rate + $home;
         //运费加燃油附加费
     }
     /*
              $SurePost   = $culModel->SurePost($length, $width, $hight, $weight, $zone);                            //SurePost运费
             if ($SurePost) {
             $result['SurePost']    = ($SurePost + ($SurePost*$rate));                                          //运费加燃油附加费
             }*/
     /*
      $ups        = $culModel->upsShipfee($weight);                                                          //ups运费计算
     if ($ups) {
     $result['UPS Ground']    = $ups + ($ups*$rate) + $home;
     }
     */
     $usps_gel = $culModel->uspsGeneral($weight, $zone);
     //usps通用运费计算
     if ($usps_gel) {
         $result['USPS'] = $usps_gel;
     }
     //         	print_r($result);exit;
     $mini = array('ship' => '', 'fee' => 10000);
     foreach ($result as $key => $fee) {
         if ($fee < $mini['fee']) {
             $mini['ship'] = $key;
             $mini['fee'] = $fee;
         }
     }
     // 	print_r($mini);
     // 	exit;
     /*
      if($weight_oz <= 13){//重量小于13盎司直接选USPS运输方式
     $getUspsCost = "SELECT cost FROM ow_usps_calcfree WHERE weight = '{$weight_oz}' AND unit = 'oz'";
     
     $getUspsCost = $dbcon->execute($getUspsCost);
     $getUspsCost = $dbcon->fetch_one($getUspsCost);
     $shipCost    = $getUspsCost['cost'];
     $carrier     = 'USPS';
     }else{
     $getUspsCost = "SELECT cost FROM ow_usps_calcfree WHERE weight = '{$weight_lbs}' AND zone = '{$zone}' AND unit = 'lbs'";
     $getUspsCost = $dbcon->execute($getUspsCost);
     $getUspsCost = $dbcon->fetch_one($getUspsCost);
     $uspsCost    = $getUspsCost['cost'];//USPS运费
     
     $getUpsCost  = "SELECT cost FROM ow_ups_calcfree WHERE weight = '{$weight_lbs}' AND zone = '{$zone}' AND unit = 'lbs'";
     $getUpsCost  = $dbcon->execute($getUpsCost);
     $getUpsCost  = $dbcon->fetch_one($getUpsCost);
     $upsCost     = $getUpsCost['cost'];//UPS运费
     $upsCost     = $upsCost*(1+0.07) + 2.8; //添加 燃油附加费 和住宅配送费
     
     if($uspsCost <= $upsCost){//运费对比
     $shipCost = $uspsCost;
     $carrier  = 'USPS';
     }else{
     $shipCost = $upsCost;
     $carrier  = 'UPS Ground';
     }
     if(empty($uspsCost)){
     $shipCost = $upsCost;
     $carrier  = 'UPS Ground';
     }
     }
     */
     /*------------- 运输方式选择 -------------- */
     $carrier = $culModel->carrerMap($mini['ship']);
     $shipCost = $mini['fee'];
     $extensionInfo = array();
     $returnData = array('shippingCode' => '', 'fee' => 0, 'extensionInfo' => $extensionInfo);
     if ($carrier == 'USPS') {
         //如果是usps 则需要计算对应的 packageType 和 mailClass
         $extensionInfo = $culModel->generateUSPSExtensionInfo($skuList, $weight);
         if (FALSE === $extensionInfo) {
             //不满足usps的发货条件
             self::$errMsg = OwShippingFeeCulModel::$errMsg;
             return FALSE;
         }
     }
     if ($shipCost != '' && $carrier != '') {
         $returnData['shippingCode'] = $carrier;
         $returnData['fee'] = $shipCost;
         $returnData['extensionInfo'] = $extensionInfo;
     }
     return $returnData;
 }