Пример #1
0
 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');
 }
Пример #2
0
 public function view_updateOrderStatus()
 {
     $returnData = array('code' => 0, 'Msg' => '');
     $orderId = isset($_GET['orderId']) ? $_GET['orderId'] : FALSE;
     $status_1 = isset($_GET['status_1']) ? $_GET['status_1'] : FALSE;
     $status_2 = isset($_GET['status_2']) ? $_GET['status_2'] : FALSE;
     //         print_r($_GET);exit;
     if (FALSE === $orderId || FALSE === $status_1 || FALSE === $status_2) {
         $returnData['code'] = 0;
         $returnData['Msg'] = '参数不完整!';
         echo json_encode($returnData);
         exit;
     }
     $orderMg = new OwOrderManageModel();
     $orderInfo = $orderMg->getOrderInfoById($orderId, array('orderStatus', 'orderType'));
     if (FALSE === $orderInfo) {
         $returnData['code'] = 0;
         $returnData['Msg'] = '不存在的订单!';
         echo json_encode($returnData);
         exit;
     }
     /* if ( 911!=$orderInfo['orderStatus'] || 917!=$orderInfo['orderType']) {
            $returnData['code']    = 0;
            $returnData['Msg']     = '当前订单状态不可改变!';
            echo json_encode($returnData);
            exit;
        } */
     $result = $orderMg->changeOrderStatus($status_1, $status_2, $orderId);
     if ($result) {
         $returnData['code'] = 1;
         $returnData['Msg'] = '更新成功!';
         echo json_encode($returnData);
         exit;
     } else {
         $returnData['code'] = 0;
         $returnData['Msg'] = '更新失败!';
         echo json_encode($returnData);
         exit;
     }
 }
Пример #3
0
            $row['note'] = $extensionInfo['note'];
        } else {
            if ('ebay' == $platSuffix) {
                //ebay订单
                $row['note'] = $extensionInfo['feedback'];
            }
        }
    }
    $sellerInfo = $owOrderMg->getSellerInfoById($row['accountId']);
    //获得卖家账号信息
    if ($sellerInfo) {
        $row['account'] = $sellerInfo['ebay_account'];
    } else {
        $row['account'] = '';
    }
    $submitData = array('orderInfo' => $row, 'userInfo' => $UserInfo, 'transInfo' => $transInfo, 'skuList' => $skuList);
    //     print_r($submitData);
    $syncResult = $orderSync->pushPrintedOrderToUsWh($orderId, $submitData);
    if ($syncResult) {
        //同步成功
        $return = $owOrderMg->changeOrderStatus(911, 917, $orderId);
        if ($return) {
            echo "同步订单成功! 订单号 : {$orderId}  === [ {$currentTime} ]\n\n\n";
        } else {
            echo "更新数据库状态出错: {$orderId} === ", "\n\n\n";
        }
    } else {
        echo "同步出错: {$orderId} === ", OwOrderSyncModel::$errMsg, "\n\n\n";
    }
}
echo "done my work !!! [ {$currentTime} ]\n\n\n";
Пример #4
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;
 }