Ahc.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Ahc extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  7. $this->load->_model('Model_fullorder','fullorder');
  8. $this->load->_model('Model_fullordertt','fullordertt');
  9. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  10. $this->load->_model('Model_shop','shop');
  11. $this->load->_model('Model_typeclass','typeclass');
  12. $this->load->_model('Model_express','express');
  13. $this->load->_model('Model_country','country');
  14. $this->load->_model('Model_productdescribe','productdescribe');
  15. $this->load->_model('Model_customs','customs');
  16. $this->load->_model('Model_detailed','detailed');
  17. $this->load->_model('Model_productdescription','productdescription');
  18. $this->load->_model('Model_logistics','logistics');
  19. $this->load->_model('Model_hl','hl');
  20. $this->load->_model('Model_excel','excel');
  21. $this->load->_model('Model_warehouse','warehouse');
  22. $this->load->_model('Model_customer','customer');
  23. $this->load->_model('Model_user','user');
  24. $this->load->_model('Model_dhl','dhl');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_api','api');
  27. }
  28. //定义方法的调用规则 获取URI第二段值
  29. public function _remap($arg,$arg_array)
  30. {
  31. if($arg == 'hcd')
  32. {
  33. $this->_hcd();
  34. }
  35. else
  36. {
  37. $this->_index();
  38. }
  39. }
  40. //管理
  41. public function _index()
  42. {
  43. $dt = 0;
  44. if(isset($_SESSION['api']))
  45. {
  46. $user = $this->user->get_api($_SESSION['api']);
  47. $usp = $user;
  48. $fgshop = "";$sid = "";
  49. $user = explode('|',trim($user['shop'],'|'));
  50. foreach ($user as $value)
  51. {
  52. $fgshop .= " shop = ".$value." or";
  53. $sid .= " id = ".$value." or";
  54. }
  55. }
  56. $post = $this->input->post(NULL, TRUE);
  57. if(isset($post['page']))
  58. {
  59. $page = $this->input->post('page',true);
  60. $perpage = $this->input->post('perpage',true);
  61. $timetk = $this->input->post('timetk',true);
  62. $timetj = $this->input->post('timetj',true);
  63. $timetk = strtotime($timetk)+12*3600;
  64. $timetj = strtotime($timetj)+12*3600;
  65. $data = $this->input->post('data',true);
  66. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  67. if($data == 1)
  68. {
  69. $where .= " and print = 2 and state = 207";
  70. }
  71. else if($data == 2)
  72. {
  73. $where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";
  74. }
  75. else if($data == 3)
  76. {
  77. $where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";
  78. }
  79. else if($data == 4)
  80. {
  81. $where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";
  82. }
  83. //数据排序
  84. $order_str = "dtime desc";
  85. if(empty($page))
  86. {
  87. $start = 0;
  88. $perpage = 1;
  89. }
  90. else
  91. {
  92. $start = ($page - 1)*$perpage;
  93. }
  94. $info_list = $this->fullorder_smt->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);
  95. //格式化数据
  96. foreach ($info_list as $key=>$value)
  97. {
  98. $ud = $this->fullorder_smt->read($value['id']);
  99. $ud['address'] = str_replace("'","’",$ud['address']);
  100. $ud['name'] = str_replace("'","’",$ud['name']);
  101. $customer = $this->customer->get_email($ud['email'],$value['shop']);
  102. $customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);
  103. //$a = array_column($customer, 'email'); //三维找其中健的数组
  104. //$a = array_flip($a); //键和值调换
  105. $shop = $this->shop->read($value['shop']);
  106. $info_list[$key]['shop'] = $shop['shopname'];
  107. //$info_list[$key]['user'] = $shop['shopuser'];
  108. $warehouse = $this->warehouse->read($value['type']);
  109. $warehousetitle = $warehouse['title'];
  110. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  111. $info_list[$key]['type'] = $warehousetitle;
  112. $typeclass = $this->typeclass->read($value['state']);
  113. $info_list[$key]['state'] = $typeclass['spare'];
  114. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  115. {
  116. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  117. }
  118. else
  119. {
  120. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
  121. }
  122. if($value['waybill'] != "")
  123. {
  124. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";
  125. }
  126. if($value['express'] != 0)
  127. {
  128. $express = $this->express->read($value['express']);
  129. $expressservicename = $express['servicename'];
  130. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  131. $info_list[$key]['express'] = $expressservicename;
  132. }
  133. else
  134. {
  135. $info_list[$key]['express'] = "无";
  136. }
  137. $x = "";
  138. if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)
  139. {
  140. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  141. }
  142. else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  143. {
  144. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  145. }
  146. if(($ud['review'] > 4) && $ud['print'] == 2)
  147. {
  148. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  149. }
  150. else if($ud['review'] >4 && $ud['print'] == 1)
  151. {
  152. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  153. }
  154. if($value['waybill'] == "" && $ud['review'] > 4)
  155. {
  156. $x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";
  157. }
  158. else if($value['waybill'] != "" && $ud['review'] > 4)
  159. {
  160. $x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";
  161. }
  162. if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
  163. {
  164. $x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  165. }
  166. if($value['black'] == 0)
  167. {
  168. $x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";
  169. }
  170. $info_list[$key]['black'] = $x;
  171. $tly = "";
  172. if($value['clientremarks'] != "")
  173. {
  174. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  175. }
  176. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder_smt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  177. }
  178. $xx1 = $this->fullorder_smt->find_count("print = 2 and state = 207");
  179. $xx2 = $this->fullorder_smt->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'");
  180. $xx3 = $this->fullorder_smt->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'");
  181. $xx4 = $this->fullorder_smt->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'");
  182. $total = $this->fullorder_smt->find_count($where);
  183. $pagenum = ceil($total/$perpage);
  184. $over = $total-($start+$perpage);
  185. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));
  186. echo json_encode($rows);exit;
  187. }
  188. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  189. $this->data['wlshop'] = $wlshop;
  190. $this->data['express'] = $this->express->find_all();
  191. $fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板
  192. $this->data['fullorderexcel'] = $fullorderexcel;
  193. $error = $this->fullorder_smt->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
  194. $this->data['error'] = $error;
  195. $this->_Template('ahc_smt',$this->data);
  196. }
  197. //管理
  198. public function _hcd()
  199. {
  200. $dt = 0;
  201. if(isset($_SESSION['api']))
  202. {
  203. $user = $this->user->get_api($_SESSION['api']);
  204. $usp = $user;
  205. $fgshop = "";$sid = "";
  206. $user = explode('|',trim($user['shop'],'|'));
  207. foreach ($user as $value)
  208. {
  209. $fgshop .= " shop = ".$value." or";
  210. $sid .= " id = ".$value." or";
  211. }
  212. }
  213. $post = $this->input->post(NULL, TRUE);
  214. if(isset($post['page']))
  215. {
  216. $page = $this->input->post('page',true);
  217. $perpage = $this->input->post('perpage',true);
  218. $timetk = $this->input->post('timetk',true);
  219. $timetj = $this->input->post('timetj',true);
  220. $timetk = strtotime($timetk)+12*3600;
  221. $timetj = strtotime($timetj)+12*3600;
  222. $data = $this->input->post('data',true);
  223. $where = "mergeid = 0 and type = 5 and review = 6 and (".rtrim($fgshop,'or').")";
  224. if($data == 1)
  225. {
  226. $where .= " and print = 2 and state = 207 and dtime > 1557244800";
  227. }
  228. else if($data == 2)
  229. {
  230. $where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";
  231. }
  232. else if($data == 3)
  233. {
  234. $where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";
  235. }
  236. else if($data == 4)
  237. {
  238. $where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";
  239. }
  240. //数据排序
  241. $order_str = "dtime desc";
  242. if(empty($page))
  243. {
  244. $start = 0;
  245. $perpage = 1;
  246. }
  247. else
  248. {
  249. $start = ($page - 1)*$perpage;
  250. }
  251. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);
  252. //格式化数据
  253. foreach ($info_list as $key=>$value)
  254. {
  255. $ud = $this->fullorder->read($value['id']);
  256. $ud['address'] = str_replace("'","’",$ud['address']);
  257. $ud['name'] = str_replace("'","’",$ud['name']);
  258. $customer = $this->customer->get_email($ud['email'],$value['shop']);
  259. $customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);
  260. //$a = array_column($customer, 'email'); //三维找其中健的数组
  261. //$a = array_flip($a); //键和值调换
  262. $shop = $this->shop->read($value['shop']);
  263. $info_list[$key]['shop'] = $shop['shopname'];
  264. //$info_list[$key]['user'] = $shop['shopuser'];
  265. $warehouse = $this->warehouse->read($value['type']);
  266. $warehousetitle = $warehouse['title'];
  267. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  268. $info_list[$key]['type'] = $warehousetitle;
  269. $typeclass = $this->typeclass->read($value['state']);
  270. $info_list[$key]['state'] = $typeclass['spare'];
  271. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  272. {
  273. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  274. }
  275. else
  276. {
  277. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
  278. }
  279. if($value['waybill'] != "")
  280. {
  281. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";
  282. }
  283. if($value['express'] != 0)
  284. {
  285. $express = $this->express->read($value['express']);
  286. $expressservicename = $express['servicename'];
  287. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  288. $info_list[$key]['express'] = $expressservicename;
  289. }
  290. else
  291. {
  292. $info_list[$key]['express'] = "无";
  293. }
  294. $x = "";
  295. if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)
  296. {
  297. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  298. }
  299. else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  300. {
  301. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  302. }
  303. if(($ud['review'] > 4) && $ud['print'] == 2)
  304. {
  305. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  306. }
  307. else if($ud['review'] >4 && $ud['print'] == 1)
  308. {
  309. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  310. }
  311. if($value['waybill'] == "" && $ud['review'] > 4)
  312. {
  313. $x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";
  314. }
  315. else if($value['waybill'] != "" && $ud['review'] > 4)
  316. {
  317. $x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";
  318. }
  319. if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
  320. {
  321. $x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  322. }
  323. if($value['black'] == 0)
  324. {
  325. $x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";
  326. }
  327. $info_list[$key]['black'] = $x;
  328. $tly = "";
  329. if($value['clientremarks'] != "")
  330. {
  331. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  332. }
  333. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  334. }
  335. $xx1 = $this->fullorder->find_count("print = 2 and dtime > 1557244800 and state = 207 and type = 5");
  336. $xx2 = $this->fullorder->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj' and type = 5");
  337. $xx3 = $this->fullorder->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj' and type = 5");
  338. $xx4 = $this->fullorder->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj' and type = 5");
  339. $total = $this->fullorder->find_count($where);
  340. $pagenum = ceil($total/$perpage);
  341. $over = $total-($start+$perpage);
  342. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));
  343. echo json_encode($rows);exit;
  344. }
  345. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  346. $this->data['wlshop'] = $wlshop;
  347. $this->data['express'] = $this->express->find_all();
  348. $fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板
  349. $this->data['fullorderexcel'] = $fullorderexcel;
  350. $error = $this->fullorder->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and type = 5 and (".rtrim($fgshop,'or').")");
  351. $this->data['error'] = $error;
  352. $this->_Template('ahc_dlz',$this->data);
  353. }
  354. }