123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377 |
- <?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 setLb1(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'=>[]];
- }
- }
|