function act_groupGenerate() { $k = 1; $group_bool = trim($_POST['group_bool']); if (!empty($group_bool)) { $userName = $_SESSION['userName']; $create_time = strtotime(date("Y-m-d")); $time = time(); $status_info = GroupRouteModel::getOrderGroup("*", "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 = GroupRouteModel::getOrderGroup("*", "order by id desc limit 0,1"); if (empty($group_info)) { $num = 0; } else { $num = substr($group_info[0]['shipOrderGroup'], 2); } $text = ''; $bool = true; $group_infos = GroupRouteModel::getRouteIndex("*", "where user='******' order by id asc"); $count = count($group_infos); $group_amount = ceil($count / 30); for ($i = 0; $i < $group_amount; $i++) { $sku_arr = array(); for ($j = 0; $j < 30; $j++) { $route_id = $j + 30 * $i; if ($route_id == $count) { break; } $car_number = $j + 1; $shipOrderId = $group_infos[$route_id]['shipOrderId']; $sku_array = GroupRouteModel::getOrderPositionIDGroup($shipOrderId); foreach ($sku_array as $sku_detail) { $sku_arr[$sku_detail['pName']][] = array('sku' => $sku_detail['sku'], 'amount' => $sku_detail['total'], 'orders' => $shipOrderId, 'car_number' => $car_number); } } ksort($sku_arr); $group_num = $num + $k; $group_num = str_pad($group_num, 9, "0", STR_PAD_LEFT); $group_num = "PH" . $group_num; $string = ""; foreach ($sku_arr as $position => $position_info) { foreach ($position_info as $sku_info) { $string .= "('" . $sku_info['sku'] . "','" . $sku_info['amount'] . "','" . $sku_info['orders'] . "','" . $group_num . "','" . $sku_info['car_number'] . "','" . $sequence . "','" . $userName . "','" . $time . "','" . $position . "'),"; } } $string = trim($string, ","); $list_one = GroupRouteModel::insertOrderGroup($string); if ($list_one) { $text .= $group_num . "配货清单生成成功;"; } else { $text .= $group_num . "配货清单生成失败;"; $bool = false; } $k++; } if ($bool) { self::$errMsg = "订单配货分组完成,请打印"; return true; } else { self::$errCode = "003"; self::$errMsg = $text; return false; } } else { self::$errCode = "003"; self::$errMsg = "请先生成订单最优配货索引"; return false; } }
function act_getGroupInfo() { $userId = $_SESSION['userId']; $shipOrderGroup = $_POST['order_group']; $group_sql = GroupRouteModel::getOrderGroup("*", "where shipOrderGroup='{$shipOrderGroup}'"); if (empty($group_sql)) { self::$errCode = "003"; self::$errMsg = "该配货清单号不存在,请重新输入!"; return false; } else { $scan_sql = GroupDistributionModel::getGroupDistList("shipOrderGroup", "where shipOrderGroup='{$shipOrderGroup}'"); if (empty($scan_sql)) { $string = ""; $time = strtotime(date('Y-m-d H:i:s')); foreach ($group_sql as $info) { $string .= "('" . $info['shipOrderGroup'] . "','" . $info['sku'] . "','" . $info['id'] . "','" . $info['skuAmount'] . "','" . $info['shipOrderId'] . "','0','0','" . $info['carNumber'] . "','" . $info['pName'] . "','" . $userId . "','" . $time . "'),"; } $string = trim($string, ","); //插入配货清单表 $insert_info = GroupDistributionModel::insertGroupDist($string); if ($insert_info) { $show_info = array(); $show_sql = GroupDistributionModel::getGroupSkuInfo("and a.shipOrderGroup='{$shipOrderGroup}' and a.status=0 group by a.pName order by a.groupId asc"); if (!empty($show_sql)) { foreach ($show_sql as $show) { $order_sku_info = $this->get_valid_order($show['shipOrderGroup'], $show['sku'], $show['pName']); if ($order_sku_info['sku_amount'] != 0) { $show_info['group_id'] = $show['groupId']; $show_info['sku'] = $show['sku']; $show_info['sku_amount'] = $order_sku_info['sku_amount']; $show_info['goods_location'] = $show['pName']; break; } } } if (empty($show_info)) { self::$errCode = "003"; self::$errMsg = "该清单不在等待配货状态,请确认!"; return false; } else { self::$errMsg = "请扫描该配货清单下的料号!"; return $show_info; } } else { self::$errCode = "003"; self::$errMsg = "订单料号初始化出错,请重试"; return false; } } else { $iscan = GroupDistributionModel::getGroupDistList("*", "where shipOrderGroup='{$shipOrderGroup}' and status=0"); if (empty($iscan)) { self::$errCode = "003"; self::$errMsg = "该清单已扫描配货完成,请扫描其他清单!"; return false; } else { //更新配货人 $data = array('userID' => $userId); GroupDistributionModel::update($data, "and shipOrderGroup='{$shipOrderGroup}' and status=0"); //检查是否有出库过 $isout = GroupDistributionModel::getGroupDistList("*", "where shipOrderGroup='{$shipOrderGroup}' and status=1"); $show_info = array(); $show_sql = GroupDistributionModel::getGroupSkuInfo("and a.shipOrderGroup='{$shipOrderGroup}' and a.status=0 group by a.pName order by a.groupId asc"); if (!empty($show_sql)) { foreach ($show_sql as $show) { $order_sku_info = $this->get_valid_order($show['shipOrderGroup'], $show['sku'], $show['pName']); if ($order_sku_info['sku_amount'] != 0) { $show_info['group_id'] = $show['groupId']; $show_info['sku'] = $show['sku']; $show_info['sku_amount'] = $order_sku_info['sku_amount']; $show_info['goods_location'] = $show['pName']; break; } } } if (empty($show_info)) { if (empty($isout)) { self::$errCode = "003"; self::$errMsg = "该清单不在等待配货状态,请确认!"; return false; } else { self::$errCode = "003"; self::$errMsg = "该清单已扫描配货完成,请扫描其他清单!"; return false; } } else { self::$errMsg = "请扫描该配货清单下的料号!"; return $show_info; } } } } }