Review.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. foreach ($id_arr as $v)
  55. {
  56. $fullorder = $this->$fu->read($v);
  57. if(in_array($fullorder['express'],[85,87])){
  58. if($fullorder['is_edit'] == 0){
  59. echo json_encode(array('msg'=>$fullorder['number'].',需要去核对快递承运商再提交','success'=>true));exit;
  60. }
  61. }
  62. if(!isset($fullorder))
  63. {
  64. $sb++;
  65. continue;
  66. }
  67. if($fullorder['print'] < 3)
  68. {
  69. $a = "订单未打印,";
  70. $b = 2;
  71. }
  72. /**
  73. if(($fullorder['budget'] > $fullorder['cost'] && $fullorder['review']==1) || $fullorder['source']==1)
  74. {
  75. $review = 6;
  76. }
  77. **/
  78. if($review == 3)
  79. {
  80. $review = 3;
  81. }
  82. else if($fullorder['source'] == 1 && $review == 2)
  83. {
  84. $review = 2;
  85. }
  86. else
  87. {
  88. /**
  89. $kcyz = $this->_kcyz($v,$fu);
  90. if($kcyz != 1)
  91. {
  92. echo json_encode(array('msg'=>$kcyz,'success'=>true));exit;
  93. }
  94. **/
  95. $review = 6;
  96. }
  97. if($fullorder['review'] > 4)//$review == 2
  98. {
  99. echo json_encode(array('msg'=>'已有提交操作,系统已刷新最新状态','success'=>true));exit;
  100. }
  101. $this->$fu->save(array('review'=>$review,'reviewtime'=>time(),'librarynot'=>$a,'print'=>$b),$v);
  102. }
  103. if(count($id_arr) > 1)
  104. {
  105. echo json_encode(array('msg'=>'操作完成!'.$sb.'条订单异常','success'=>true));exit;
  106. }
  107. else
  108. {
  109. echo json_encode(array('msg'=>'操作完成!鼠标任意点击关闭'.$review.' - '.$fullorder['review'],'success'=>true));exit;
  110. }
  111. }
  112. }
  113. function _kcyz($id,$fu)
  114. {
  115. if(isset($id))
  116. {
  117. $data = $this->$fu->read($id);
  118. if($data['type'] != 5)//目前只有美店验证仓库
  119. {
  120. return 1;exit;
  121. }
  122. $warehouse = $data['type'];
  123. $shop = $data['shop'];
  124. $whlabel = $data['whlabel'];
  125. if(!$whlabel)
  126. {
  127. return '请先添加产品信息!';exit;
  128. }
  129. $save = array();$x=0;
  130. $pp = explode('|',trim($whlabel,'|'));
  131. $asd = array();
  132. foreach ($pp as $va)
  133. {
  134. $ckcg = 0;
  135. $num = explode('-',$va);
  136. $ftime = time()-30*24*3600;
  137. $order = $this->fullorder->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  138. $order2 = $this->fullorder_smt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  139. $order3 = $this->fullordersmt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
  140. $whlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (shop IS NULL or shop = '')");
  141. $shopwhlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and shop like '%,".$shop.",%'");
  142. $od = 0;
  143. foreach ($order as $v)
  144. {
  145. $or = explode('|',ltrim($v['whlabel'],'|'));
  146. for($i=0;$i<count($or);$i++)
  147. {
  148. $orod = explode('-',$or[$i]);
  149. if($orod[0] == $num[0])
  150. {
  151. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  152. if($zs < 1)
  153. {
  154. $od += $orod[1];
  155. }
  156. }
  157. }
  158. }
  159. foreach ($order2 as $v)
  160. {
  161. $or = explode('|',ltrim($v['whlabel'],'|'));
  162. for($i=0;$i<count($or);$i++)
  163. {
  164. $orod = explode('-',$or[$i]);
  165. if($orod[0] == $num[0])
  166. {
  167. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  168. if($zs < 1)
  169. {
  170. $od += $orod[1];
  171. }
  172. }
  173. }
  174. }
  175. foreach ($order3 as $v)
  176. {
  177. $or = explode('|',ltrim($v['whlabel'],'|'));
  178. for($i=0;$i<count($or);$i++)
  179. {
  180. $orod = explode('-',$or[$i]);
  181. if($orod[0] == $num[0])
  182. {
  183. $zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
  184. if($zs < 1)
  185. {
  186. $od += $orod[1];
  187. }
  188. }
  189. }
  190. }
  191. if(($whlabel+$shopwhlabel < 1) || ($shopwhlabel+$whlabel-$od) < $num[1])
  192. {
  193. $save[] = $x;
  194. }
  195. $x++;
  196. //$asd[] = $whlabel.'!'.$shopwhlabel.'!!'.$od.'~'.$num[1].'-'.count($order);
  197. }
  198. if(count($save) > 0)
  199. {
  200. return "库存匹配错误或库存不够扣减";exit;
  201. }
  202. else
  203. {
  204. return 1;exit;
  205. }
  206. }
  207. }
  208. }