$code, 'message' => $msg, 'data' => $data, ]; return response()->json($result); } public function error($msg = null, $code = 1, $data = null) { $result = [ 'code' => $code, 'message' => $msg, 'data' => $data, ]; return response()->json($result); } public function validatorError($arr, $code = 1, $message = '') { foreach ($arr as $val) { if ($val && '' == $message) { $message = $val; } } if (0 !== $code && ErrorCode::CLIENT_WRONG_PARAMS && empty($msg)) { $msg = ErrorCode::message($code); } $result = [ 'code' => $code, 'message' => $msg, 'data' => $data, ]; return response()->json($result); } /** * @return ByteDance|Kuaishou|Wechat */ protected function getUniFactory(int $platform = 1) { if (1 == $platform) { return $this->getByteDanceFactory(); } elseif (2 == $platform) { return $this->getKuishouFactory(); } return $this->getWechatFactory(); } protected function getByteDanceFactory(): ByteDance { $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(): Kuaishou { $setting = PayConfig::first(); return (new Kuaishou(app(KuaishouAPI::class)))->factory([ 'app_id' => $setting->kuaishou_app_id, 'app_secret' => $setting->kuaishou_app_secret, ]); } protected function getWechatFactory(): Wechat { $setting = PayConfig::first(); return (new Wechat(app(WechatAPI::class)))->factory([ 'app_id' => $setting->mini_app_id, 'app_secret' => $setting->mini_app_key, 'mch_id' => $setting->wechat_mch_id, 'mch_key' => $setting->wechat_mch_key, 'response_type' => 'array', ]); } }