Review.php 6.1 KB

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