union_ad_ssgf/lib/flutter_unio_ad_bidding_controller.dart
2024-11-25 11:54:02 +08:00

88 lines
2.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

part of 'flutter_union_ad.dart';
/// @Description: 优量汇竞价
class FlutterUnioAdBiddingController {
late MethodChannel? _methodChannel;
init(MethodChannel? method) {
_methodChannel = method;
}
//回传竞价结果
void biddingResult(FlutterTencentBiddingResult result) {
//竞价成功
if (result.isSuccess) {
_methodChannel?.invokeMethod('biddingSucceeded', {
'expectCostPrice': result.expectCostPrice,
'highestLossPrice': result.highestLossPrice,
});
//竞价失败
} else {
_methodChannel?.invokeMethod('biddingSucceeded', {
'winPrice': result.winPrice,
'lossReason': result.lossReason,
'adnId': result.adnId,
});
}
}
}
class FlutterTencentBiddingResult {
int? expectCostPrice;
int? highestLossPrice;
int? winPrice;
int? lossReason;
String? adnId;
bool isSuccess = true;
FlutterTencentBiddingResult();
///竞价成功
///
///[expectCostPrice] 竞胜出价类型为Integer
///
///[highestLossPrice] 最大竞败方出价类型为Integer
FlutterTencentBiddingResult success(
int expectCostPrice, int highestLossPrice) {
this.isSuccess = true;
this.expectCostPrice = expectCostPrice;
this.highestLossPrice = highestLossPrice;
return this;
}
///竞价失败
///
/// [winPrice] 本次竞胜方出价单位类型为Integer。选填
///
/// [lossReason] 优量汇广告竞败原因类型为Integer。必填 [FlutterTencentAdBiddingLossReason]
///
/// [adnId] 本次竞胜方渠道ID类型为Integer。必填。 [FlutterTencentAdADNID]
FlutterTencentBiddingResult fail(int winPrice, int lossReason, String adnId) {
this.isSuccess = false;
this.winPrice = winPrice;
this.lossReason = lossReason;
this.adnId = adnId;
return this;
}
FlutterTencentBiddingResult.fromJson(Map<String, dynamic> json) {
expectCostPrice = json['expectCostPrice'];
highestLossPrice = json['highestLossPrice'];
winPrice = json['winPrice'];
lossReason = json['lossReason'];
adnId = json['adnId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['isSuccess'] = this.isSuccess;
data['expectCostPrice'] = this.expectCostPrice;
data['highestLossPrice'] = this.highestLossPrice;
data['winPrice'] = this.winPrice;
data['lossReason'] = this.lossReason;
data['adnId'] = this.adnId;
return data;
}
}