Esempio n. 1
0
 /**
  * 插入一条记录
  * @para $data as array
  * return insert_id
  */
 public static function insertRow($data)
 {
     self::initDB();
     $sql = array2sql($data);
     $sql = "INSERT INTO `" . self::$table . "` SET " . $sql;
     $query = self::$dbConn->query($sql);
     if ($query) {
         $insertId = self::$dbConn->insert_id();
         return $insertId;
     } else {
         self::$errCode = "003";
         self::$errMsg = "error";
         return false;
     }
 }
Esempio n. 2
0
 function act_groupGenerate()
 {
     $list_id = trim($_POST['print_list']);
     $order_all = array();
     //获取所有请求生成提货单的配货单号
     $list_info = OrderPrintListModel::getPrintList("*", "where id in({$list_id}) and storeId=2 and is_delete=0");
     if ($list_info) {
         foreach ($list_info as $info) {
             $order_arr = array();
             $order_arr = array_filter(explode(',', $info['orderIds']));
             foreach ($order_arr as $orders) {
                 $order_all[] = $orders;
             }
         }
     }
     if (empty($order_all)) {
         self::$errCode = "401";
         self::$errMsg = "配货单为空,请确认";
         return false;
     }
     if (!empty($order_all)) {
         $userName = $_SESSION['userName'];
         $create_time = strtotime(date("Y-m-d"));
         $time = time();
         $sku_arr = array();
         $status_info = GroupRouteBModel::getOrderGroupB("*", "where createdTime>'{$create_time}' and user='******' order by id desc limit 0,1");
         //当天打印次数
         if (empty($status_info)) {
             $sequence = 1;
         } else {
             $sequence = $status_info[0]['todaySequence'] + 1;
         }
         //获取当前最后一个提货单编号
         $group_info = GroupRouteBModel::getOrderGroupB("*", "order by id desc limit 0,1");
         if (empty($group_info)) {
             $num = 0;
         } else {
             $num = substr($group_info[0]['shipOrderGroup'], 3);
         }
         foreach ($order_all as $order) {
             $position_arr = GroupRouteModel::getOrderPositionID($order);
             foreach ($position_arr as $position) {
                 if ($position['storeId'] == 2) {
                     if (isset($sku_arr[$position['pName']][$position['sku']])) {
                         $sku_arr[$position['pName']][$position['sku']]['amount'] = $sku_arr[$position['pName']][$position['sku']]['amount'] + $position['amount'];
                         $sku_arr[$position['pName']][$position['sku']]['shipOrderId'] = $sku_arr[$position['pName']][$position['sku']]['shipOrderId'] . ',' . $position['shipOrderId'];
                     } else {
                         $sku_arr[$position['pName']][$position['sku']]['amount'] = $position['amount'];
                         $sku_arr[$position['pName']][$position['sku']]['shipOrderId'] = $position['shipOrderId'];
                     }
                 }
             }
         }
         ksort($sku_arr);
         $group_num = $num + 1;
         $group_num = str_pad($group_num, 9, "0", STR_PAD_LEFT);
         $group_num = "BPH" . $group_num;
         $string = "";
         foreach ($sku_arr as $position => $position_info) {
             foreach ($position_info as $sku => $sku_info) {
                 $string .= "('" . $sku . "','" . $sku_info['amount'] . "','" . $sku_info['shipOrderId'] . "','" . $group_num . "','" . $position . "','" . $sequence . "','" . $userName . "','" . $time . "'),";
             }
         }
         $string = trim($string, ",");
         if (empty($string)) {
             self::$errCode = "004";
             self::$errMsg = "没有B仓料号";
             return false;
         }
         $list_one = GroupRouteBModel::insertOrderGroupB($string);
         if ($list_one) {
             self::$errMsg = "提货单生成已完成,请打印!";
             return true;
         } else {
             self::$errCode = "003";
             self::$errMsg = "提货单生成失败,请联系it!";
             return false;
         }
     } else {
         self::$errCode = "003";
         self::$errMsg = "请选择打印列表";
         return false;
     }
 }
Esempio n. 3
0
 public function act_applyforB()
 {
     $pid = isset($_GET['pid']) ? trim($_GET['pid']) : 0;
     if ($pid == '') {
         self::$errCode = 0;
         self::$errMsg = '输入非法值!';
         return;
     }
     $idar = explode(',', $pid);
     foreach ($idar as $key => $idval) {
         $idar[$key] = intval($idval);
     }
     $o_count = count($idar);
     $orderist = OrderPrintListModel::getPrintList('*', ' where id in (' . implode(',', $idar) . ') and status!=1001 and storeId=2');
     $n_count = count($orderist);
     if ($o_count != $n_count) {
         self::$errCode = 0;
         self::$errMsg = '申请提货不能包含未打印地址条订单或包含A仓订单';
         return;
     }
     $oidar = array();
     //发货单id数组
     foreach ($orderist as $orlval) {
         //验证合法性
         if ($orlval['is_delete'] == 1) {
             $data = array('data' => array('包含已经删除单号!', '单号id为' . $orlval['id']), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
             goErrMsgPage($data);
             exit;
         }
         $tempar = explode(',', $orlval['orderIds']);
         $oidar = array_merge($oidar, $tempar);
     }
     $po_obj = new PackingOrderModel();
     $qresult = $po_obj->changeStatusToWaitGetGoodsB(implode(',', $oidar));
     OrderPrintListModel::deleteAsetOfPrint(implode(',', $idar));
     printLabelModel::inserRecords($oidar, $_SESSION['userId']);
     if ($qresult) {
         $time = time();
         self::$errCode = 1;
         self::$errMsg = '申请成功';
         return;
     } else {
         self::$errCode = 0;
         self::$errMsg = '失败';
         return FALSE;
     }
 }
Esempio n. 4
0
 function act_groupIndex()
 {
     $userName = $_SESSION['userName'];
     $order_all = array();
     $status = '';
     $list_id = trim($_POST['print_list']);
     if (empty($list_id)) {
         return "-[<font color='#FF0000'>配货单为空,请确认</font>]-";
         exit;
     }
     //清空数据库本人记录
     GroupRouteModel::delRouteIndex("where user='******'");
     //获取所有请求生成配货清单的配货单号
     $list_info = OrderPrintListModel::getPrintList("*", "where id in({$list_id}) and storeId=1 and is_delete=0");
     if ($list_info) {
         foreach ($list_info as $info) {
             $order_arr = array();
             $order_arr = array_filter(explode(',', $info['orderIds']));
             foreach ($order_arr as $orders) {
                 $order_all[] = $orders;
             }
         }
     }
     if (empty($order_all)) {
         return "-[<font color='#FF0000'>配货单为空,请确认</font>]-";
         exit;
     }
     for ($level = 8; $level > 0; $level--) {
         $order_index = array();
         if ($level == 1) {
             //剩下的全公司订单
             $string = '';
             $order_res = array();
             foreach ($order_all as $order) {
                 $now_order_info = GroupRouteModel::getRouteIndex("*", "where shipOrderId={$order} and user='******'");
                 if (!$now_order_info) {
                     $location_info = array();
                     $position_arr = GroupRouteModel::getOrderPositionIDGroup($order);
                     foreach ($position_arr as $position) {
                         $location_info[] = $position['pName'];
                     }
                     sort($location_info);
                     $order_res[$order] = $location_info[0];
                 }
             }
             asort($order_res);
             foreach ($order_res as $ord => $value) {
                 $string .= "('" . $ord . "','" . $level . "','" . $userName . "'),";
             }
             $string = trim($string, ",");
             if (!empty($string)) {
                 $list_one = GroupRouteModel::insertRouteIndex($string);
                 if ($list_one) {
                     $status .= " -[<font color='#33CC33'>操作记录: " . $level . "级索引生成成功</font>]<br/>";
                     $status .= " -[<font color='#33CC33'>操作记录: 订单生产最优配货组完成,请输入打印预览条数进行打印</font>]<br/>";
                     $status .= " -[<font color='#33CC33'>温馨提示: 生成配货索引后请不要刷新该页面,如刷新会重新生成,可能造成数据出错</font>]";
                     return $status;
                     //	$order_count = GroupRouteModel::getRouteIndexNum("where user='******'");
                     //	$group_bool = 1;
                 } else {
                     $status .= " -[<font color='#FF0000'>操作记录: " . $level . "级索引生成失败</font>]<br/>";
                     $status .= " -[<font color='#FF0000'>操作记录: 订单生产最优配货组失败,请重试</font>]";
                     return $status;
                 }
             } else {
                 $status .= " -[<font color='#33CC33'>操作记录: 订单生产最优配货组完成,请输入打印预览条数进行打印</font>]<br/>";
                 $status .= " -[<font color='#33CC33'>温馨提示: 生成配货索引后请不要刷新该页面,如刷新会重新生成,可能造成数据出错</font>]";
                 return $status;
             }
         } else {
             $string = '';
             $level_info = PositionModel::getPositonIndexList("*", "where level='{$level}'");
             //仓位级别索引
             foreach ($order_all as $order) {
                 $now_order_info = GroupRouteModel::getRouteIndex("*", "where shipOrderId={$order} and user='******'");
                 if (!$now_order_info) {
                     $position_arr = GroupRouteModel::getOrderPositionID($order);
                     //记录订单sku可能存在的级别里面的某个模块
                     if (!empty($position_arr)) {
                         foreach ($level_info as $levels) {
                             $bool = true;
                             $position_id = array_filter(explode(',', $levels['positionId']));
                             foreach ($position_arr as $position) {
                                 if (!in_array($position['positionId'], $position_id)) {
                                     $bool = false;
                                     break;
                                 }
                             }
                             if ($bool) {
                                 $order_index[$levels['piece']][] = $order;
                                 break;
                             }
                         }
                     }
                 }
             }
             foreach ($order_index as $key => $index) {
                 $piece_count = count($index);
                 //30单为配货单位
                 if ($piece_count < 30) {
                     unset($order_index[$key]);
                 } else {
                     $del_num = $piece_count % 30;
                     //for($i=0;$i<$del_num;$i++){
                     for ($i = $piece_count - 1; $i >= $piece_count - $del_num; $i--) {
                         unset($order_index[$key][$i]);
                     }
                 }
             }
             if (!empty($order_index)) {
                 foreach ($order_index as $order) {
                     foreach ($order as $o) {
                         $string .= "('" . $o . "','" . $level . "','" . $userName . "'),";
                     }
                 }
             }
             $string = trim($string, ",");
             if (!empty($string)) {
                 $list_one = GroupRouteModel::insertRouteIndex($string);
                 if ($list_one) {
                     $status .= " -[<font color='#33CC33'>操作记录: " . $level . "级索引生成成功</font>]<br/>";
                 } else {
                     $status .= " -[<font color='#FF0000'>操作记录: " . $level . "级索引生成失败</font>]<br/>";
                 }
             }
             //print_r($order_index);
         }
     }
 }
Esempio n. 5
0
 public function view_printASetOfOrder()
 {
     $pid = isset($_GET['pid']) ? trim($_GET['pid']) : 0;
     if (empty($pid)) {
         $data = array('data' => array('没指定单号!'), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
         goErrMsgPage($data);
         exit;
     }
     $idar = explode(',', $pid);
     foreach ($idar as $key => $idval) {
         $idar[$key] = intval($idval);
     }
     $orderist = OrderPrintListModel::getPrintList('*', ' where id in (' . implode(',', $idar) . ')');
     if (empty($orderist)) {
         //订单不存在
         $data = array('data' => array('单号不合法!'), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
         goErrMsgPage($data);
         exit;
     }
     $oidar = array();
     //发货单id数组
     foreach ($orderist as $orlval) {
         //验证合法性
         if ($orlval['status'] != PR_WPRINT) {
             //不在待打印的返回
             $data = array('data' => array('包含非待打印单号!', '单号id为' . $orlval['id']), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
             goErrMsgPage($data);
             exit;
         }
         if ($orlval['is_delete'] == 1) {
             $data = array('data' => array('包含已经删除单号!', '单号id为' . $orlval['id']), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
             goErrMsgPage($data);
             exit;
         }
         $tempar = explode(',', $orlval['orderIds']);
         $oidar = array_merge($oidar, $tempar);
     }
     $type = isset($_GET['type']) ? intval($_GET['type']) : 0;
     $printtypearray1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 31, 32, 33, 311, 312);
     $printtypearray2 = array(11, 12, 13, 31, 32, 33, 34, 35, 14, 15, 16, 17, 71, 72, 73, 74, 18, 19, 91, 92, 93, 94, 110, 131, 132, 133, 134, 135, 161, 162, 163, 164, 181, 182, 183, 184);
     if (!in_array($type, $printtypearray1) && !in_array($type, $printtypearray2)) {
         $data = array('data' => array('请指定正确的打印类型!'), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
         goErrMsgPage($data);
         exit;
     }
     $lockresult = OrderPrintListModel::lockPrint($idar);
     //加锁
     if ($lockresult == false) {
         $data = array('data' => array('加锁失败!'), 'link' => 'index.php?mod=orderWaitforPrint&act=printList');
         goErrMsgPage($data);
         exit;
     }
     if (in_array($type, $printtypearray1)) {
         $this->printDispatchOrder(implode(',', $oidar), $type);
     } else {
         if (in_array($type, $printtypearray2)) {
             $this->printTaobaoMore(implode(',', $oidar), $type);
         }
     }
 }