Review.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Review extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_api','api');
  7. $this->load->_model('Model_shop','shop');
  8. $this->load->_model('Model_fullorder','fullorder');
  9. $this->load->_model('Model_fullordertt','fullordertt');
  10. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  11. $this->load->_model('Model_fullordersmt','fullordersmt');
  12. $this->load->_model('Model_fullorderxw','fullorderxw');
  13. $this->load->_model('Model_fullorderamz','fullorderamz');
  14. $this->load->_model('Model_country','country');
  15. $this->load->_model('Model_hl','hl');
  16. $this->load->_model('Model_is','is');
  17. $this->load->_model('Model_kdniao','kdniao');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_warehouse','warehouse');
  20. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_customer','customer');
  23. $this->load->_model('Model_express','express');
  24. $this->load->_model('Model_notice','notice');
  25. $this->load->_model('Model_whlabel','whlabel');
  26. }
  27. //定义方法的调用规则 获取URI第二段值
  28. public function _remap($arg,$arg_array)
  29. {
  30. if($arg == 'isorder')//添加
  31. {
  32. $this->_isorder();
  33. }
  34. else if($arg == 'kcyz')//库存验证
  35. {
  36. $this->_kcyz();
  37. }
  38. else
  39. {
  40. $this->_index($arg_array);
  41. }
  42. }
  43. public function _index($arg_array)
  44. {
  45. $post = $this->input->post(NULL, TRUE);
  46. if(isset($post['s']))
  47. {
  48. $a = "";$b = 3;
  49. $id_arr = $this->input->post('s');
  50. $id_arr = explode(',',rtrim($id_arr,','));
  51. $review = $this->input->post('review',true);
  52. $sb = 0;
  53. $fu = $arg_array[0];
  54. $fulltt_str = "";
  55. foreach ($id_arr as $v)
  56. {
  57. $fullorder = $this->$fu->read($v);
  58. if($fu == 'fullordertt'){
  59. if($fullorder['is_edit'] == 0){
  60. $fulltt_str.= $fullorder['number'].',';
  61. continue;
  62. //echo json_encode(array('msg'=>$fullorder['number'].',请保存后再提交审核!','success'=>true));exit;
  63. }
  64. }
  65. if(!isset($fullorder))
  66. {
  67. $sb++;
  68. continue;
  69. }
  70. if($fullorder['print'] < 3)
  71. {
  72. $a = "订单未打印,";
  73. $b = 2;
  74. }
  75. /**
  76. if(($fullorder['budget'] > $fullorder['cost'] && $fullorder['review']==1) || $fullorder['source']==1)
  77. {
  78. $review = 6;
  79. }
  80. **/
  81. if($review == 3)
  82. {
  83. $review = 3;
  84. }
  85. else if($fullorder['source'] == 1 && $review == 2)
  86. {
  87. $review = 2;
  88. }
  89. else
  90. {
  91. /**
  92. $kcyz = $this->_kcyz($v,$fu);
  93. if($kcyz != 1)
  94. {
  95. echo json_encode(array('msg'=>$kcyz,'success'=>true));exit;
  96. }
  97. **/
  98. $review = 6;
  99. }
  100. if($fullorder['review'] > 4)//$review == 2
  101. {
  102. echo json_encode(array('msg'=>'已有提交操作,系统已刷新最新状态','success'=>true));exit;
  103. }
  104. $this->$fu->save(array('review'=>$review,'reviewtime'=>time(),'librarynot'=>$a,'print'=>$b),$v);
  105. }
  106. if($fulltt_str != "")
  107. {
  108. echo json_encode(array('msg'=>$fulltt_str.'请保存后再提交审核!','success'=>true));exit;
  109. }
  110. if(count($id_arr) > 1)
  111. {
  112. echo json_encode(array('msg'=>'操作完成!'.$sb.'条订单异常','success'=>true));exit;
  113. }
  114. else
  115. {
  116. echo json_encode(array('msg'=>'操作完成!鼠标任意点击关闭'.$review.' - '.$fullorder['review'],'success'=>true));exit;
  117. }
  118. }
  119. }
  120. function _kcyz($id,$fu)
  121. {
  122. if(isset($id))
  123. {
  124. $data = $this->$fu->read($id);
  125. if($data['type'] != 5)//目前只有美店验证仓库
  126. {
  127. return 1;exit;
  128. }
  129. $warehouse = $data['type'];
  130. $shop = $data['shop'];
  131. $whlabel = $data['whlabel'];
  132. if(!$whlabel)
  133. {
  134. return '请先添加产品信息!';exit;
  135. }
  136. $save = array();$x=0;
  137. $pp = explode('|',trim($whlabel,'|'));
  138. $asd = array();
  139. foreach ($pp as $va)
  140. {
  141. $ckcg = 0;
  142. $num = explode('-',$va);
  143. $ftime = time()-30*24*3600;
  144. $order = $this->fullorder->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  145. $order2 = $this->fullorder_smt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  146. $order3 = $this->fullordersmt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  147. $whlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (shop IS NULL or shop = '')");
  148. $shopwhlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and shop like '%,".$shop.",%'");
  149. $od = 0;
  150. foreach ($order as $v)
  151. {
  152. $or = explode('|',ltrim($v['whlabel'],'|'));
  153. for($i=0;$i<count($or);$i++)
  154. {
  155. $orod = explode('-',$or[$i]);
  156. if($orod[0] == $num[0])
  157. {
  158. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  159. if($zs < 1)
  160. {
  161. $od += $orod[1];
  162. }
  163. }
  164. }
  165. }
  166. foreach ($order2 as $v)
  167. {
  168. $or = explode('|',ltrim($v['whlabel'],'|'));
  169. for($i=0;$i<count($or);$i++)
  170. {
  171. $orod = explode('-',$or[$i]);
  172. if($orod[0] == $num[0])
  173. {
  174. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  175. if($zs < 1)
  176. {
  177. $od += $orod[1];
  178. }
  179. }
  180. }
  181. }
  182. foreach ($order3 as $v)
  183. {
  184. $or = explode('|',ltrim($v['whlabel'],'|'));
  185. for($i=0;$i<count($or);$i++)
  186. {
  187. $orod = explode('-',$or[$i]);
  188. if($orod[0] == $num[0])
  189. {
  190. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  191. if($zs < 1)
  192. {
  193. $od += $orod[1];
  194. }
  195. }
  196. }
  197. }
  198. if(($whlabel+$shopwhlabel < 1) || ($shopwhlabel+$whlabel-$od) < $num[1])
  199. {
  200. $save[] = $x;
  201. }
  202. $x++;
  203. //$asd[] = $whlabel.'!'.$shopwhlabel.'!!'.$od.'~'.$num[1].'-'.count($order);
  204. }
  205. if(count($save) > 0)
  206. {
  207. return "库存匹配错误或库存不够扣减";exit;
  208. }
  209. else
  210. {
  211. return 1;exit;
  212. }
  213. }
  214. }
  215. }