DwyController.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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['id'])) return [201, ''];
  949. $result = BigKingTbj::where('id',$data['id'])->get()->toArray();
  950. if(empty($result)) return [200,'data' => []];
  951. $return = [];
  952. foreach ($result as $value){
  953. $return[] = [
  954. 'mac' => $value['mac'],
  955. 'data' => json_decode($value['data'],true),
  956. ];
  957. }
  958. return [200, 'data' => $return];
  959. }
  960. public function setBoxTrademark(Request $request){
  961. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list';
  962. $header = [
  963. 'Content-Type:application/json',
  964. 'Authorization: ' .'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2MzM1NTJ9.CC69s4dpUdd9UqQlpeK5UF3DwY5Zenn-YHv8Iy1ai0cCXgere7r7jskWU9ARmKotys2tCGYRlO-Idtxdwdsefg',
  965. ];
  966. $data = [
  967. 'roll_qr_code_list' => [
  968. '171368443563212'
  969. ]
  970. ];
  971. $a = $this->post_helper($url, json_encode($data), $header);
  972. var_dump($a);die;
  973. $a = json_decode($a,true);
  974. $detail = [];
  975. foreach ($a['data'] as $v){
  976. $code = $v['brand_qr_code'];
  977. $detail[] = $code;
  978. }
  979. file_put_contents('1.txt',json_encode($detail));
  980. var_dump($a);die;
  981. }
  982. public function getBoxTrademark(Request $request){
  983. $data = $request->all();
  984. if(empty($data['box_nos']) && empty($data['mac'])) return ['status' => 201,'data' => []];
  985. $box_nos = $data['box_nos'];
  986. $dv = $data['mac'];
  987. $detail = [];
  988. //测试写入文件
  989. // foreach ($box_nos as $v) {
  990. // $filePath = storage_path( "app/box_trade/"."{$dv}_{$v}.txt");
  991. // if (! file_exists(storage_path('box_trade'))) Storage::makeDirectory('box_trade');
  992. // file_put_contents($filePath,json_encode(['a' => '测试','b'=>'测试2']));
  993. // }
  994. //读取文件
  995. foreach ($box_nos as $v) {
  996. // $filePath = public_path($file_path . "{$dv}_{$v}.txt");
  997. $filePath = storage_path("app/box_trade/"."{$dv}_{$v}.txt");
  998. if(file_exists($filePath)){
  999. if (($content = file_get_contents($filePath)) === false) continue;
  1000. $decodedContent = json_decode($content, true);
  1001. if (json_last_error() !== JSON_ERROR_NONE) continue;
  1002. $detail[] = [
  1003. 'detail'=>$decodedContent,
  1004. 'code'=>$v,
  1005. ];
  1006. }
  1007. }
  1008. return ['status' => 200, 'data' => $detail];
  1009. }
  1010. }