$code, 'msg' => $msg, 'data' => $data ]; return response()->json($result); } public function error($msg = null, $code = 1, $data = null) { $result = [ 'code' => $code, 'msg' => $msg, 'data' => $data ]; return response()->json($result); } public function validatorError($arr, $code = 1, $message = '') { foreach ($arr as $val) { if ($val && $message == '') { $message = $val; } } if ($code !== 0 && ErrorCode::CLIENT_WRONG_PARAMS && empty($msg)) { $msg = ErrorCode::message($code); } $result = [ 'code' => $code, 'msg' => $msg, 'data' => $data ]; return response()->json($result); } /** * @param int $platform * @return ByteDance|Kuaishou */ protected function getUniFactory($platform = 1) { if($platform == 1){ return $this->getByteDanceFactory(); } return $this->getKuishouFactory(); } protected function getByteDanceFactory() { $setting = PayConfig::first(); return (new ByteDance(app(ByteDanceAPI::class)))->factory([ 'app_id' => $setting->douyin_app_id, 'app_secret' => $setting->douyin_app_secret, 'slat' => $setting->douyin_salt, 'token' => $setting->douyin_token, ]); } protected function getKuishouFactory() { $setting = PayConfig::first(); return (new Kuaishou(app(KuaishouAPI::class)))->factory([ 'app_id' => $setting->kuaishou_app_id, 'app_secret' => $setting->kuaishou_app_secret, ]); } }