1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Model\BigKingTbj;
- use App\Service\DwyService;
- use App\Service\EmployeeService;
- use App\Service\SysMenuService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Redis;
- use Illuminate\Support\Str;
- use Obs\ObsClient;
- use Carbon\Carbon;
- class DwyController extends BaseController
- {
- public function advertisement(Request $request)
- {
- $data = $request->all();
- file_put_contents('dwy1.txt', json_encode(['data'=>$data,'header']) . PHP_EOL, 8);
- if(!isset($data['mac'])){
- return ['status' => 200, 'data' => [
- 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
- 'https://clouddevice.qingyaokeji.com/2.mp4'],
- 'img' => [
- 'https://clouddevice.qingyaokeji.com/3.jpeg',
- 'https://clouddevice.qingyaokeji.com/3.jpeg',
- ],
- 'limit_time' => 10
- ]];
- }
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/poster/poster/diy/device_code';
- $token = $data['token'];
- $param = ['device_code'=>$data['mac']];
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $token,
- ];
- $box_data = $this->post_helper($url, json_encode($param), $header);
- $box_data = json_decode($box_data, true);
- if(isset($box_data)&&$box_data['status'] === 'success'){
- $return = [
- 'video' => [],
- 'img' => [],
- 'limit_time' => 1
- ];
- foreach ($box_data['data'] as $v){
- if(isset($v['poster_attachment']['picture_attachment']['attachFile'])){
- foreach ($v['poster_attachment']['picture_attachment']['attachFile'] as $vv){
- // var_dump($vv);
- $return['img'][] = $this->getObsUrl($vv['path']);
- }
- }
- if(isset($v['poster_attachment']['attachment']['attachFile'])){
- foreach ($v['poster_attachment']['attachment']['attachFile'] as $vv){
- // var_dump($vv);
- $return['video'][] = $this->getObsUrl($vv['path']);
- }
- }
- }
- }else{
- $return = [
- 'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
- 'https://clouddevice.qingyaokeji.com/2.mp4'],
- 'img' => [
- 'https://clouddevice.qingyaokeji.com/3.jpeg',
- 'https://clouddevice.qingyaokeji.com/3.jpeg',
- ],
- 'limit_time' => 15
- ];
- }
- return ['status' => 200, 'data' => $return];
- }
- public function getObsUrl($key){
- //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/E1F5AF36B011AEBAACB7246DD15F5E1E
- //https://shangbiaoji-test.obs.cn-east-2.myhuaweicloud.com/shangbiaoji/20240621/1718928008131.jpg
- $obsClient = new ObsClient([
- 'key' => '0LLP17PIAGNVS5SFLMZL',
- 'secret' => 'A5dANNHaTelCzdLuhq9Gyrw13QZF3aNpZkKoySWF',
- 'endpoint' => 'https://obs.cn-east-2.myhuaweicloud.com'
- ]);
- // 设置桶名和对象名
- $bucketName = 'shangbiaoji-test';
- $objectKey = $key; // 例如:path/to/video.mp4
- // 设置过期时间(以秒为单位)
- $expires = 86400; // URL的有效期为1小时
- // 生成预签名URL
- $response = $obsClient->createSignedUrl([
- 'Method' => 'GET', // 请求方法
- 'Bucket' => $bucketName,
- 'Key' => $objectKey,
- 'Expires' => $expires
- ]);
- // 获取预签名URL
- $signedUrl = $response['SignedUrl'];
- $obsClient->close();
- return $signedUrl;
- }
- public function openCommand(Request $request)
- {
- $data = $request->all();
- file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
- $device_id = $data['device_code'];
- $box_code = $data['box_code'];
- $key = $data['type'];
- $limit = 60;
- if ($key === 'UP') {
- $num = Redis::get($device_id . 'status_num');
- if (empty($num)) $num = 0;
- $num++;
- if ($num === 1) {
- Redis::set($device_id . 'status_num', $num);
- Redis::expire($device_id . 'status_num', $limit);
- Redis::set($device_id . 'status', 201);
- Redis::expire($device_id . 'status', $limit);
- Redis::set($device_id, json_encode([$box_code]));
- Redis::expire($device_id, $limit);
- } else {
- $old = Redis::get($device_id);
- if (empty($old)) $old = [];
- else $old = json_decode($old, true);
- $data = array_merge($old, [$box_code]);
- Redis::set($device_id, json_encode($data));
- Redis::expire($device_id, $limit);
- Redis::del($device_id . 'status');
- Redis::del($device_id . 'status_num');
- }
- } else {
- Redis::set($device_id, json_encode([$box_code]));
- Redis::expire($device_id, $limit);
- }
- return ['status' => 200];
- }
- public function openDoor(Request $request)
- {
- $data = $s = $request->all();
- file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
- $data = $data['device_code'];
- $code = Redis::get($data);
- Redis::del($data);
- // return ['data'=>['CK00001','CK00018'],'status'=>200];
- if (empty($code)) return ['data' => [], 'status' => 201];
- $status = Redis::get($data . 'status');
- if (empty($status)) $status = 200;
- if(isset($s['again'])&&$s['again']===true) $status = 201;
- return ['data' => json_decode($code, true), 'status' => $status];
- }
- public function maintenance(Request $request)
- {
- $data = [
- [
- 'code' => 'CK00001',
- 'title' => '设备仓'
- ],[
- 'code' => 'CK00003',
- 'title' => '维修仓'
- ],[
- 'code' => 'CK00004',
- 'title' => '商标一号仓'
- ],[
- 'code' => 'CK00005',
- 'title' => '商标二号仓'
- ],[
- 'code' => 'CK00006',
- 'title' => '商标三号仓'
- ],[
- 'code' => 'CK00007',
- 'title' => '商标四号仓'
- ],[
- 'code' => 'CK00008',
- 'title' => '商标五号仓'
- ],[
- 'code' => 'CK00009',
- 'title' => '商标六号仓'
- ],[
- 'code' => 'CK00010',
- 'title' => '商标七号仓'
- ],[
- 'code' => 'CK00011',
- 'title' => '商标八号仓'
- ],[
- 'code' => 'CK00012',
- 'title' => '商标九号仓'
- ],[
- 'code' => 'CK00013',
- 'title' => '商标十号仓'
- ],[
- 'code' => 'CK00014',
- 'title' => '商标十一号仓'
- ],[
- 'code' => 'CK00015',
- 'title' => '商标十二号仓'
- ],[
- 'code' => 'CK00016',
- 'title' => '商标十三号仓'
- ],[
- 'code' => 'CK00017',
- 'title' => '商标十四号仓'
- ],[
- 'code' => 'CK00018',
- 'title' => '商标十五号仓'
- ],[
- 'code' => 'CK00019',
- 'title' => '商标十六号仓'
- ]
- ];
- return ['data' => $data, 'status' => 200];
- }
- public function getOpenCommand(Request $request)
- {
- $data = $request->all();
- file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
- $device_id = $data['device_code'];
- $box_code = $data['box_code'];
- $key = $device_id . '_' . $box_code;
- $return = 201;
- $status = Redis::get($key);
- if ($status) {
- $return = 200;
- Redis::del($key);
- }
- return ['status' => $return];
- }
- public function boxList(Request $request)
- {
- $param = $request->all();
- $token = $param['token'];
- $device_code = $param['device_code'];
- //商标仓列表
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $token,
- ];
- $box_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
- $box_data = json_decode($box_data, true);
- if (isset($box_data['status']) && $box_data['status'] === 'success') {
- //库存查询
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
- $stock_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
- $stock_data = json_decode($stock_data, true);
- if ($stock_data) {
- $list = [];
- $material_list = [];
- foreach ($box_data['data'] as $v) {
- $list[$v['box_code']] = [
- 'material_code' => $v['material_code'],
- 'material_code_show' => $v['material_code_show'],
- 'box_code' => $v['box_code'],
- 'box_code_show' => $v['box_code_show'],
- 'min_stock_qty' => $v['min_stock_qty'] ?? 0,
- 'safe_stock_qty' => $v['safe_stock_qty'] ?? 0,
- 'status' => 1, //0设备仓中没有对应库存,1有对应库存,2对应商标仓中还有数量不允许上标
- 'qty' => 0,
- 'device_title' => $v['device']['name'] ?? '',
- ];
- $material_list[$v['material_code']][] = $v['box_code'];
- }
- $return = [];
- foreach ($stock_data as $v) {
- if (isset($material_list[$v['material_code']]) && $v['box_code'] == 'CK00001' && $v['qty'] > 0) {
- foreach ($material_list[$v['material_code']] as $vv) {
- $list[$vv]['status'] = 1;
- }
- }
- if (isset($list[$v['box_code']]) && $v['qty'] > 0) {
- $list[$v['box_code']]['qty'] = $v['qty'];
- }
- }
- foreach ($list as $v) {
- if ($v['qty'] > 0) {
- $v['status'] = 2;
- }
- $return[] = $v;
- }
- return ['status' => 'success', 'data' => $return];
- }
- }
- return $box_data;
- }
- public function test(){
- $a = json_decode('{
- "status": 200,
- "data": [
- {
- "created_date_lt": "2024-06-08T08:30:15.000Z",
- "created_date": "2024-06-08T08:30:15.086Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010127000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "587196751249805312",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "587196751312719872",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-08T08:30:15.000Z",
- "material_code_show": "尊贵免漆板ENF小标",
- "qty": 4040,
- "specs": null,
- "box_code": "CK00005",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-08T08:30:15.095Z",
- "box_code_show": "商标二号仓",
- "in_stock_qty": 5000,
- "use_qty": 4040,
- "product_list": [
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211289030656",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "120",
- "fake_qty": "120",
- "restock_qty": 0
- },
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211242893312",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "30",
- "fake_qty": "30",
- "restock_qty": 0
- },
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211221921792",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "160",
- "fake_qty": "160",
- "restock_qty": 0
- }
- ],
- "send_qty": 310,
- "restore_qty": 0
- },
- {
- "created_date_lt": "2024-06-06T10:34:14.000Z",
- "created_date": "2024-06-06T10:34:14.502Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010232000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586503178690891776",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586503178758000640",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-06T10:34:14.000Z",
- "material_code_show": "优选A6森芯板E0小标",
- "qty": 4519,
- "specs": null,
- "box_code": "CK00007",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-06T10:34:14.512Z",
- "box_code_show": "商标四号仓",
- "in_stock_qty": 4652,
- "use_qty": 4519,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-08T05:59:10.000Z",
- "created_date": "2024-06-08T05:59:10.127Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010504000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "587158730056011776",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "587158730123120640",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-08T05:59:10.000Z",
- "material_code_show": "ENF圆标",
- "qty": 2909,
- "specs": null,
- "box_code": "CK00010",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-08T05:59:10.136Z",
- "box_code_show": "商标七号仓",
- "in_stock_qty": 5000,
- "use_qty": 2909,
- "safe_stock_qty": 400,
- "min_stock_qty": 100,
- "product_list": [
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211289030656",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "120",
- "fake_qty": "120",
- "restock_qty": 0
- },
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211242893312",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "30",
- "fake_qty": "30",
- "restock_qty": 0
- },
- {
- "product_code": "BC450108000001",
- "product_code_show": "大王椰1700尊贵型ENF机拼香杉木-智能生态免漆板W",
- "order_item_id": "581029211221921792",
- "order_item_id_show": "SO202405200171",
- "process_title": "",
- "color": "",
- "process_title_two": "",
- "color_two": "",
- "send_qty": "160",
- "fake_qty": "160",
- "restock_qty": 0
- }
- ],
- "send_qty": 310,
- "restore_qty": 0
- },
- {
- "created_date_lt": "2024-06-06T07:05:12.000Z",
- "created_date": "2024-06-06T07:05:12.783Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010102000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586450574908723200",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586450574980026368",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-06T07:05:12.000Z",
- "material_code_show": "尊贵免漆背板E0小标",
- "qty": 5001,
- "specs": null,
- "box_code": "CK00011",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-06T07:05:12.793Z",
- "box_code_show": "商标八号仓",
- "in_stock_qty": 5001,
- "use_qty": 5001,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-06T07:37:23.000Z",
- "created_date": "2024-06-06T07:37:23.194Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010134000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586458671639302144",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586458671702216704",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-06T07:37:23.000Z",
- "material_code_show": "优选免漆板ENF小标",
- "qty": 3345,
- "specs": null,
- "box_code": "CK00014",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-06T07:37:23.203Z",
- "box_code_show": "商标十一号仓",
- "in_stock_qty": 3345,
- "use_qty": 3345,
- "safe_stock_qty": 400,
- "min_stock_qty": 300,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-07T08:37:02.000Z",
- "created_date": "2024-06-07T08:37:02.353Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010101000999",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586836071590006784",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586836071657115648",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-07T08:37:02.000Z",
- "material_code_show": "E0批零免漆(测试白标)",
- "qty": 1234,
- "specs": null,
- "box_code": "CK00015",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-07T08:37:02.364Z",
- "box_code_show": "商标十二号仓",
- "in_stock_qty": 1518,
- "use_qty": 1234,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-08T02:08:40.000Z",
- "created_date": "2024-06-08T02:08:40.233Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010504000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "587100723276288000",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "587100723347591168",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-08T02:08:40.000Z",
- "material_code_show": "ENF圆标",
- "qty": 4467,
- "specs": null,
- "box_code": "CK00016",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-08T02:08:40.243Z",
- "box_code_show": "商标十三号仓",
- "in_stock_qty": 5000,
- "use_qty": 4467,
- "safe_stock_qty": 400,
- "min_stock_qty": 100,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-07T08:12:36.000Z",
- "created_date": "2024-06-07T08:12:36.275Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010501000999",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586829922408992768",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586829922471907328",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-07T08:12:36.000Z",
- "material_code_show": "银盾抗菌圆标(测试白标)",
- "qty": 1236,
- "specs": null,
- "box_code": "CK00017",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-07T08:12:36.284Z",
- "box_code_show": "商标十四号仓",
- "in_stock_qty": 1510,
- "use_qty": 1236,
- "product_list": [],
- "send_qty": 0
- },
- {
- "created_date_lt": "2024-06-06T07:35:54.000Z",
- "created_date": "2024-06-06T07:35:54.496Z",
- "last_modified_by_show": "余丽娴",
- "device_code": "a6a672c3e458bed2",
- "material_code": "40010504000001",
- "last_modified_by": "553395510115962882",
- "unit_code_show": "张",
- "bus_type_dk": "SUPPLIER",
- "created_by": "553395510115962882",
- "unit_code": "ST",
- "dynamic_form_value_id": "586458299612925952",
- "supplier_code_show": "嘉善大王椰整体橱柜有限公司",
- "device_code_show": "天凝工厂1号机",
- "belong_org": "0102",
- "bus_type_dk_show": "工厂",
- "created_by_show": "余丽娴",
- "id": "586458299675840512",
- "supplier_code": "0102",
- "main_table_id": null,
- "last_modified_date_lt": "2024-06-06T07:35:54.000Z",
- "material_code_show": "ENF圆标",
- "qty": 32,
- "specs": null,
- "box_code": "CK00018",
- "request_id": null,
- "detail_table_id": null,
- "last_modified_date": "2024-06-06T07:35:54.505Z",
- "box_code_show": "商标十五号仓",
- "in_stock_qty": 1540,
- "use_qty": 32,
- "safe_stock_qty": 400,
- "min_stock_qty": 100,
- "product_list": [],
- "send_qty": 0
- }
- ]
- }',true);
- foreach ($a['data'] as $k=>$v){
- if($v['box_code'] == 'CK00005') {
- foreach ($v['product_list'] as $kk=>$vv){
- if($kk > 0 ){
- unset($v['product_list'][$kk]);
- continue;
- }
- $v['product_list'][$kk]['send_qty'] = 200;
- $v['product_list'][$kk]['fake_qty'] = 200;
- }
- // $a['data'][$k]['box_code'] = 'CK00006';
- // $a['data'][$k]['box_code_show'] = '商标三号仓';
- $aa = $v;
- // $aa['box_code'] = 'CK00019';
- // $aa['box_code_show'] = '商标十六号';
- $aa['send_qty'] = 200;
- //
- // $bb = $v;
- // $bb['box_code'] = 'CK00013';
- // $bb['box_code_show'] = '商标十号';
- // $bb['send_qty'] = '15';
- //
- // $cc = $v;
- // $cc['box_code'] = 'CK00014';
- // $cc['box_code_show'] = '商标十一号';
- // $cc['send_qty'] = '15';
- //
- // $dd = $v;
- // $dd['box_code'] = 'CK00015';
- // $dd['box_code_show'] = '商标十二号';
- // $dd['send_qty'] = '15';
- //
- // $gg = $v;
- // $gg['box_code'] = 'CK00018';
- // $gg['box_code_show'] = '商标十五号';
- // $gg['send_qty'] = '15';
- }
- 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') {
- unset($a['data'][$k]);
- continue;
- }
- }
- $box_list = [
- 1,2
- ];
- foreach ($box_list as $v){
- $v = $v+3;
- if($v<10) $n = '0'.$v;
- else $n = $v;
- $aa['box_code'] = 'CK000'.$n;
- $aa['box_code_show'] = '商标'.($n-3).'号';
- $a['data'][] = $aa;
- }
- // $a['data'][] = $bb;
- // $a['data'][] = $cc;
- // $a['data'][] = $dd;
- // $a['data'][] = $gg;
- usort( $a['data'], function ($jj,$kk){
- return str_replace('CK','',$jj['box_code']) - str_replace('CK','',$kk['box_code']);
- });
- return $a;
- }
- public function setLb(Request $request)
- {
- $param = $request->all();
- file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
- //单独的处理哪些口子不能用的逻辑
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
- $token = $param['token'];
- $json = ['device_code'=>$param['mac']];
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $token,
- ];
- $box_data = $this->post_helper($url, json_encode($json), $header);
- $box_data = json_decode($box_data, true);
- $un_box = [];
- if(isset($box_data['data'])){
- foreach ($box_data['data'] as $d){
- if(isset($d['status'])&&$d['status'] == 0){
- $un_box[] = $d['box_code'] ?? '';
- }
- }
- }
- // $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);
- $token = $param['token'];
- $list = $param['list'];
- $mac = $param['mac'];
- // if($mac === '28f1e65c8cfd496f'){
- ////
- // return $this->test();
- // }
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $token,
- ];
- $data = $this->post_helper($url, '{"device_code":"'.$mac.'"}', $header);
- $data = json_decode($data, true);
- // if($mac == 'a6a672c3e458bed2'||$mac == 'DV00001'){
- // usort($data, function ($a,$b){
- // return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
- // });
- // }else{
- //
- // }
- usort($data, function($a, $b) {
- return $b['qty'] < $a['qty'];
- });
- //做一个单独的校验,如果数量不够则返回失败
- $out_key_list = [];
- foreach ($list as $l){
- if(!isset($out_key_list[$l['title']])) $out_key_list[$l['title']] = 0;
- $out_key_list[$l['title']] += $l['num'];
- }
- $box_key_list = [];
- foreach ($data as $d){
- if (!isset($d['box_code_show']) || $d['box_code_show'] == '设备仓') {
- continue;
- }
- if(!isset($box_key_list[$d['material_code_show']])) $box_key_list[$d['material_code_show']] = 0;
- $box_key_list[$d['material_code_show']] += $d['qty'];
- }
- foreach ($out_key_list as $k=>$v){
- if(!isset($box_key_list[$k])){
- return ['status' => '201', 'data' => [],'msg'=>$k.'没有库存信息!'];
- }
- if($box_key_list[$k] < $v) {
- return ['status' => '201','data'=>[], 'msg' => $k.'库存数量不足信息!'];
- }
- }
- //end
- foreach ($data as $k => &$v) {
- if (!isset($v['product_list'])) $v['product_list'] = [];
- if (!isset($v['box_code_show']) || $v['box_code_show'] == '设备仓') {
- unset($data[$k]);
- continue;
- }
- if(isset($v['box_code'])&&in_array($v['box_code'],$un_box)) continue;
- if ($v['qty'] <= 0) {
- unset($data[$k]);
- continue;
- }
- $v['use_qty'] = $v['qty'];
- if (!isset($v['send_qty'])) $v['send_qty'] = 0;
- foreach ($list as $kk => $vv) {
- if(!isset($vv['restock_qty'])) $vv['restock_qty'] = 0;
- if($vv['restock_qty'] > 0) return ['status' => '201','data'=>[], 'msg' => '不允许超出可领数量'];
- if ($vv['num'] == 0 && $vv['restock_qty'] == 0) continue;
- if ($v['material_code_show'] === $vv['title']) {
- $v['restore_qty'] = isset($vv['restock_qty']) && $vv['restock_qty'] > 0 ? $vv['restock_qty'] : 0;
- if (($v['qty'] - $v['send_qty']) > $vv['num']) {
- $list[$kk]['num'] -= $vv['num'];
- $v['send_qty'] += $vv['num'];
- $p_total = $vv['num'];
- } else {
- $list[$kk]['num'] -= ($v['qty'] - $v['send_qty']);
- $p_total = ($v['qty'] - $v['send_qty']);
- $v['send_qty'] += ($v['qty'] - $v['send_qty']);
- }
- //把产品相关参数进行封装
- ////产品编号
- //"product_code": "",
- ////产品名称
- //"product_code_show": "",
- ////工艺
- //"process_title": "",
- ////花色
- //"color": "",
- ////工艺2
- //"process_title_two": "",
- ////花色2
- //"color_two": "",
- if($p_total == 0 && $vv['restock_qty'] <= 0) continue;
- $key_arr = [
- 'product_code' => $vv['product_code'] ?? '',
- 'product_code_show' => $vv['product_code_show'] ?? '',
- 'order_item_id' => $vv['order_item_id'] ?? '',
- 'order_item_id_show' => $vv['order_item_id_show'] ?? '',
- 'process_title' => $vv['craft_type_code_show'] ?? '',
- 'color' => $vv['decor_code_show'] ?? '',
- 'process_title_two' => $vv['craft_type_two_code_show'] ?? '',
- 'color_two' => $vv['decor_two_code_show'] ?? '',
- 'send_qty' => $p_total,
- 'fake_qty' => $p_total,
- // 'send_qty' => 0,
- 'restock_qty' => $vv['restock_qty'] ?? 0,
- ];
- if($vv['restock_qty'] > 0) $list[$kk]['restock_qty'] = 0;
- $v['product_list'][] = $key_arr;
- }
- // var_dump($key_arr);
- // var_dump($key_arr);
- }
- }
- // dd($data);die;
- foreach ($data as $k=>$d){
- if(empty($d['product_list'])) unset($data[$k]);
- }
- usort($data, function ($a,$b){
- return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
- });
- // list($status,$msg) = DwyService::getInstance()->setLimitForBoxOut($param);
- // if(! $status) return ['status' => '201', 'data' => [],'msg'=> $msg];
- $this->unusualRestock($data,$mac,$token);
- if(empty($data)) return ['status' => '201', 'data' => $data,'msg'=>'无商标需要申领'];
- return ['status' => '200', 'data' => $data];
- }
- //单独的没有出标数据但是需要保存补领
- public function unusualRestock($data,$mac,$token){
- $send_status = true;
- $send_data = [];
- //2024-06-19T21:01:51.948Z,赖的写,直接拼
- $iso8601Time = date('Y-m-d').'T'.date('H:i:s').'.'.rand(100,999).'Z';
- foreach ($data as $v){
- if($v['send_qty'] > 0) $send_status = false;
- $send_product = [];
- //创建异常数据
- $box_data = [
- 'in_out_type_code' => 'CK00004',
- 'in_out_type_code_show' => '商标仓正常领标出库',
- 'send_box_code' => $v['box_code'],
- 'send_box_code_show' => $v['box_code_show'],
- 'device_code' => $mac,
- 'get_brand_source_dk' => 'SALE_ORDER',
- 'abnormal_flag' => false,
- 'abnormal_date' => $iso8601Time,
- ];
- foreach ($v['product_list'] as $kk=>$vv){
- $send_product[] = [
- 'item_no' => 10+$kk*10,
- 'brand_qr_code_list' => '',
- 'material_code' => $v['material_code'],
- 'material_code_show' => $v['material_code_show'],
- 'unit_code' => $v['unit_code'],
- 'unit_code_show' => $v['unit_code_show'],
- 'restock_qty' => $vv['restock_qty'],
- 'qty' => 0,
- 'fake_qty' => 0,
- 'bus_type_dk' => 'SALE_ORDER',
- 'bus_type_dk_show' => '销售订单',
- 'bus_no' => $vv['order_item_id'],
- 'bus_no_show' => $vv['order_item_id_show'],
- 'product_code' => $vv['product_code'],
- 'product_code_show' => $vv['product_code_show'],
- 'process_title' => $vv['process_title'],
- 'color' => $vv['color'],
- 'process_title_two' => $vv['process_title_two'],
- 'color_two' => $vv['color_two'],
- ];
- }
- $box_data['brand_out_stock_dtl'] =$send_product;
- $send_data[] = $box_data;
- }
- $param = [
- 'brand_out_stock_list' => $send_data
- ];
- if($send_status){
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $token,
- ];
- $res = $this->post_helper($url, json_encode($param), $header);
- file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($header) . PHP_EOL, 8);
- file_put_contents('dwy1.txt', date('Y-m-d H:i:s').json_encode($param) . PHP_EOL, 8);
- file_put_contents('dwy1.txt', date('Y-m-d H:i:s').$res . PHP_EOL, 8);
- }
- }
- public function zjlb(Request $request)
- {
- $param = $request->all();
- file_put_contents('dwy1.txt', json_encode($param) . PHP_EOL, 8);
- // $param = [
- // 'token'=>'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNzM2OTUyNTA3NTI5NTQzNzMiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfQVJSRVNULFJPTEVfQURNSU4iLCJ0b2tlbklkIjoiOTUwIiwiZXhwIjoxNzA3OTcxMTcxfQ.2VQ9Wqmk4rvKAcTsQPw59llBbeXjalKDGIZA4kesnuOJ0POmPVOVlRLbTtUDxl0XiFdPDUrKzuEFl2DXSgQdJg',
- // 'list'=>[
- // [
- // 'title'=>'优选A7家具板ENF小标',
- // 'num'=>'20',
- // ],[
- // 'title'=>'植萃除醛圆标',
- // 'num'=>'10',
- // ],
- // ],
- // ];
- // dd(json_encode($param));
- // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/box_inventory_dtl_qr/page';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $request->header('Authorization'),
- ];
- $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}';
- $data = $this->post_helper($url, $param, $header);
- // $data = $this->post_helper($url, json_encode($param), $header);
- $data = json_decode($data, true);
- // var_dump($data);die;
- $data = $data['content'] ?? [];
- foreach ($data as $k => &$v) {
- $v['material_code_show'] = $v['box_inventory']['material_code_show'];
- $v['qty'] = $v['roll_qty'];
- $v['bus_date'] = $v['bus_date'] ? strtotime($v['bus_date']) : '1722441600';
- $v['use_qty'] = 0;
- }
- sort($data);
- return json_encode($data);
- }
- public function boxOut(Request $request)
- {
- $param = $request->all();
- file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
- //商标绑定
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/1';
- // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' . $request->header('Authorization'),
- ];
- $lead_bind = $param['lead_bind'];
- $this->post_helper($url, json_encode($lead_bind), $header);
- //商标出库
- // $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/11';
- $lead_bind = $param['lead_out'];
- $this->post_helper($url, json_encode($lead_bind), $header);
- return ['status'=>200,'msg'=>'success'];
- }
- public function post_helper($url, $data, $header)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- if (!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- $r = curl_exec($ch);
- curl_close($ch);
- file_put_contents('33.txt',$r.PHP_EOL,8);
- return $r;
- }
- public function setTbData(Request $request){
- $data = $request->all();
- if(empty($data['id']) && empty($data['data'])) return [201, ''];
- BigKingTbj::updateOrCreate(
- ['id' => $data['id']], //查询条件
- [
- "id" => $data['id'],
- "data" => json_encode($data['data'])
- ] //添加或者修改的数据
- );
- return [200, ''];
- }
- public function getTbData(Request $request){
- $data = $request->all();
- if(empty($data['id'])) return [201, ''];
- $result = BigKingTbj::where('id',$data['id'])->first();
- if(empty($result)) return [200,'data' => []];
- return [200, 'data' => json_decode($result['data'],true)];
- }
- public function setBoxTrademark(Request $request){
- $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list';
- $header = [
- 'Content-Type:application/json',
- 'Authorization: ' .'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2MzM1NTJ9.CC69s4dpUdd9UqQlpeK5UF3DwY5Zenn-YHv8Iy1ai0cCXgere7r7jskWU9ARmKotys2tCGYRlO-Idtxdwdsefg',
- ];
- $data = [
- 'roll_qr_code_list' => [
- '171368443563212'
- ]
- ];
- $a = $this->post_helper($url, json_encode($data), $header);
- var_dump($a);die;
- $a = json_decode($a,true);
- $detail = [];
- foreach ($a['data'] as $v){
- $code = $v['brand_qr_code'];
- $detail[] = $code;
- }
- file_put_contents('1.txt',json_encode($detail));
- var_dump($a);die;
- }
- public function getBoxTrademark(Request $request){
- $data = $request->all();
- if(empty($data['box_nos']) && empty($data['mac'])) return ['status' => 201,'data' => []];
- $box_nos = $data['box_nos'];
- $dv = $data['mac'];
- $detail = [];
- //测试写入文件
- // foreach ($box_nos as $v) {
- // $filePath = storage_path( "app/box_trade/"."{$dv}_{$v}.txt");
- // if (! file_exists(storage_path('box_trade'))) Storage::makeDirectory('box_trade');
- // file_put_contents($filePath,json_encode(['a' => '测试','b'=>'测试2']));
- // }
- //读取文件
- foreach ($box_nos as $v) {
- // $filePath = public_path($file_path . "{$dv}_{$v}.txt");
- $filePath = storage_path("app/box_trade/"."{$dv}_{$v}.txt");
- if(file_exists($filePath)){
- if (($content = file_get_contents($filePath)) === false) continue;
- $decodedContent = json_decode($content, true);
- if (json_last_error() !== JSON_ERROR_NONE) continue;
- $detail[] = [
- 'detail'=>$decodedContent,
- 'code'=>$v,
- ];
- }
- }
- return ['status' => 200, 'data' => $detail];
- }
- public function andriodLog(Request $request){
- // $data = $request->all();
- $data = file_get_contents('php://input');
- $path = date('Ymd');
- $file = 'dwyAndriod.txt';
- if (!is_dir($path)) {
- // 创建目录,第三个参数 true 表示递归创建目录
- mkdir($path, 0755, true);
- }
- $param = json_decode($data,true);
- if(isset($param['type'])&&isset($param['content'])){
- $file = $path.'/'.$param['type'].'_'.$file;
- file_put_contents($file,$param['content'].PHP_EOL,8);
- }else{
- file_put_contents($file,$data.PHP_EOL,8);
- }
- return ['status' => 200, 'data' => []];
- }
- public function andriodDownload(Request $request){
- $data = file_get_contents('andriodList.txt');
- $data = json_decode($data,true);
- $param = $request->all();
- if(isset($param['type'])){
- $type = $param['type'];
- $return = [];
- foreach ($data as $v){
- if($v['type'] == $type) $return[] = $v;
- }
- $data = $return;
- }
- return ['status'=>200,'data'=> $data];
- }
- public function setAndriodDownload(Request $request){
- // $data = file_get_contents('andriodList.txt');
- // if(empty($data)) $data = [];
- // else $data = json_decode($data,true);
- $param = $request->all();
- file_put_contents('andriodList.txt',json_encode($param));
- return ['status'=>200,'msg'=>'ok','data'=>[]];
- }
- }
|