Ac.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Ac extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->_model('Model_shop','shop');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullorderxw','fullorderxw');
  9. $this->load->_model('Model_fullordersmt','fullordersmt');
  10. $this->load->_model('Model_fullorder_2020','fullorder2020');
  11. $this->load->_model('Model_fullordersmt_2020','fullordersmt2020');
  12. $this->load->_model('Model_customersmt','customersmt');
  13. $this->load->_model('Model_country','country');
  14. $this->load->_model('Model_hl','hl');
  15. $this->load->_model('Model_is','is');
  16. $this->load->_model('Model_kdniao','kdniao');
  17. $this->load->_model('Model_typeclass','typeclass');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_usps','usps');
  22. $this->load->_model('Model_dhltest','dhltest');
  23. $this->load->_model('Model_customer','customer');
  24. $this->load->_model('Model_express','express');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_whlabel','whlabel');
  27. $this->load->_model('Model_productdescribe','productdescribe');
  28. $this->load->_model('Model_ljg','ljg');
  29. $this->load->_model('Model_commodityread','commodityread');
  30. $this->load->_model('Model_service','service');
  31. $this->load->_model('Model_fedex','fedex');
  32. $this->load->_model('Model_commodity','commodity');
  33. $this->load->_model('Model_fullordersmtorder','fullordersmtorder');
  34. $this->load->_model('Model_ali','ali');
  35. $this->load->_model('Model_fullordersmthb','fullordersmthb');
  36. $this->load->_model('Model_fullordersmtbf','fullordersmtbf');
  37. $this->load->_model('Model_taxzhengzhou','taxzhengzhou');
  38. $this->load->_model('Model_taxshanghai','taxshanghai');
  39. $this->load->_model('Model_excel','excel');
  40. $this->load->_model('Model_ups','ups');
  41. $this->load->_model('Model_dpd','dpd');
  42. $this->load->_model('Model_dpdold','dpdold');
  43. $this->load->_model('Model_dpd_IOSS','dpd_IOSS');
  44. $this->load->_model('Model_dpdxw','dpdxw');
  45. $this->load->_model('Model_cne','cne');
  46. $this->load->_model('Model_outbound','outbound');
  47. $this->load->_model('Model_api','api');
  48. $this->load->_model('Model_dhlhz','dhlhz');
  49. $this->load->_model('Model_apismt','apismt');
  50. $this->load->_model('Model_specialstock','specialstock');
  51. $this->load->_model('Model_systemwigsout','systemwigsout');
  52. $this->load->_model('Model_purchaseorder','purchaseorder');
  53. $this->load->_model('Model_returns','returns');
  54. $this->load->_model('Model_whlabellabel','whlabellabel');
  55. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  56. $this->load->_model('Model_tjadd','tjadd');
  57. $this->load->_model('Model_stafflist','stafflist');
  58. $this->load->_model('Model_paypal','paypal');
  59. $this->load->_model('Model_warehousefactory','warehousefactory');
  60. $this->load->_model('Model_commodityread_del','commodityreaddel');
  61. $this->load->_model('Model_als','als');
  62. $this->load->_model('Model_allocation','allocation');
  63. $this->load->_model('Model_17track','17track');
  64. $this->load->_model('Model_hualei','hualei');
  65. $this->load->_model('Model_hualeixw','hualeixw');
  66. $this->load->_model('Model_ck','ck');
  67. $this->load->_model('Model_colour','colour');
  68. $this->load->_model('Model_color','color');
  69. $this->load->_model('Model_emaildata','emaildata');
  70. $this->load->_model('Model_wigprint','wigprint');
  71. $this->load->_model('Model_weight','weight');
  72. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  73. $this->load->_model('Model_pay','pay');
  74. $this->load->_model('Model_orderurl','orderurl');
  75. $this->load->_model('Model_classid','classid');
  76. $this->load->_model('Model_whlabel','whlabel');
  77. $this->load->_model('Model_systemtransfer','systemtransfer');
  78. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  79. $this->load->_model('Model_excel','excel');
  80. $this->load->_model('Model_yuntu','yuntu');
  81. $this->load->_model('Model_fedex_ficp','fedex_ficp');
  82. $this->load->_model('Model_fedexv1','fedexv1');
  83. $this->load->_model("Model_customsdeclaration","customsdeclaration");
  84. }
  85. //定义方法的调用规则 获取URI第二段值
  86. public function _remap($arg,$arg_array)
  87. {
  88. if($arg == 'x3')
  89. {
  90. $this->_x3($arg_array);
  91. }
  92. else if($arg == 'qk')
  93. {
  94. $this->_qk();
  95. }
  96. else if($arg == 'qczd')
  97. {
  98. $this->_qczd($arg_array);
  99. }
  100. else if($arg == 'd')
  101. {
  102. $this->_d($arg_array);
  103. }
  104. else if($arg == 'w')
  105. {
  106. $this->_w($arg_array);
  107. }
  108. else if($arg == 'wz')
  109. {
  110. $this->_wz($arg_array);//改仓库位置
  111. }
  112. else if($arg == 'qkyy')
  113. {
  114. $this->_qkyy($arg_array);//清除备货用友数据
  115. }
  116. else if($arg == 'cxxq')
  117. {
  118. $this->_cxxq($arg_array);//查询独立站订单详情
  119. }
  120. else if($arg == 'user')
  121. {
  122. $this->_user($arg_array);//批量添加店铺权限
  123. }
  124. }
  125. public function _x3($arg_array)
  126. {
  127. $fullorder = $this->fullorder->get_number($arg_array[0]);
  128. if(!$fullorder)
  129. {
  130. $fullorder = $this->fullordersmt->get_number($arg_array[0]);
  131. }
  132. if(!$fullorder)
  133. {
  134. $fullorder = $this->fullordertt->get_number($arg_array[0]);
  135. }
  136. if(!$fullorder)
  137. {
  138. $fullorder = $this->fullorderxw->get_number($arg_array[0]);
  139. }
  140. if(!$fullorder)
  141. {
  142. echo "编号错误";exit;
  143. }
  144. /** 发票地址信息暂时无用
  145. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  146. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  147. $fullorder['baddress'][1] = $country['ename'];
  148. **/
  149. //获取所用相关信息
  150. $warehouse = $this->warehouse->read($fullorder['type']);
  151. $country = $this->country->read($fullorder['country']);//订单国家信息
  152. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  153. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  154. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  155. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  156. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  157. $fullorder['country'] = $country['ename'];//订单国家名
  158. $fullorder['zhou'] = $country['continent'];//所属州
  159. $express = $this->express->read($fullorder['express']);
  160. $fullorder['express'] = $express['servicename'];
  161. $fullorder['account'] = $express['account'];
  162. $fullorder['printcode'] = $express['printcode'];
  163. $fullorder['time'] = date('Y-m-d',time());
  164. $fullorder['times'] = date('Y-m-d H:i',time());
  165. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  166. //var_dump($declara_info);
  167. $sbbm = "";
  168. if(empty($declara_info)){
  169. $sbbm = "";
  170. }else{
  171. $sbbm = $declara_info['bname'];
  172. }
  173. $fullorder['sbbm']= $sbbm;
  174. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  175. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  176. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  177. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  178. $shop = $this->shop->read($fullorder['shop']);
  179. $fullorder['shop'] = $shop['shopname'];
  180. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  181. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  182. if(is_numeric($fullorder['pay']))
  183. {
  184. $pay = $this->typeclass->read($fullorder['pay']);
  185. if($pay['classid'] == '4')
  186. {
  187. $fullorder['pay'] = $pay['title'];
  188. }
  189. }
  190. if($fullorder['printcode'] != "USPS")
  191. {
  192. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  193. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  194. }
  195. //增加退货单所需信息
  196. $pt = '';
  197. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  198. foreach ($fpdata as $v)
  199. {
  200. $p = explode('|',trim($v,'|'));
  201. //$pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  202. }
  203. $fullorder['pt'] = $pt;
  204. $fullorder['printnumber'] += 2;
  205. // echo "<pre>";
  206. // var_dump($fullorder['sbbm']);
  207. // die;
  208. //$fullorder['printcode'] = 'HUALEIXW-FEDEX';
  209. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  210. //$fullorder['sbbm']= 4202320000;//($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  211. //$fullorder['sbpm']= 'eyelashes';
  212. //$fullorder['zwpm']= '假睫毛';
  213. //$fullorder['sbpm']= 'Satin Bag';
  214. //$fullorder['zwpm']= '袋子';
  215. //$fullorder['hgbm']= 4202320000;
  216. //$fullorder['address'] = '1653 Treutlan Place';
  217. //$fullorder['address2'] = '';
  218. //$fullorder['qm'] = 2;
  219. //$notice = $this->notice->read(6);
  220. //$fcountry['warehouse']['name'] = 'Hair Me Please LLC';
  221. //$fullorder['cxcode'] = strtolower($express['cxcode']);
  222. //$barcode = $this->fedex->get_logistics($fullorder);//获取联邦快递信息
  223. //echo $fullorder['name'];
  224. //$b = $this->yuntu->get_data($fullorder);
  225. //$b = $this->usps->get_logistics($fullorder);
  226. // $fullorder['printcode'] = 'HUALEI-DHL';
  227. // $fullorder['js'] = 2;
  228. // $fullorder['bx'] = 110;
  229. //$fullorder['qm'] = 1;
  230. echo "<pre>";
  231. var_dump($fullorder['printcode']);
  232. //$fullorder['printcode'] = 'usps_priority';
  233. $b = $this->cne->get_data($fullorder);
  234. print_r($b);
  235. die;
  236. // echo "<pre>";
  237. // $b = $this->fedexv1->get_data($fullorder);
  238. // var_dump($b);
  239. //echo $fullorder['zzl'];
  240. // echo "<pre>";
  241. // var_dump($fullorder);
  242. //$b = $this->usps->get_data_new($fullorder);
  243. // $b = $this->ups->get_data($fullorder);
  244. // echo "<pre>";
  245. // print_r($b);
  246. //$this->_pdf($b['labelImage'],"test",date("Ymd"));
  247. }
  248. public function get_data($data)
  249. {
  250. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  251. $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
  252. $data['province'] = trim($data['province'],' ');
  253. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  254. $data['address'] = str_replace(array('#','&#38;','&'),array('%23','%26'),$data['address']);
  255. $data['address2'] = str_replace(array('#','&#38;','&'),array('%23','%26'),$data['address2']);
  256. $data['client'] = str_replace(array('#','&#38;','&'),array('%23','%26'),$data['client']);
  257. $data['name'] = str_replace(array('#','&#38;','&'),array('%23','%26'),$data['name']);
  258. $data['name'] = str_replace(' ',' ',$data['name']);
  259. $xml = "";
  260. $xml .= "<eVSRequest USERID='050GHAIR7974'>";
  261. $xml .= "<Option></Option>";
  262. $xml .= "<Revision>1</Revision>";
  263. $xml .= "<ImageParameters>";
  264. $xml .= "<ImageParameter>4X6LABELP</ImageParameter>";
  265. $xml .= "</ImageParameters>";
  266. $xml .= "<FromName>Kenny Kwok</FromName>";//发件人姓名或公司
  267. $xml .= "<FromFirm>Long Human Hair Factory Inc</FromFirm>";//发件人姓名或公司
  268. $xml .= "<FromAddress1></FromAddress1>";//发件人地址1 公寓或套房号码 不超过50个字符
  269. $xml .= "<FromAddress2>819 6th Avenue Store front</FromAddress2>";//发件人地址2
  270. $xml .= "<FromCity>New York</FromCity>";//发件人城市
  271. $xml .= "<FromState>NY</FromState>";//发件人所属州
  272. $xml .= "<FromZip5>10001</FromZip5>";//发件人邮政编码
  273. $xml .= "<FromZip4></FromZip4>";//发件人邮编2
  274. $xml .= "<FromPhone>8455583605</FromPhone>";//发件人电话,10位
  275. $xml .= "<AllowNonCleansedOriginAddr>true</AllowNonCleansedOriginAddr>";//是否检查地址 true不检查
  276. $xml .= "<ToName>".$data['name']."</ToName>";//收件人名称
  277. $xml .= "<ToFirm></ToFirm>";//收件人名称
  278. if($data['address2'] == "")
  279. {
  280. $xml .= "<ToAddress1>".$data['address2']."</ToAddress1>";//收件人地址1 不超过50个字符
  281. $xml .= "<ToAddress2>".$data['address']."</ToAddress2>";//收件人地址2
  282. }
  283. else
  284. {
  285. $xml .= "<ToAddress1>".$data['address']."</ToAddress1>";//收件人地址1 不超过50个字符
  286. $xml .= "<ToAddress2>".$data['address2']."</ToAddress2>";//收件人地址2
  287. }
  288. $xml .= "<ToCity>".$data['city']."</ToCity>";//收件人城市
  289. $xml .= "<ToState>".$dataprovince."</ToState>";//收件人州
  290. $xml .= "<ToZip5>".trim($data['zipcode'],' ')."</ToZip5>";//收件人邮编
  291. $xml .= "<ToZip4></ToZip4>";//收件人邮编2
  292. $xml .= "<ToPhone></ToPhone>";//收件人电话
  293. $xml .= "<POBox></POBox>";//目标地址是否为邮政信箱。
  294. if($data['qm']==1 && $data['js'] == 1)//如果需要签名,并且快递服务选择优先
  295. {
  296. $ServiceType = 'PRIORITY';
  297. $Container = 'FLAT RATE ENVELOPE';
  298. $ExtraService = '156';
  299. $ExtraServicebx = '125';
  300. }
  301. else if($data['qm']==1 && $data['js'] == 0)//如果需要签名,并且快递服务不选择优先
  302. {
  303. $ServiceType = 'FIRST CLASS';
  304. $Container = 'VARIABLE';
  305. $ExtraService = '120';
  306. $ExtraServicebx = '100';
  307. }
  308. else if($data['qm']==1 && $data['js'] == 2)//如果需要签名,并且快递服务选择PRIORITY EXPRESS
  309. {
  310. $ServiceType = 'PRIORITY EXPRESS';
  311. $Container = 'FLAT RATE ENVELOPE';
  312. $ExtraServicebx = '101';
  313. }
  314. else if($data['qm']==0 && $data['js'] == 1)//如果不需要签名,并且快递服务选择优先
  315. {
  316. $ServiceType = 'PRIORITY';
  317. $Container = 'FLAT RATE ENVELOPE';
  318. $ExtraServicebx = '125';
  319. }
  320. else if($data['qm']==0 && $data['js'] == 0)//如果不需要签名,并且快递服务不选择优先
  321. {
  322. $ServiceType = 'FIRST CLASS';
  323. $Container = 'VARIABLE';
  324. $ExtraServicebx = '100';
  325. }
  326. else if($data['qm']==0 && $data['js'] == 3)//如果不需要签名,并且快递服务不选择优先
  327. {
  328. $ServiceType = 'Standard Mail Marketing Parcel';
  329. $Container = 'VARIABLE';
  330. $ExtraServicebx = '100';
  331. }
  332. else if($data['qm']==0 && $data['js'] == 2)//如果不需要签名,并且快递服务选择PRIORITY EXPRESS
  333. {
  334. $ServiceType = 'PRIORITY EXPRESS';
  335. $Container = 'FLAT RATE ENVELOPE';
  336. $ExtraServicebx = '125';
  337. }
  338. if($data['email'])
  339. {
  340. if(strlen($data['email']) < 60 && stripos($data['email'],'tiktok') === false)
  341. {
  342. $xml .= "<ToContactPreference>EMAIL</ToContactPreference>";
  343. $xml .= "<ToContactEMail>".$data['email']."</ToContactEMail>";
  344. }
  345. }
  346. $xml .= "<AllowNonCleansedDestAddr>false</AllowNonCleansedDestAddr>";
  347. $xml .= "<WeightInOunces>".$data['zzl']."</WeightInOunces>";//重量
  348. $xml .= "<ServiceType>".$ServiceType."</ServiceType>";//服务类型
  349. $xml .= "<Container>".$Container."</Container>";//货物类型
  350. $xml .= "<Width></Width>";//可选
  351. $xml .= "<Length></Length>";//可选
  352. $xml .= "<Height></Height>";//可选
  353. $xml .= "<Machinable></Machinable>";//可选
  354. $xml .= "<ProcessingCategory></ProcessingCategory>";//可选
  355. $xml .= "<PriceOptions></PriceOptions>";//可选
  356. $xml .= "<InsuredAmount>".$data['bx']."</InsuredAmount>";//保险金 可选
  357. $xml .= "<AddressServiceRequested>True</AddressServiceRequested>";//可选 客户变更地址提醒
  358. /**
  359. $data['qm'] = ($data['qm']==1)?'False':'True';
  360. if($data['qm'] == 'False')
  361. {
  362. $xml .= "<ExpressMailOptions>";
  363. //$xml .= "<DeliveryOption>1</DeliveryOption>";//可选 交付选择 默认1:正常交付
  364. $xml .= "<WaiverOfSignature>".$data['qm']."</WaiverOfSignature>";//可选 接收签名用False
  365. $xml .= "</ExpressMailOptions>";
  366. }
  367. **/
  368. if($data['qm']==1 && $data['js'] == 2)
  369. {
  370. $xml .= "<ExpressMailOptions>";
  371. //$xml .= "<DeliveryOption>1</DeliveryOption>";//可选 交付选择 默认1:正常交付
  372. $xml .= "<WaiverOfSignature>FALSE</WaiverOfSignature>";//可选 接收签名用False
  373. $xml .= "</ExpressMailOptions>";
  374. }
  375. $xml .= "<ShipDate>".date('m/d/Y',time()-(12*3600)+($data['yc']*24*3600))."</ShipDate>";//可选 发货日期 当前至7天 格式 mm/ dd/ yyyy 延迟发货
  376. //$xml .= "<ReturnCommitments>true</ReturnCommitments>";
  377. $xml .= "<CustomerRefNo>".$data['number']."</CustomerRefNo>";//可选 内部编号显示在运单 不超过19字符
  378. $xml .= "<ExtraServices>";
  379. if(isset($ExtraService))
  380. {
  381. $xml .= "<ExtraService>".$ExtraService."</ExtraService>";//可选额外服务
  382. }
  383. if($data['bx'] > 0)
  384. {
  385. $xml .= "<ExtraService>".$ExtraServicebx."</ExtraService>";//可选额外服务
  386. }
  387. $xml .= "</ExtraServices>";
  388. $xml .= "<ReceiptOption>NONE</ReceiptOption>";//可选打印布局SEPARATE PAGE 或NONE
  389. $xml .= "<ImageType>PDF</ImageType>";//输出类型
  390. $xml .= "<HoldForManifest>Y</HoldForManifest>";
  391. $xml .= "<PrintCustomerRefNo>true</PrintCustomerRefNo>";//内部编号显示要用这个标签
  392. $xml .= "</eVSRequest>";
  393. /** 直连 **/
  394. $ch = curl_init();
  395. $url = 'https://secure.shippingapis.com/ShippingAPI.dll?API=eVS&XML='.$xml;
  396. $url = str_replace(" ",'%20',$url);
  397. curl_setopt($ch,CURLOPT_URL,$url);
  398. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  399. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,0);
  400. curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
  401. curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
  402. curl_setopt($ch,CURLOPT_TIMEOUT,25);
  403. $data = curl_exec($ch);
  404. curl_close($ch);
  405. $data = utf8_encode($data);
  406. libxml_disable_entity_loader(true);
  407. // @$values = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  408. return $data;
  409. /**
  410. $ch = curl_init();
  411. $url = 'http://z.wepolicy.cn/usps.php?XML='.$xml;
  412. $url = str_replace(" ",'%20',$url);
  413. curl_setopt($ch,CURLOPT_URL,$url);
  414. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  415. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,0);
  416. curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
  417. curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
  418. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  419. $data = curl_exec($ch);
  420. curl_close($ch);
  421. $data = json_decode($data,TRUE);
  422. return $data;
  423. //Description提示错误 LabelImage运单PDF BarcodeNumber运单号
  424. **/
  425. }
  426. public function _pdf($pdf,$title,$bctime)
  427. {
  428. $pdf_path = './data/pdf/'.$bctime.'/';
  429. $file_base64 = $pdf;
  430. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  431. $file_base64 = base64_decode($file_base64);
  432. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  433. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  434. return $bctime;
  435. }
  436. public function _qk()//清空用友数据
  437. {
  438. $sc = array();
  439. $a = $this->fullorder->find_all("scapi = '99'");
  440. foreach ($a as $v)
  441. {
  442. if(stripos($v['scid'],'XD') === false || $v['scid'] == '|' || $v['scid'] == '')
  443. {
  444. $this->fullorder->save(array('scid'=>'','scapi'=>0,'dbapi'=>0),$v['id']);
  445. continue;
  446. }
  447. $b = explode('|',trim($v['scid'],'|'));
  448. $b = explode('~',trim($b[0],'~'));
  449. //$c = str_replace('XD','',$b[1]);
  450. if(strlen($b[1]) != 12)
  451. {
  452. $this->fullorder->save(array('scid'=>'','scapi'=>0,'dbapi'=>0),$v['id']);
  453. continue;
  454. }
  455. }
  456. echo "<pre>";
  457. print_r($sc);
  458. exit;
  459. }
  460. public function _w($arg_array)
  461. {
  462. $a = $this->whlabel->read($arg_array[0]);
  463. $s = $this->whlabel->find_all("features = '".$a['features']."'");
  464. echo "<pre>";
  465. print_r($a);
  466. echo "<pre>";
  467. print_r($s);
  468. exit;
  469. }
  470. public function _qczd($arg_array)//清空用友数据
  471. {
  472. $a = $this->whlabel->find_all("zd = '$arg_array[0]'");
  473. foreach ($a as $v)
  474. {
  475. $this->whlabel->save(array('zd'=>''),$v['id']);
  476. }
  477. }
  478. public function _d($arg_array)
  479. {
  480. $a = $this->fullorder->get_number($arg_array[0]);
  481. if(!$a)
  482. {
  483. //$a = $this->fullorder->get_orderinfo($arg_array[0]);
  484. if(!$a)
  485. {
  486. $a = $this->fullordersmt->get_number($arg_array[0]);
  487. if(!$a)
  488. {
  489. //$a = $this->fullordersmt->get_orderinfo($arg_array[0]);
  490. if(!$a)
  491. {
  492. $a = $this->fullordertt->get_number($arg_array[0]);
  493. if(!$a)
  494. {
  495. $a = $this->fullorderxw->get_number($arg_array[0]);
  496. if(!$a)
  497. {
  498. //$a = $this->fullordertt->get_orderinfo($arg_array[0]);
  499. }
  500. }
  501. }
  502. }
  503. }
  504. }
  505. if($a)
  506. {
  507. echo "<pre>";
  508. print_r($a);
  509. }
  510. else
  511. {
  512. echo "没有此数据";
  513. }
  514. exit;
  515. }
  516. public function _wz($arg_array)
  517. {
  518. if(!isset($arg_array[1]))
  519. {
  520. //echo "没有位置数据";
  521. return "没有位置数据";
  522. }
  523. $cid = $this->whlabellabel->find_all("cpid = '".$arg_array[0]."'");
  524. if(isset($cid[0]))
  525. {
  526. $w = $this->whlabel->find_all("number = '".$cid[0]['number']."' and warehouse = '13'");
  527. foreach ($w as $v)
  528. {
  529. $this->whlabel->save(array('details'=>$arg_array[1]),$v['id']);
  530. }
  531. echo json_encode(array('msg'=>'!','success'=>true));exit;
  532. //echo '成功';
  533. //echo "<pre>";
  534. //print_r($w);
  535. }
  536. }
  537. public function _qkyy($arg_array)//清空备货用友数据
  538. {
  539. $y = $this->whlabel_bh->read($arg_array[0]);
  540. if($y)
  541. {
  542. $this->whlabel_bh->save(array('scid'=>'','scapi'=>0,'dbapi'=>0,'state'=>0),$y['id']);
  543. echo 'ok';
  544. }
  545. else
  546. {
  547. echo '没有ID';
  548. }
  549. }
  550. public function _cxxq()//查询独立站订单详情
  551. {
  552. $value = $this->shop->read(3);
  553. $res = $this->get_hq($value['brandname'],$value['shopadmin'],$value);
  554. echo "<pre>";
  555. print_r($res);
  556. }
  557. public function get_hq($name,$shopapi,$shop)
  558. {
  559. $jqtime = ($name=='SuperNova')?24*3600:2*3600;
  560. $fromTime = time()-24*3600-$jqtime;//strtotime('yesterday')-$jqtime;//昨日0点+1小时保险无漏单
  561. $toTime = time();
  562. $post['cs'] = 1;
  563. $post['name'] = $name;
  564. $post['from'] = $fromTime;
  565. $post['to'] = $toTime;
  566. $ch = curl_init();
  567. curl_setopt($ch,CURLOPT_URL,$shopapi);
  568. curl_setopt($ch, CURLOPT_POST, 1);
  569. curl_setopt($ch, CURLOPT_HEADER, 0);
  570. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  571. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  572. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  573. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  574. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  575. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  576. $res = curl_exec($ch);
  577. curl_close($ch);
  578. if($res)
  579. {
  580. $res = json_decode($res,true);
  581. $x = array();
  582. foreach ($res as $v)
  583. {
  584. $source = '';
  585. $sc = substr($v['order_id'],0,3);
  586. if($sc == '600')
  587. {
  588. $source = $shop['thurl']; //手机订单
  589. }
  590. else
  591. {
  592. $source = $shop['url'];//PC订单
  593. }
  594. if($v['wjauthorid'] != '' && $v['sourcecontentid'] != '' && $source != '' && $shop['tweak'] != '')
  595. {
  596. $authorid = $this->authorid($source.'?author_id='.$v['wjauthorid'].'&source_content_id='.$v['sourcecontentid'],$shop['tweak']);
  597. if($authorid)
  598. {
  599. $v['authorid'] = $authorid;
  600. }
  601. }
  602. $x[] = $v;
  603. }
  604. return $x;
  605. }
  606. }
  607. public function _user($arg_array)//查询独立站订单详情
  608. {
  609. $id = $arg_array[0];
  610. $d = $arg_array[1];
  611. $shop = $this->shop->read($id);
  612. $value = $this->user->find_all("shop not like '|".$id."|' and shop like '%|".$d."|%'");
  613. foreach ($value as $v)
  614. {
  615. //$this->user->save(array('shop'=>$v['shop'].$id.'|','shoptext'=>$v['shoptext'].$shop[''].'|'),$v['id']);
  616. }
  617. echo "<pre>";
  618. print_r($value);
  619. }
  620. }