123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Review extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_api','api');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_fullorderxw','fullorderxw');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_hl','hl');
- $this->load->_model('Model_is','is');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_customer','customer');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_whlabel','whlabel');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'isorder')//添加
- {
- $this->_isorder();
- }
- else if($arg == 'kcyz')//库存验证
- {
- $this->_kcyz();
- }
- else
- {
- $this->_index($arg_array);
- }
- }
- public function _index($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $a = "";$b = 3;
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',rtrim($id_arr,','));
- $review = $this->input->post('review',true);
- $sb = 0;
- $fu = $arg_array[0];
- foreach ($id_arr as $v)
- {
- $fullorder = $this->$fu->read($v);
- if(!isset($fullorder))
- {
- $sb++;
- continue;
- }
- if($fullorder['print'] < 3)
- {
- $a = "订单未打印,";
- $b = 2;
- }
- /**
- if(($fullorder['budget'] > $fullorder['cost'] && $fullorder['review']==1) || $fullorder['source']==1)
- {
- $review = 6;
- }
- **/
- if($review == 3)
- {
- $review = 3;
- }
- else if($fullorder['source'] == 1 && $review == 2)
- {
- $review = 2;
- }
- else
- {
- /**
- $kcyz = $this->_kcyz($v,$fu);
- if($kcyz != 1)
- {
- echo json_encode(array('msg'=>$kcyz,'success'=>true));exit;
- }
- **/
- $review = 6;
- }
- if($fullorder['review'] > 4)//$review == 2
- {
- echo json_encode(array('msg'=>'已有提交操作,系统已刷新最新状态','success'=>true));exit;
- }
- $this->$fu->save(array('review'=>$review,'reviewtime'=>time(),'librarynot'=>$a,'print'=>$b),$v);
- }
- if(count($id_arr) > 1)
- {
- echo json_encode(array('msg'=>'操作完成!'.$sb.'条订单异常','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'操作完成!鼠标任意点击关闭'.$review.' - '.$fullorder['review'],'success'=>true));exit;
- }
- }
- }
- function _kcyz($id,$fu)
- {
- if(isset($id))
- {
- $data = $this->$fu->read($id);
- if($data['type'] != 5)//目前只有美店验证仓库
- {
- return 1;exit;
- }
- $warehouse = $data['type'];
- $shop = $data['shop'];
- $whlabel = $data['whlabel'];
- if(!$whlabel)
- {
- return '请先添加产品信息!';exit;
- }
- $save = array();$x=0;
- $pp = explode('|',trim($whlabel,'|'));
- $asd = array();
- foreach ($pp as $va)
- {
- $ckcg = 0;
- $num = explode('-',$va);
- $ftime = time()-30*24*3600;
- $order = $this->fullorder->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
- $order2 = $this->fullorder_smt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
- $order3 = $this->fullordersmt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
- $whlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (shop IS NULL or shop = '')");
- $shopwhlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and shop like '%,".$shop.",%'");
-
- $od = 0;
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $num[0])
- {
- $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
- if($zs < 1)
- {
- $od += $orod[1];
- }
- }
- }
- }
- foreach ($order2 as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $num[0])
- {
- $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
- if($zs < 1)
- {
- $od += $orod[1];
- }
- }
- }
- }
- foreach ($order3 as $v)
- {
- $or = explode('|',ltrim($v['whlabel'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $num[0])
- {
- $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
- if($zs < 1)
- {
- $od += $orod[1];
- }
- }
- }
- }
- if(($whlabel+$shopwhlabel < 1) || ($shopwhlabel+$whlabel-$od) < $num[1])
- {
- $save[] = $x;
- }
- $x++;
- //$asd[] = $whlabel.'!'.$shopwhlabel.'!!'.$od.'~'.$num[1].'-'.count($order);
- }
- if(count($save) > 0)
- {
- return "库存匹配错误或库存不够扣减";exit;
- }
- else
- {
- return 1;exit;
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- }
|