Test.Class.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <?php
  2. /**
  3. * 测试队列任务脚本入口文件
  4. * Created by PhpStorm.
  5. * User: phperstar
  6. * Date: 2018/6/10
  7. * Time: 下午4:49
  8. */
  9. namespace Jobs\Controller;
  10. use Jobs\Dao\DCloudUsers;
  11. use Jobs\Dao\DUsersTestify;
  12. use Jobs\Model\MTopic\Push\MPush;
  13. use Jobs\Model\Middleware;
  14. use Jobs\Dao\DCloudUsersCategory;
  15. use Jobs\Dao\DUsersCategory;
  16. use Jobs\Dao\DGoodsSku;
  17. use Jobs\Dao\DGoods;
  18. use Jobs\Model\Test\K3Handle;
  19. use Jobs\Dao\DOrder;
  20. use Jobs\Model\MTopic\Finance\MReceivable;
  21. use Mall\Framework\Db\Db;
  22. class Test
  23. {
  24. /**
  25. * php ./Public/www/index.php --c=Test --a=Test
  26. */
  27. public function test()
  28. {
  29. $objMReceivable = new MReceivable();
  30. $params = [
  31. 'userCenterId' => 35,
  32. 'enterpriseId' => 64,
  33. 'id' => 9,
  34. 'type' => 5,
  35. ];
  36. $objMReceivable->createReceivable($params);
  37. }
  38. public function testk3()
  39. {
  40. //K/3 Cloud 业务站点地址
  41. $cloudUrl = "http://123.206.51.139/k3cloud/";
  42. //登陆参数
  43. $data = array(
  44. '597be128163613',//帐套Id
  45. '秦统业',//用户名
  46. 'Cwb20141222',//密码
  47. 2052//语言标识
  48. );
  49. //定义记录Cloud服务端返回的Session
  50. $cookie_jar = tempnam('./tmp','CloudSession');
  51. $post_content = self::create_postdata($data);
  52. //$result = invoke_login($cloudUrl,$post_content,$cookie_jar);
  53. $loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  54. $result = self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
  55. header("Content-type: text/html; charset=gb2312");
  56. //echo '<pre>';print_r('登陆请求数据:');
  57. //echo '<pre>';print_r($post_content);
  58. //echo '<pre>';print_r('登陆返回结果:');
  59. //echo '<pre>';print_r($result);
  60. unset($post_content);
  61. unset($result);
  62. unset($data);
  63. /*$data = array(
  64. 'FormId'=>'STK_Inventory',//业务对象表单Id(必录)
  65. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  66. 'Limit'=>10,
  67. 'StartRow'=>0,
  68. 'OrderString'=>'FID ASC',
  69. 'FieldKeys'=>'FMaterialId,FMaterialId.FNumber,FStockName,FMaterialName,FBaseQty,FStockStatusId,FStockOrgId.FNumber',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  70. 'FilterString'=>"FMaterialId=147946",//过滤(非必录)
  71. );*/
  72. /*$k3GoodsInfo = '{"FormId":"STK_Inventory","FieldKeys":"FMaterialId.FNumber,FMaterialName,FStockUnitId.FName,FBaseQty",
  73. "FilterString":"FMaterialId=147946 and ( FStockName = \'菏泽G1库\' or FStockName = \'绿源冷库\' or FStockName = \'绿源冷库3号库\' )",
  74. "OrderString":"","TopRowCount":"0","StartRow":"0","Limit":"100"}';*/
  75. $data = array(
  76. 'FormId'=>'STK_Inventory',//业务对象表单Id(必录)
  77. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  78. 'Limit'=>100,
  79. 'StartRow'=>0,
  80. 'OrderString'=>'',
  81. 'FieldKeys'=>'FMaterialId,FMaterialId.FNumber,FStockName,FMaterialName,FBaseQty,FStockStatusId,FStockOrgId.FNumber',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  82. 'FilterString'=>"FMaterialId.FNumber ='0602070004' and (FStockName = '菏泽G1库' or FStockName = '绿源冷库' or FStockName = '绿源冷库3号库') and FStockOrgId.FNumber='101' ",//过滤(非必录)
  83. );
  84. //定义记录Cloud服务端返回的Session
  85. $post_content = self::create_postdata([$data]);
  86. $url = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc';
  87. $result = self::invoke_post($url,$post_content,$cookie_jar,false);
  88. header("Content-type: text/html; charset=gb2312");
  89. //echo '<pre>';print_r('及时库存请求数据:');
  90. //echo '<pre>';print_r($post_content);
  91. //echo '<pre>';print_r('及时库存返回结果:');
  92. echo '<pre>';var_dump(json_decode($result, true));
  93. $k3Weight = 0.00;
  94. $resultArray = json_decode($result, true);
  95. if(!empty($resultArray)){
  96. foreach ($resultArray as $key => $value){
  97. $k3Weight += $value[4];
  98. }
  99. }
  100. var_dump($k3Weight);
  101. return $k3Weight;
  102. }
  103. public function testk4()
  104. {
  105. //K/3 Cloud 业务站点地址
  106. $cloudUrl = "http://123.206.51.139/k3cloud/";
  107. //登陆参数
  108. $data = array(
  109. '597be128163613',//帐套Id
  110. '秦统业',//用户名
  111. 'Cwb20141222',//密码
  112. 2052//语言标识
  113. );
  114. //定义记录Cloud服务端返回的Session
  115. $cookie_jar = tempnam('./tmp','CloudSession');
  116. $post_content = self::create_postdata($data);
  117. //$result = invoke_login($cloudUrl,$post_content,$cookie_jar);
  118. $loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  119. $result = self::invoke_post($loginurl,$post_content,$cookie_jar,true);
  120. header("Content-type: text/html; charset=gb2312");
  121. echo '<pre>';print_r('登陆请求数据:');
  122. echo '<pre>';print_r($post_content);
  123. echo '<pre>';print_r('登陆返回结果:');
  124. echo '<pre>';print_r($result);
  125. unset($post_content);
  126. unset($result);
  127. unset($data);
  128. /*$data = array(
  129. 'FormId'=>'STK_Inventory',//业务对象表单Id(必录)
  130. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  131. 'Limit'=>10,
  132. 'StartRow'=>0,
  133. 'OrderString'=>'FID ASC',
  134. 'FieldKeys'=>'FMaterialId,FMaterialId.FNumber,FStockName,FMaterialName,FBaseQty,FStockStatusId,FStockOrgId.FNumber',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  135. 'FilterString'=>"FMaterialId=147946",//过滤(非必录)
  136. );*/
  137. /*$k3GoodsInfo = '{"FormId":"STK_Inventory","FieldKeys":"FMaterialId.FNumber,FMaterialName,FStockUnitId.FName,FBaseQty",
  138. "FilterString":"FMaterialId=147946 and ( FStockName = \'菏泽G1库\' or FStockName = \'绿源冷库\' or FStockName = \'绿源冷库3号库\' )",
  139. "OrderString":"","TopRowCount":"0","StartRow":"0","Limit":"100"}';*/
  140. $data = '{"Model":{"FNumber":"xyc2218","FCreateOrgId":{"FNumber":"101"},"FUseOrgId":{"FNumber":"101"},"FName":"u5218u5e05uff08u4ebfu6210u98dfu54c1u5185u90e8u5458u5de5uff09","FTEL":"18114640037","FADDRESS":"u5c71u4e1cu7701u6d4eu5357u5e02u5386u4e0bu533au6d4bu8bd5u5730u5740","FSALDEPTID":{"FNumber":"0020"},"FSALGROUPID":{"FNumber":"16"},"FSELLER":{"FNumber":"0020"},"FCustTypeId":{"FNumber":"KHLB001_SYS"},"FTRADINGCURRID":{"FNumber":"PRE001"},"F_PAEZ_Assistant3":{"FNumber":"0101"},"F_PAEZ_Assistant5":{"FNumber":"01"}},"Creator":"u4ebfu6210u5546u57ce"}';
  141. //定义记录Cloud服务端返回的Session
  142. $post_content = self::create_postdata(["BD_Customer",$data]);
  143. $url = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc';
  144. $result = self::invoke_post($url,$post_content,$cookie_jar,false);
  145. //header("Content-type: text/html; charset=gb2312");
  146. //echo '<pre>';print_r('及时库存请求数据:');
  147. echo '<pre>';print_r($post_content);
  148. //echo '<pre>';print_r('及时库存返回结果:');
  149. //file_put_contents('/tmp/11.log',var_export($result,true),FILE_APPEND);
  150. V($result);
  151. }
  152. // 采购入库单
  153. public function testk5()
  154. {
  155. //K/3 Cloud 业务站点地址
  156. $cloudUrl = "http://123.206.51.139/k3cloud/";
  157. //登陆参数
  158. $data = array(
  159. '597be128163613',//帐套Id
  160. '秦统业',//用户名
  161. 'Cwb20141222',//密码
  162. 2052//语言标识
  163. );
  164. //定义记录Cloud服务端返回的Session
  165. $cookie_jar = tempnam('./tmp','CloudSession');
  166. $post_content = self::create_postdata($data);
  167. //$result = invoke_login($cloudUrl,$post_content,$cookie_jar);
  168. $loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  169. $result = self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
  170. header("Content-type: text/html; charset=gb2312");
  171. //echo '<pre>';print_r('登陆请求数据:');
  172. //echo '<pre>';print_r($post_content);
  173. //echo '<pre>';print_r('登陆返回结果:');
  174. //echo '<pre>';print_r($result);
  175. unset($post_content);
  176. unset($result);
  177. unset($data);
  178. /*$data = array(
  179. 'FormId'=>'STK_Inventory',//业务对象表单Id(必录)
  180. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  181. 'Limit'=>10,
  182. 'StartRow'=>0,
  183. 'OrderString'=>'FID ASC',
  184. 'FieldKeys'=>'FMaterialId,FMaterialId.FNumber,FStockName,FMaterialName,FBaseQty,FStockStatusId,FStockOrgId.FNumber',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  185. 'FilterString'=>"FMaterialId=147946",//过滤(非必录)
  186. );*/
  187. /*$k3GoodsInfo = '{"FormId":"STK_Inventory","FieldKeys":"FMaterialId.FNumber,FMaterialName,FStockUnitId.FName,FBaseQty",
  188. "FilterString":"FMaterialId=147946 and ( FStockName = \'菏泽G1库\' or FStockName = \'绿源冷库\' or FStockName = \'绿源冷库3号库\' )",
  189. "OrderString":"","TopRowCount":"0","StartRow":"0","Limit":"100"}';*/
  190. $data = array(
  191. 'FormId'=>'STK_InStock',//业务对象表单Id(必录)
  192. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  193. 'Limit'=>1,
  194. 'StartRow'=>0,
  195. 'OrderString'=>'FBillNo desc',
  196. 'FieldKeys'=>'FMaterialId.FNumber,FID,FDate,FBillNo,FDocumentStatus,FMaterialId,FStockStatusid,FMaterialName',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  197. 'FilterString'=>"FMaterialId.FNumber ='01110101010001',FDocumentStatus = 'c'",//过滤(非必录)
  198. );
  199. //定义记录Cloud服务端返回的Session
  200. $post_content = self::create_postdata([$data]);
  201. $url = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc';
  202. $result = self::invoke_post($url,$post_content,$cookie_jar,false);
  203. header("Content-type: text/html; charset=gb2312");
  204. //echo '<pre>';print_r('及时库存请求数据:');
  205. //echo '<pre>';print_r($post_content);
  206. //echo '<pre>';print_r('及时库存返回结果:');
  207. V(json_decode($result, true));
  208. }
  209. // 销售退货单
  210. public function testk6()
  211. {
  212. //K/3 Cloud 业务站点地址
  213. $cloudUrl = "http://123.206.51.139/k3cloud/";
  214. //登陆参数
  215. $data = array(
  216. '597be128163613',//帐套Id
  217. '秦统业',//用户名
  218. 'Cwb20141222',//密码
  219. 2052//语言标识
  220. );
  221. //定义记录Cloud服务端返回的Session
  222. $cookie_jar = tempnam('./tmp','CloudSession');
  223. $post_content = self::create_postdata($data);
  224. //$result = invoke_login($cloudUrl,$post_content,$cookie_jar);
  225. $loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  226. $result = self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
  227. header("Content-type: text/html; charset=gb2312");
  228. //echo '<pre>';print_r('登陆请求数据:');
  229. //echo '<pre>';print_r($post_content);
  230. //echo '<pre>';print_r('登陆返回结果:');
  231. //echo '<pre>';print_r($result);
  232. unset($post_content);
  233. unset($result);
  234. unset($data);
  235. /*$data = array(
  236. 'FormId'=>'STK_Inventory',//业务对象表单Id(必录)
  237. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  238. 'Limit'=>10,
  239. 'StartRow'=>0,
  240. 'OrderString'=>'FID ASC',
  241. 'FieldKeys'=>'FMaterialId,FMaterialId.FNumber,FStockName,FMaterialName,FBaseQty,FStockStatusId,FStockOrgId.FNumber',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  242. 'FilterString'=>"FMaterialId=147946",//过滤(非必录)
  243. );*/
  244. /*$k3GoodsInfo = '{"FormId":"STK_Inventory","FieldKeys":"FMaterialId.FNumber,FMaterialName,FStockUnitId.FName,FBaseQty",
  245. "FilterString":"FMaterialId=147946 and ( FStockName = \'菏泽G1库\' or FStockName = \'绿源冷库\' or FStockName = \'绿源冷库3号库\' )",
  246. "OrderString":"","TopRowCount":"0","StartRow":"0","Limit":"100"}';*/
  247. $data = array(
  248. 'FormId'=>'STK_InStock',//业务对象表单Id(必录)
  249. 'TopRowCount'=>0, // 最多允许查询的数量,0或者不要此属性表示不限制
  250. 'Limit'=>1,
  251. 'StartRow'=>0,
  252. 'OrderString'=>'FBillNo desc',
  253. 'FieldKeys'=>'FMaterialId.FNumber,FID,FDate,FBillNo,FDocumentStatus,FMaterialId,FStockStatusid,FMaterialName',//字段keys,字符串类型用逗号分隔,比如"key1,key2..."(必录)
  254. 'FilterString'=>"FMaterialId.FNumber ='01110101010001',FDocumentStatus = 'c'",//过滤(非必录)
  255. );
  256. //定义记录Cloud服务端返回的Session
  257. $post_content = self::create_postdata([$data]);
  258. $url = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc';
  259. $result = self::invoke_post($url,$post_content,$cookie_jar,false);
  260. header("Content-type: text/html; charset=gb2312");
  261. //echo '<pre>';print_r('及时库存请求数据:');
  262. //echo '<pre>';print_r($post_content);
  263. //echo '<pre>';print_r('及时库存返回结果:');
  264. V(json_decode($result, true));
  265. }
  266. //构造Web API请求格式
  267. public function create_postdata($args) {
  268. $postdata = array(
  269. 'format'=>1,
  270. 'useragent'=>'ApiClient',
  271. 'rid'=>self::create_guid(),
  272. 'parameters'=>$args,
  273. 'timestamp'=>date('Y-m-d'),
  274. 'v'=>'1.0'
  275. );
  276. return json_encode($postdata);
  277. }
  278. public function create_guid() {
  279. $charid = strtoupper(md5(uniqid(mt_rand(), true)));
  280. $hyphen = chr(45);// "-"
  281. $uuid = chr(123)// "{"
  282. .substr($charid, 0, 8).$hyphen
  283. .substr($charid, 8, 4).$hyphen
  284. .substr($charid,12, 4).$hyphen
  285. .substr($charid,16, 4).$hyphen
  286. .substr($charid,20,12)
  287. .chr(125);// "}"
  288. return $uuid;
  289. }
  290. public function invoke_post($url,$post_content,$cookie_jar,$isLogin)
  291. {
  292. $ch = curl_init($url);
  293. $this_header = array(
  294. 'Content-Type: application/json',
  295. 'Content-Length: '.strlen($post_content)
  296. );
  297. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  298. curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
  299. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
  300. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  301. if($isLogin){
  302. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
  303. }
  304. else{
  305. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
  306. }
  307. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  308. $result = curl_exec($ch);
  309. curl_close($ch);
  310. return $result;
  311. }
  312. public static function s_put_txt()
  313. {
  314. $objDOrder = new DOrder('pifabbc');
  315. $orderData = $objDOrder->query('SELECT order_id,buyer_id,order_no,order_status,created_at,pay_money,payment_type from ns_order');
  316. foreach ($orderData as $key => $value){
  317. $buyerids[] = $value['buyer_id'];
  318. $orderData[$value['order_id']] = $value;
  319. }
  320. $objDusersCategory = new DUsersCategory('pifabbc');
  321. $infos = $objDusersCategory ->query('SELECT
  322. t.id,
  323. t.user_id as user_id,
  324. t.contact_phone,
  325. t.legal_person,
  326. r.referee_name,
  327. g.group_name,
  328. c.id as category_id,
  329. c.category_name,
  330. c.pid,
  331. t.check_status,
  332. t.company_address,
  333. t.detail_address,
  334. t.erp_no
  335. FROM
  336. cloud_users_testify AS t,
  337. cloud_referee AS r,
  338. cloud_referee_group AS g,
  339. cloud_users_category AS c
  340. WHERE
  341. t.referrer_no = r.referee_no
  342. AND t.referrer_group_no = g.group_no
  343. AND t.category_id = c.id and t.user_id in ('.implode(',', $buyerids).')');
  344. if (!empty($infos)){
  345. foreach ($infos as $key => $value) {
  346. if ($value['pid'] != 0) {
  347. $data = self::s_handle($value);
  348. }
  349. $info = array_merge($value, $data);
  350. $data_file = implode(',', $info);
  351. $userData[$value['user_id']] = $data_file;
  352. }
  353. }
  354. foreach ($orderData as $key => $value){
  355. $content = $userData[$value['user_id']].','.implode(',', $value);
  356. file_put_contents('order.txt',$content . PHP_EOL,FILE_APPEND) ;
  357. unset($content);
  358. }
  359. // $data_file = implode(',', $file);
  360. //
  361. // file_put_contents('cat.txt', $data_file);
  362. }
  363. public static function s_handle(&$info_value)
  364. {
  365. $objDusersCategory = new DUsersCategory();
  366. $id = $info_value['pid'];
  367. $detail = $objDusersCategory->get($id);
  368. if (!empty($detail)) {
  369. $info_value[] = $detail['category_name'];
  370. $info_value['pid'] = $detail['pid'];
  371. self::s_handle($info_value);
  372. }
  373. return $info_value;
  374. }
  375. //php ./Jobs/Public/www/index.php --c=Test --a=userErpReset
  376. public static function userErpReset(){
  377. $objectDCloudUsers = new DCloudUsers();
  378. $objectDUsersTestify = new DUsersTestify();
  379. $fileName = 'k3id.txt';
  380. /*
  381. * 逐行读取TXT文件
  382. */
  383. $file = fopen($fileName,'r');
  384. $content = array();
  385. if(!$file){
  386. return 'file open fail';
  387. }else{
  388. $i = 0;
  389. while (!feof($file)){
  390. $content = mb_convert_encoding(fgets($file),"UTF-8","GBK,ASCII,ANSI,UTF-8");
  391. //print_r($content);
  392. $data = explode(',',$content);
  393. $info = $objectDUsersTestify -> get(['erp_no' => $data[1]]);
  394. if (empty($info)){
  395. echo 0;
  396. continue;
  397. }else{
  398. $res = $objectDUsersTestify ->update(['k3_id'=>$data[0]],['erp_no' => $data[1]]);
  399. echo $res;
  400. }
  401. }
  402. // fclose($file);
  403. // $content = array_filter($content); //数组去空
  404. }
  405. // return $content;
  406. }
  407. //php ./Jobs/Public/www/index.php --c=Test --a=resetErpNo
  408. public static function resetErpNo(){
  409. $log ='';
  410. $objectDCloudUsers = new DCloudUsers();
  411. $objectDUsersTestify = new DUsersTestify();
  412. $sql = "select *from cloud_users_testify WHERE SUBSTR(erp_no,1,3) !='xyc'";
  413. $data = $objectDUsersTestify ->query($sql);
  414. $log .= 'ID,客户新编号,客户旧编号,客户推荐人编码,客户推荐人组织编码,客户推荐人电话'.PHP_EOL;
  415. $K3Handle = new K3Handle();
  416. foreach($data as $value){
  417. $id = $value['id'];
  418. //V($value);
  419. if(!$value['erp_no']){
  420. continue;
  421. }
  422. $erp_no = 'xyc'.$value['user_id'];
  423. $res = $objectDUsersTestify -> update(['erp_no'=>$erp_no],['id'=>$id]);
  424. $res = $K3Handle ->store($value,$erp_no);
  425. if ($res['code'] !=200){
  426. continue;
  427. }
  428. $log .= $id.','.$erp_no.','.$value['erp_no']?:'空'.','.$value['referrer_no'].','.$value['referrer_group_no'].','.$value['referrer_phone'].PHP_EOL;
  429. }
  430. file_put_contents('update_erp_no.txt',$log,FILE_APPEND);
  431. }
  432. //php ./Jobs/Public/www/index.php --c=Test --a=export
  433. public static function export(){
  434. $objDOrder = new DOrder('pifabbc');
  435. $orderData = $objDOrder->query('SELECT sum(pay_money) as order_money ,count(order_id) as total_count,buyer_id from ns_order where order_status <>5 group by buyer_id');
  436. $a =[];
  437. foreach ($orderData as $key => $value){
  438. //$buyerids[] = $value['buyer_id'];
  439. $a[$value['buyer_id']] = $value;
  440. }
  441. $objDusersCategory = new DUsersCategory('pifabbc');
  442. $infos = $objDusersCategory ->query('SELECT
  443. t.id,
  444. t.user_id as user_id,
  445. t.contact_phone,
  446. t.legal_person,
  447. r.referee_name,
  448. g.group_name,
  449. c.id as category_id,
  450. c.category_name,
  451. c.pid,
  452. t.check_status,
  453. t.company_address,
  454. t.detail_address,
  455. t.erp_no
  456. FROM
  457. cloud_users_testify AS t,
  458. cloud_referee AS r,
  459. cloud_referee_group AS g,
  460. cloud_users_category AS c
  461. WHERE
  462. t.referrer_no = r.referee_no
  463. AND t.referrer_group_no = g.group_no
  464. AND t.category_id = c.id and t.user_id ');
  465. $user =[];
  466. if (!empty($infos)){
  467. foreach ($infos as $key => $value) {
  468. if ($value['pid'] != 0) {
  469. $data = self::s_handle($value);
  470. }
  471. $user[$value['user_id']] = $data;
  472. }
  473. }
  474. foreach ($user as $key => $value){
  475. echo 1 .'//';
  476. echo ($key);
  477. // $orderMoney = $objDOrder->query("SELECT sum('pay_money') as order_money ,count('order_id') as total_count from ns_order where order_status <>5 and buyer_id = $key");
  478. $lastTime = $objDOrder->query("SELECT created_at from ns_order where order_status <>5 and buyer_id = $key ORDER by order_id DESC limit 0,1");
  479. if (isset($a[$key])){
  480. $content = implode(',', $value).','.'总金额:'.$a[$key]['order_money']?:0;
  481. $content .= ',订单数:'.$a[$key]['total_count']?:0 ;
  482. $content .= ',最后下单时间:'.$lastTime[0]['created_at']?:0 ;
  483. }else{
  484. $content = implode(',', $value);
  485. }
  486. file_put_contents('export.txt',$content . PHP_EOL,FILE_APPEND) ;
  487. unset($content);
  488. }
  489. }
  490. public function ce(){
  491. $objDOrder = new DOrder('pifabbc');
  492. $lastTime = $objDOrder->query("SELECT created_at from ns_order where order_status <>5 and buyer_id = 4739 ORDER by order_id DESC limit 0,1");
  493. V($lastTime);
  494. }
  495. public function jpush()
  496. {
  497. $swResult = Middleware::getInstance('ThirdPartyService')->sendSwoole('Jpush', 'broadcastPush', ['alias'=>['7581'],'content'=>'优鲜供应链新版即将发布']);
  498. if( !$swResult['state'] ){
  499. V( $swResult['data']);
  500. }else{
  501. V($swResult['data']);
  502. }
  503. }
  504. }