Review.php 6.3 KB

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