Browse Source

上传更新vip过期时间代码

newdev_shunjiawei
liwei1dao 10 months ago
parent
commit
b5fb681cee
  1. 11
      lib/data/services/pay_service.dart
  2. 12
      lib/modules/goods/controllers/goods_base_controller.dart
  3. 12
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt
  4. 15
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentServicePlugin.kt
  5. 8
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift
  6. 9
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift
  7. 24
      local_plugins/agent_service/lib/agent_service.dart

11
lib/data/services/pay_service.dart

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:agent_service/agent_service.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -335,6 +336,7 @@ class PayService extends GetxService {
final bool ok = status == 1 || user != null; final bool ok = status == 1 || user != null;
if (ok && user != null) { if (ok && user != null) {
User.instance.updateUserInfo(user); User.instance.updateUserInfo(user);
setVipExptime(User.instance.vipexptime);
} }
if (!ok) { if (!ok) {
final code = (resp is Map) ? resp['code'] : null; final code = (resp is Map) ? resp['code'] : null;
@ -1157,4 +1159,13 @@ class PayService extends GetxService {
return null; return null;
} }
} }
/// 请求蓝牙权限
void setVipExptime(int vipexptime) {
try {
AgentService.setVipExptime(vipexptime);
} catch (e) {
print('请求蓝牙权限失败: ${e.toString()}');
}
}
} }

12
lib/modules/goods/controllers/goods_base_controller.dart

@ -446,6 +446,8 @@ abstract class GoodsBaseController extends GetxController {
); );
if (paymentData == null) { if (paymentData == null) {
onResult?.call(false, '创建微信订单失败'); onResult?.call(false, '创建微信订单失败');
isPaying.value = false;
_cancelPayingTimeout();
return false; return false;
} }
final orderId = final orderId =
@ -481,6 +483,8 @@ abstract class GoodsBaseController extends GetxController {
); );
if (orderInfo == null) { if (orderInfo == null) {
onResult?.call(false, '创建支付宝订单失败'); onResult?.call(false, '创建支付宝订单失败');
isPaying.value = false;
_cancelPayingTimeout();
return false; return false;
} }
final orderId = _payService.lastOrderId; // 创建订单时已缓存 final orderId = _payService.lastOrderId; // 创建订单时已缓存
@ -514,6 +518,8 @@ abstract class GoodsBaseController extends GetxController {
); );
if (orderId == null || orderId.isEmpty) { if (orderId == null || orderId.isEmpty) {
onResult?.call(false, '创建 Apple 订单失败'); onResult?.call(false, '创建 Apple 订单失败');
isPaying.value = false;
_cancelPayingTimeout();
return false; return false;
} }
// 使用商品id作为内购的 productId(与后台保持一致) // 使用商品id作为内购的 productId(与后台保持一致)
@ -568,6 +574,8 @@ abstract class GoodsBaseController extends GetxController {
); );
if (orderId == null || orderId.isEmpty) { if (orderId == null || orderId.isEmpty) {
onResult?.call(false, '创建 Google 订单失败'); onResult?.call(false, '创建 Google 订单失败');
isPaying.value = false;
_cancelPayingTimeout();
return false; return false;
} }
isPaying.value = true; isPaying.value = true;
@ -650,6 +658,7 @@ abstract class GoodsBaseController extends GetxController {
final orderStatus = order["status"]; final orderStatus = order["status"];
if (orderStatus == 1) { if (orderStatus == 1) {
User.instance.updateUserInfo(user); User.instance.updateUserInfo(user);
_payService.setVipExptime(User.instance.vipexptime);
success = true; success = true;
break; break;
} }
@ -685,6 +694,7 @@ abstract class GoodsBaseController extends GetxController {
final orderStatus = order['status']; final orderStatus = order['status'];
if (orderStatus == 1 && user != null) { if (orderStatus == 1 && user != null) {
User.instance.updateUserInfo(user); User.instance.updateUserInfo(user);
_payService.setVipExptime(User.instance.vipexptime);
Get.snackbar('提示', '订单已确认,额度已刷新', Get.snackbar('提示', '订单已确认,额度已刷新',
snackPosition: SnackPosition.BOTTOM, snackPosition: SnackPosition.BOTTOM,
margin: const EdgeInsets.all(12)); margin: const EdgeInsets.all(12));
@ -808,6 +818,8 @@ abstract class GoodsBaseController extends GetxController {
); );
if (approvalUrl == null) { if (approvalUrl == null) {
onResult?.call(false, '创建 PayPal 订单失败'); onResult?.call(false, '创建 PayPal 订单失败');
isPaying.value = false;
_cancelPayingTimeout();
return false; return false;
} }
final orderId = _payService.lastOrderId; // 创建订单时已缓存 final orderId = _payService.lastOrderId; // 创建订单时已缓存

12
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

@ -296,13 +296,14 @@ object AgentService : CoroutineScope {
usertoken = config["usertoken"]?.toString() ?: usertoken usertoken = config["usertoken"]?.toString() ?: usertoken
callingToolText = config["callingToolText"]?.toString() ?: callingToolText callingToolText = config["callingToolText"]?.toString() ?: callingToolText
insufficientIntegralText = config["insufficientIntegralText"]?.toString() ?: insufficientIntegralText insufficientIntegralText = config["insufficientIntegralText"]?.toString() ?: insufficientIntegralText
vipExptime = config["vipexptime"]?.toString()?.toIntOrNull() ?: 0; vipExptime = config["vipexptime"]?.toString()?.toIntOrNull() ?: vipExptime;
navigationMode = config["navigationMode"]?.toString() ?: navigationMode navigationMode = config["navigationMode"]?.toString() ?: navigationMode
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "应用配置更新失败: ${e.message}") Log.e(TAG, "应用配置更新失败 config: $config Exception:${e.message}")
} }
} }
/** /**
* 释放所有资源 * 释放所有资源
*/ */
@ -1374,6 +1375,7 @@ object AgentService : CoroutineScope {
} }
} }
/** /**
* 更新TTS语言设置 * 更新TTS语言设置
* *
@ -1408,6 +1410,12 @@ object AgentService : CoroutineScope {
} }
} }
fun setvipExptime(vipexptime: Int): Boolean {
vipExptime = vipexptime
return true
}
/** /**
* 根据ASR语言代码获取对应的TTS语音角色名称 * 根据ASR语言代码获取对应的TTS语音角色名称
* 与LanguageManager中的映射保持一致 * 与LanguageManager中的映射保持一致

15
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentServicePlugin.kt

@ -267,7 +267,20 @@ class AgentServicePlugin : FlutterPlugin, MethodCallHandler, EventChannel.Stream
result.error("SET_LANGUAGES_ERROR", "设置支持语言失败: ${e.message}", null) result.error("SET_LANGUAGES_ERROR", "设置支持语言失败: ${e.message}", null)
} }
} }
"setVipExptime" -> {
try {
val vipexptime = call.argument<Int>("vipexptime")
if (vipexptime == null) {
result.error("INVALID_ARGUMENTS", "vipexptime参数不能为空", null)
return
}
val isSuccess = AgentService.setvipExptime(vipexptime)
result.success(isSuccess)
} catch (e: Exception) {
Log.e(TAG, "更新用户信息失败", e)
result.error("UPDATE_USER_INFO_ERROR", "更新用户信息失败: ${e.message}", null)
}
}
"stopAiSteam" -> { "stopAiSteam" -> {
try { try {
AgentService.stopAiStream() AgentService.stopAiStream()

8
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -1524,7 +1524,13 @@ private func jsonToString(_ json: [String: Any]) -> String? {
return false return false
} }
} }
/*
* 设置vip过期时间
*/
func setVipExptime(_ vipexptime:Int) -> Bool {
self.vipexptime = vipexptime
return true
}
/** /**
* 根据ASR语言代码获取对应的TTS语音角色名称 * 根据ASR语言代码获取对应的TTS语音角色名称
* 与LanguageManager中的映射保持一致 * 与LanguageManager中的映射保持一致

9
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift

@ -178,7 +178,14 @@ public class AgentServicePlugin: NSObject, FlutterPlugin {
let success = impl.setSupportedLanguages(languages) let success = impl.setSupportedLanguages(languages)
result(success) result(success)
case "setVipExptime":
guard let arguments = call.arguments as? [String: Any],
let vipexptime = arguments["vipexptime"] as? Int else {
result(FlutterError(code: "INVALID_ARGUMENTS", message: "vipexptime参数不能为空", details: nil))
return
}
let success = impl.setVipExptime(vipexptime)
result(success)
default: default:
result(FlutterMethodNotImplemented) result(FlutterMethodNotImplemented)
} }

24
local_plugins/agent_service/lib/agent_service.dart

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -489,6 +490,29 @@ class AgentService {
} }
} }
/// 更新用户信息
///
/// 更新用户信息,包括姓名、手机号、邮箱等
/// [config] 配置参数,应包含以下参数:
/// - azureSpeechKey: Azure语音服务密钥
/// - azureSpeechRegion: Azure语音服务区域
/// - openaiApiKey: OpenAI API密钥
/// - openaiBaseUrl: (可选) OpenAI API 基础URL
/// - openaiModel: (可选) OpenAI模型名称,默认为"gpt-3.5-turbo"
/// - mcpServer: (可选) MCP服务器地址
///
/// 返回是否成功启动服务
static Future<bool> setVipExptime(int vipexptime) async {
try {
final bool result = await _channel.invokeMethod('setVipExptime', {
'vipexptime': vipexptime,
});
return result;
} on PlatformException catch (e) {
throw AgentServiceException(e.code, e.message ?? '更新用户信息失败', e.details);
}
}
/// 释放资源 /// 释放资源
static Future<bool> dispose() async { static Future<bool> dispose() async {
try { try {

Loading…
Cancel
Save