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 act_overWeightSplit()
 {
     $omOrderIds = isset($_POST['omOrderIds']) ? $_POST['omOrderIds'] : '';
     //选中要拆分的订单
     //var_dump($omOrderIds); exit;
     if (empty($omOrderIds)) {
         self::$errCode = '0061';
         self::$errMsg = "empty omOrderIds";
         return false;
     }
     $omOrderIdArr = array_filter(explode(',', $omOrderIds));
     if (empty($omOrderIdArr)) {
         self::$errCode = '0062';
         self::$errMsg = "error moOrderIdArr";
         return false;
     }
     try {
         $OrderindexAct = new OrderindexAct();
         $OrderRecordAct = new OrderRecordAct();
         //BaseModel :: begin();
         foreach ($omOrderIdArr as $omOrderId) {
             $skuinfos = $OrderindexAct->act_getRealskulist($omOrderId);
             //var_dump($skuinfos); echo "<br>";
             $issend = $OrderRecordAct->act_judgeAuditRecordsInSkus($omOrderId, $skuinfos);
             //var_dump($issend); exit;
             if (!$issend) {
                 $flag = SplitOrderModel::overWeightSplit($omOrderId);
                 //拆分订单
                 if (!$flag) {
                     self::$errCode = SplitOrderModel::$errCode;
                     self::$errMsg = SplitOrderModel::$errMsg;
                     return false;
                 }
             }
         }
         self::$errCode = SplitOrderModel::$errCode;
         self::$errMsg = SplitOrderModel::$errMsg;
         return true;
     } catch (Exception $e) {
         self::$errCode = '404';
         self::$errMsg = "split in ones error";
         return $flag;
         //返回splitOverWeightOrderForOne中的错误return值
     }
 }
echo "--------- 同步海外仓已打印订单  [ {$currentTime} ] ---------\n";
$sql = "select * from om_unshipped_order where orderStatus=900 and orderType=910";
$resultData = $dbConn->fetch_array_all($dbConn->query($sql));
$owOrderMg = new OwOrderManageModel();
$orderAct = new OrderindexAct();
$orderSync = new OwOrderSyncModel();
foreach ($resultData as $row) {
    $orderId = $row['id'];
    $userSql = "select * from om_unshipped_order_userInfo where omOrderId = '{$orderId}'";
    $UserInfo = $dbConn->fetch_first($userSql);
    //获取用户信息
    if (empty($UserInfo)) {
        echo "订单未找到用户信息 [订单号:] === {$orderId} \n\n";
        continue;
    }
    $skuList = $orderAct->act_getRealskulist($orderId);
    //获取sku信息列表
    if (empty($skuList)) {
        echo "无法获取该订单的料号信息 [订单号:] === {$orderId} \n\n";
        continue;
    }
    $transInfo = $owOrderMg->getShippingInfo($orderId);
    if (empty($transInfo)) {
        //获取运输方式信息
        echo "无法获取该订单运输方式信息 [订单号:] === {$orderId} \n\n";
        continue;
    }
    $platformInfo = $owOrderMg->getPlatformInfoByPid($row['platformId']);
    if (FALSE == $platformInfo) {
        echo "获取平台信息失败!!!";
        continue;
Beispiel #4
0
 public function view_syncLocalPickUpOrder()
 {
     $orderId = isset($_GET['orderId']) ? $_GET['orderId'] : FALSE;
     $returnData = array('code' => 0, 'msg' => '');
     if (FALSE == $orderId) {
         $returnData['msg'] = ' 未指定订单号';
         echo json_encode($returnData);
         exit;
     }
     $owOrderMg = new OwOrderManageModel();
     $orderInfo = $owOrderMg->getOrderInfoById($orderId, '*');
     if (FALSE == $orderInfo) {
         $returnData['msg'] = '不存在的订单';
         echo json_encode($returnData);
         exit;
     }
     if ($orderInfo['orderStatus'] != 911 || $orderInfo['orderType'] != 928) {
         $returnData['msg'] = '该订购单不是上门取件订单';
         echo json_encode($returnData);
         exit;
     }
     $orderAct = new OrderindexAct();
     $orderSync = new OwOrderSyncModel();
     $skuList = $orderAct->act_getRealskulist($orderId);
     //获取sku信息列表
     if (empty($skuList)) {
         $returnData['msg'] = '未找到sku';
         echo json_encode($returnData);
         exit;
     }
     $transInfo = $owOrderMg->getShippingInfo($orderId);
     if (empty($transInfo)) {
         //获取运输方式信息
         $transInfo = array('shippingWay' => 'localPickup', 'tracknumber' => '');
     }
     $platformInfo = $owOrderMg->getPlatformInfoByPid($orderInfo['platformId']);
     if (FALSE == $platformInfo) {
         $returnData['msg'] = '无法获取平台信息';
         echo json_encode($returnData);
         exit;
     }
     $platSuffix = $platformInfo['suffix'];
     $extensionTabel = 'om_unshipped_order_extension_' . $platSuffix;
     //扩展信息表名
     $extensionInfo = $owOrderMg->getExtensionInfo($extensionTabel, $orderId);
     if ($extensionInfo) {
         if ("amazon" == $platSuffix) {
             //亚马逊订单
             $orderInfo['note'] = $extensionInfo['note'];
         } else {
             if ('ebay' == $platSuffix) {
                 //ebay订单
                 $orderInfo['note'] = $extensionInfo['feedback'];
             }
         }
     }
     $UserInfo = $owOrderMg->getBuyerInfoById($orderId);
     $sellerInfo = $owOrderMg->getSellerInfoById($orderInfo['accountId']);
     //获得卖家账号信息
     if ($sellerInfo) {
         $orderInfo['account'] = $sellerInfo['ebay_account'];
     } else {
         $orderInfo['account'] = '';
     }
     $orderInfo['putstatus'] = 16;
     $submitData = array('orderInfo' => $orderInfo, 'userInfo' => $UserInfo, 'transInfo' => $transInfo, 'skuList' => $skuList);
     //         print_r($submitData);exit;
     $reuslt = $orderSync->pushPrintedOrderToUsWh($orderId, $submitData);
     if (TRUE == $reuslt) {
         $returnData['code'] = 1;
     } else {
         $returnData['msg'] = OwOrderSyncModel::$errMsg;
     }
     echo json_encode($returnData);
 }
Beispiel #5
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;
 }