Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
0742a081
提交
0742a081
authored
1月 25, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交书豆支付订单
上级
a6bc143c
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
139 行增加
和
12 行删除
+139
-12
common.dart
lib/apis/common.dart
+26
-0
shop.dart
lib/models/shop.dart
+69
-0
controller.dart
lib/pages/book_pay/controller.dart
+38
-9
index.dart
lib/pages/book_pay/index.dart
+3
-0
view.dart
lib/pages/book_pay/view.dart
+1
-1
pay_count.dart
lib/pages/book_pay/widgets/pay_count.dart
+1
-1
view.dart
lib/pages/credit_points/view.dart
+1
-1
没有找到文件。
lib/apis/common.dart
浏览文件 @
0742a081
...
@@ -163,4 +163,29 @@ abstract class CommonAPI {
...
@@ -163,4 +163,29 @@ abstract class CommonAPI {
return
result
.
data
[
'filesUrl'
];
return
result
.
data
[
'filesUrl'
];
}
}
/// 11、创建订单
///
static
Future
<
PayOrderModel
>
createOrder
({
required
String
bookIdsList
,
required
String
totalPrice
,
required
String
couponRecId
,
required
String
integral
,
required
String
type
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/orders/Orders/createOrders'
,
params:
{
'book_ids_list'
:
bookIdsList
,
'total_price'
:
totalPrice
,
'coupon_rec_id'
:
couponRecId
,
'integral'
:
integral
,
'type'
:
type
,
},
);
if
(
result
.
data
is
!
Map
)
return
PayOrderModel
();
return
PayOrderModel
.
fromJson
(
result
.
data
);
}
}
}
\ No newline at end of file
lib/models/shop.dart
浏览文件 @
0742a081
...
@@ -149,3 +149,71 @@ class CouponNumModel {
...
@@ -149,3 +149,71 @@ class CouponNumModel {
}
}
}
}
/// 创建订单模型
class
PayOrderModel
{
PayOrderModel
({
this
.
appid
,
this
.
partnerid
,
this
.
prepayid
,
this
.
package
,
this
.
noncestr
,
this
.
timestamp
,
this
.
sign
,
this
.
ordersnum
,
this
.
encryptionOrder
,});
PayOrderModel
.
fromJson
(
dynamic
json
)
{
appid
=
json
[
'appid'
];
partnerid
=
json
[
'partnerid'
];
prepayid
=
json
[
'prepayid'
];
package
=
json
[
'package'
];
noncestr
=
json
[
'noncestr'
];
timestamp
=
json
[
'timestamp'
];
sign
=
json
[
'sign'
];
ordersnum
=
json
[
'ordersnum'
];
encryptionOrder
=
json
[
'encryption_order'
];
}
String
?
appid
;
String
?
partnerid
;
String
?
prepayid
;
String
?
package
;
String
?
noncestr
;
num
?
timestamp
;
String
?
sign
;
String
?
ordersnum
;
String
?
encryptionOrder
;
PayOrderModel
copyWith
({
String
?
appid
,
String
?
partnerid
,
String
?
prepayid
,
String
?
package
,
String
?
noncestr
,
num
?
timestamp
,
String
?
sign
,
String
?
ordersnum
,
String
?
encryptionOrder
,
})
=>
PayOrderModel
(
appid:
appid
??
this
.
appid
,
partnerid:
partnerid
??
this
.
partnerid
,
prepayid:
prepayid
??
this
.
prepayid
,
package:
package
??
this
.
package
,
noncestr:
noncestr
??
this
.
noncestr
,
timestamp:
timestamp
??
this
.
timestamp
,
sign:
sign
??
this
.
sign
,
ordersnum:
ordersnum
??
this
.
ordersnum
,
encryptionOrder:
encryptionOrder
??
this
.
encryptionOrder
,
);
Map
<
String
,
dynamic
>
toJson
()
{
final
map
=
<
String
,
dynamic
>{};
map
[
'appid'
]
=
appid
;
map
[
'partnerid'
]
=
partnerid
;
map
[
'prepayid'
]
=
prepayid
;
map
[
'package'
]
=
package
;
map
[
'noncestr'
]
=
noncestr
;
map
[
'timestamp'
]
=
timestamp
;
map
[
'sign'
]
=
sign
;
map
[
'ordersnum'
]
=
ordersnum
;
map
[
'encryption_order'
]
=
encryptionOrder
;
return
map
;
}
}
\ No newline at end of file
lib/pages/book_pay/controller.dart
浏览文件 @
0742a081
...
@@ -2,10 +2,10 @@ part of book_pay;
...
@@ -2,10 +2,10 @@ part of book_pay;
class
BookPayController
extends
GetxController
{
class
BookPayController
extends
GetxController
{
// 购物车选中的书籍列表
// 购物车选中的书籍列表
final
List
<
CourseModel
>
?
buy
;
final
List
<
CourseModel
>
buy
;
BookPayController
({
this
.
buy
});
BookPayController
({
required
this
.
buy
});
// 积分模型
// 积分模型
CreditPointModel
creditPointModel
=
CreditPointModel
();
CreditPointModel
creditPointModel
=
CreditPointModel
(
deductibleIntegral:
0
);
// 是否展示优惠券和积分模型
// 是否展示优惠券和积分模型
ShowModel
showModel
=
ShowModel
();
ShowModel
showModel
=
ShowModel
();
...
@@ -14,7 +14,9 @@ class BookPayController extends GetxController {
...
@@ -14,7 +14,9 @@ class BookPayController extends GetxController {
// 优惠券可用不可用数量模型
// 优惠券可用不可用数量模型
CouponNumModel
couponNumModel
=
CouponNumModel
();
CouponNumModel
couponNumModel
=
CouponNumModel
();
// 选择的优惠券模型
// 选择的优惠券模型
late
CouponModel
useCouponModel
=
CouponModel
(
couponId:
0
,
reducedPrice:
'0.00'
);
late
CouponModel
useCouponModel
=
CouponModel
(
couponId:
0
,
reducedPrice:
'0.00'
,
couponRecId:
0
);
// 创建订单模型
late
PayOrderModel
payOrderModel
;
// 支付方式
// 支付方式
List
<
PayModel
>
pays
=
Platform
.
isIOS
?[
List
<
PayModel
>
pays
=
Platform
.
isIOS
?[
...
@@ -30,8 +32,8 @@ class BookPayController extends GetxController {
...
@@ -30,8 +32,8 @@ class BookPayController extends GetxController {
// 优惠前的原始价钱
// 优惠前的原始价钱
late
double
originalPrice
=
getOriginalPrice
();
late
double
originalPrice
=
getOriginalPrice
();
late
double
finalPrice
=
0.00
;
//
late double finalPrice = 0.00;
Decimal
finalPrice
=
Decimal
.
zero
;
@override
@override
...
@@ -119,17 +121,43 @@ class BookPayController extends GetxController {
...
@@ -119,17 +121,43 @@ class BookPayController extends GetxController {
/// 获取优惠后的价格
/// 获取优惠后的价格
void
computeFinalPrice
(){
void
computeFinalPrice
(){
finalPrice
=
originalPrice
;
finalPrice
=
Decimal
.
parse
(
originalPrice
.
toString
())
;
if
(
useCreditPoint
){
if
(
useCreditPoint
){
finalPrice
=
finalPrice
-
Decimal
.
parse
(
creditPointModel
.
deductibleAmount
??
'0.00'
)
.
toDouble
()
;
finalPrice
=
finalPrice
-
Decimal
.
parse
(
creditPointModel
.
deductibleAmount
??
'0.00'
);
}
}
// 不等0的时候证明使用了 优惠券
// 不等0的时候证明使用了 优惠券
if
(
useCouponModel
.
couponId
!=
0
){
if
(
useCouponModel
.
couponId
!=
0
){
finalPrice
=
finalPrice
-
Decimal
.
parse
(
useCouponModel
.
reducedPrice
??
'0.00'
)
.
toDouble
()
;
finalPrice
=
finalPrice
-
Decimal
.
parse
(
useCouponModel
.
reducedPrice
??
'0.00'
);
}
}
update
();
update
();
}
}
/// 创建订单
void
createOrder
()
async
{
List
<
Map
<
String
,
dynamic
>>
bookIdsList
=
[];
for
(
CourseModel
model
in
buy
){
Map
<
String
,
dynamic
>
tempMap
=
{
'book_id'
:
model
.
bookId
,
'price'
:
model
.
price
,
'cart_id'
:
model
.
cartId
,
};
bookIdsList
.
add
(
tempMap
);
}
final
result
=
await
CommonAPI
.
createOrder
(
bookIdsList:
jsonEncode
(
bookIdsList
)
,
totalPrice:
finalPrice
.
toString
(),
couponRecId:
useCouponModel
.
couponRecId
.
toString
(),
integral:
creditPointModel
.
deductibleIntegral
.
toString
(),
type:
payModel
.
type
.
toString
()
);
payOrderModel
=
result
;
}
}
}
\ No newline at end of file
lib/pages/book_pay/index.dart
浏览文件 @
0742a081
library
book_pay
;
library
book_pay
;
import
'dart:convert'
;
import
'dart:core'
;
import
'package:decimal/decimal.dart'
;
import
'package:decimal/decimal.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/apis/index.dart'
;
import
'package:flutter_book/apis/index.dart'
;
...
...
lib/pages/book_pay/view.dart
浏览文件 @
0742a081
...
@@ -104,7 +104,7 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -104,7 +104,7 @@ class _BookPayPageState extends State<BookPayPage> {
bottomNavigationBar:
SafeArea
(
child:
BuildPayCount
(
bottomNavigationBar:
SafeArea
(
child:
BuildPayCount
(
payTap:
(){
payTap:
(){
Console
.
log
(
'--------------支付------------------'
);
Console
.
log
(
'--------------支付------------------'
);
controller
.
createOrder
();
},
},
showTap:
(){
showTap:
(){
controller
.
show
();
controller
.
show
();
...
...
lib/pages/book_pay/widgets/pay_count.dart
浏览文件 @
0742a081
...
@@ -15,7 +15,7 @@ class BuildPayCount extends StatelessWidget {
...
@@ -15,7 +15,7 @@ class BuildPayCount extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
BookPayController
>(
return
GetBuilder
<
BookPayController
>(
init:
BookPayController
(),
init:
BookPayController
(
buy:
[]
),
builder:
(
controller
)=>
Container
(
builder:
(
controller
)=>
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
height:
55
.
w
,
height:
55
.
w
,
...
...
lib/pages/credit_points/view.dart
浏览文件 @
0742a081
...
@@ -13,7 +13,7 @@ class CreditPointsPage extends StatelessWidget {
...
@@ -13,7 +13,7 @@ class CreditPointsPage extends StatelessWidget {
return
false
;
return
false
;
},
},
child:
GetBuilder
<
BookPayController
>(
child:
GetBuilder
<
BookPayController
>(
init:
BookPayController
(),
init:
BookPayController
(
buy:
[]
),
builder:
(
controller
)=>
Scaffold
(
builder:
(
controller
)=>
Scaffold
(
extendBodyBehindAppBar:
true
,
extendBodyBehindAppBar:
true
,
appBar:
AppBar
(
appBar:
AppBar
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论