Aatest.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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_returngoods','returngoods');
  52. $this->load->_model('Model_returnlogs','returnlogs');
  53. }
  54. //定义方法的调用规则 获取URI第二段值
  55. public function _remap($arg,$arg_array)
  56. {
  57. if($arg == 'fout')
  58. {
  59. $this->_fout();
  60. }else if($arg == 'waybillemail'){
  61. $this->_waybillemail();
  62. }else if($arg == 'getorder'){
  63. $this->_getorder();
  64. }elseif($arg == 'upadtel'){
  65. //$this->upadtel();
  66. }else{
  67. $this->_a($arg_array);
  68. }
  69. }
  70. //物流轨迹
  71. public function _logistic(){
  72. echo "<pre>";
  73. $list = $this->fullorder->findall("waybill = 9205590251001335234515");
  74. $v = $list['0'];
  75. @$fs = $this->usps->get_logistics($v);
  76. $csck[] = array($v['number'],$fs['f'],$fs['content']);
  77. if(!isset($fs['f']))
  78. {
  79. $fs = $this->usps->get_logistics($v);
  80. }
  81. var_dump($fs);
  82. die;
  83. }
  84. public function _getorder(){
  85. $name = 'SuperNova';
  86. $userKey = array(
  87. 'Alipearl' => array('username'=>'huchunmei','api_key'=>'huchunmei126_alipearl_erp888','url'=>'https://www.alipearlhair.com'),
  88. 'Asteria' => array('username'=>'huchunmei','api_key'=>'huchunmei126_asteria_erp888','url'=>'https://www.asteriahair.com'),
  89. 'WestKiss' => array('username'=>'huchunmei','api_key'=>'huchunmei126_westkiss_erp868','url'=>'https://www.westkiss.com'),
  90. 'SuperNova' => array('username'=>'huchunmei','api_key'=>'huchunmei126_supernova_erp6898','url'=>'https://www.supernovahair.com'),
  91. 'Wiggins' => array('username'=>'huchunmei','api_key'=>'huchunmei126_wiggins_erp652','url'=>'https://www.wigginshair.com'),
  92. 'Yolissa' => array('username'=>'huchunmei','api_key'=>'huchunmei126_yolissa_688','url'=>'https://www.yolissahair.com'),
  93. );
  94. $proxy = new SoapClient($userKey[$name]['url'].'/api/soap/?wsdl');
  95. try {
  96. $sessionId = $proxy->login($userKey[$name]['username'], $userKey[$name]['api_key']);
  97. }
  98. catch (Exception $e) {
  99. echo $e->getMessage();
  100. }
  101. $data = array('proxy'=>$proxy,'sessionId'=>$sessionId,'url'=>$userKey[$name]['url']);
  102. $fromTime = date('Y-m-d H:i:s',time()- 3600*24*6);
  103. $toTime = date('Y-m-d H:i:s',time());
  104. $filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
  105. $result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
  106. echo "<pre>";
  107. // print_r($result[0]);
  108. foreach($result as $item)
  109. {
  110. // print_r($item);exit;
  111. $iteminfo= $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
  112. print_r($iteminfo['items']);
  113. die;
  114. }
  115. }
  116. public function _a($arg_array){
  117. $this->_logistic();
  118. die;
  119. $time = time();
  120. $jiami = "alipearlhair+".(string)$time;
  121. echo json_encode([
  122. 'shop'=>3,
  123. 'waybill'=>'283786008019',
  124. 'time'=>$time,
  125. 'key'=>$this->logic_tools->toolsjiami($jiami,"6amg!pnfrlbpnjgirv", "6ook4k!2w94m6jtm"),
  126. ]);
  127. die;
  128. $dtc = array();
  129. /* 订单号加入键值-j */
  130. /* 匹配加入 */
  131. $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');
  132. // 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)
  133. foreach ($dictionaries as $v)
  134. {
  135. if(stripos($v['spare'],'|') !== false)//如果有多个值
  136. {
  137. $v['spare'] = explode('|',$v['spare']);
  138. foreach ($v['spare'] as $k=>$vs)
  139. {
  140. if(stripos($v['zh'],'|') !== false)
  141. {
  142. $vzh = explode('|',$v['zh']);
  143. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  144. }
  145. else
  146. {
  147. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  148. }
  149. }
  150. }
  151. else
  152. {
  153. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  154. }
  155. }
  156. $dtctitle = [];
  157. $dictionaries2 = $this->typeclass->find_all();
  158. foreach ($dictionaries2 as $v)
  159. {
  160. $dtctitle[$v['id']] = $v['title'];
  161. }
  162. echo "<pre>";
  163. $sku = "Free,Gift--PackQQS,NW--3+Ori6*6C-22 24 26-20-6*6C";
  164. $sl = "1;1;1;";
  165. $r = $this->api->matching($sl,$sku,$dtc,"","",$dtctitle,$shop=[],$extra = [
  166. "price"=>"565.7700",
  167. "row_total"=>"565.7700"
  168. ]);
  169. var_dump($r['title']);
  170. $r = $r['product'];
  171. $rr = explode(";",$r);
  172. print_r($rr);
  173. }
  174. public function _fout()
  175. {
  176. $waybill = $this->input->get('waybill');
  177. $info = $this->fullorder->get_waybill($waybill);
  178. $r = $this->usps->get_new_logistics($info);
  179. echo "<pre>";
  180. var_dump($r);
  181. //$this->fedexv1->makeAccessToken();
  182. }
  183. public function _waybillemail()
  184. {
  185. $urls = array();$sl = 0;$time = time();
  186. $wid = 2;
  187. // if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  188. // {
  189. // $wid = 1;
  190. // }
  191. // else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  192. // {
  193. // $wid = 2;
  194. // }
  195. // else
  196. // {
  197. // exit;
  198. // }
  199. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  200. foreach ($notice as $key=>$var)
  201. {
  202. $this->_waybillfs([
  203. 'var'=>$var,
  204. 'wid'=>$wid
  205. ]);
  206. }
  207. }
  208. public function upadtel(){
  209. $returngoods_id = 10;
  210. $insert_flag = 1213834;
  211. $number = 'ASTE-50203-040';
  212. $returngoods_info = $this->returngoods->read($returngoods_id);
  213. $this->returngoods->save([
  214. 'status'=>80,
  215. 'back_no'=>$number,
  216. 'back_id'=>$insert_flag,
  217. 'update_time'=>date('Y-m-d H:i:s'),
  218. ],$returngoods_id);
  219. $this->returnlogs->insert([
  220. 'rg_id'=>(int)$returngoods_id,
  221. 'operat_id'=>10,
  222. 'operat_name'=>'admin',
  223. 'remark'=>"订单号:".$returngoods_info['orderinfo']."重新换货-换货新订单编码".$number,
  224. 'create_time'=>date('Y-m-d H:i:s'),
  225. ]);
  226. }
  227. public function _waybillfs($data)
  228. {
  229. if($data)
  230. {
  231. $notice = $data['var'];
  232. $notice['email'] = $this->emaildata->read($notice['email']);
  233. $wid = $data['wid'];
  234. $fsjs = "";
  235. if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
  236. {
  237. $js = explode(',',trim($notice['js'],','));
  238. if(count($js) > 1)
  239. {
  240. $fsjs = " and (";
  241. foreach ($js as $v)
  242. {
  243. $fsjs .= "js = '$v' or ";
  244. }
  245. $fsjs = trim($fsjs,' or ').")" ;
  246. }
  247. else if(count($js) == 1)
  248. {
  249. $fsjs = " and js = '$js[0]'";
  250. }
  251. $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
  252. }
  253. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  254. {
  255. $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
  256. }
  257. else
  258. {
  259. exit;
  260. }
  261. $this->logic_ding->sendToDing("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  262. // $wlfs = array();
  263. // $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  264. // foreach($dd as $v){
  265. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】");
  266. // }
  267. // foreach ($dd as $v)
  268. // {
  269. // $shop = $this->shop->read($v['shop']);
  270. // $express = $this->express->read($v['express']);
  271. // $fs = $this->notice->get_god($v,$shop,$express,$notice);
  272. // $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】获取快递信息【".json_encode($notice,JSON_UNESCAPED_UNICODE)."】返回的信息".json_encode($fs));
  273. // if($fs == 1)
  274. // {
  275. // $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
  276. // //给crm发送信息 先存储数据 后续定时任务执行
  277. // if($v['shop'] < 10){
  278. // $this->zztmpdata->insert([
  279. // 'type'=>2,
  280. // 'act_name'=>'crm_order',
  281. // 'content'=>json_encode($v),
  282. // 'create_time'=>time()
  283. // ]);
  284. // }
  285. // }
  286. // else
  287. // {
  288. // //$pdtime = date('Y-m-d',time());
  289. // //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
  290. // //$permissions = 0777; // 权限设置
  291. // //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  292. // //file_exists($folderPath);
  293. // if(!is_file("./data/dlzemail/".$v['number'].".txt"))
  294. // {
  295. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
  296. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  297. // fclose($myfile);
  298. // }
  299. // else
  300. // {
  301. // $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
  302. // fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  303. // fclose($myfile);
  304. // }
  305. // $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
  306. // }
  307. // sleep(50);
  308. // }
  309. }
  310. }
  311. }