初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
@@ -0,0 +1,45 @@
/// 单条账单
class BillItemModel {
final String? createdAt;
final String? desc;
final String? tranType;
final int? tranTypeInt;
final int? actualAmount; //实际变动金币
final int? actualIntegral; //实际变动积分
final int? integral;
BillItemModel({
this.createdAt,
this.desc,
this.tranType,
this.tranTypeInt,
this.actualAmount,
this.actualIntegral,
this.integral,
});
/// 数量单位:有积分变动记积分,特定交易类型记次数,其余记金币
String get unit {
if ((integral ?? 0) != 0) return '积分';
if (const {103, 104, 109, 110, 111}.contains(tranTypeInt)) return '';
return '金币';
}
/// 展示用数量:金币和积分只会变动其中一种,同时变动时不展示
int get realCount {
if (actualAmount == 0) return actualIntegral ?? 0;
if (actualIntegral == 0) return actualAmount ?? 0;
return 0;
}
factory BillItemModel.fromJson(Map<String, dynamic> json) => BillItemModel(
createdAt: json["createdAt"],
desc: json["desc"],
tranType: json["tranType"],
tranTypeInt: json["tranTypeInt"],
actualAmount: json["actualAmount"],
actualIntegral: json["actualIntegral"],
integral: json["integral"],
);
}
+172
View File
@@ -0,0 +1,172 @@
/// 代充商人
class PayForModel {
int? imId; //商人在聊天系统中的ID
String? userId; //商人在代充系统中的ID
String? avatar; //头像
String? nickName; //昵称
String? welcomeMsg; //商人欢迎语
List<PayInfoModel>? payInfos; //支持的支付方式
PayForModel();
PayForModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
imId = json['imId'];
userId = json['userId'];
avatar = json['avatar'];
nickName = json['nickName'];
welcomeMsg = json['welcomeMsg'];
payInfos = (json['payInfos'] as List?)?.map((e) => PayInfoModel.fromJson(e)).toList();
}
Map<String, dynamic> toJson() => {
"imId": imId,
"userId": userId,
"avatar": avatar,
"welcomeMsg": welcomeMsg,
"nickName": nickName,
"payInfos": payInfos,
};
PayForModel clone() => PayForModel()
..imId = imId
..userId = userId
..avatar = avatar
..nickName = nickName
..welcomeMsg = welcomeMsg
..payInfos = payInfos?.map((e) => e.clone()).toList() ?? [];
}
/// 一种支付方式
class PayInfoModel {
int? payMethod;
List<int>? payType;
PayInfoModel();
PayInfoModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
payMethod = json['payMethod'];
payType = (json['payType'] as List?)?.cast<int>().toList() ?? [];
}
Map<String, dynamic> toJson() => {
"payMethod": payMethod,
"payType": payType,
};
PayInfoModel clone() => PayInfoModel()
..payMethod = payMethod
..payType = [...?payType];
}
/// 代充配置,整体 base64 后透传给代充 H5
class DCModel {
bool? isReconnect;
/// 商人列表 为空则不展示代充
List<PayForModel>? traders;
String? url;
String? ordUrl;
String? traderUrl;
int? chargeMoney;
///大额支付 小额支付
int? limit;
String? userAgent;
String? wsUrl;
String? picUrl;
/// 商品id,客户端添加,非后端返回,代充值给h5的时候使用
String? productInfo;
DcUserInfo? userInfo;
/// 支付渠道,客户端下单时赋值,非后端返回
String? channel;
DCModel();
DCModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
isReconnect = json['isReconnect'];
//只取第一个商人,后续逻辑都按 traders[0] 走
final trader = (json['traders'] as List?)?.firstOrNull;
if (trader != null) traders = [PayForModel.fromJson(trader)];
url = json['url'];
wsUrl = json['wsUrl'];
picUrl = json['picUrl'];
ordUrl = json['ordUrl'];
traderUrl = json['traderUrl'];
userInfo = DcUserInfo.fromJson(json['userInfo']);
chargeMoney = json['chargeMoney'];
limit = json['limit'];
userAgent = json['userAgent'];
productInfo = json['productInfo'];
}
Map<String, dynamic> toJson() => {
"isReconnect": isReconnect,
"traders": traders,
"url": url,
"ordUrl": ordUrl,
"traderUrl": traderUrl,
"userInfo": userInfo,
"chargeMoney": chargeMoney,
"limit": limit,
"wsUrl": wsUrl,
"picUrl": picUrl,
"userAgent": userAgent,
"productInfo": productInfo,
"channel": channel,
};
DCModel clone() => DCModel()
..isReconnect = isReconnect
..traders = traders?.map((e) => e.clone()).toList() ?? []
..url = url
..ordUrl = ordUrl
..traderUrl = traderUrl
..userInfo = userInfo?.clone()
..chargeMoney = chargeMoney
..limit = limit
..userAgent = userAgent
..wsUrl = wsUrl
..picUrl = picUrl
..productInfo = productInfo
..channel = channel;
}
/// 代充里透传给 H5 的用户信息
class DcUserInfo {
int? uid;
String? gender;
String? name;
String? portrait;
DcUserInfo();
DcUserInfo.fromJson(Map<String, dynamic>? json) {
json ??= {};
uid = json['uid'];
if (json['gender'] is String) gender = json['gender'];
name = json['name'];
portrait = json['portrait'];
}
Map<String, dynamic> toJson() => {
"uid": uid,
"gender": gender,
"name": name,
"portrait": portrait,
};
DcUserInfo clone() => DcUserInfo()
..uid = uid
..gender = gender
..name = name
..portrait = portrait;
}
@@ -0,0 +1,18 @@
import 'package:hgdj/hj_model/mine/exchange/recharge_type_list_model.dart';
import 'dc_model.dart';
/// 可供充值的金币列表
class RechargeListModel {
DCModel? daichong;
List<RechargeTypeModel>? list;
RechargeListModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
daichong = DCModel.fromJson(json['daichong']);
//代充数据挂在上级,逐条塞给档位,档位内部才能拼出代充支付方式
list = (json['list'] as List?)
?.map((e) => RechargeTypeModel.fromJson(e)..daichong = daichong)
.toList();
}
}
@@ -0,0 +1,60 @@
import '../../../hj_page/mine/mine_vip/vip_support_model.dart';
import 'dc_model.dart';
/// 代充的 payMethod → (type, 展示名)
const _dcPayTypes = {
101: ('alipy', '支付寶(人工充值)'),
102: ('wechat', '微信(人工充值)'),
103: ('union', '银联(人工充值)'),
104: ('credit', '信用卡(人工充值)'),
105: ('huabei', '花呗(人工充值)'),
106: ('yunSanPay', '云闪付(人工充值)'),
107: ('qqWallet', 'QQ錢包(人工充值)'),
108: ('jindongPay', '京东支付(人工充值)'),
};
/// 一个充值档位
class RechargeTypeModel {
String? id;
int? amount;
int? money;
String? couponDesc;
DCModel? daichong; // 从上级数据结构手动赋值过来
List<RchgType>? rechargeTypeList;
/// 展示用的支付方式:代充那条要按商人支持的 payMethod 展开成多条
List<RchgType> get rechargeTypeListUI {
final payList = <RchgType>[];
for (final rchg in (rechargeTypeList ?? [])) {
if (rchg.type != 'daichong') {
payList.add(rchg);
continue;
}
final payInfos = daichong?.traders?.firstOrNull?.payInfos ?? [];
for (final info in payInfos) {
final named = _dcPayTypes[info.payMethod];
payList.add(RchgType()
..isOfficial = true
..channel = rchg.channel
..incrAmount = rchg.incrAmount
..incTax = rchg.incTax
..payMethod = info.payMethod
..type = named?.$1
..typeName = named?.$2);
}
}
return payList;
}
//money是分单位 需要/100
int get moneyYuan => ((money ?? 0) / 100).round();
RechargeTypeModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
id = json['id'];
amount = json['amount'];
money = json['money'];
couponDesc = json['couponDesc'];
rechargeTypeList = (json['rchgType'] as List?)?.map((o) => RchgType.fromJson(o)).toList();
}
}
@@ -0,0 +1,13 @@
/// 下单返回的支付链接
class RechargeUrlModel {
String? payUrl;
/// url-打开外部支付链接;sdk-走 sdk
String? mode;
RechargeUrlModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
payUrl = json['payUrl'];
mode = json['mode'];
}
}