Beispiel #1
0
 public function act_orderWeighingFlat()
 {
     $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : "";
     $mailway = isset($_POST['channelId']) ? $_POST['channelId'] : "";
     //$partionId   = isset($_POST['partionId'])?$_POST['partionId']:"";//不作处理
     $orderweight = isset($_POST['orderweight']) ? $_POST['orderweight'] : "";
     if (!is_numeric($orderid) || empty($orderid)) {
         self::$errCode = 501;
         self::$errMsg = "错误的发货单号!";
         return false;
     }
     $where = "where id={$orderid}";
     $lists = orderWeighingModel::selectRecord($where);
     $calcweight = $lists[0]['calcWeight'] * 1000;
     //估算重量
     $userName = $_SESSION['userCnName'];
     /**重量拦截的逻辑**/
     $vip_users = C('weight_vip');
     //获取具有VIP权限的
     $lists = orderWeighingModel::selectOrderDetail($orderid);
     if (!in_array($userName, $vip_users)) {
         //判断是否具有vip操作权限
         $minRate = 0.8;
         $maxRate = 1.2;
     } else {
         $minRate = 0.5;
         $maxRate = 2;
     }
     if ($calcweight < 50 && $orderweight < 50) {
         if (abs($orderweight - $calcweight) >= 20) {
             self::$errCode = 509;
             self::$errMsg = "该订单重量与实际不符合!系统重量为{$calcweight}称重重量为{$orderweight}";
             return false;
         }
     } else {
         if (($orderweight < $calcweight * $minRate || $orderweight > $calcweight * $maxRate) && $calcweight != 0) {
             self::$errCode = 510;
             self::$errMsg = "该订单重量与实际不符合!系统重量为{$calcweight}称重重量为{$orderweight}";
             return false;
         }
     }
     TransactionBaseModel::begin();
     //更新状态,插入记录
     $userId = $_SESSION['userId'];
     $msg = orderWeighingModel::insertRecord($orderid, $userId);
     if (!$msg) {
         self::$errCode = 511;
         self::$errMsg = "插入称重记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     $msg = orderWeighingModel::updateRecord($orderid, $orderweight, $userId);
     if (!$msg) {
         self::$errCode = 512;
         self::$errMsg = "更新操作记录表失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //更新发货单实际重量和状态
     $orderData = array('orderWeight' => $orderweight, 'orderStatus' => PKS_WDISTRICT);
     $msg = WhShippingOrderModel::update($orderData, $orderid);
     //orderWeighingModel::updateStatus($orderid);
     if (!$msg) {
         self::$errCode = 513;
         self::$errMsg = "更新发货单重量和状态失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //插入运输方式跟踪号申请记录表
     $transportData = array('shipOrderId' => $orderid, 'createTime' => time());
     $msg = WhWaveOrderTransportModel::insert($transportData);
     if (!$msg) {
         self::$errCode = 514;
         self::$errMsg = "插入运输方式跟踪号记录表失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     WhPushModel::pushOrderStatus($orderid, 'PKS_WDISTRICT', $userId, time());
     //状态推送
     TransactionBaseModel::commit();
     return true;
 }
 /**
  * pda_ExpressWeighingAct::act_trackingCount()
  * @author cxy 
  *快递箱子和跟踪号数量添加到数据库
  * @return
  */
 public function act_trackingCount()
 {
     $userId = $_SESSION['userId'];
     $ebay_id = trim($_POST['ebay_id']);
     $count_box = trim(intval($_POST['count_box']));
     $tracking_count = trim(intval($_POST['tracking']));
     $weighing = trim($_POST['weighing']);
     $weighing = $weighing * 1000;
     if (empty($userId)) {
         self::$errCode = '0';
         self::$errMsg = '系统登录超时,请先关闭浏览器 然后登录扫描!!';
         return false;
     }
     if (empty($ebay_id)) {
         self::$errCode = 0;
         self::$errMsg = '请填写单号!';
         return;
     }
     if ($count_box <= 1) {
         self::$errCode = 0;
         self::$errMsg = '请输入正确的箱子数量,最小是2!';
         return false;
     }
     if ($tracking_count < 1) {
         self::$errCode = 0;
         self::$errMsg = '请输入正确的跟踪号数量,最小是1!';
         return false;
     }
     if ($weighing <= 0) {
         self::$errCode = 0;
         self::$errMsg = '请输入正确的重量!';
         return;
     }
     $where = "where id={$ebay_id}";
     $order = orderPartionModel::selectOrder($where);
     if ($order[0]['transportId'] == 48) {
         //顺丰快递的跟踪号值能是一个
         $tracking_count = 1;
     } else {
         if ($tracking_count != $count_box) {
             self::$errCode = 0;
             self::$errMsg = '跟踪号数量与箱子数量不相等!';
             return;
         }
     }
     //逻辑删除以前称重的记录
     $update = WhWaveTrackingBoxModel::update(array('is_delete' => 1), array('shipOrderId' => $ebay_id));
     $data = array('boxCount' => $count_box, 'trackingCount' => $tracking_count, 'shipOrderId' => $ebay_id, 'weighTime' => time());
     $result = WhWaveTrackingBoxModel::insert($data);
     if ($result) {
         WhBaseModel::begin();
         $status = PKS_PRINT_SHIPPING_INVOICE;
         $result = WhShippingOrderModel::update_shipping_order_by_id("id = '{$ebay_id}' and is_delete = 0", "orderStatus = '{$status}',orderWeight = '{$weighing}'");
         if (!$result) {
             WhBaseModel::rollback();
             self::$errCode = 0;
             self::$errMsg = '称重添加失败,请联系负责人';
             return false;
         }
         $msg = orderWeighingModel::insertRecord($ebay_id, $userId);
         if (!$msg) {
             self::$errCode = 511;
             self::$errMsg = "插入称重记录失败!";
             WhBaseModel::rollback();
             return false;
         }
         $msg_update = orderWeighingModel::updateRecord($ebay_id, $weighing, $userId);
         if (!$msg_update) {
             self::$errCode = 512;
             self::$errMsg = "更新操作记录表失败!";
             WhBaseModel::rollback();
             return false;
         }
         WhPushModel::pushOrderStatus($ebay_id, 'PKS_PRINT_SHIPPING_INVOICE', $_SESSION['userId'], time());
         //状态推送,需要改为待打印面单(订单系统提供状态常量)
         WhBaseModel::commit();
         self::$errCode = 200;
         self::$errMsg = '操作成功,请称重下一个发货单号';
         return true;
     } else {
         self::$errCode = 211;
         self::$errMsg = '操作失败,请联系IT部门';
         return false;
     }
 }