load->_model("Model_whlabel_bh_transfer",'whlabel_bh_transfer'); $this->load->_model("Model_whlabel_bh_scan",'whlabel_bh_scan'); $this->load->_model("Model_logic_u9tools","logic_u9tools"); $this->load->_model("Model_whlabellabel","whlabellabel"); $this->load->_model('Model_purchase', 'purchase'); $this->load->_model('Model_whlabel_type', 'whlabel_type'); $this->load->_model("Model_shop","shop"); $this->load->_model("Model_warehouse","warehouse"); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg, $arg_array) { if ($arg == 'scam_mgxx') // { $this->_scanMgxx(); } else if($arg =='scam_mgxx_post') { $this->_scanMgxxPost(); }else if($arg == 'mgxxindex'){ $this->_mgxxindex(); } else if($arg == 'get_scan_info'){ $this->_getScanInfo(); } else if($arg =='typedy'){ $this->_typedy(); } else { $this->_index(); } } private function _index(){ die('No direct script access allowed'); } private function _mgxxindex(){ $post = $this->input->post(); if(!empty($post)){ $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([])); echo json_encode($rows);exit; } $this->_Template('whlabelfz1_mgxxindex', $this->data); } //美国销售 扫描出库的 private function _scanMgxx(){ $post = $this->input->post(); if(!empty($post)){ $type = $this->input->post('type',true); $orderinfo = $this->input->post('orderinfo',true); $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $where = " type = ".$type." and orderinfo = '".(string)$orderinfo."' "; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $order_str = 'id desc'; $info_list = $this->whlabel_bh_scan->find_all($where,'id,orderinfo,pm,label,sl,scantime',$order_str,$start,$perpage); $total = $this->whlabel_bh_scan->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); foreach($info_list as $k=>$v){ $info_list[$k]['scantime'] = date('Y-m-d H:i:s',$v['scantime']); } $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; }else{ $orderinfo = $this->input->get('orderinfo',true); $type = $this->input->get('type',true); $this->data['orderinfo'] = $orderinfo; $this->data['type'] = $type; $this->_Template('whlabelfz1_scammgxx', $this->data); } } private function _getScanInfo(){ $post = $this->input->post(); $label = $post['label']; if(empty($label)){ die(json_encode(['code'=>-1,'msg'=>'请输入标签号','data'=>[]])); } $info = $this->whlabel_bh_transfer->find("label ='".$label."'"); if(empty($info)){ die(json_encode(['code'=>-1,'msg'=>'标签号不存在','data'=>[]])); } echo "
";
print_r($info);
die;
}
//接收美店销售的post提交
private function _scanMgxxPost(){
$post = $this->input->post();
$type = $post['type'];
$orderinfo = $post['orderinfo'];
$label = $post['scanlabel'];
$num = (int)$post['num'];
if(empty($type)){
exit(json_encode(['code'=>-1,'msg'=>'数据类型异常,请联系技术','data'=>[]],JSON_UNESCAPED_UNICODE));
}
if(empty($orderinfo)){
exit(json_encode(['code'=>-1,'msg'=>'美国销售单号未输入','data'=>[]],JSON_UNESCAPED_UNICODE));
}
if(empty($label)){
exit(json_encode(['code'=>-1,'msg'=>'标签号不能为空','data'=>[]],JSON_UNESCAPED_UNICODE));
}
if(!in_array($type,[1,2])){
exit(json_encode(['code'=>-1,'msg'=>'数据类型异常,请联系技术','data'=>[],JSON_UNESCAPED_UNICODE]));
}
if($type == 1){
$num = 1;
}
if($type == 2){
if($num > 200){
exit(json_encode(['code'=>-1,'msg'=>'扫描数量不能大于200','data'=>[],JSON_UNESCAPED_UNICODE]));
}
}
$info = $this->whlabel_bh_scan->find("label ='".$label."'");
if(!empty($info)){
exit(json_encode(['code'=>-1,'msg'=>'该标签已被扫描','data'=>[],JSON_UNESCAPED_UNICODE]));
}
if($type == 1){
$res = $this->_bbscan($orderinfo,$label);
}elseif($type == 2){
$res = $this->_bqscan($orderinfo,$label,$num);
}
exit(json_encode($res));
}
//生产布标扫描
private function _bbscan($orderinfo,$label){
$info = $this->whlabel_bh_transfer->find("label ='".$label."'");
if(empty($info)){
return ['code'=>-1,'msg'=>'标签号不存在','data'=>[]];
}
if($info['label'] != $label){
return ['code'=>-1,'msg'=>'条码对应的美国销售单号不一致','data'=>[]];
}
$arr = [
'orderinfo'=>(string)$orderinfo,
'type'=>1,
'label'=>(string)$label,
'features'=>(string)$info['features'],
'fid'=>$info['id'],
'jm'=>$info['jm'],
'pm'=>$info['pm'],
'sl'=>1,
'scantime'=>time(),
'status'=>0,
];
$this->whlabel_bh_scan->insert($arr);
return ['code'=>1,'msg'=>'标签扫描成功','data'=>[]];
}
//标签扫描
private function _bqscan($orderinfo,$label,$num){
$info = $this->whlabellabel->find("label ='".$label."'");
if(empty($info)){
return ['code'=>-1,'msg'=>'标签号不存在','data'=>[]];
}
$list = [
[
'sku2'=>$info['features'],
]
];
$res = $this->logic_u9tools->getU9bm($list,'sku2');
if(empty($res[0])){
return ['code'=>-1,'msg'=>'u9条码编辑错误-1','data'=>[]];
}
if(empty($res[0]['jm'])){
return ['code'=>-1,'msg'=>'u9条码编辑异常-2','data'=>[]];
}
$arr = [
'orderinfo'=>(string)$orderinfo,
'type'=>1,
'label'=>(string)$label,
'features'=>(string)$info['features'],
'fid'=>$info['id'],
'jm'=>$res[0]['jm'],
'pm'=>$res[0]['zh'],
'sl'=>$num,
'scantime'=>time(),
'status'=>0,
];
$this->whlabel_bh_scan->insert($arr);
return ['code'=>1,'msg'=>'标签扫描成功','data'=>[]];
}
// 可以排序的仓库数量
private function _typedy(){
$prc = array();
$purchase = $this->purchase->find_all();
foreach ($purchase as $k => $v) {
$prc[$v['id']] = $v['title'];
}
$post = $this->input->post(NULL, TRUE);
if (isset($post['page'])) {
$page = $this->input->post('page', true);
$perpage = $this->input->post('perpage', true);
$category = $this->input->post('category', true);
$warehouse = $this->input->post('warehouse', true);
//这里的仓库是隐藏传递的所以不需要判断
$where_sql = " state = 0 and warehouse and ".$warehouse." ";
if(!empty($post['purchase'])){
$where_sql .= " and purchase = ".$post['purchase']." ";
}
if(!empty($post['type'])){
$where_sql .= " and type = ".$post['type']." ";
}
if(!empty($post['category'])){//类目
$where_sql .= " and features like '%-".$post['category']."-%' ";
}
if(!empty($post['grade'])){//等级
$where_sql .= " and grade like '%-".$post['grade']."-%' ";
}
if(!empty($post['color'])){//颜色
$where_sql .= " and color like '%-".$post['color']."-%' ";
}
if(!empty($post['lowe'])){//曲度
$where_sql .= " and lowe like '%-".$post['lowe']."-%' ";
}
if(!empty($post['lacetype'])){//头套种类
$where_sql .= " and lacetype like '%-".$post['lacetype']."-%' ";
}
if(!empty($post['lacecolor'])){//头套颜色
$where_sql .= " and lacecolor like '%-".$post['lacecolor']."-%' ";
}
if(!empty($post['size'])){//尺寸
$where_sql .= " and size like '%-".$post['size']."-%' ";
}
if(!empty($post['density'])){//密度
$where_sql .= " and density like '%-".$post['density']."-%' ";
}
if(!empty($post['haircap'])){
$where_sql .= " and haircap like '%-".$post['haircap']."-%' ";
}
if(!empty($post['hairnumber'])){
$where_sql .= " and hairnumber like '%-".$post['hairnumber']."-%' ";
}
if(!empty($post['cklx'])){
$shop_info = $this->shop->read($post['cklx']);
if(!empty($shop_info)){
$where_sql .= " and zd like '%-".$shop_info['shortname']."-%' ";
}
}
if(!empty($post['sku'])){
$sku = trim($post['sku'], ' ');
$sku = trim($sku, ' ');
$where_sql .= " and sku like '%-".$sku."-%' ";
}
if(!empty($post['title'])){
$title = trim($post['title']);
$where_sql .= " and title like '%". $title ."%' ";
}
if(!empty($post['cpbz'])){
$cpbz = trim($post['cpbz']);
$where_sql .= " and cpbz like '%". $cpbz ."%' ";
}
if(!empty($post['sm'])){
$sm = trim($post['sm']);
$where_sql .= " and sm like '%". $sm ."%' ";
}
if (empty($page)) {
$start = 0;
$perpage = 1;
} else {
$start = ($page - 1) * $perpage;
}
var_dump($where_sql);
die;
$get_model = $this->db->from("whlabel")->where($where_sql)->select("id,number,purchase,sku,warehouse,title,details,cpid,COUNT(id) AS total_num")->group_by('number');
if(!empty($post['dopx'])){
if($post['dopx'] == 1){
$get_model = $get_model->order_by("total_num",'ASC');
}
if($post['dopx'] == 2){
$get_model = $get_model->order_by("total_num",'DESC');
}
}
$list = $get_model->limit($perpage,$start)->get()->result_array();
$warehouse_info = $this->warehouse->read($warehouse);
$final_list = [];
foreach($list as $k => $v){
$final_list[$k]['id'] = $v['id'];
$final_list[$k]['warehous'] = $warehouse_info['title'];
$final_list[$k]['purchase'] = $prc[$v['purchase']];
$final_list[$k]['sku'] = $v['sku'];
$final_list[$k]['title'] = $v['title'];
$final_list[$k]['details'] = $v['details']."
".$v['cpid'];
$final_list[$k]['total_num'] = $v['total_num'];
$final_list[$k]['zt'] = "";
$final_list[$k]['zd'] = "";
}
$total = $this->db->from("whlabel")->where($where_sql)->select("id,number,sku,warehouse,title,details,cpid,COUNT(id) AS total_num")->group_by('number')->count_all_results();
$pagenum = ceil($total / $perpage);
$over = $total - ($start + $perpage);
$rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_list), 'CS' => $warehouse);
echo json_encode($rows);
exit;
}
$this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
$this->_Template('whlabelfz1_typedy', $this->data);
}
}