DwyController.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Model\BigKingTbj;
  4. use App\Model\SysConfig;
  5. use App\Service\DwyService;
  6. use App\Service\EmployeeService;
  7. use App\Service\SysMenuService;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\Redis;
  10. use Illuminate\Support\Str;
  11. use Obs\ObsClient;
  12. use Carbon\Carbon;
  13. class DwyController extends BaseController
  14. {
  15. public function advertisement(Request $request)
  16. {
  17. $data = $request->all();
  18. file_put_contents('dwy1.txt', json_encode(['data'=>$data,'header']) . PHP_EOL, 8);
  19. if(!isset($data['mac'])){
  20. return ['status' => 200, 'data' => [
  21. 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
  22. 'https://clouddevice.qingyaokeji.com/2.mp4'],
  23. 'img' => [
  24. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  25. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  26. ],
  27. 'limit_time' => 10
  28. ]];
  29. }
  30. $url = 'https://tm.dwycloud.com/jbl/api/module-data/poster/poster/diy/device_code';
  31. $token = $data['token'];
  32. $param = ['device_code'=>$data['mac']];
  33. $header = [
  34. 'Content-Type:application/json',
  35. 'Authorization: ' . $token,
  36. ];
  37. $box_data = $this->post_helper($url, json_encode($param), $header);
  38. $box_data = json_decode($box_data, true);
  39. if(isset($box_data)&&$box_data['status'] === 'success'){
  40. $return = [
  41. 'video' => [],
  42. 'img' => [],
  43. 'limit_time' => 1
  44. ];
  45. foreach ($box_data['data'] as $v){
  46. if(isset($v['poster_attachment']['picture_attachment']['attachFile'])){
  47. foreach ($v['poster_attachment']['picture_attachment']['attachFile'] as $vv){
  48. // var_dump($vv);
  49. $return['img'][] = $this->getObsUrl($vv['path']);
  50. }
  51. }
  52. if(isset($v['poster_attachment']['attachment']['attachFile'])){
  53. foreach ($v['poster_attachment']['attachment']['attachFile'] as $vv){
  54. // var_dump($vv);
  55. $return['video'][] = $this->getObsUrl($vv['path']);
  56. }
  57. }
  58. }
  59. }else{
  60. $return = [
  61. 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
  62. 'https://clouddevice.qingyaokeji.com/2.mp4'],
  63. 'img' => [
  64. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  65. 'https://clouddevice.qingyaokeji.com/3.jpeg',
  66. ],
  67. 'limit_time' => 15
  68. ];
  69. }
  70. return ['status' => 200, 'data' => $return];
  71. }
  72. public function getObsUrl($key){
  73. //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/E1F5AF36B011AEBAACB7246DD15F5E1E
  74. //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/1718928008131.jpg
  75. $obsClient = new ObsClient([
  76. 'key' => '0LLP17PIAGNVS5SFLMZL',
  77. 'secret' => 'A5dANNHaTelCzdLuhq9Gyrw13QZF3aNpZkKoySWF',
  78. 'endpoint' => 'https://obs.cn-east-2.myhuaweicloud.com'
  79. ]);
  80. // 设置桶名和对象名
  81. $bucketName = 'shangbiaoji-test';
  82. $objectKey = $key; // 例如:path/to/video.mp4
  83. // 设置过期时间(以秒为单位)
  84. $expires = 86400; // URL的有效期为1小时
  85. // 生成预签名URL
  86. $response = $obsClient->createSignedUrl([
  87. 'Method' => 'GET', // 请求方法
  88. 'Bucket' => $bucketName,
  89. 'Key' => $objectKey,
  90. 'Expires' => $expires
  91. ]);
  92. // 获取预签名URL
  93. $signedUrl = $response['SignedUrl'];
  94. $obsClient->close();
  95. return $signedUrl;
  96. }
  97. public function openCommand(Request $request)
  98. {
  99. $data = $request->all();
  100. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  101. $device_id = $data['device_code'];
  102. $box_code = $data['box_code'];
  103. $key = $data['type'];
  104. $limit = 60;
  105. if ($key === 'UP') {
  106. $num = Redis::get($device_id . 'status_num');
  107. if (empty($num)) $num = 0;
  108. $num++;
  109. if ($num === 1) {
  110. Redis::set($device_id . 'status_num', $num);
  111. Redis::expire($device_id . 'status_num', $limit);
  112. Redis::set($device_id . 'status', 201);
  113. Redis::expire($device_id . 'status', $limit);
  114. Redis::set($device_id, json_encode([$box_code]));
  115. Redis::expire($device_id, $limit);
  116. } else {
  117. $old = Redis::get($device_id);
  118. if (empty($old)) $old = [];
  119. else $old = json_decode($old, true);
  120. $data = array_merge($old, [$box_code]);
  121. Redis::set($device_id, json_encode($data));
  122. Redis::expire($device_id, $limit);
  123. Redis::del($device_id . 'status');
  124. Redis::del($device_id . 'status_num');
  125. }
  126. } else {
  127. Redis::set($device_id, json_encode([$box_code]));
  128. Redis::expire($device_id, $limit);
  129. }
  130. return ['status' => 200];
  131. }
  132. public function openDoor(Request $request)
  133. {
  134. $data = $s = $request->all();
  135. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  136. $data = $data['device_code'];
  137. $code = Redis::get($data);
  138. Redis::del($data);
  139. // return ['data'=>['CK00001','CK00018'],'status'=>200];
  140. if (empty($code)) return ['data' => [], 'status' => 201];
  141. $status = Redis::get($data . 'status');
  142. if (empty($status)) $status = 200;
  143. if(isset($s['again'])&&$s['again']===true) $status = 201;
  144. return ['data' => json_decode($code, true), 'status' => $status];
  145. }
  146. public function maintenance(Request $request)
  147. {
  148. $data = [
  149. [
  150. 'code' => 'CK00001',
  151. 'title' => '设备仓'
  152. ],[
  153. 'code' => 'CK00003',
  154. 'title' => '维修仓'
  155. ],[
  156. 'code' => 'CK00004',
  157. 'title' => '商标一号仓'
  158. ],[
  159. 'code' => 'CK00005',
  160. 'title' => '商标二号仓'
  161. ],[
  162. 'code' => 'CK00006',
  163. 'title' => '商标三号仓'
  164. ],[
  165. 'code' => 'CK00007',
  166. 'title' => '商标四号仓'
  167. ],[
  168. 'code' => 'CK00008',
  169. 'title' => '商标五号仓'
  170. ],[
  171. 'code' => 'CK00009',
  172. 'title' => '商标六号仓'
  173. ],[
  174. 'code' => 'CK00010',
  175. 'title' => '商标七号仓'
  176. ],[
  177. 'code' => 'CK00011',
  178. 'title' => '商标八号仓'
  179. ],[
  180. 'code' => 'CK00012',
  181. 'title' => '商标九号仓'
  182. ],[
  183. 'code' => 'CK00013',
  184. 'title' => '商标十号仓'
  185. ],[
  186. 'code' => 'CK00014',
  187. 'title' => '商标十一号仓'
  188. ],[
  189. 'code' => 'CK00015',
  190. 'title' => '商标十二号仓'
  191. ],[
  192. 'code' => 'CK00016',
  193. 'title' => '商标十三号仓'
  194. ],[
  195. 'code' => 'CK00017',
  196. 'title' => '商标十四号仓'
  197. ],[
  198. 'code' => 'CK00018',
  199. 'title' => '商标十五号仓'
  200. ],[
  201. 'code' => 'CK00019',
  202. 'title' => '商标十六号仓'
  203. ]
  204. ];
  205. return ['data' => $data, 'status' => 200];
  206. }
  207. public function getOpenCommand(Request $request)
  208. {
  209. $data = $request->all();
  210. file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
  211. $device_id = $data['device_code'];
  212. $box_code = $data['box_code'];
  213. $key = $device_id . '_' . $box_code;
  214. $return = 201;
  215. $status = Redis::get($key);
  216. if ($status) {
  217. $return = 200;
  218. Redis::del($key);
  219. }
  220. return ['status' => $return];
  221. }
  222. public function boxList(Request $request)
  223. {
  224. $param = $request->all();
  225. $token = $param['token'];
  226. $device_code = $param['device_code'];
  227. //商标仓列表
  228. $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
  229. $header = [
  230. 'Content-Type:application/json',
  231. 'Authorization: ' . $token,
  232. ];
  233. $box_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
  234. $box_data = json_decode($box_data, true);
  235. if (isset($box_data['status']) && $box_data['status'] === 'success') {
  236. //库存查询
  237. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  238. $stock_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
  239. $stock_data = json_decode($stock_data, true);
  240. if ($stock_data) {
  241. $list = [];
  242. $material_list = [];
  243. foreach ($box_data['data'] as $v) {
  244. $list[$v['box_code']] = [
  245. 'material_code' => $v['material_code'],
  246. 'material_code_show' => $v['material_code_show'],
  247. 'box_code' => $v['box_code'],
  248. 'box_code_show' => $v['box_code_show'],
  249. 'min_stock_qty' => $v['min_stock_qty'] ?? 0,
  250. 'safe_stock_qty' => $v['safe_stock_qty'] ?? 0,
  251. 'status' => 1, //0设备仓中没有对应库存,1有对应库存,2对应商标仓中还有数量不允许上标
  252. 'qty' => 0,
  253. 'device_title' => $v['device']['name'] ?? '',
  254. ];
  255. $material_list[$v['material_code']][] = $v['box_code'];
  256. }
  257. $return = [];
  258. foreach ($stock_data as $v) {
  259. if (isset($material_list[$v['material_code']]) && $v['box_code'] == 'CK00001' && $v['qty'] > 0) {
  260. foreach ($material_list[$v['material_code']] as $vv) {
  261. $list[$vv]['status'] = 1;
  262. }
  263. }
  264. if (isset($list[$v['box_code']]) && $v['qty'] > 0) {
  265. $list[$v['box_code']]['qty'] = $v['qty'];
  266. }
  267. }
  268. foreach ($list as $v) {
  269. if ($v['qty'] > 0) {
  270. $v['status'] = 2;
  271. }
  272. $return[] = $v;
  273. }
  274. return ['status' => 'success', 'data' => $return];
  275. }
  276. }
  277. return $box_data;
  278. }
  279. public function test(){
  280. $a = json_decode('{
  281. "status": 200,
  282. "data": [
  283. {
  284. "created_date_lt": "2024-06-08T08:30:15.000Z",
  285. "created_date": "2024-06-08T08:30:15.086Z",
  286. "last_modified_by_show": "余丽娴",
  287. "device_code": "a6a672c3e458bed2",
  288. "material_code": "40010127000001",
  289. "last_modified_by": "553395510115962882",
  290. "unit_code_show": "张",
  291. "bus_type_dk": "SUPPLIER",
  292. "created_by": "553395510115962882",
  293. "unit_code": "ST",
  294. "dynamic_form_value_id": "587196751249805312",
  295. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  296. "device_code_show": "天凝工厂1号机",
  297. "belong_org": "0102",
  298. "bus_type_dk_show": "工厂",
  299. "created_by_show": "余丽娴",
  300. "id": "587196751312719872",
  301. "supplier_code": "0102",
  302. "main_table_id": null,
  303. "last_modified_date_lt": "2024-06-08T08:30:15.000Z",
  304. "material_code_show": "尊贵免漆板ENF小标",
  305. "qty": 4040,
  306. "specs": null,
  307. "box_code": "CK00005",
  308. "request_id": null,
  309. "detail_table_id": null,
  310. "last_modified_date": "2024-06-08T08:30:15.095Z",
  311. "box_code_show": "商标二号仓",
  312. "in_stock_qty": 5000,
  313. "use_qty": 4040,
  314. "product_list": [
  315. {
  316. "product_code": "BC450108000001",
  317. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  318. "order_item_id": "581029211289030656",
  319. "order_item_id_show": "SO202405200171",
  320. "process_title": "",
  321. "color": "",
  322. "process_title_two": "",
  323. "color_two": "",
  324. "send_qty": "120",
  325. "fake_qty": "120",
  326. "restock_qty": 0
  327. },
  328. {
  329. "product_code": "BC450108000001",
  330. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  331. "order_item_id": "581029211242893312",
  332. "order_item_id_show": "SO202405200171",
  333. "process_title": "",
  334. "color": "",
  335. "process_title_two": "",
  336. "color_two": "",
  337. "send_qty": "30",
  338. "fake_qty": "30",
  339. "restock_qty": 0
  340. },
  341. {
  342. "product_code": "BC450108000001",
  343. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  344. "order_item_id": "581029211221921792",
  345. "order_item_id_show": "SO202405200171",
  346. "process_title": "",
  347. "color": "",
  348. "process_title_two": "",
  349. "color_two": "",
  350. "send_qty": "160",
  351. "fake_qty": "160",
  352. "restock_qty": 0
  353. }
  354. ],
  355. "send_qty": 310,
  356. "restore_qty": 0
  357. },
  358. {
  359. "created_date_lt": "2024-06-06T10:34:14.000Z",
  360. "created_date": "2024-06-06T10:34:14.502Z",
  361. "last_modified_by_show": "余丽娴",
  362. "device_code": "a6a672c3e458bed2",
  363. "material_code": "40010232000001",
  364. "last_modified_by": "553395510115962882",
  365. "unit_code_show": "张",
  366. "bus_type_dk": "SUPPLIER",
  367. "created_by": "553395510115962882",
  368. "unit_code": "ST",
  369. "dynamic_form_value_id": "586503178690891776",
  370. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  371. "device_code_show": "天凝工厂1号机",
  372. "belong_org": "0102",
  373. "bus_type_dk_show": "工厂",
  374. "created_by_show": "余丽娴",
  375. "id": "586503178758000640",
  376. "supplier_code": "0102",
  377. "main_table_id": null,
  378. "last_modified_date_lt": "2024-06-06T10:34:14.000Z",
  379. "material_code_show": "优选A6森芯板E0小标",
  380. "qty": 4519,
  381. "specs": null,
  382. "box_code": "CK00007",
  383. "request_id": null,
  384. "detail_table_id": null,
  385. "last_modified_date": "2024-06-06T10:34:14.512Z",
  386. "box_code_show": "商标四号仓",
  387. "in_stock_qty": 4652,
  388. "use_qty": 4519,
  389. "product_list": [],
  390. "send_qty": 0
  391. },
  392. {
  393. "created_date_lt": "2024-06-08T05:59:10.000Z",
  394. "created_date": "2024-06-08T05:59:10.127Z",
  395. "last_modified_by_show": "余丽娴",
  396. "device_code": "a6a672c3e458bed2",
  397. "material_code": "40010504000001",
  398. "last_modified_by": "553395510115962882",
  399. "unit_code_show": "张",
  400. "bus_type_dk": "SUPPLIER",
  401. "created_by": "553395510115962882",
  402. "unit_code": "ST",
  403. "dynamic_form_value_id": "587158730056011776",
  404. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  405. "device_code_show": "天凝工厂1号机",
  406. "belong_org": "0102",
  407. "bus_type_dk_show": "工厂",
  408. "created_by_show": "余丽娴",
  409. "id": "587158730123120640",
  410. "supplier_code": "0102",
  411. "main_table_id": null,
  412. "last_modified_date_lt": "2024-06-08T05:59:10.000Z",
  413. "material_code_show": "ENF圆标",
  414. "qty": 2909,
  415. "specs": null,
  416. "box_code": "CK00010",
  417. "request_id": null,
  418. "detail_table_id": null,
  419. "last_modified_date": "2024-06-08T05:59:10.136Z",
  420. "box_code_show": "商标七号仓",
  421. "in_stock_qty": 5000,
  422. "use_qty": 2909,
  423. "safe_stock_qty": 400,
  424. "min_stock_qty": 100,
  425. "product_list": [
  426. {
  427. "product_code": "BC450108000001",
  428. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  429. "order_item_id": "581029211289030656",
  430. "order_item_id_show": "SO202405200171",
  431. "process_title": "",
  432. "color": "",
  433. "process_title_two": "",
  434. "color_two": "",
  435. "send_qty": "120",
  436. "fake_qty": "120",
  437. "restock_qty": 0
  438. },
  439. {
  440. "product_code": "BC450108000001",
  441. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  442. "order_item_id": "581029211242893312",
  443. "order_item_id_show": "SO202405200171",
  444. "process_title": "",
  445. "color": "",
  446. "process_title_two": "",
  447. "color_two": "",
  448. "send_qty": "30",
  449. "fake_qty": "30",
  450. "restock_qty": 0
  451. },
  452. {
  453. "product_code": "BC450108000001",
  454. "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
  455. "order_item_id": "581029211221921792",
  456. "order_item_id_show": "SO202405200171",
  457. "process_title": "",
  458. "color": "",
  459. "process_title_two": "",
  460. "color_two": "",
  461. "send_qty": "160",
  462. "fake_qty": "160",
  463. "restock_qty": 0
  464. }
  465. ],
  466. "send_qty": 310,
  467. "restore_qty": 0
  468. },
  469. {
  470. "created_date_lt": "2024-06-06T07:05:12.000Z",
  471. "created_date": "2024-06-06T07:05:12.783Z",
  472. "last_modified_by_show": "余丽娴",
  473. "device_code": "a6a672c3e458bed2",
  474. "material_code": "40010102000001",
  475. "last_modified_by": "553395510115962882",
  476. "unit_code_show": "张",
  477. "bus_type_dk": "SUPPLIER",
  478. "created_by": "553395510115962882",
  479. "unit_code": "ST",
  480. "dynamic_form_value_id": "586450574908723200",
  481. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  482. "device_code_show": "天凝工厂1号机",
  483. "belong_org": "0102",
  484. "bus_type_dk_show": "工厂",
  485. "created_by_show": "余丽娴",
  486. "id": "586450574980026368",
  487. "supplier_code": "0102",
  488. "main_table_id": null,
  489. "last_modified_date_lt": "2024-06-06T07:05:12.000Z",
  490. "material_code_show": "尊贵免漆背板E0小标",
  491. "qty": 5001,
  492. "specs": null,
  493. "box_code": "CK00011",
  494. "request_id": null,
  495. "detail_table_id": null,
  496. "last_modified_date": "2024-06-06T07:05:12.793Z",
  497. "box_code_show": "商标八号仓",
  498. "in_stock_qty": 5001,
  499. "use_qty": 5001,
  500. "product_list": [],
  501. "send_qty": 0
  502. },
  503. {
  504. "created_date_lt": "2024-06-06T07:37:23.000Z",
  505. "created_date": "2024-06-06T07:37:23.194Z",
  506. "last_modified_by_show": "余丽娴",
  507. "device_code": "a6a672c3e458bed2",
  508. "material_code": "40010134000001",
  509. "last_modified_by": "553395510115962882",
  510. "unit_code_show": "张",
  511. "bus_type_dk": "SUPPLIER",
  512. "created_by": "553395510115962882",
  513. "unit_code": "ST",
  514. "dynamic_form_value_id": "586458671639302144",
  515. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  516. "device_code_show": "天凝工厂1号机",
  517. "belong_org": "0102",
  518. "bus_type_dk_show": "工厂",
  519. "created_by_show": "余丽娴",
  520. "id": "586458671702216704",
  521. "supplier_code": "0102",
  522. "main_table_id": null,
  523. "last_modified_date_lt": "2024-06-06T07:37:23.000Z",
  524. "material_code_show": "优选免漆板ENF小标",
  525. "qty": 3345,
  526. "specs": null,
  527. "box_code": "CK00014",
  528. "request_id": null,
  529. "detail_table_id": null,
  530. "last_modified_date": "2024-06-06T07:37:23.203Z",
  531. "box_code_show": "商标十一号仓",
  532. "in_stock_qty": 3345,
  533. "use_qty": 3345,
  534. "safe_stock_qty": 400,
  535. "min_stock_qty": 300,
  536. "product_list": [],
  537. "send_qty": 0
  538. },
  539. {
  540. "created_date_lt": "2024-06-07T08:37:02.000Z",
  541. "created_date": "2024-06-07T08:37:02.353Z",
  542. "last_modified_by_show": "余丽娴",
  543. "device_code": "a6a672c3e458bed2",
  544. "material_code": "40010101000999",
  545. "last_modified_by": "553395510115962882",
  546. "unit_code_show": "张",
  547. "bus_type_dk": "SUPPLIER",
  548. "created_by": "553395510115962882",
  549. "unit_code": "ST",
  550. "dynamic_form_value_id": "586836071590006784",
  551. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  552. "device_code_show": "天凝工厂1号机",
  553. "belong_org": "0102",
  554. "bus_type_dk_show": "工厂",
  555. "created_by_show": "余丽娴",
  556. "id": "586836071657115648",
  557. "supplier_code": "0102",
  558. "main_table_id": null,
  559. "last_modified_date_lt": "2024-06-07T08:37:02.000Z",
  560. "material_code_show": "E0批零免漆(测试白标)",
  561. "qty": 1234,
  562. "specs": null,
  563. "box_code": "CK00015",
  564. "request_id": null,
  565. "detail_table_id": null,
  566. "last_modified_date": "2024-06-07T08:37:02.364Z",
  567. "box_code_show": "商标十二号仓",
  568. "in_stock_qty": 1518,
  569. "use_qty": 1234,
  570. "product_list": [],
  571. "send_qty": 0
  572. },
  573. {
  574. "created_date_lt": "2024-06-08T02:08:40.000Z",
  575. "created_date": "2024-06-08T02:08:40.233Z",
  576. "last_modified_by_show": "余丽娴",
  577. "device_code": "a6a672c3e458bed2",
  578. "material_code": "40010504000001",
  579. "last_modified_by": "553395510115962882",
  580. "unit_code_show": "张",
  581. "bus_type_dk": "SUPPLIER",
  582. "created_by": "553395510115962882",
  583. "unit_code": "ST",
  584. "dynamic_form_value_id": "587100723276288000",
  585. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  586. "device_code_show": "天凝工厂1号机",
  587. "belong_org": "0102",
  588. "bus_type_dk_show": "工厂",
  589. "created_by_show": "余丽娴",
  590. "id": "587100723347591168",
  591. "supplier_code": "0102",
  592. "main_table_id": null,
  593. "last_modified_date_lt": "2024-06-08T02:08:40.000Z",
  594. "material_code_show": "ENF圆标",
  595. "qty": 4467,
  596. "specs": null,
  597. "box_code": "CK00016",
  598. "request_id": null,
  599. "detail_table_id": null,
  600. "last_modified_date": "2024-06-08T02:08:40.243Z",
  601. "box_code_show": "商标十三号仓",
  602. "in_stock_qty": 5000,
  603. "use_qty": 4467,
  604. "safe_stock_qty": 400,
  605. "min_stock_qty": 100,
  606. "product_list": [],
  607. "send_qty": 0
  608. },
  609. {
  610. "created_date_lt": "2024-06-07T08:12:36.000Z",
  611. "created_date": "2024-06-07T08:12:36.275Z",
  612. "last_modified_by_show": "余丽娴",
  613. "device_code": "a6a672c3e458bed2",
  614. "material_code": "40010501000999",
  615. "last_modified_by": "553395510115962882",
  616. "unit_code_show": "张",
  617. "bus_type_dk": "SUPPLIER",
  618. "created_by": "553395510115962882",
  619. "unit_code": "ST",
  620. "dynamic_form_value_id": "586829922408992768",
  621. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  622. "device_code_show": "天凝工厂1号机",
  623. "belong_org": "0102",
  624. "bus_type_dk_show": "工厂",
  625. "created_by_show": "余丽娴",
  626. "id": "586829922471907328",
  627. "supplier_code": "0102",
  628. "main_table_id": null,
  629. "last_modified_date_lt": "2024-06-07T08:12:36.000Z",
  630. "material_code_show": "银盾抗菌圆标(测试白标)",
  631. "qty": 1236,
  632. "specs": null,
  633. "box_code": "CK00017",
  634. "request_id": null,
  635. "detail_table_id": null,
  636. "last_modified_date": "2024-06-07T08:12:36.284Z",
  637. "box_code_show": "商标十四号仓",
  638. "in_stock_qty": 1510,
  639. "use_qty": 1236,
  640. "product_list": [],
  641. "send_qty": 0
  642. },
  643. {
  644. "created_date_lt": "2024-06-06T07:35:54.000Z",
  645. "created_date": "2024-06-06T07:35:54.496Z",
  646. "last_modified_by_show": "余丽娴",
  647. "device_code": "a6a672c3e458bed2",
  648. "material_code": "40010504000001",
  649. "last_modified_by": "553395510115962882",
  650. "unit_code_show": "张",
  651. "bus_type_dk": "SUPPLIER",
  652. "created_by": "553395510115962882",
  653. "unit_code": "ST",
  654. "dynamic_form_value_id": "586458299612925952",
  655. "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
  656. "device_code_show": "天凝工厂1号机",
  657. "belong_org": "0102",
  658. "bus_type_dk_show": "工厂",
  659. "created_by_show": "余丽娴",
  660. "id": "586458299675840512",
  661. "supplier_code": "0102",
  662. "main_table_id": null,
  663. "last_modified_date_lt": "2024-06-06T07:35:54.000Z",
  664. "material_code_show": "ENF圆标",
  665. "qty": 32,
  666. "specs": null,
  667. "box_code": "CK00018",
  668. "request_id": null,
  669. "detail_table_id": null,
  670. "last_modified_date": "2024-06-06T07:35:54.505Z",
  671. "box_code_show": "商标十五号仓",
  672. "in_stock_qty": 1540,
  673. "use_qty": 32,
  674. "safe_stock_qty": 400,
  675. "min_stock_qty": 100,
  676. "product_list": [],
  677. "send_qty": 0
  678. }
  679. ]
  680. }',true);
  681. foreach ($a['data'] as $k=>$v){
  682. if($v['box_code'] == 'CK00005') {
  683. foreach ($v['product_list'] as $kk=>$vv){
  684. if($kk > 0 ){
  685. unset($v['product_list'][$kk]);
  686. continue;
  687. }
  688. $v['product_list'][$kk]['send_qty'] = 200;
  689. $v['product_list'][$kk]['fake_qty'] = 200;
  690. }
  691. // $a['data'][$k]['box_code'] = 'CK00006';
  692. // $a['data'][$k]['box_code_show'] = '商标三号仓';
  693. $aa = $v;
  694. // $aa['box_code'] = 'CK00019';
  695. // $aa['box_code_show'] = '商标十六号';
  696. $aa['send_qty'] = 200;
  697. //
  698. // $bb = $v;
  699. // $bb['box_code'] = 'CK00013';
  700. // $bb['box_code_show'] = '商标十号';
  701. // $bb['send_qty'] = '15';
  702. //
  703. // $cc = $v;
  704. // $cc['box_code'] = 'CK00014';
  705. // $cc['box_code_show'] = '商标十一号';
  706. // $cc['send_qty'] = '15';
  707. //
  708. // $dd = $v;
  709. // $dd['box_code'] = 'CK00015';
  710. // $dd['box_code_show'] = '商标十二号';
  711. // $dd['send_qty'] = '15';
  712. //
  713. // $gg = $v;
  714. // $gg['box_code'] = 'CK00018';
  715. // $gg['box_code_show'] = '商标十五号';
  716. // $gg['send_qty'] = '15';
  717. }
  718. 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') {
  719. unset($a['data'][$k]);
  720. continue;
  721. }
  722. }
  723. $box_list = [
  724. 1,2
  725. ];
  726. foreach ($box_list as $v){
  727. $v = $v+3;
  728. if($v<10) $n = '0'.$v;
  729. else $n = $v;
  730. $aa['box_code'] = 'CK000'.$n;
  731. $aa['box_code_show'] = '商标'.($n-3).'号';
  732. $a['data'][] = $aa;
  733. }
  734. // $a['data'][] = $bb;
  735. // $a['data'][] = $cc;
  736. // $a['data'][] = $dd;
  737. // $a['data'][] = $gg;
  738. usort( $a['data'], function ($jj,$kk){
  739. return str_replace('CK','',$jj['box_code']) - str_replace('CK','',$kk['box_code']);
  740. });
  741. return $a;
  742. }
  743. public function setLb(Request $request)
  744. {
  745. $param = $request->all();
  746. file_put_contents('dwy_setlb.txt', json_encode($param) . PHP_EOL, 8);
  747. //单独的处理哪些口子不能用的逻辑
  748. $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
  749. $token = $param['token'];
  750. $json = ['device_code'=>$param['mac']];
  751. $header = [
  752. 'Content-Type:application/json',
  753. 'Authorization: ' . $token,
  754. ];
  755. $box_data = $this->post_helper($url, json_encode($json), $header);
  756. $box_data = json_decode($box_data, true);
  757. $un_box = [];
  758. if(isset($box_data['data'])){
  759. foreach ($box_data['data'] as $d){
  760. if(isset($d['status'])&&$d['status'] == 0){
  761. $un_box[] = $d['box_code'] ?? '';
  762. }
  763. }
  764. }
  765. // $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);
  766. $token = $param['token'];
  767. $list = $param['list'];
  768. foreach ($list as &$a){
  769. if($a['num'] < 0) {
  770. $a['num'] = $a['num'] + $a['restock_qty'];
  771. $a['restock_qty'] = 0;
  772. }
  773. }
  774. $mac = $param['mac'];
  775. // if($mac === '28f1e65c8cfd496f'){
  776. ////
  777. // return $this->test();
  778. // }
  779. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  780. $header = [
  781. 'Content-Type:application/json',
  782. 'Authorization: ' . $token,
  783. ];
  784. $data = $this->post_helper($url, '{"device_code":"'.$mac.'"}', $header);
  785. $data = json_decode($data, true);
  786. if($mac == '6766748e144e3b7b'){
  787. foreach ($data as $k=>$v){
  788. if($v['material_code_show'] == '尊贵免漆背板E0小标' && $v['box_code_show'] == '商标二号仓'){
  789. unset($data[$k]);
  790. }
  791. }
  792. }
  793. // if($mac == 'a6a672c3e458bed2'||$mac == 'DV00001'){
  794. // usort($data, function ($a,$b){
  795. // return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  796. // });
  797. // }else{
  798. //
  799. // }
  800. usort($data, function($a, $b) {
  801. return $b['qty'] < $a['qty'];
  802. });
  803. //做一个单独的校验,如果数量不够则返回失败
  804. $out_key_list = [];
  805. foreach ($list as $l){
  806. if(!isset($out_key_list[$l['title']])) $out_key_list[$l['title']] = 0;
  807. $out_key_list[$l['title']] += $l['num'];
  808. }
  809. $box_key_list = [];
  810. foreach ($data as $d){
  811. if (!isset($d['box_code_show']) || $d['box_code_show'] == '设备仓') {
  812. continue;
  813. }
  814. if(!isset($box_key_list[$d['material_code_show']])) $box_key_list[$d['material_code_show']] = 0;
  815. $box_key_list[$d['material_code_show']] += $d['qty'];
  816. }
  817. foreach ($out_key_list as $k=>$v){
  818. if(!isset($box_key_list[$k])){
  819. return ['status' => '201', 'data' => [],'msg'=>$k.'没有库存信息!'];
  820. }
  821. if($box_key_list[$k] < $v) {
  822. return ['status' => '201','data'=>[], 'msg' => $k.'库存数量不足信息!'];
  823. }
  824. }
  825. //end
  826. foreach ($data as $k => &$v) {
  827. if (!isset($v['product_list'])) $v['product_list'] = [];
  828. if (!isset($v['box_code_show']) || $v['box_code_show'] == '设备仓') {
  829. unset($data[$k]);
  830. continue;
  831. }
  832. if(isset($v['box_code'])&&in_array($v['box_code'],$un_box)) continue;
  833. if ($v['qty'] <= 0) {
  834. unset($data[$k]);
  835. continue;
  836. }
  837. $v['use_qty'] = $v['qty'];
  838. if (!isset($v['send_qty'])) $v['send_qty'] = 0;
  839. foreach ($list as $kk => $vv) {
  840. if(!isset($vv['restock_qty'])) $vv['restock_qty'] = 0;
  841. if($vv['restock_qty'] > 0) return ['status' => '201','data'=>[], 'msg' => '不允许超出可领数量'];
  842. if ($vv['num'] == 0 && $vv['restock_qty'] == 0) continue;
  843. if ($v['material_code_show'] === $vv['title']) {
  844. $v['restore_qty'] = isset($vv['restock_qty']) && $vv['restock_qty'] > 0 ? $vv['restock_qty'] : 0;
  845. if (($v['qty'] - $v['send_qty']) > $vv['num']) {
  846. $list[$kk]['num'] -= $vv['num'];
  847. $v['send_qty'] += $vv['num'];
  848. $p_total = $vv['num'];
  849. } else {
  850. $list[$kk]['num'] -= ($v['qty'] - $v['send_qty']);
  851. $p_total = ($v['qty'] - $v['send_qty']);
  852. $v['send_qty'] += ($v['qty'] - $v['send_qty']);
  853. }
  854. //把产品相关参数进行封装
  855. ////产品编号
  856. //"product_code": "",
  857. ////产品名称
  858. //"product_code_show": "",
  859. ////工艺
  860. //"process_title": "",
  861. ////花色
  862. //"color": "",
  863. ////工艺2
  864. //"process_title_two": "",
  865. ////花色2
  866. //"color_two": "",
  867. if($p_total == 0 && $vv['restock_qty'] <= 0) continue;
  868. $key_arr = [
  869. 'product_code' => $vv['product_code'] ?? '',
  870. 'product_code_show' => $vv['product_code_show'] ?? '',
  871. 'order_item_id' => $vv['order_item_id'] ?? '',
  872. 'order_item_id_show' => $vv['order_item_id_show'] ?? '',
  873. 'process_title' => $vv['craft_type_code_show'] ?? '',
  874. 'color' => $vv['decor_code_show'] ?? '',
  875. 'process_title_two' => $vv['craft_type_two_code_show'] ?? '',
  876. 'color_two' => $vv['decor_two_code_show'] ?? '',
  877. 'send_qty' => $p_total,
  878. 'fake_qty' => $p_total,
  879. // 'send_qty' => 0,
  880. 'restock_qty' => $vv['restock_qty'] ?? 0,
  881. ];
  882. if($vv['restock_qty'] > 0) $list[$kk]['restock_qty'] = 0;
  883. $v['product_list'][] = $key_arr;
  884. }
  885. // var_dump($key_arr);
  886. // var_dump($key_arr);
  887. }
  888. }
  889. // dd($data);die;
  890. foreach ($data as $k=>$d){
  891. if(empty($d['product_list'])) unset($data[$k]);
  892. }
  893. usort($data, function ($a,$b){
  894. return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  895. });
  896. // list($status,$msg) = DwyService::getInstance()->setLimitForBoxOut($param);
  897. // if(! $status) return ['status' => '201', 'data' => [],'msg'=> $msg];
  898. // $this->unusualRestock($data,$mac,$token);
  899. if(empty($data)) return ['status' => '201', 'data' => $data,'msg'=>'无商标需要申领'];
  900. return ['status' => '200', 'data' => $data];
  901. }
  902. public function setLb1(Request $request)
  903. {
  904. $param = $request->all();
  905. file_put_contents('dwy_setlb1.txt', json_encode($param) . PHP_EOL, 8);
  906. // var_dump($param);
  907. //start 增加一层逻辑,数量超了不允许领用
  908. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/sale_order_dtl_brand/page';
  909. // $token = $param['token'];
  910. // $json = json_decode('{"direction":"DESC","property":"id","fromClientType":"pc","number":0,"sorts":[],"rules":[{"field":"exe_sale_order_b.no","option":"LIKE_ANYWHERE","values":["SO202405300207"]}],"size":100,"specialConditions":[],"workflowSearchBean":{},"dynamicFormCode":"sale_order","dynamicFormTable":null,"ignoreField":true,"developmentSystemId":null}',true);
  911. // $json['rules'][0]['values'] = [$param['list'][0]['order_item_id_show']];
  912. // $json['workflowSearchBean'] = [""=>""];
  913. //// var_dump(json_encode($json));die;
  914. // $header = [
  915. // 'Content-Type:application/json',
  916. // 'Authorization: ' . $token,
  917. // ];
  918. // $box_data = $this->post_helper($url, json_encode($json), $header);
  919. // $box_data = json_decode($box_data,true);
  920. //// var_dump($box_data);die;
  921. // $limit_data = [];
  922. // if(isset($box_data['content'])){
  923. // $box_data = $box_data['content'];
  924. // foreach ($box_data as $b){
  925. //// $key = $b['material_code_show'].'_'.$b['specs'].'_'.$b['decor_code_show'].'_'.$b['decor_two_code_show'].'_'.$b['craft_type_code_show'].'_'.$b['craft_type_two_code_show'].'_'.$b['mat_material_a']['mat_category_code'].'_'.$b['mat_material_a']['grade_show'].'_'.$b['mat_material_a']['cpdj_show'];
  926. // $key = $b['material_code'].'_'.$b['prod_trademark_compare_view']['brand_code_show'];
  927. // $qty = $b['qty'];
  928. // $out_qty = $b['out_stock_qty_total'];
  929. // if(isset($limit_data[$key])){
  930. // $limit_data[$key]['qty'] += $qty;
  931. // }else{
  932. // $limit_data[$key] = [
  933. // 'qty' => $qty,
  934. // 'out_qty' => $out_qty,
  935. // 'key' => $key,
  936. // ];
  937. // }
  938. // }
  939. // foreach ($param['list'] as $v){
  940. // $key = $v['product_code'].'_'.$v['title'];
  941. // var_dump($key);
  942. // var_dump($limit_data);die;
  943. // }
  944. //
  945. foreach ($param['list'] as &$a){
  946. if($a['num'] < 0) {
  947. $a['num'] = $a['num'] + $a['restock_qty'];
  948. $a['restock_qty'] = 0;
  949. }
  950. if($a['num'] == 0) {
  951. $a['num'] = $a['restock_qty'];
  952. $a['restock_qty'] = 0;
  953. }
  954. }
  955. $nlist = [];
  956. foreach ($param['list'] as $ll){
  957. $ll['restock_qty'] = 0;
  958. if($ll['num'] <= 0) {
  959. continue;
  960. }
  961. $nlist[] = $ll;
  962. }
  963. $param['list'] = $nlist;
  964. //end
  965. //单独的处理哪些口子不能用的逻辑
  966. $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
  967. $token = $param['token'];
  968. $json = ['device_code'=>$param['mac']];
  969. $header = [
  970. 'Content-Type:application/json',
  971. 'Authorization: ' . $token,
  972. ];
  973. $box_data = $this->post_helper($url, json_encode($json), $header);
  974. $box_data = json_decode($box_data, true);
  975. $un_box = [];
  976. if(isset($box_data['data'])){
  977. foreach ($box_data['data'] as $d){
  978. if(isset($d['status'])&&$d['status'] == 0){
  979. //这个数组重的仓库编码不需要
  980. $un_box[] = $d['box_code'] ?? '';
  981. }
  982. }
  983. }
  984. // $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);
  985. $token = $param['token'];
  986. $list = $param['list'];
  987. $mac = $param['mac'];
  988. // if($mac === '28f1e65c8cfd496f'){
  989. ////
  990. // return $this->test();
  991. // }
  992. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  993. $header = [
  994. 'Content-Type:application/json',
  995. 'Authorization: ' . $token,
  996. ];
  997. $data = $this->post_helper($url, '{"device_code":"'.$mac.'"}', $header);
  998. $data = json_decode($data, true);
  999. // if($mac == 'a6a672c3e458bed2'||$mac == 'DV00001'){
  1000. // usort($data, function ($a,$b){
  1001. // return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  1002. // });
  1003. // }else{
  1004. //
  1005. // }
  1006. // var_dump($data);die;
  1007. if($mac == '6766748e144e3b7b'){
  1008. foreach ($data as $k=>$v){
  1009. if($v['material_code_show'] == '尊贵免漆背板E0小标' && $v['box_code_show'] == '商标二号仓'){
  1010. unset($data[$k]);
  1011. }
  1012. }
  1013. }
  1014. // var_dump($data);die;
  1015. usort($data, function($a, $b) {
  1016. return $b['qty'] < $a['qty'];
  1017. });
  1018. foreach ($data as $kk=> $vv){
  1019. $data[$kk]['material_code_show'] = trim($vv['material_code_show']);
  1020. }
  1021. //做一个单独的校验,如果数量不够则返回失败
  1022. $out_key_list = [];
  1023. foreach ($list as $l){
  1024. if(!isset($out_key_list[$l['title']])) $out_key_list[$l['title']] = 0;
  1025. $out_key_list[$l['title']] += $l['num'];
  1026. }
  1027. $box_key_list = [];
  1028. foreach ($data as $d){
  1029. if (!isset($d['box_code_show']) || $d['box_code_show'] == '设备仓') {
  1030. continue;
  1031. }
  1032. if(!isset($box_key_list[$d['material_code_show']])) $box_key_list[trim($d['material_code_show'])] = 0;
  1033. $box_key_list[trim($d['material_code_show'])] += $d['qty'];
  1034. }
  1035. foreach ($out_key_list as $k=>$v){
  1036. if(!isset($box_key_list[$k])){
  1037. return ['status' => '201', 'data' => [],'msg'=>$k.'没有库存信息!'];
  1038. }
  1039. if($box_key_list[$k] < $v) {
  1040. return ['status' => '201','data'=>[], 'msg' => $k.'库存数量不足信息!'];
  1041. }
  1042. }
  1043. //end
  1044. foreach ($data as $k => &$v) {
  1045. if (!isset($v['product_list'])) $v['product_list'] = [];
  1046. if (!isset($v['box_code_show']) || $v['box_code_show'] == '设备仓') {
  1047. unset($data[$k]);
  1048. continue;
  1049. }
  1050. if(isset($v['box_code'])&&in_array($v['box_code'],$un_box)) continue;
  1051. if ($v['qty'] <= 0) {
  1052. unset($data[$k]);
  1053. continue;
  1054. }
  1055. $v['use_qty'] = $v['qty'];
  1056. if (!isset($v['send_qty'])) $v['send_qty'] = 0;
  1057. foreach ($list as $kk => $vv) {
  1058. if(!isset($vv['restock_qty'])) $vv['restock_qty'] = 0;
  1059. if($vv['restock_qty'] > 0 && $vv['num'] > 0 ) return ['status' => '201','data'=>[], 'msg' => '不允许超出可领数量'];
  1060. if ($vv['num'] == 0 && $vv['restock_qty'] == 0) continue;
  1061. if($vv['num'] <= 0) {
  1062. $vv['num'] = $vv['restock_qty']+$vv['num'];
  1063. $vv['restock_qty'] = 0;
  1064. }
  1065. if ($v['material_code_show'] === $vv['title']) {
  1066. $v['restore_qty'] = isset($vv['restock_qty']) && $vv['restock_qty'] > 0 ? $vv['restock_qty'] : 0;
  1067. if (($v['qty'] - $v['send_qty']) > $vv['num']) {
  1068. $list[$kk]['num'] -= $vv['num'];
  1069. $v['send_qty'] += $vv['num'];
  1070. $p_total = $vv['num'];
  1071. } else {
  1072. $list[$kk]['num'] -= ($v['qty'] - $v['send_qty']);
  1073. $p_total = ($v['qty'] - $v['send_qty']);
  1074. $v['send_qty'] += ($v['qty'] - $v['send_qty']);
  1075. }
  1076. //把产品相关参数进行封装
  1077. ////产品编号
  1078. //"product_code": "",
  1079. ////产品名称
  1080. //"product_code_show": "",
  1081. ////工艺
  1082. //"process_title": "",
  1083. ////花色
  1084. //"color": "",
  1085. ////工艺2
  1086. //"process_title_two": "",
  1087. ////花色2
  1088. //"color_two": "",
  1089. if($p_total == 0 && $vv['restock_qty'] <= 0) continue;
  1090. $key_arr = [
  1091. 'product_code' => $vv['product_code'] ?? '',
  1092. 'product_code_show' => $vv['product_code_show'] ?? '',
  1093. 'order_item_id' => $vv['order_item_id'] ?? '',
  1094. 'order_item_id_show' => $vv['order_item_id_show'] ?? '',
  1095. 'process_title' => $vv['craft_type_code_show'] ?? '',
  1096. 'color' => $vv['decor_code_show'] ?? '',
  1097. 'process_title_two' => $vv['craft_type_two_code_show'] ?? '',
  1098. 'color_two' => $vv['decor_two_code_show'] ?? '',
  1099. 'send_qty' => $p_total,
  1100. 'fake_qty' => $p_total,
  1101. // 'send_qty' => 0,
  1102. 'restock_qty' => $vv['restock_qty'] ?? 0,
  1103. 'mat_material_a' => $vv['mat_material_a'] ?? []
  1104. ];
  1105. if($vv['restock_qty'] > 0) $list[$kk]['restock_qty'] = 0;
  1106. $v['product_list'][] = $key_arr;
  1107. }
  1108. // var_dump($key_arr);
  1109. // var_dump($key_arr);
  1110. }
  1111. }
  1112. // dd($data);die;
  1113. foreach ($data as $k=>$d){
  1114. if(empty($d['product_list'])) unset($data[$k]);
  1115. }
  1116. usort($data, function ($a,$b){
  1117. return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
  1118. });
  1119. // list($status,$msg) = DwyService::getInstance()->setLimitForBoxOut($param);
  1120. // if(! $status) return ['status' => '201', 'data' => [],'msg'=> $msg];
  1121. // $this->unusualRestock1($data,$mac,$token);
  1122. if(empty($data)) return ['status' => '201', 'data' => $data,'msg'=>'无商标需要申领'];
  1123. return ['status' => '200', 'data' => $data];
  1124. }
  1125. //单独的没有出标数据但是需要保存补领
  1126. public function unusualRestock($data,$mac,$token){
  1127. $send_status = true;
  1128. $send_data = [];
  1129. //2024-06-19T21:01:51.948Z,赖的写,直接拼
  1130. $iso8601Time = date('Y-m-d').'T'.date('H:i:s').'.'.rand(100,999).'Z';
  1131. foreach ($data as $v){
  1132. if($v['send_qty'] > 0) $send_status = false;
  1133. $send_product = [];
  1134. //创建异常数据
  1135. $box_data = [
  1136. 'in_out_type_code' => 'CK00004',
  1137. 'in_out_type_code_show' => '商标仓正常领标出库',
  1138. 'send_box_code' => $v['box_code'],
  1139. 'send_box_code_show' => $v['box_code_show'],
  1140. 'device_code' => $mac,
  1141. 'get_brand_source_dk' => 'SALE_ORDER',
  1142. 'abnormal_flag' => false,
  1143. 'abnormal_date' => $iso8601Time,
  1144. ];
  1145. foreach ($v['product_list'] as $kk=>$vv){
  1146. $send_product[] = [
  1147. 'item_no' => 10+$kk*10,
  1148. 'brand_qr_code_list' => '',
  1149. 'material_code' => $v['material_code'],
  1150. 'material_code_show' => $v['material_code_show'],
  1151. 'unit_code' => $v['unit_code'],
  1152. 'unit_code_show' => $v['unit_code_show'],
  1153. 'restock_qty' => $vv['restock_qty'],
  1154. 'qty' => 0,
  1155. 'fake_qty' => 0,
  1156. 'bus_type_dk' => 'SALE_ORDER',
  1157. 'bus_type_dk_show' => '销售订单',
  1158. 'bus_no' => $vv['order_item_id'],
  1159. 'bus_no_show' => $vv['order_item_id_show'],
  1160. 'product_code' => $vv['product_code'],
  1161. 'product_code_show' => $vv['product_code_show'],
  1162. 'process_title' => $vv['process_title'],
  1163. 'color' => $vv['color'],
  1164. 'process_title_two' => $vv['process_title_two'],
  1165. 'color_two' => $vv['color_two'],
  1166. ];
  1167. }
  1168. $box_data['brand_out_stock_dtl'] =$send_product;
  1169. $send_data[] = $box_data;
  1170. }
  1171. $param = [
  1172. 'brand_out_stock_list' => $send_data
  1173. ];
  1174. if($send_status){
  1175. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
  1176. $header = [
  1177. 'Content-Type:application/json',
  1178. 'Authorization: ' . $token,
  1179. ];
  1180. $res = $this->post_helper($url, json_encode($param), $header);
  1181. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($header) . PHP_EOL, 8);
  1182. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($param) . PHP_EOL, 8);
  1183. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').$res . PHP_EOL, 8);
  1184. }
  1185. }
  1186. public function unusualRestock1($data,$mac,$token){
  1187. $send_status = true;
  1188. $send_data = [];
  1189. //2024-06-19T21:01:51.948Z,赖的写,直接拼
  1190. $iso8601Time = date('Y-m-d').'T'.date('H:i:s').'.'.rand(100,999).'Z';
  1191. foreach ($data as $v){
  1192. if($v['send_qty'] > 0) $send_status = false;
  1193. $send_product = [];
  1194. //创建异常数据
  1195. $box_data = [
  1196. 'in_out_type_code' => 'CK00004',
  1197. 'in_out_type_code_show' => '商标仓正常领标出库',
  1198. 'send_box_code' => $v['box_code'],
  1199. 'send_box_code_show' => $v['box_code_show'],
  1200. 'device_code' => $mac,
  1201. 'get_brand_source_dk' => 'SALE_ORDER',
  1202. 'abnormal_flag' => false,
  1203. 'abnormal_date' => $iso8601Time,
  1204. ];
  1205. foreach ($v['product_list'] as $kk=>$vv){
  1206. $send_product[] = [
  1207. 'item_no' => 10+$kk*10,
  1208. 'brand_qr_code_list' => '',
  1209. 'material_code' => $v['material_code'],
  1210. 'material_code_show' => $v['material_code_show'],
  1211. 'unit_code' => $v['unit_code'],
  1212. 'unit_code_show' => $v['unit_code_show'],
  1213. 'restock_qty' => $vv['restock_qty'],
  1214. 'qty' => 0,
  1215. 'fake_qty' => 0,
  1216. 'bus_type_dk' => 'SALE_ORDER',
  1217. 'bus_type_dk_show' => '销售订单',
  1218. 'bus_no' => $vv['order_item_id'],
  1219. 'bus_no_show' => $vv['order_item_id_show'],
  1220. 'product_code' => $vv['product_code'],
  1221. 'product_code_show' => $vv['product_code_show'],
  1222. 'process_title' => $vv['process_title'],
  1223. 'color' => $vv['color'],
  1224. 'process_title_two' => $vv['process_title_two'],
  1225. 'color_two' => $vv['color_two'],
  1226. ];
  1227. }
  1228. $box_data['brand_out_stock_dtl'] =$send_product;
  1229. $send_data[] = $box_data;
  1230. }
  1231. $param = [
  1232. 'brand_out_stock_list' => $send_data
  1233. ];
  1234. if($send_status){
  1235. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
  1236. $header = [
  1237. 'Content-Type:application/json',
  1238. 'Authorization: ' . $token,
  1239. ];
  1240. $res = $this->post_helper($url, json_encode($param), $header);
  1241. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($header) . PHP_EOL, 8);
  1242. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($param) . PHP_EOL, 8);
  1243. file_put_contents('dwy1.txt', date('Y-m-d H:i:s').$res . PHP_EOL, 8);
  1244. }
  1245. }
  1246. public function zjlb(Request $request)
  1247. {
  1248. $param = $request->all();
  1249. file_put_contents('dwy1.txt', json_encode($param) . PHP_EOL, 8);
  1250. // $param = [
  1251. // 'token'=>'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNzM2OTUyNTA3NTI5NTQzNzMiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfQVJSRVNULFJPTEVfQURNSU4iLCJ0b2tlbklkIjoiOTUwIiwiZXhwIjoxNzA3OTcxMTcxfQ.2VQ9Wqmk4rvKAcTsQPw59llBbeXjalKDGIZA4kesnuOJ0POmPVOVlRLbTtUDxl0XiFdPDUrKzuEFl2DXSgQdJg',
  1252. // 'list'=>[
  1253. // [
  1254. // 'title'=>'优选A7家具板ENF小标',
  1255. // 'num'=>'20',
  1256. // ],[
  1257. // 'title'=>'植萃除醛圆标',
  1258. // 'num'=>'10',
  1259. // ],
  1260. // ],
  1261. // ];
  1262. // dd(json_encode($param));
  1263. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
  1264. $url = 'https://tm.dwycloud.com/jbl/api/module-data/box_inventory_dtl_qr/page';
  1265. $header = [
  1266. 'Content-Type:application/json',
  1267. 'Authorization: ' . $request->header('Authorization'),
  1268. ];
  1269. $param = '{"direction":"DESC","property":"id","fromClientType":"pc","number":0,"sorts":[],"rules":[{"field":"box_inventory.device_code","option":"LIKE_ANYWHERE","values":["'.$param['device_code'].'"]}],"size":999,"specialConditions":[],"workflowSearchBean":{},"dynamicFormCode":"box_inventory","developmentSystemId":null,"debugFlag":true}';
  1270. $data = $this->post_helper($url, $param, $header);
  1271. // $data = $this->post_helper($url, json_encode($param), $header);
  1272. $data = json_decode($data, true);
  1273. // var_dump($data);die;
  1274. $data = $data['content'] ?? [];
  1275. foreach ($data as $k => &$v) {
  1276. $v['material_code_show'] = $v['box_inventory']['material_code_show'];
  1277. $v['qty'] = $v['roll_qty'];
  1278. $v['bus_date'] = $v['bus_date'] ? strtotime($v['bus_date']) : '1722441600';
  1279. $v['use_qty'] = 0;
  1280. }
  1281. sort($data);
  1282. return json_encode($data);
  1283. }
  1284. public function boxOut(Request $request)
  1285. {
  1286. $param = $request->all();
  1287. file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
  1288. //商标绑定
  1289. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/1';
  1290. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind';
  1291. $header = [
  1292. 'Content-Type:application/json',
  1293. 'Authorization: ' . $request->header('Authorization'),
  1294. ];
  1295. $lead_bind = $param['lead_bind'];
  1296. $this->post_helper($url, json_encode($lead_bind), $header);
  1297. //商标出库
  1298. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
  1299. // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/11';
  1300. $lead_bind = $param['lead_out'];
  1301. $this->post_helper($url, json_encode($lead_bind), $header);
  1302. return ['status'=>200,'msg'=>'success'];
  1303. }
  1304. public function post_helper($url, $data, $header)
  1305. {
  1306. $ch = curl_init();
  1307. curl_setopt($ch, CURLOPT_POST, 1);
  1308. curl_setopt($ch, CURLOPT_URL, $url);
  1309. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1310. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1311. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1312. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  1313. if (!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  1314. $r = curl_exec($ch);
  1315. curl_close($ch);
  1316. file_put_contents('33.txt',$r.PHP_EOL,8);
  1317. return $r;
  1318. }
  1319. public function setTbData(Request $request){
  1320. $data = $request->all();
  1321. if(empty($data['id']) && empty($data['data'])) return [201, ''];
  1322. BigKingTbj::updateOrCreate(
  1323. ['id' => $data['id']], //查询条件
  1324. [
  1325. "id" => $data['id'],
  1326. "data" => json_encode($data['data'])
  1327. ] //添加或者修改的数据
  1328. );
  1329. return [200, ''];
  1330. }
  1331. public function getTbData(Request $request){
  1332. $data = $request->all();
  1333. if(empty($data['id'])) return [201, ''];
  1334. $result = BigKingTbj::where('id',$data['id'])->first();
  1335. if(empty($result)) return [200,'data' => []];
  1336. return [200, 'data' => json_decode($result['data'],true)];
  1337. }
  1338. public function setBoxTrademark(Request $request){
  1339. $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list';
  1340. $header = [
  1341. 'Content-Type:application/json',
  1342. 'Authorization: ' .'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2MzM1NTJ9.CC69s4dpUdd9UqQlpeK5UF3DwY5Zenn-YHv8Iy1ai0cCXgere7r7jskWU9ARmKotys2tCGYRlO-Idtxdwdsefg',
  1343. ];
  1344. $data = [
  1345. 'roll_qr_code_list' => [
  1346. '171368443563212'
  1347. ]
  1348. ];
  1349. $a = $this->post_helper($url, json_encode($data), $header);
  1350. var_dump($a);die;
  1351. $a = json_decode($a,true);
  1352. $detail = [];
  1353. foreach ($a['data'] as $v){
  1354. $code = $v['brand_qr_code'];
  1355. $detail[] = $code;
  1356. }
  1357. file_put_contents('1.txt',json_encode($detail));
  1358. var_dump($a);die;
  1359. }
  1360. public function getBoxTrademark(Request $request){
  1361. $data = $request->all();
  1362. if(empty($data['box_nos']) && empty($data['mac'])) return ['status' => 201,'data' => []];
  1363. $box_nos = $data['box_nos'];
  1364. $dv = $data['mac'];
  1365. $detail = [];
  1366. //测试写入文件
  1367. // foreach ($box_nos as $v) {
  1368. // $filePath = storage_path( "app/box_trade/"."{$dv}_{$v}.txt");
  1369. // if (! file_exists(storage_path('box_trade'))) Storage::makeDirectory('box_trade');
  1370. // file_put_contents($filePath,json_encode(['a' => '测试','b'=>'测试2']));
  1371. // }
  1372. //读取文件
  1373. foreach ($box_nos as $v) {
  1374. // $filePath = public_path($file_path . "{$dv}_{$v}.txt");
  1375. $filePath = storage_path("app/box_trade/"."{$dv}_{$v}.txt");
  1376. if(file_exists($filePath)){
  1377. if (($content = file_get_contents($filePath)) === false) continue;
  1378. $decodedContent = json_decode($content, true);
  1379. if (json_last_error() !== JSON_ERROR_NONE) continue;
  1380. $detail[] = [
  1381. 'detail'=>$decodedContent,
  1382. 'code'=>$v,
  1383. ];
  1384. }
  1385. }
  1386. return ['status' => 200, 'data' => $detail];
  1387. }
  1388. public function andriodLog(Request $request){
  1389. // $data = $request->all();
  1390. $data = file_get_contents('php://input');
  1391. $path = date('Ymd');
  1392. $file = 'dwyAndriod.txt';
  1393. if (!is_dir($path)) {
  1394. // 创建目录,第三个参数 true 表示递归创建目录
  1395. mkdir($path, 0755, true);
  1396. }
  1397. $param = json_decode($data,true);
  1398. if(isset($param['type'])&&isset($param['content'])){
  1399. $file = $path.'/'.$param['type'].'_'.$file;
  1400. file_put_contents($file,$param['content'].PHP_EOL,8);
  1401. }else{
  1402. file_put_contents($file,$data.PHP_EOL,8);
  1403. }
  1404. return ['status' => 200, 'data' => []];
  1405. }
  1406. public function andriodDownload(Request $request){
  1407. $data = file_get_contents('andriodList.txt');
  1408. $data = json_decode($data,true);
  1409. $param = $request->all();
  1410. if(!isset($param['package'])){
  1411. $param['package'] = 'cbj';
  1412. }
  1413. if(isset($param['type'])){
  1414. $type = $param['type'];
  1415. $return = [];
  1416. foreach ($data as $v){
  1417. if($v['type'] == $type) $return[] = $v;
  1418. }
  1419. $data = $return;
  1420. }
  1421. if(isset($param['package'])){
  1422. $type = $param['package'];
  1423. $return = [];
  1424. foreach ($data as $v){
  1425. if($v['package'] == $type) $return[] = $v;
  1426. }
  1427. $data = $return;
  1428. }
  1429. return ['status'=>200,'data'=> $data];
  1430. }
  1431. public function setAndriodDownload(Request $request){
  1432. // $data = file_get_contents('andriodList.txt');
  1433. // if(empty($data)) $data = [];
  1434. // else $data = json_decode($data,true);
  1435. $param = $request->all();
  1436. file_put_contents('andriodList.txt',json_encode($param));
  1437. return ['status'=>200,'msg'=>'ok','data'=>[]];
  1438. }
  1439. public function setAndroidVersion(Request $request){
  1440. $data = $request->all();
  1441. $type = $data['type'] ?? 'android';
  1442. $version = $data['version'];
  1443. $model = new SysConfig();
  1444. $model->where('type',$type)->update(
  1445. [
  1446. 'value' => $version
  1447. ]
  1448. );
  1449. return ['status'=>200,'msg'=>'ok','data'=>[]];
  1450. }
  1451. public function androidVersion(Request $request){
  1452. $data = $request->all();
  1453. $type = $data['type'] ?? 'android';
  1454. $model = new SysConfig();
  1455. $v = $model->where('type',$type)->value('value');
  1456. return ['status'=>200,'msg'=>'ok','data'=>['version'=>$v]];
  1457. }
  1458. }