Review.php 6.2 KB

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