Aatest.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Aatest extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_productprice','productprice');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullordersmt','fullordersmt');
  13. $this->load->_model('Model_outbound','outbound');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_kdniao','kdniao');
  19. $this->load->_model('Model_notice','notice');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_dhlhz','dhlhz');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_fedex','fedex');
  24. $this->load->_model('Model_fedex_cby','fedex_cby');
  25. $this->load->_model('Model_ups','ups');
  26. $this->load->_model('Model_ali','ali');
  27. $this->load->_model('Model_dpd','dpd');
  28. $this->load->_model('Model_shop','shop');
  29. $this->load->_model('Model_user','user');
  30. $this->load->_model('Model_whlabel','whlabel');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_ck','ck');
  33. $this->load->_model('Model_whlabellabel','whlabellabel');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->helper('url');
  36. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  37. $this->load->_model('Model_systemtransfer','systemtransfer');
  38. $this->load->_model('Model_classid','classid');
  39. $this->load->_model('Model_allocation','allocation');
  40. $this->load->_model('Model_fullorderxw','fullorderxw');
  41. $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
  42. //$this->load->_model('Model_fedexv1','fedexv1');
  43. $this->load->_model('Model_logic_crm','logic_crm');
  44. $this->load->_model("Model_fullorder","fullorder");
  45. $this->load->_model("Model_express","express");
  46. $this->load->_model("Model_logic_ding","logic_ding");
  47. $this->load->_model("Model_api",'api');
  48. $this->load->_model("Model_usps",'usps');
  49. $this->load->_model('Model_emaildata','emaildata');
  50. $this->load->_model('Model_logic_tools','logic_tools');
  51. }
  52. //定义方法的调用规则 获取URI第二段值
  53. public function _remap($arg,$arg_array)
  54. {
  55. if($arg == 'fout')
  56. {
  57. $this->_fout();
  58. }else if($arg == 'waybillemail'){
  59. $this->_waybillemail();
  60. }else{
  61. $this->_a($arg_array);
  62. }
  63. }
  64. public function _a($arg_array){
  65. $time = time();
  66. $jiami = "alipearlhair+".(string)$time;
  67. echo json_encode([
  68. 'shop'=>3,
  69. 'waybill'=>'283786008019',
  70. 'time'=>$time,
  71. 'key'=>$this->logic_tools->toolsjiami($jiami,"6amg!pnfrlbpnjgirv", "6ook4k!2w94m6jtm"),
  72. ]);
  73. die;
  74. $dtc = array();
  75. /* 订单号加入键值-j */
  76. /* 匹配加入 */
  77. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
  78. // and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
  79. foreach ($dictionaries as $v)
  80. {
  81. if(stripos($v['spare'],'|') !== false)//如果有多个值
  82. {
  83. $v['spare'] = explode('|',$v['spare']);
  84. foreach ($v['spare'] as $k=>$vs)
  85. {
  86. if(stripos($v['zh'],'|') !== false)
  87. {
  88. $vzh = explode('|',$v['zh']);
  89. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  90. }
  91. else
  92. {
  93. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  94. }
  95. }
  96. }
  97. else
  98. {
  99. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  100. }
  101. }
  102. $dtctitle = [];
  103. $dictionaries2 = $this->typeclass->find_all();
  104. foreach ($dictionaries2 as $v)
  105. {
  106. $dtctitle[$v['id']] = $v['title'];
  107. }
  108. echo "<pre>";
  109. $sku = "Free,Gift--PackQQS,NW--3+Ori6*6C-22 24 26-20-6*6C";
  110. $sl = "1;1;1;";
  111. $r = $this->api->matching($sl,$sku,$dtc,"","",$dtctitle,$shop=[],$extra = [
  112. "price"=>"565.7700",
  113. "row_total"=>"565.7700"
  114. ]);
  115. var_dump($r['title']);
  116. $r = $r['product'];
  117. $rr = explode(";",$r);
  118. print_r($rr);
  119. }
  120. public function _fout()
  121. {
  122. $waybill = $this->input->get('waybill');
  123. $info = $this->fullorder->get_waybill($waybill);
  124. $r = $this->usps->get_new_logistics($info);
  125. echo "<pre>";
  126. var_dump($r);
  127. //$this->fedexv1->makeAccessToken();
  128. }
  129. public function _waybillemail()
  130. {
  131. $urls = array();$sl = 0;$time = time();
  132. $wid = 2;
  133. // if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  134. // {
  135. // $wid = 1;
  136. // }
  137. // else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  138. // {
  139. // $wid = 2;
  140. // }
  141. // else
  142. // {
  143. // exit;
  144. // }
  145. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  146. foreach ($notice as $key=>$var)
  147. {
  148. $this->_waybillfs([
  149. 'var'=>$var,
  150. 'wid'=>$wid
  151. ]);
  152. }
  153. }
  154. public function _waybillfs($data)
  155. {
  156. if($data)
  157. {
  158. $notice = $data['var'];
  159. $notice['email'] = $this->emaildata->read($notice['email']);
  160. $wid = $data['wid'];
  161. $fsjs = "";
  162. if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
  163. {
  164. $js = explode(',',trim($notice['js'],','));
  165. if(count($js) > 1)
  166. {
  167. $fsjs = " and (";
  168. foreach ($js as $v)
  169. {
  170. $fsjs .= "js = '$v' or ";
  171. }
  172. $fsjs = trim($fsjs,' or ').")" ;
  173. }
  174. else if(count($js) == 1)
  175. {
  176. $fsjs = " and js = '$js[0]'";
  177. }
  178. $where = "(express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 8:30:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 8:30:0",time()))."'".$fsjs;//3
  179. }
  180. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  181. {
  182. $where = "express != '2' and express != '63' and express != '64' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//4
  183. }
  184. else
  185. {
  186. exit;
  187. }
  188. $this->logic_ding->sendToDing("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  189. // $wlfs = array();
  190. // $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  191. // foreach($dd as $v){
  192. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】");
  193. // }
  194. // foreach ($dd as $v)
  195. // {
  196. // $shop = $this->shop->read($v['shop']);
  197. // $express = $this->express->read($v['express']);
  198. // $fs = $this->notice->get_god($v,$shop,$express,$notice);
  199. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】获取快递信息【".json_encode($notice,JSON_UNESCAPED_UNICODE)."】返回的信息".json_encode($fs));
  200. // if($fs == 1)
  201. // {
  202. // $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
  203. // //给crm发送信息 先存储数据 后续定时任务执行
  204. // if($v['shop'] < 10){
  205. // $this->zztmpdata->insert([
  206. // 'type'=>2,
  207. // 'act_name'=>'crm_order',
  208. // 'content'=>json_encode($v),
  209. // 'create_time'=>time()
  210. // ]);
  211. // }
  212. // }
  213. // else
  214. // {
  215. // //$pdtime = date('Y-m-d',time());
  216. // //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
  217. // //$permissions = 0777; // 权限设置
  218. // //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  219. // //file_exists($folderPath);
  220. // if(!is_file("./data/dlzemail/".$v['number'].".txt"))
  221. // {
  222. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
  223. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  224. // fclose($myfile);
  225. // }
  226. // else
  227. // {
  228. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
  229. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  230. // fclose($myfile);
  231. // }
  232. // $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
  233. // }
  234. // sleep(50);
  235. // }
  236. }
  237. }
  238. }