Aatest.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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. $this->load->_model('Model_logic_order','logic_order');
  52. $this->load->_model('Model_returngoods','returngoods');
  53. $this->load->_model('Model_returnlogs','returnlogs');
  54. $this->load->_model('Model_productdescribe','productdescribe');
  55. $this->load->_model('Model_logic_u9tools','logic_u9tools');
  56. }
  57. //定义方法的调用规则 获取URI第二段值
  58. public function _remap($arg,$arg_array)
  59. {
  60. if($arg == 'fout')
  61. {
  62. $this->_fout();
  63. }else if($arg == 'waybillemail'){
  64. $this->_waybillemail();
  65. }else if($arg == 'getorder'){
  66. $this->_getorder();
  67. }elseif($arg == 'logistic'){
  68. $this->_logistic();
  69. }elseif($arg == 'th'){
  70. $this->_th($arg_array);
  71. }else{
  72. $this->_a($arg_array);
  73. }
  74. }
  75. public function _th($arg_array){
  76. die;
  77. if(empty($arg_array)){
  78. die(1);
  79. }
  80. $order_no = $arg_array[0];
  81. var_dump($order_no);
  82. $data = $this->fullorder->get_number($order_no);
  83. if(empty($data)){
  84. echo 2;
  85. exit(2);
  86. }
  87. $r = $this->usps->get_return($data);
  88. echo "<pre>";
  89. var_dump($r);
  90. }
  91. //物流轨迹
  92. public function _logistic(){
  93. echo "<pre>";
  94. die;
  95. // $list = $this->fullorder->find_all("waybill = 284280923614");
  96. // var_dump($list);
  97. // die;
  98. // $v = $list[0];
  99. // $v = [
  100. // 'waybill'=>'285250961332'
  101. // ];
  102. // $fs = $this->fedexv1->get_logistics($v);
  103. // var_dump($fs);
  104. // die;
  105. // die;
  106. $list = $this->fullorder->get_waybill("9205890251001335261703");
  107. $v = $list;
  108. @$fs = $this->usps->get_logistics_new($v);
  109. // $csck[] = array($v['number'],$fs['f'],$fs['content']);
  110. // if(!isset($fs['f']))
  111. // {
  112. // $fs = $this->usps->get_logistics($v);
  113. // }
  114. var_dump($fs);
  115. //$fs = $this->usps->get_logistics($v);
  116. die;
  117. }
  118. public function _getorder(){
  119. $name = 'SuperNova';
  120. $userKey = array(
  121. 'Alipearl' => array('username'=>'huchunmei','api_key'=>'huchunmei126_alipearl_erp888','url'=>'https://www.alipearlhair.com'),
  122. 'Asteria' => array('username'=>'huchunmei','api_key'=>'huchunmei126_asteria_erp888','url'=>'https://www.asteriahair.com'),
  123. 'WestKiss' => array('username'=>'huchunmei','api_key'=>'huchunmei126_westkiss_erp868','url'=>'https://www.westkiss.com'),
  124. 'SuperNova' => array('username'=>'huchunmei','api_key'=>'huchunmei126_supernova_erp6898','url'=>'https://www.supernovahair.com'),
  125. 'Wiggins' => array('username'=>'huchunmei','api_key'=>'huchunmei126_wiggins_erp652','url'=>'https://www.wigginshair.com'),
  126. 'Yolissa' => array('username'=>'huchunmei','api_key'=>'huchunmei126_yolissa_688','url'=>'https://www.yolissahair.com'),
  127. );
  128. $proxy = new SoapClient($userKey[$name]['url'].'/api/soap/?wsdl');
  129. try {
  130. $sessionId = $proxy->login($userKey[$name]['username'], $userKey[$name]['api_key']);
  131. }
  132. catch (Exception $e) {
  133. echo $e->getMessage();
  134. }
  135. $data = array('proxy'=>$proxy,'sessionId'=>$sessionId,'url'=>$userKey[$name]['url']);
  136. $fromTime = date('Y-m-d H:i:s',time()- 3600*24*6);
  137. $toTime = date('Y-m-d H:i:s',time());
  138. $filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
  139. $result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
  140. echo "<pre>";
  141. // print_r($result[0]);
  142. foreach($result as $item)
  143. {
  144. // print_r($item);exit;
  145. $iteminfo= $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
  146. print_r($iteminfo['items']);
  147. die;
  148. }
  149. }
  150. public function getDtc(){
  151. $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');
  152. $dtc = array();
  153. foreach ($dictionaries as $v)
  154. {
  155. if(stripos($v['spare'],'|') !== false)//如果有多个值
  156. {
  157. $v['spare'] = explode('|',$v['spare']);
  158. foreach ($v['spare'] as $k=>$vs)
  159. {
  160. if(stripos($v['zh'],'|') !== false)
  161. {
  162. $vzh = explode('|',$v['zh']);
  163. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  164. }
  165. else
  166. {
  167. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  168. }
  169. }
  170. }
  171. else
  172. {
  173. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  174. }
  175. }
  176. $dtctitle = [];
  177. $dictionaries2 = $this->typeclass->find_all();
  178. foreach ($dictionaries2 as $v)
  179. {
  180. $dtctitle[$v['id']] = $v['title'];
  181. }
  182. return [
  183. 'dtc'=>$dtc,
  184. 'dtctitle'=>$dtctitle
  185. ];
  186. }
  187. public function _a($arg_array){
  188. $list = [
  189. [
  190. 'sku2'=>'-128-80-89-57-106-341-30-72-',
  191. ],
  192. [
  193. 'sku2'=>'-128-80-88-57-2248-2096-30-72-2071-1645-',
  194. ]
  195. ];
  196. $r = $this->logic_u9tools->getU9bm($list,'sku2');
  197. echo "<pre>";
  198. var_dump($r);
  199. die;
  200. $data = $this->getDtc();
  201. $dtc = $data['dtc'];
  202. $dtctitle = $data['dtctitle'];
  203. $quantity = 'Loose Body--HDWig-26-HD5*5Wig-180%,WKPack';
  204. $issku = '1;1';
  205. $money = array();
  206. $productdescribe = $this->productdescribe->find_all('1=1');
  207. foreach ($productdescribe as $v)
  208. {
  209. $money[$v['number']] = array();
  210. }
  211. /* 价格加入 */
  212. /* 匹配ID加入 */
  213. $int = array();
  214. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  215. foreach ($intdata as $v)
  216. {
  217. $v['spare'] = explode('|',$v['spare']);
  218. $int[$v['id']] = $v['spare'][0];
  219. }
  220. var_dump($dtc);
  221. var_dump($dtctitle);
  222. $r = $this->api->matching($quantity,$issku,$dtc,$money,$int,$dtctitle,[1],[
  223. ]);
  224. echo "<pre>";
  225. var_dump($r);
  226. die;
  227. $time = time();
  228. $jiami = "alipearlhair+".(string)$time;
  229. echo json_encode([
  230. 'shop'=>3,
  231. 'waybill'=>'283786008019',
  232. 'time'=>$time,
  233. 'key'=>$this->logic_tools->toolsjiami($jiami,"6amg!pnfrlbpnjgirv", "6ook4k!2w94m6jtm"),
  234. ]);
  235. die;
  236. $dtc = array();
  237. /* 订单号加入键值-j */
  238. /* 匹配加入 */
  239. $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');
  240. // 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)
  241. foreach ($dictionaries as $v)
  242. {
  243. if(stripos($v['spare'],'|') !== false)//如果有多个值
  244. {
  245. $v['spare'] = explode('|',$v['spare']);
  246. foreach ($v['spare'] as $k=>$vs)
  247. {
  248. if(stripos($v['zh'],'|') !== false)
  249. {
  250. $vzh = explode('|',$v['zh']);
  251. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  252. }
  253. else
  254. {
  255. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  256. }
  257. }
  258. }
  259. else
  260. {
  261. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  262. }
  263. }
  264. $dtctitle = [];
  265. $dictionaries2 = $this->typeclass->find_all();
  266. foreach ($dictionaries2 as $v)
  267. {
  268. $dtctitle[$v['id']] = $v['title'];
  269. }
  270. echo "<pre>";
  271. $sku = "Free,Gift--PackQQS,NW--3+Ori6*6C-22 24 26-20-6*6C";
  272. $sl = "1;1;1;";
  273. $r = $this->api->matching($sl,$sku,$dtc,"","",$dtctitle,$shop=[],$extra = [
  274. "price"=>"565.7700",
  275. "row_total"=>"565.7700"
  276. ]);
  277. var_dump($r['title']);
  278. $r = $r['product'];
  279. $rr = explode(";",$r);
  280. print_r($rr);
  281. }
  282. public function _fout()
  283. {
  284. $waybill = $this->input->get('waybill');
  285. $info = $this->fullorder->get_waybill($waybill);
  286. //$r = $this->usps->get_new_logistics($info);
  287. $r = $this->fedexv1->get_logistics(123);
  288. echo "<pre>";
  289. var_dump($r);
  290. //$this->fedexv1->makeAccessToken();
  291. }
  292. public function _waybillemail()
  293. {
  294. $urls = array();$sl = 0;$time = time();
  295. $wid = 2;
  296. // if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  297. // {
  298. // $wid = 1;
  299. // }
  300. // else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  301. // {
  302. // $wid = 2;
  303. // }
  304. // else
  305. // {
  306. // exit;
  307. // }
  308. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  309. foreach ($notice as $key=>$var)
  310. {
  311. $this->_waybillfs([
  312. 'var'=>$var,
  313. 'wid'=>$wid
  314. ]);
  315. }
  316. }
  317. public function upadtel(){
  318. $returngoods_id = 150;
  319. $insert_flag = 1217819;
  320. $number = 'KISS-50206-004';
  321. $returngoods_info = $this->returngoods->read($returngoods_id);
  322. $this->returngoods->save([
  323. 'status'=>80,
  324. 'back_no'=>$number,
  325. 'back_id'=>$insert_flag,
  326. 'update_time'=>date('Y-m-d H:i:s'),
  327. ],$returngoods_id);
  328. $this->returnlogs->insert([
  329. 'rg_id'=>(int)$returngoods_id,
  330. 'operat_id'=>10,
  331. 'operat_name'=>'admin',
  332. 'remark'=>"订单号:".$returngoods_info['orderinfo']."重新换货-换货新订单编码".$number,
  333. 'create_time'=>date('Y-m-d H:i:s'),
  334. ]);
  335. }
  336. public function _waybillfs($data)
  337. {
  338. if($data)
  339. {
  340. $notice = $data['var'];
  341. $notice['email'] = $this->emaildata->read($notice['email']);
  342. $wid = $data['wid'];
  343. $fsjs = "";
  344. if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
  345. {
  346. $js = explode(',',trim($notice['js'],','));
  347. if(count($js) > 1)
  348. {
  349. $fsjs = " and (";
  350. foreach ($js as $v)
  351. {
  352. $fsjs .= "js = '$v' or ";
  353. }
  354. $fsjs = trim($fsjs,' or ').")" ;
  355. }
  356. else if(count($js) == 1)
  357. {
  358. $fsjs = " and js = '$js[0]'";
  359. }
  360. $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
  361. }
  362. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  363. {
  364. $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
  365. }
  366. else
  367. {
  368. exit;
  369. }
  370. $this->logic_ding->sendToDing("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  371. // $wlfs = array();
  372. // $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  373. // foreach($dd as $v){
  374. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】");
  375. // }
  376. // foreach ($dd as $v)
  377. // {
  378. // $shop = $this->shop->read($v['shop']);
  379. // $express = $this->express->read($v['express']);
  380. // $fs = $this->notice->get_god($v,$shop,$express,$notice);
  381. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】获取快递信息【".json_encode($notice,JSON_UNESCAPED_UNICODE)."】返回的信息".json_encode($fs));
  382. // if($fs == 1)
  383. // {
  384. // $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
  385. // //给crm发送信息 先存储数据 后续定时任务执行
  386. // if($v['shop'] < 10){
  387. // $this->zztmpdata->insert([
  388. // 'type'=>2,
  389. // 'act_name'=>'crm_order',
  390. // 'content'=>json_encode($v),
  391. // 'create_time'=>time()
  392. // ]);
  393. // }
  394. // }
  395. // else
  396. // {
  397. // //$pdtime = date('Y-m-d',time());
  398. // //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
  399. // //$permissions = 0777; // 权限设置
  400. // //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  401. // //file_exists($folderPath);
  402. // if(!is_file("./data/dlzemail/".$v['number'].".txt"))
  403. // {
  404. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
  405. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  406. // fclose($myfile);
  407. // }
  408. // else
  409. // {
  410. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
  411. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  412. // fclose($myfile);
  413. // }
  414. // $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
  415. // }
  416. // sleep(50);
  417. // }
  418. }
  419. }
  420. }