makeSign(['appid'=>'ehiV145x0sq2pIdR'],'zcJOeS7Ty1Zk5sEYQ36ia9UbDxWgGRlm'); // var_dump($sign); var_dump($sign);die; } function makeSign($params,$appkey,$sign_type=1){ ksort($params); unset($params['sign']); $str = ''; foreach($params as $key=>$val){ if(is_array($val)){ continue; } if($sign_type == 1 || !$sign_type){ if(strlen($val) > 0){ $str.= trim($val); } }else{ if(strlen($val) > 0){ $str.= trim($key).'='.trim($val); } } } $hash_hmac = hash_hmac('sha256', $str, $appkey, true); return urlencode(base64_encode($hash_hmac)); } public function boxInsert(){ $data = [ 'out_order_no' => 'test123', 'ext_1' => '1', 'ext_2' => '2', 'ext_3' => '3', 'ext_4' => '4', 'ext_5' => '5', 'detail' => [ [ 'top_id' => '1', 'code' => '001', 'title' => '产品名称', 'ext_1' => '1', 'ext_2' => '2', 'ext_3' => '3', 'ext_4' => '4', 'ext_5' => '5', ],[ 'top_id' => '2', 'code' => '002', 'title' => '产品名称1', 'ext_1' => '11', 'ext_2' => '22', 'ext_3' => '33', 'ext_4' => '44', 'ext_5' => '55', ], ], ]; $service = BoxHookService::getInstance(); list($status,$msg) = $service->boxInsert($data); var_dump($status); var_dump($msg); } public function aa(){ //处理数据 $data = '{"param":{"key":"DV00001","lead_bind":{"device_code":"DV00001","material_list":[{"product_code":"BC020202000999","fake_qty":"5","product_code_show":"信息部测试1800香杉木","order_item_id":"599057977894375424","order_item_id_show":"SO202407110062","material_code":"40010101000999","material_code_show":"E0批零免漆(测试白标)","process_title":"挪威森林","process_title_two":null,"color":"测试花色01","color_two":null,"mat_material_a":{"mat_category_code_show":"免漆板1800香杉木","mat_category_code":"BC020202","cpdj_show":"尊贵型","cpdj":"cpdj01","grade_show":"E0","grade":"01"},"brand_qr_code_list":["K45SDTL4BGIT93MVEPM1","EK60TLDMP1G26WD2G38R","CS0OMSFOS8UB480KP7UY","ME9D9RFU69B79YLM6V9J","N8CPA3WOWGBPFH6M1VUV"],"order_no_list":"SO202407110062"},{"product_code":"BC020202000999","fake_qty":"5","product_code_show":"信息部测试1800香杉木","order_item_id":"599057977894375424","order_item_id_show":"SO202407110062","material_code":"40010501000999","material_code_show":"银盾抗菌圆标(测试白标)","process_title":"挪威森林","process_title_two":null,"color":"测试花色01","color_two":null,"mat_material_a":{"mat_category_code_show":"免漆板1800香杉木","mat_category_code":"BC020202","cpdj_show":"尊贵型","cpdj":"cpdj01","grade_show":"E0","grade":"01"},"brand_qr_code_list":["6A51SIUC74AJ8E2JECGP","8VP60YJ5D7C3DX9R93XY","UJ4R8XMJ49AKXQOSW376","8VP6VYJ0CFWRQ49SD3X8","1R6B8DOCUVN67DA2G6A2"],"order_no_list":"SO202407110062"}]},"lead_out":{"brand_out_stock_list":[{"in_out_type_code":"CK00004","in_out_type_code_show":"商标仓正常领标出库","send_box_code":"CK00011","send_box_code_show":"商标八号仓","device_code":"DV00001","get_brand_source_dk":"SALE_ORDER","abnormal_flag":false,"abnormal_date":"2024-08-26T16:53:29.109Z","brand_out_stock_dtl":[{"item_no":10,"brand_qr_code_list":"K45SDTL4BGIT93MVEPM1,EK60TLDMP1G26WD2G38R,CS0OMSFOS8UB480KP7UY,ME9D9RFU69B79YLM6V9J,N8CPA3WOWGBPFH6M1VUV","material_code":"40010101000999","restock_qty":0,"material_code_show":"E0批零免漆(测试白标)","unit_code":"ST","unit_code_show":"张","qty":"5","fake_qty":"5","make_qty":"5","bus_type_dk":"SALE_ORDER","bus_type_dk_show":"销售订单","bus_no":"599057977894375424","bus_no_show":"SO202407110062","mat_material_a":{"mat_category_code_show":"免漆板1800香杉木","mat_category_code":"BC020202","cpdj_show":"尊贵型","cpdj":"cpdj01","grade_show":"E0","grade":"01"}}]},{"in_out_type_code":"CK00004","in_out_type_code_show":"商标仓正常领标出库","send_box_code":"CK00018","send_box_code_show":"商标十五号仓","device_code":"DV00001","get_brand_source_dk":"SALE_ORDER","abnormal_flag":false,"abnormal_date":"2024-08-26T16:53:29.109Z","brand_out_stock_dtl":[{"item_no":10,"brand_qr_code_list":"6A51SIUC74AJ8E2JECGP,8VP60YJ5D7C3DX9R93XY,UJ4R8XMJ49AKXQOSW376,8VP6VYJ0CFWRQ49SD3X8,1R6B8DOCUVN67DA2G6A2","material_code":"40010501000999","restock_qty":0,"material_code_show":"银盾抗菌圆标(测试白标)","unit_code":"ST","unit_code_show":"张","qty":"5","fake_qty":"5","make_qty":"5","bus_type_dk":"SALE_ORDER","bus_type_dk_show":"销售订单","bus_no":"599057977894375424","bus_no_show":"SO202407110062","mat_material_a":{"mat_category_code_show":"免漆板1800香杉木","mat_category_code":"BC020202","cpdj_show":"尊贵型","cpdj":"cpdj01","grade_show":"E0","grade":"01"}}]}]}}} '; $data = json_decode($data,true); $data = $data['param']; // $data = $this->data; $dv = $data['key']; $return = $box_list = []; LabelDealService::getInstance()->clearData($data,$return,$box_list); Log::channel('apiLog')->info('测试--出库(清洗数据)', ["param" => $return]); //调用外部方法 list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData1('Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1OTAwNDY0ODg5NDAzODQyNTYiLCJhdXRoIjoiUk9MRV9PVVRFUl9VU0VSLFJPTEVfSU5URVJGQUNFLFJPTEVfU0VORF9CUkFORF9TVVBQTElFUixST0xFX1VTRV9CUkFORF9TVVBQTElFUixST0xFX0JSQU5EX1NVUFBMSUVSLFJPTEVfSU5ORVJfVVNFUiIsInRva2VuSWQiOiIzIiwiZXhwIjoxNzI3MjUzMjE0fQ.ucMycX2b2Nzcc4tF0ZPcYDW8QOmqX942MLdmcd3PLa5O4DAseRHkAtyiPxzGf8cIj2qWppGcjusP5c4f0RyDig',$dv,$return,$box_list,$data); die; //删除限制 DwyService::getInstance()->delLimitForBoxOut($lead_bind); //调用保存接口 cs todo LabelDealService::getInstance()->boxOut1($lead_bind,$lead_out,$this->header,$this->id); } public function encryption($jsonToString, $saltKey, $aesEncRequestKey) { $this->aesKey = $aesEncRequestKey; $this->saltIVKey = $saltKey; return $this->encryptJsonData($jsonToString); } public function decryption($encryptedResponseData, $saltKey, $aesEncRequestKey) { $this->aesKey = $aesEncRequestKey; $this->saltIVKey = $saltKey; return $this->decryptResponseData($encryptedResponseData); } private function encryptJsonData($jsonToString) { $saltBytes = $this->saltIVKey; $secretKey = $this->generateSecretKey($this->aesKey, $saltBytes); $cipher = "AES-256-CBC"; $encryptedTextBytes = openssl_encrypt($jsonToString, $cipher, $secretKey, OPENSSL_RAW_DATA, $this->ivBytes); return $this->byteToHex($encryptedTextBytes); } private function decryptResponseData($encryptedResponseData) { $saltBytes = $this->saltIVKey; $encryptedTextBytes = $this->hex2ByteArray($encryptedResponseData); $secretKey = $this->generateSecretKey($this->aesKey, $saltBytes); $cipher = "AES-256-CBC"; $decryptedTextBytes = openssl_decrypt($encryptedTextBytes, $cipher, $secretKey, OPENSSL_RAW_DATA, $this->ivBytes); return $decryptedTextBytes; } private function generateSecretKey($aesKey, $saltBytes) { return hash_pbkdf2("sha1", $aesKey, $saltBytes, 65536, 32, true); } private function byteToHex($byData) { return strtoupper(bin2hex($byData)); } private function hex2ByteArray($sHexData) { return hex2bin($sHexData); } }