DwyController.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Model\BigKingTbj;
  4. use App\Service\DwyService;
  5. use App\Service\EmployeeService;
  6. use App\Service\SysMenuService;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\Redis;
  9. use Illuminate\Support\Str;
  10. use Obs\ObsClient;
  11. class DwyController extends BaseController
  12. {
  13. public function advertisement(Request $request)
  14. {
  15. $data = $request->all();
  16. file_put_contents('dwy1.txt', json_encode(['data'=>$data,'header']) . PHP_EOL, 8);
  17. if(!isset($data['mac'])||$data['mac'] == 'a6a672c3e458bed2'){
  18. return ['status' => 200, 'data' => [
  19. 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
  20. 'https://clouddevice.qingyaokeji.com/2.mp4'],
  21. 'img' => [
  22. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  23. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  24. ],
  25. 'limit_time' => 10
  26. ]];
  27. }
  28. $url = 'https://tm.dwycloud.com/jbl/api/module-data/poster/poster/diy/device_code';
  29. $token = $data['token'];
  30. $param = ['device_code'=>$data['mac']];
  31. $header = [
  32. 'Content-Type:application/json',
  33. 'Authorization: ' . $token,
  34. ];
  35. $box_data = $this->post_helper($url, json_encode($param), $header);
  36. $box_data = json_decode($box_data, true);
  37. if(isset($box_data)&&$box_data['status'] === 'success'){
  38. $return = [
  39. 'video' => [],
  40. 'img' => [],
  41. 'limit_time' => 1
  42. ];
  43. foreach ($box_data['data'] as $v){
  44. if(isset($v['poster_attachment']['picture_attachment']['attachFile'])){
  45. foreach ($v['poster_attachment']['picture_attachment']['attachFile'] as $vv){
  46. // var_dump($vv);
  47. $return['img'][] = $this->getObsUrl($vv['path']);
  48. }
  49. }
  50. if(isset($v['poster_attachment']['attachment']['attachFile'])){
  51. foreach ($v['poster_attachment']['attachment']['attachFile'] as $vv){
  52. // var_dump($vv);
  53. $return['video'][] = $this->getObsUrl($vv['path']);
  54. }
  55. }
  56. }
  57. }else{
  58. $return = [
  59. 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
  60. 'https://clouddevice.qingyaokeji.com/2.mp4'],
  61. 'img' => [
  62. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  63. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  64. ],
  65. 'limit_time' => 15
  66. ];
  67. }
  68. return ['status' => 200, 'data' => $return];
  69. }
  70. public function getObsUrl($key){
  71. //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/E1F5AF36B011AEBAACB7246DD15F5E1E
  72. //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/1718928008131.jpg
  73. $obsClient = new ObsClient([
  74. 'key' => '0LLP17PIAGNVS5SFLMZL',
  75. 'secret' => 'A5dANNHaTelCzdLuhq9Gyrw13QZF3aNpZkKoySWF',
  76. 'endpoint' => 'https://obs.cn-east-2.myhuaweicloud.com'
  77. ]);
  78. // 设置桶名和对象名
  79. $bucketName = 'shangbiaoji-test';
  80. $objectKey = $key; // 例如:path/to/video.mp4
  81. // 设置过期时间(以秒为单位)
  82. $expires = 86400; // URL的有效期为1小时
  83. // 生成预签名URL
  84. $response = $obsClient->createSignedUrl([
  85. 'Method' => 'GET', // 请求方法
  86. 'Bucket' => $bucketName,
  87. 'Key' => $objectKey,
  88. 'Expires' => $expires
  89. ]);
  90. // 获取预签名URL
  91. $signedUrl = $response['SignedUrl'];
  92. $obsClient->close();
  93. return $signedUrl;
  94. }
  95. public function openCommand(Request $request)
  96. {
  97. $data = $request->all();
  98. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  99. $device_id = $data['device_code'];
  100. $box_code = $data['box_code'];
  101. $key = $data['type'];
  102. $limit = 60;
  103. if ($key === 'UP') {
  104. $num = Redis::get($device_id . 'status_num');
  105. if (empty($num)) $num = 0;
  106. $num++;
  107. if ($num === 1) {
  108. Redis::set($device_id . 'status_num', $num);
  109. Redis::expire($device_id . 'status_num', $limit);
  110. Redis::set($device_id . 'status', 201);
  111. Redis::expire($device_id . 'status', $limit);
  112. Redis::set($device_id, json_encode([$box_code]));
  113. Redis::expire($device_id, $limit);
  114. } else {
  115. $old = Redis::get($device_id);
  116. if (empty($old)) $old = [];
  117. else $old = json_decode($old, true);
  118. $data = array_merge($old, [$box_code]);
  119. Redis::set($device_id, json_encode($data));
  120. Redis::expire($device_id, $limit);
  121. Redis::del($device_id . 'status');
  122. Redis::del($device_id . 'status_num');
  123. }
  124. } else {
  125. Redis::set($device_id, json_encode([$box_code]));
  126. Redis::expire($device_id, $limit);
  127. }
  128. return ['status' => 200];
  129. }
  130. public function openDoor(Request $request)
  131. {
  132. $data = $s = $request->all();
  133. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  134. $data = $data['device_code'];
  135. $code = Redis::get($data);
  136. Redis::del($data);
  137. // return ['data'=>['CK00001','CK00018'],'status'=>200];
  138. if (empty($code)) return ['data' => [], 'status' => 201];
  139. $status = Redis::get($data . 'status');
  140. if (empty($status)) $status = 200;
  141. if(isset($s['again'])&&$s['again']===true) $status = 201;
  142. return ['data' => json_decode($code, true), 'status' => $status];
  143. }
  144. public function maintenance(Request $request)
  145. {
  146. $data = [
  147. [
  148. 'code' => 'CK00001',
  149. 'title' => '设备仓'
  150. ],[
  151. 'code' => 'CK00003',
  152. 'title' => '维修仓'
  153. ],[
  154. 'code' => 'CK00004',
  155. 'title' => '商标一号仓'
  156. ],[
  157. 'code' => 'CK00005',
  158. 'title' => '商标二号仓'
  159. ],[
  160. 'code' => 'CK00006',
  161. 'title' => '商标三号仓'
  162. ],[
  163. 'code' => 'CK00007',
  164. 'title' => '商标四号仓'
  165. ],[
  166. 'code' => 'CK00008',
  167. 'title' => '商标五号仓'
  168. ],[
  169. 'code' => 'CK00009',
  170. 'title' => '商标六号仓'
  171. ],[
  172. 'code' => 'CK00010',
  173. 'title' => '商标七号仓'
  174. ],[
  175. 'code' => 'CK00011',
  176. 'title' => '商标八号仓'
  177. ],[
  178. 'code' => 'CK00012',
  179. 'title' => '商标九号仓'
  180. ],[
  181. 'code' => 'CK00013',
  182. 'title' => '商标十号仓'
  183. ],[
  184. 'code' => 'CK00014',
  185. 'title' => '商标十一号仓'
  186. ],[
  187. 'code' => 'CK00015',
  188. 'title' => '商标十二号仓'
  189. ],[
  190. 'code' => 'CK00016',
  191. 'title' => '商标十三号仓'
  192. ],[
  193. 'code' => 'CK00017',
  194. 'title' => '商标十四号仓'
  195. ],[
  196. 'code' => 'CK00018',
  197. 'title' => '商标十五号仓'
  198. ],[
  199. 'code' => 'CK00019',
  200. 'title' => '商标十六号仓'
  201. ]
  202. ];
  203. return ['data' => $data, 'status' => 200];
  204. }
  205. public function getOpenCommand(Request $request)
  206. {
  207. $data = $request->all();
  208. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  209. $device_id = $data['device_code'];
  210. $box_code = $data['box_code'];
  211. $key = $device_id . '_' . $box_code;
  212. $return = 201;
  213. $status = Redis::get($key);
  214. if ($status) {
  215. $return = 200;
  216. Redis::del($key);
  217. }
  218. return ['status' => $return];
  219. }
  220. public function boxList(Request $request)
  221. {
  222. $param = $request->all();
  223. $token = $param['token'];
  224. $device_code = $param['device_code'];
  225. //商标仓列表
  226. $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
  227. $header = [
  228. 'Content-Type:application/json',
  229. 'Authorization: ' . $token,
  230. ];
  231. $box_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
  232. $box_data = json_decode($box_data, true);
  233. if (isset($box_data['status']) && $box_data['status'] === 'success') {
  234. //库存查询
  235. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  236. $stock_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
  237. $stock_data = json_decode($stock_data, true);
  238. if ($stock_data) {
  239. $list = [];
  240. $material_list = [];
  241. foreach ($box_data['data'] as $v) {
  242. $list[$v['box_code']] = [
  243. 'material_code' => $v['material_code'],
  244. 'material_code_show' => $v['material_code_show'],
  245. 'box_code' => $v['box_code'],
  246. 'box_code_show' => $v['box_code_show'],
  247. 'min_stock_qty' => $v['min_stock_qty'] ?? 0,
  248. 'safe_stock_qty' => $v['safe_stock_qty'] ?? 0,
  249. 'status' => 1, //0设备仓中没有对应库存,1有对应库存,2对应商标仓中还有数量不允许上标
  250. 'qty' => 0,
  251. 'device_title' => $v['device']['name'] ?? '',
  252. ];
  253. $material_list[$v['material_code']][] = $v['box_code'];
  254. }
  255. $return = [];
  256. foreach ($stock_data as $v) {
  257. if (isset($material_list[$v['material_code']]) && $v['box_code'] == 'CK00001' && $v['qty'] > 0) {
  258. foreach ($material_list[$v['material_code']] as $vv) {
  259. $list[$vv]['status'] = 1;
  260. }
  261. }
  262. if (isset($list[$v['box_code']]) && $v['qty'] > 0) {
  263. $list[$v['box_code']]['qty'] = $v['qty'];
  264. }
  265. }
  266. foreach ($list as $v) {
  267. if ($v['qty'] > 0) {
  268. $v['status'] = 2;
  269. }
  270. $return[] = $v;
  271. }
  272. return ['status' => 'success', 'data' => $return];
  273. }
  274. }
  275. return $box_data;
  276. }
  277. public function test(){
  278. $a = json_decode('{
  279. "status": 200,
  280. "data": [
  281. {
  282. "created_date_lt": "2024-06-08T08:30:15.000Z",
  283. "created_date": "2024-06-08T08:30:15.086Z",
  284. "last_modified_by_show": "余丽娴",
  285. "device_code": "a6a672c3e458bed2",
  286. "material_code": "40010127000001",
  287. "last_modified_by": "553395510115962882",
  288. "unit_code_show": "张",
  289. "bus_type_dk": "SUPPLIER",
  290. "created_by": "553395510115962882",
  291. "unit_code": "ST",
  292. "dynamic_form_value_id": "587196751249805312",
  293. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  294. "device_code_show": "天凝工厂1号机",
  295. "belong_org": "0102",
  296. "bus_type_dk_show": "工厂",
  297. "created_by_show": "余丽娴",
  298. "id": "587196751312719872",
  299. "supplier_code": "0102",
  300. "main_table_id": null,
  301. "last_modified_date_lt": "2024-06-08T08:30:15.000Z",
  302. "material_code_show": "尊贵免漆板ENF小标",
  303. "qty": 4040,
  304. "specs": null,
  305. "box_code": "CK00005",
  306. "request_id": null,
  307. "detail_table_id": null,
  308. "last_modified_date": "2024-06-08T08:30:15.095Z",
  309. "box_code_show": "商标二号仓",
  310. "in_stock_qty": 5000,
  311. "use_qty": 4040,
  312. "product_list": [
  313. {
  314. "product_code": "BC450108000001",
  315. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  316. "order_item_id": "581029211289030656",
  317. "order_item_id_show": "SO202405200171",
  318. "process_title": "",
  319. "color": "",
  320. "process_title_two": "",
  321. "color_two": "",
  322. "send_qty": "120",
  323. "fake_qty": "120",
  324. "restock_qty": 0
  325. },
  326. {
  327. "product_code": "BC450108000001",
  328. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  329. "order_item_id": "581029211242893312",
  330. "order_item_id_show": "SO202405200171",
  331. "process_title": "",
  332. "color": "",
  333. "process_title_two": "",
  334. "color_two": "",
  335. "send_qty": "30",
  336. "fake_qty": "30",
  337. "restock_qty": 0
  338. },
  339. {
  340. "product_code": "BC450108000001",
  341. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  342. "order_item_id": "581029211221921792",
  343. "order_item_id_show": "SO202405200171",
  344. "process_title": "",
  345. "color": "",
  346. "process_title_two": "",
  347. "color_two": "",
  348. "send_qty": "160",
  349. "fake_qty": "160",
  350. "restock_qty": 0
  351. }
  352. ],
  353. "send_qty": 310,
  354. "restore_qty": 0
  355. },
  356. {
  357. "created_date_lt": "2024-06-06T10:34:14.000Z",
  358. "created_date": "2024-06-06T10:34:14.502Z",
  359. "last_modified_by_show": "余丽娴",
  360. "device_code": "a6a672c3e458bed2",
  361. "material_code": "40010232000001",
  362. "last_modified_by": "553395510115962882",
  363. "unit_code_show": "张",
  364. "bus_type_dk": "SUPPLIER",
  365. "created_by": "553395510115962882",
  366. "unit_code": "ST",
  367. "dynamic_form_value_id": "586503178690891776",
  368. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  369. "device_code_show": "天凝工厂1号机",
  370. "belong_org": "0102",
  371. "bus_type_dk_show": "工厂",
  372. "created_by_show": "余丽娴",
  373. "id": "586503178758000640",
  374. "supplier_code": "0102",
  375. "main_table_id": null,
  376. "last_modified_date_lt": "2024-06-06T10:34:14.000Z",
  377. "material_code_show": "优选A6森芯板E0小标",
  378. "qty": 4519,
  379. "specs": null,
  380. "box_code": "CK00007",
  381. "request_id": null,
  382. "detail_table_id": null,
  383. "last_modified_date": "2024-06-06T10:34:14.512Z",
  384. "box_code_show": "商标四号仓",
  385. "in_stock_qty": 4652,
  386. "use_qty": 4519,
  387. "product_list": [],
  388. "send_qty": 0
  389. },
  390. {
  391. "created_date_lt": "2024-06-08T05:59:10.000Z",
  392. "created_date": "2024-06-08T05:59:10.127Z",
  393. "last_modified_by_show": "余丽娴",
  394. "device_code": "a6a672c3e458bed2",
  395. "material_code": "40010504000001",
  396. "last_modified_by": "553395510115962882",
  397. "unit_code_show": "张",
  398. "bus_type_dk": "SUPPLIER",
  399. "created_by": "553395510115962882",
  400. "unit_code": "ST",
  401. "dynamic_form_value_id": "587158730056011776",
  402. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  403. "device_code_show": "天凝工厂1号机",
  404. "belong_org": "0102",
  405. "bus_type_dk_show": "工厂",
  406. "created_by_show": "余丽娴",
  407. "id": "587158730123120640",
  408. "supplier_code": "0102",
  409. "main_table_id": null,
  410. "last_modified_date_lt": "2024-06-08T05:59:10.000Z",
  411. "material_code_show": "ENF圆标",
  412. "qty": 2909,
  413. "specs": null,
  414. "box_code": "CK00010",
  415. "request_id": null,
  416. "detail_table_id": null,
  417. "last_modified_date": "2024-06-08T05:59:10.136Z",
  418. "box_code_show": "商标七号仓",
  419. "in_stock_qty": 5000,
  420. "use_qty": 2909,
  421. "safe_stock_qty": 400,
  422. "min_stock_qty": 100,
  423. "product_list": [
  424. {
  425. "product_code": "BC450108000001",
  426. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  427. "order_item_id": "581029211289030656",
  428. "order_item_id_show": "SO202405200171",
  429. "process_title": "",
  430. "color": "",
  431. "process_title_two": "",
  432. "color_two": "",
  433. "send_qty": "120",
  434. "fake_qty": "120",
  435. "restock_qty": 0
  436. },
  437. {
  438. "product_code": "BC450108000001",
  439. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  440. "order_item_id": "581029211242893312",
  441. "order_item_id_show": "SO202405200171",
  442. "process_title": "",
  443. "color": "",
  444. "process_title_two": "",
  445. "color_two": "",
  446. "send_qty": "30",
  447. "fake_qty": "30",
  448. "restock_qty": 0
  449. },
  450. {
  451. "product_code": "BC450108000001",
  452. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  453. "order_item_id": "581029211221921792",
  454. "order_item_id_show": "SO202405200171",
  455. "process_title": "",
  456. "color": "",
  457. "process_title_two": "",
  458. "color_two": "",
  459. "send_qty": "160",
  460. "fake_qty": "160",
  461. "restock_qty": 0
  462. }
  463. ],
  464. "send_qty": 310,
  465. "restore_qty": 0
  466. },
  467. {
  468. "created_date_lt": "2024-06-06T07:05:12.000Z",
  469. "created_date": "2024-06-06T07:05:12.783Z",
  470. "last_modified_by_show": "余丽娴",
  471. "device_code": "a6a672c3e458bed2",
  472. "material_code": "40010102000001",
  473. "last_modified_by": "553395510115962882",
  474. "unit_code_show": "张",
  475. "bus_type_dk": "SUPPLIER",
  476. "created_by": "553395510115962882",
  477. "unit_code": "ST",
  478. "dynamic_form_value_id": "586450574908723200",
  479. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  480. "device_code_show": "天凝工厂1号机",
  481. "belong_org": "0102",
  482. "bus_type_dk_show": "工厂",
  483. "created_by_show": "余丽娴",
  484. "id": "586450574980026368",
  485. "supplier_code": "0102",
  486. "main_table_id": null,
  487. "last_modified_date_lt": "2024-06-06T07:05:12.000Z",
  488. "material_code_show": "尊贵免漆背板E0小标",
  489. "qty": 5001,
  490. "specs": null,
  491. "box_code": "CK00011",
  492. "request_id": null,
  493. "detail_table_id": null,
  494. "last_modified_date": "2024-06-06T07:05:12.793Z",
  495. "box_code_show": "商标八号仓",
  496. "in_stock_qty": 5001,
  497. "use_qty": 5001,
  498. "product_list": [],
  499. "send_qty": 0
  500. },
  501. {
  502. "created_date_lt": "2024-06-06T07:37:23.000Z",
  503. "created_date": "2024-06-06T07:37:23.194Z",
  504. "last_modified_by_show": "余丽娴",
  505. "device_code": "a6a672c3e458bed2",
  506. "material_code": "40010134000001",
  507. "last_modified_by": "553395510115962882",
  508. "unit_code_show": "张",
  509. "bus_type_dk": "SUPPLIER",
  510. "created_by": "553395510115962882",
  511. "unit_code": "ST",
  512. "dynamic_form_value_id": "586458671639302144",
  513. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  514. "device_code_show": "天凝工厂1号机",
  515. "belong_org": "0102",
  516. "bus_type_dk_show": "工厂",
  517. "created_by_show": "余丽娴",
  518. "id": "586458671702216704",
  519. "supplier_code": "0102",
  520. "main_table_id": null,
  521. "last_modified_date_lt": "2024-06-06T07:37:23.000Z",
  522. "material_code_show": "优选免漆板ENF小标",
  523. "qty": 3345,
  524. "specs": null,
  525. "box_code": "CK00014",
  526. "request_id": null,
  527. "detail_table_id": null,
  528. "last_modified_date": "2024-06-06T07:37:23.203Z",
  529. "box_code_show": "商标十一号仓",
  530. "in_stock_qty": 3345,
  531. "use_qty": 3345,
  532. "safe_stock_qty": 400,
  533. "min_stock_qty": 300,
  534. "product_list": [],
  535. "send_qty": 0
  536. },
  537. {
  538. "created_date_lt": "2024-06-07T08:37:02.000Z",
  539. "created_date": "2024-06-07T08:37:02.353Z",
  540. "last_modified_by_show": "余丽娴",
  541. "device_code": "a6a672c3e458bed2",
  542. "material_code": "40010101000999",
  543. "last_modified_by": "553395510115962882",
  544. "unit_code_show": "张",
  545. "bus_type_dk": "SUPPLIER",
  546. "created_by": "553395510115962882",
  547. "unit_code": "ST",
  548. "dynamic_form_value_id": "586836071590006784",
  549. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  550. "device_code_show": "天凝工厂1号机",
  551. "belong_org": "0102",
  552. "bus_type_dk_show": "工厂",
  553. "created_by_show": "余丽娴",
  554. "id": "586836071657115648",
  555. "supplier_code": "0102",
  556. "main_table_id": null,
  557. "last_modified_date_lt": "2024-06-07T08:37:02.000Z",
  558. "material_code_show": "E0批零免漆(测试白标)",
  559. "qty": 1234,
  560. "specs": null,
  561. "box_code": "CK00015",
  562. "request_id": null,
  563. "detail_table_id": null,
  564. "last_modified_date": "2024-06-07T08:37:02.364Z",
  565. "box_code_show": "商标十二号仓",
  566. "in_stock_qty": 1518,
  567. "use_qty": 1234,
  568. "product_list": [],
  569. "send_qty": 0
  570. },
  571. {
  572. "created_date_lt": "2024-06-08T02:08:40.000Z",
  573. "created_date": "2024-06-08T02:08:40.233Z",
  574. "last_modified_by_show": "余丽娴",
  575. "device_code": "a6a672c3e458bed2",
  576. "material_code": "40010504000001",
  577. "last_modified_by": "553395510115962882",
  578. "unit_code_show": "张",
  579. "bus_type_dk": "SUPPLIER",
  580. "created_by": "553395510115962882",
  581. "unit_code": "ST",
  582. "dynamic_form_value_id": "587100723276288000",
  583. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  584. "device_code_show": "天凝工厂1号机",
  585. "belong_org": "0102",
  586. "bus_type_dk_show": "工厂",
  587. "created_by_show": "余丽娴",
  588. "id": "587100723347591168",
  589. "supplier_code": "0102",
  590. "main_table_id": null,
  591. "last_modified_date_lt": "2024-06-08T02:08:40.000Z",
  592. "material_code_show": "ENF圆标",
  593. "qty": 4467,
  594. "specs": null,
  595. "box_code": "CK00016",
  596. "request_id": null,
  597. "detail_table_id": null,
  598. "last_modified_date": "2024-06-08T02:08:40.243Z",
  599. "box_code_show": "商标十三号仓",
  600. "in_stock_qty": 5000,
  601. "use_qty": 4467,
  602. "safe_stock_qty": 400,
  603. "min_stock_qty": 100,
  604. "product_list": [],
  605. "send_qty": 0
  606. },
  607. {
  608. "created_date_lt": "2024-06-07T08:12:36.000Z",
  609. "created_date": "2024-06-07T08:12:36.275Z",
  610. "last_modified_by_show": "余丽娴",
  611. "device_code": "a6a672c3e458bed2",
  612. "material_code": "40010501000999",
  613. "last_modified_by": "553395510115962882",
  614. "unit_code_show": "张",
  615. "bus_type_dk": "SUPPLIER",
  616. "created_by": "553395510115962882",
  617. "unit_code": "ST",
  618. "dynamic_form_value_id": "586829922408992768",
  619. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  620. "device_code_show": "天凝工厂1号机",
  621. "belong_org": "0102",
  622. "bus_type_dk_show": "工厂",
  623. "created_by_show": "余丽娴",
  624. "id": "586829922471907328",
  625. "supplier_code": "0102",
  626. "main_table_id": null,
  627. "last_modified_date_lt": "2024-06-07T08:12:36.000Z",
  628. "material_code_show": "银盾抗菌圆标(测试白标)",
  629. "qty": 1236,
  630. "specs": null,
  631. "box_code": "CK00017",
  632. "request_id": null,
  633. "detail_table_id": null,
  634. "last_modified_date": "2024-06-07T08:12:36.284Z",
  635. "box_code_show": "商标十四号仓",
  636. "in_stock_qty": 1510,
  637. "use_qty": 1236,
  638. "product_list": [],
  639. "send_qty": 0
  640. },
  641. {
  642. "created_date_lt": "2024-06-06T07:35:54.000Z",
  643. "created_date": "2024-06-06T07:35:54.496Z",
  644. "last_modified_by_show": "余丽娴",
  645. "device_code": "a6a672c3e458bed2",
  646. "material_code": "40010504000001",
  647. "last_modified_by": "553395510115962882",
  648. "unit_code_show": "张",
  649. "bus_type_dk": "SUPPLIER",
  650. "created_by": "553395510115962882",
  651. "unit_code": "ST",
  652. "dynamic_form_value_id": "586458299612925952",
  653. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  654. "device_code_show": "天凝工厂1号机",
  655. "belong_org": "0102",
  656. "bus_type_dk_show": "工厂",
  657. "created_by_show": "余丽娴",
  658. "id": "586458299675840512",
  659. "supplier_code": "0102",
  660. "main_table_id": null,
  661. "last_modified_date_lt": "2024-06-06T07:35:54.000Z",
  662. "material_code_show": "ENF圆标",
  663. "qty": 32,
  664. "specs": null,
  665. "box_code": "CK00018",
  666. "request_id": null,
  667. "detail_table_id": null,
  668. "last_modified_date": "2024-06-06T07:35:54.505Z",
  669. "box_code_show": "商标十五号仓",
  670. "in_stock_qty": 1540,
  671. "use_qty": 32,
  672. "safe_stock_qty": 400,
  673. "min_stock_qty": 100,
  674. "product_list": [],
  675. "send_qty": 0
  676. }
  677. ]
  678. }',true);
  679. foreach ($a['data'] as $k=>$v){
  680. if($v['box_code'] == 'CK00005') {
  681. foreach ($v['product_list'] as $kk=>$vv){
  682. if($kk > 0 ){
  683. unset($v['product_list'][$kk]);
  684. continue;
  685. }
  686. $v['product_list'][$kk]['send_qty'] = 200;
  687. $v['product_list'][$kk]['fake_qty'] = 200;
  688. }
  689. // $a['data'][$k]['box_code'] = 'CK00006';
  690. // $a['data'][$k]['box_code_show'] = '商标三号仓';
  691. $aa = $v;
  692. // $aa['box_code'] = 'CK00019';
  693. // $aa['box_code_show'] = '商标十六号';
  694. $aa['send_qty'] = 200;
  695. //
  696. // $bb = $v;
  697. // $bb['box_code'] = 'CK00013';
  698. // $bb['box_code_show'] = '商标十号';
  699. // $bb['send_qty'] = '15';
  700. //
  701. // $cc = $v;
  702. // $cc['box_code'] = 'CK00014';
  703. // $cc['box_code_show'] = '商标十一号';
  704. // $cc['send_qty'] = '15';
  705. //
  706. // $dd = $v;
  707. // $dd['box_code'] = 'CK00015';
  708. // $dd['box_code_show'] = '商标十二号';
  709. // $dd['send_qty'] = '15';
  710. //
  711. // $gg = $v;
  712. // $gg['box_code'] = 'CK00018';
  713. // $gg['box_code_show'] = '商标十五号';
  714. // $gg['send_qty'] = '15';
  715. }
  716. if($v['box_code'] == 'CK00004'||$v['box_code'] == 'CK00005'||$v['box_code'] == 'CK00006'||$v['box_code'] == 'CK00007'||$v['box_code'] == 'CK00008'||$v['box_code'] == 'CK00009'||$v['box_code'] == 'CK00010'||$v['box_code'] == 'CK00011'||$v['box_code'] == 'CK00012'||$v['box_code'] == 'CK00013'||$v['box_code'] == 'CK00014'||$v['box_code'] == 'CK00015'||$v['box_code'] == 'CK00016'||$v['box_code'] == 'CK00017'||$v['box_code'] == 'CK00018'||$v['box_code'] == 'CK00019') {
  717. unset($a['data'][$k]);
  718. continue;
  719. }
  720. }
  721. $box_list = [
  722. 1,2
  723. ];
  724. foreach ($box_list as $v){
  725. $v = $v+3;
  726. if($v<10) $n = '0'.$v;
  727. else $n = $v;
  728. $aa['box_code'] = 'CK000'.$n;
  729. $aa['box_code_show'] = '商标'.($n-3).'号';
  730. $a['data'][] = $aa;
  731. }
  732. // $a['data'][] = $bb;
  733. // $a['data'][] = $cc;
  734. // $a['data'][] = $dd;
  735. // $a['data'][] = $gg;
  736. usort( $a['data'], function ($jj,$kk){
  737. return str_replace('CK','',$jj['box_code']) - str_replace('CK','',$kk['box_code']);
  738. });
  739. return $a;
  740. }
  741. public function setLb(Request $request)
  742. {
  743. $param = $request->all();
  744. file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
  745. // $param = json_decode('{"token":"Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1OTAwNDY0ODg5NDAzODQyNTYiLCJhdXRoIjoiUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9PVVRFUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTk5FUl9VU0VSLFJPTEVfSU5URVJGQUNFLFJPTEVfU0VORF9CUkFORF9TVVBQTElFUiIsInRva2VuSWQiOiIzIiwiZXhwIjoxNzIxMzU1NDczfQ.BMRYPq_8TXaSE4isig-2hn3I6J25IeFe8_Z9_-LZZt41yGVRE0OQUlSO9zl93a1Lv7fW9D0BB8V9ZoHxvRfWhA","list":[{"title":"E0\u6279\u96f6\u514d\u6f06\uff08\u6d4b\u8bd5\u767d\u6807\uff09","num":"6500","restock_qty":0,"product_code":"BC020202000999","product_code_show":"\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728","order_item_id":"590882008738308096","order_item_id_show":"SO202406180173","decor_code_show":"\u6d4b\u8bd5\u82b1\u827201","craft_type_code_show":"\u5178\u96c5\u6c99\u8d1d","specs":"\u5178\u96c5\u6c99\u8d1d \u6d4b\u8bd5\u82b1\u827201 11345","material_name":"\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728"},{"title":"\u94f6\u76fe\u6297\u83cc\u5706\u6807\uff08\u6d4b\u8bd5\u767d\u6807\uff09","num":"500","restock_qty":0,"product_code":"BC020202000999","product_code_show":"\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728","order_item_id":"590882008738308096","order_item_id_show":"SO202406180173","decor_code_show":"\u6d4b\u8bd5\u82b1\u827201","craft_type_code_show":"\u5178\u96c5\u6c99\u8d1d","specs":"\u5178\u96c5\u6c99\u8d1d \u6d4b\u8bd5\u82b1\u827201 11345","material_name":"\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728"}],"mac":"28f1e65c8cfd496f"}',true);
  746. $token = $param['token'];
  747. $list = $param['list'];
  748. $mac = $param['mac'];
  749. // if($mac === '28f1e65c8cfd496f'){
  750. ////
  751. // return $this->test();
  752. // }
  753. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  754. $header = [
  755. 'Content-Type:application/json',
  756. 'Authorization: ' . $token,
  757. ];
  758. $data = $this->post_helper($url, '{"device_code":"'.$mac.'"}', $header);
  759. $data = json_decode($data, true);
  760. if($mac == 'a6a672c3e458bed2'||$mac == 'DV00001'){
  761. usort($data, function ($a,$b){
  762. return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  763. });
  764. }else{
  765. usort($data, function($a, $b) {
  766. return $b['qty'] < $a['qty'];
  767. });
  768. }
  769. //做一个单独的校验,如果数量不够则返回失败
  770. $out_key_list = [];
  771. foreach ($list as $l){
  772. if(!isset($out_key_list[$l['title']])) $out_key_list[$l['title']] = 0;
  773. $out_key_list[$l['title']] += $l['num'];
  774. }
  775. $box_key_list = [];
  776. foreach ($data as $d){
  777. if (!isset($d['box_code_show']) || $d['box_code_show'] == '设备仓') {
  778. continue;
  779. }
  780. if(!isset($box_key_list[$d['material_code_show']])) $box_key_list[$d['material_code_show']] = 0;
  781. $box_key_list[$d['material_code_show']] += $d['qty'];
  782. }
  783. foreach ($out_key_list as $k=>$v){
  784. if(!isset($box_key_list[$k])){
  785. return ['status' => '201', 'data' => [],'msg'=>$k.'没有库存信息!'];
  786. }
  787. if($box_key_list[$k] < $v) {
  788. return ['status' => '201','data'=>[], 'msg' => $k.'库存数量不足信息!'];
  789. }
  790. }
  791. //end
  792. foreach ($data as $k => &$v) {
  793. if (!isset($v['product_list'])) $v['product_list'] = [];
  794. if (!isset($v['box_code_show']) || $v['box_code_show'] == '设备仓') {
  795. unset($data[$k]);
  796. continue;
  797. }
  798. if ($v['qty'] <= 0) {
  799. unset($data[$k]);
  800. continue;
  801. }
  802. $v['use_qty'] = $v['qty'];
  803. if (!isset($v['send_qty'])) $v['send_qty'] = 0;
  804. foreach ($list as $kk => $vv) {
  805. if ($vv['num'] == 0) continue;
  806. if ($v['material_code_show'] === $vv['title']) {
  807. $v['restore_qty'] = isset($vv['restock_qty']) && $vv['restock_qty'] > 0 ? $vv['restock_qty'] : 0;
  808. if (($v['qty'] - $v['send_qty']) > $vv['num']) {
  809. $list[$kk]['num'] -= $vv['num'];
  810. $v['send_qty'] += $vv['num'];
  811. $p_total = $vv['num'];
  812. } else {
  813. $list[$kk]['num'] -= ($v['qty'] - $v['send_qty']);
  814. $p_total = ($v['qty'] - $v['send_qty']);
  815. $v['send_qty'] += ($v['qty'] - $v['send_qty']);
  816. }
  817. //把产品相关参数进行封装
  818. ////产品编号
  819. //"product_code": "",
  820. ////产品名称
  821. //"product_code_show": "",
  822. ////工艺
  823. //"process_title": "",
  824. ////花色
  825. //"color": "",
  826. ////工艺2
  827. //"process_title_two": "",
  828. ////花色2
  829. //"color_two": "",
  830. if($p_total == 0) continue;
  831. $key_arr = [
  832. 'product_code' => $vv['product_code'] ?? '',
  833. 'product_code_show' => $vv['product_code_show'] ?? '',
  834. 'order_item_id' => $vv['order_item_id'] ?? '',
  835. 'order_item_id_show' => $vv['order_item_id_show'] ?? '',
  836. 'process_title' => $vv['craft_type_code_show'] ?? '',
  837. 'color' => $vv['decor_code_show'] ?? '',
  838. 'process_title_two' => $vv['craft_type_two_code_show'] ?? '',
  839. 'color_two' => $vv['decor_two_code_show'] ?? '',
  840. 'send_qty' => $p_total,
  841. 'fake_qty' => $p_total,
  842. // 'send_qty' => 0,
  843. 'restock_qty' => $vv['restock_qty'] ?? 0,
  844. ];
  845. if($vv['restock_qty'] > 0) $list[$kk]['restock_qty'] = 0;
  846. $v['product_list'][] = $key_arr;
  847. }
  848. // var_dump($key_arr);
  849. // var_dump($key_arr);
  850. }
  851. }
  852. foreach ($data as $k=>$d){
  853. if($d['send_qty'] <= 0) unset($data[$k]);
  854. }
  855. usort($data, function ($a,$b){
  856. return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  857. });
  858. // list($status,$msg) = DwyService::getInstance()->setLimitForBoxOut($param);
  859. // if(! $status) return ['status' => '201', 'data' => [],'msg'=> $msg];
  860. return ['status' => '200', 'data' => $data];
  861. }
  862. public function zjlb(Request $request)
  863. {
  864. $param = $request->all();
  865. file_put_contents('dwy1.txt', json_encode($param) . PHP_EOL, 8);
  866. // $param = [
  867. // 'token'=>'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNzM2OTUyNTA3NTI5NTQzNzMiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfQVJSRVNULFJPTEVfQURNSU4iLCJ0b2tlbklkIjoiOTUwIiwiZXhwIjoxNzA3OTcxMTcxfQ.2VQ9Wqmk4rvKAcTsQPw59llBbeXjalKDGIZA4kesnuOJ0POmPVOVlRLbTtUDxl0XiFdPDUrKzuEFl2DXSgQdJg',
  868. // 'list'=>[
  869. // [
  870. // 'title'=>'优选A7家具板ENF小标',
  871. // 'num'=>'20',
  872. // ],[
  873. // 'title'=>'植萃除醛圆标',
  874. // 'num'=>'10',
  875. // ],
  876. // ],
  877. // ];
  878. // dd(json_encode($param));
  879. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  880. $url = 'https://tm.dwycloud.com/jbl/api/module-data/box_inventory_dtl_qr/page';
  881. $header = [
  882. 'Content-Type:application/json',
  883. 'Authorization: ' . $request->header('Authorization'),
  884. ];
  885. $param = '{"direction":"DESC","property":"id","fromClientType":"pc","number":0,"sorts":[],"rules":[{"field":"box_inventory.device_code","option":"LIKE_ANYWHERE","values":["'.$param['device_code'].'"]}],"size":15,"specialConditions":[],"workflowSearchBean":{},"dynamicFormCode":"box_inventory","developmentSystemId":null,"debugFlag":true}';
  886. $data = $this->post_helper($url, $param, $header);
  887. // $data = $this->post_helper($url, json_encode($param), $header);
  888. $data = json_decode($data, true);
  889. $data = $data['content'] ?? [];
  890. foreach ($data as $k => &$v) {
  891. $v['material_code_show'] = $v['box_inventory']['material_code_show'];
  892. $v['qty'] = $v['roll_qty'];
  893. $v['use_qty'] = 0;
  894. }
  895. sort($data);
  896. return json_encode($data);
  897. }
  898. public function boxOut(Request $request)
  899. {
  900. $param = $request->all();
  901. file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
  902. //商标绑定
  903. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/1';
  904. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind';
  905. $header = [
  906. 'Content-Type:application/json',
  907. 'Authorization: ' . $request->header('Authorization'),
  908. ];
  909. $lead_bind = $param['lead_bind'];
  910. $this->post_helper($url, json_encode($lead_bind), $header);
  911. //商标出库
  912. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
  913. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/11';
  914. $lead_bind = $param['lead_out'];
  915. $this->post_helper($url, json_encode($lead_bind), $header);
  916. return ['status'=>200,'msg'=>'success'];
  917. }
  918. public function post_helper($url, $data, $header)
  919. {
  920. $ch = curl_init();
  921. curl_setopt($ch, CURLOPT_POST, 1);
  922. curl_setopt($ch, CURLOPT_URL, $url);
  923. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  924. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  925. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  926. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  927. if (!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  928. $r = curl_exec($ch);
  929. curl_close($ch);
  930. file_put_contents('33.txt',$r.PHP_EOL,8);
  931. return $r;
  932. }
  933. public function setTbData(Request $request){
  934. $data = $request->all();
  935. if(empty($data['id']) && empty($data['mac']) && empty($data['data'])) return [201, ''];
  936. BigKingTbj::updateOrCreate(
  937. ['id' => $data['id'], 'mac' => $data['mac']], //查询条件
  938. [
  939. "id" => $data['id'],
  940. "mac" => $data['mac'],
  941. "data" => json_encode($data['data'])
  942. ] //添加或者修改的数据
  943. );
  944. return [200, ''];
  945. }
  946. public function getTbData(Request $request){
  947. $data = $request->all();
  948. // if(empty($data['mac'])) return [201, ''];
  949. if(empty($data['id'])) return [201, ''];
  950. $result = BigKingTbj::where('id',$data['id'])->get()->toArray();
  951. // $result = BigKingTbj::where('mac',$data['mac'])->get()->toArray();
  952. if(empty($result)) return [200,'data' => []];
  953. $return = [];
  954. foreach ($result as $value){
  955. $return[] = [
  956. // 'id' => $value['id'],
  957. 'mac' => $value['mac'],
  958. 'data' => json_decode($value['data'],true),
  959. ];
  960. }
  961. return [200, 'data' => $return];
  962. }
  963. public function setBoxTrademark(Request $request){
  964. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list';
  965. $header = [
  966. 'Content-Type:application/json',
  967. 'Authorization: ' .'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2MzM1NTJ9.CC69s4dpUdd9UqQlpeK5UF3DwY5Zenn-YHv8Iy1ai0cCXgere7r7jskWU9ARmKotys2tCGYRlO-Idtxdwdsefg',
  968. ];
  969. $data = [
  970. 'roll_qr_code_list' => [
  971. '171368443563212'
  972. ]
  973. ];
  974. $a = $this->post_helper($url, json_encode($data), $header);
  975. var_dump($a);die;
  976. $a = json_decode($a,true);
  977. $detail = [];
  978. foreach ($a['data'] as $v){
  979. $code = $v['brand_qr_code'];
  980. $detail[] = $code;
  981. }
  982. file_put_contents('1.txt',json_encode($detail));
  983. var_dump($a);die;
  984. }
  985. public function getBoxTrademark(Request $request){
  986. $data = $request->all();
  987. if(empty($data['box_nos']) && empty($data['mac'])) return ['status' => 201,'data' => []];
  988. $box_nos = $data['box_nos'];
  989. $dv = $data['mac'];
  990. $detail = [];
  991. //测试写入文件
  992. // foreach ($box_nos as $v) {
  993. // $filePath = storage_path( "app/box_trade/"."{$dv}_{$v}.txt");
  994. // if (! file_exists(storage_path('box_trade'))) Storage::makeDirectory('box_trade');
  995. // file_put_contents($filePath,json_encode(['a' => '测试','b'=>'测试2']));
  996. // }
  997. //读取文件
  998. foreach ($box_nos as $v) {
  999. // $filePath = public_path($file_path . "{$dv}_{$v}.txt");
  1000. $filePath = storage_path("app/box_trade/"."{$dv}_{$v}.txt");
  1001. if(file_exists($filePath)){
  1002. if (($content = file_get_contents($filePath)) === false) continue;
  1003. $decodedContent = json_decode($content, true);
  1004. if (json_last_error() !== JSON_ERROR_NONE) continue;
  1005. $detail[] = [
  1006. 'detail'=>$decodedContent,
  1007. 'code'=>$v,
  1008. ];
  1009. }
  1010. }
  1011. return ['status' => 200, 'data' => $detail];
  1012. }
  1013. }