Browse Source

购买流程更改

zyh
w-R 3 years ago
parent
commit
1683361f4c
  1. 2
      lib/generated/intl/messages_en.dart
  2. 2
      lib/generated/intl/messages_zh_CN.dart
  3. 2
      lib/generated/intl/messages_zh_Hans_CN.dart
  4. 4
      lib/generated/l10n.dart
  5. 2
      lib/l10n/intl_en.arb
  6. 2
      lib/l10n/intl_zh_CN.arb
  7. 2
      lib/l10n/intl_zh_Hans_CN.arb
  8. 9
      lib/order/order_history_page.dart
  9. 2
      lib/order/order_view/order_status.dart
  10. 8
      lib/retrofit/data/activity_details.dart
  11. 119
      lib/settlement/settlement.dart
  12. 212
      lib/store/shopping/shopping_goods_details.dart

2
lib/generated/intl/messages_en.dart

@ -185,7 +185,7 @@ class MessageLookup extends MessageLookupByLibrary {
"dingdanyisongda" : MessageLookupByLibrary.simpleMessage("订单送达"),
"dingdanyituikuan" : MessageLookupByLibrary.simpleMessage("订单已退款"),
"dingdanyiwancheng" : MessageLookupByLibrary.simpleMessage("订单已完成"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingwei" : MessageLookupByLibrary.simpleMessage("定位"),
"dizhi" : MessageLookupByLibrary.simpleMessage("地址"),
"duihuan" : MessageLookupByLibrary.simpleMessage("兑换"),

2
lib/generated/intl/messages_zh_CN.dart

@ -185,7 +185,7 @@ class MessageLookup extends MessageLookupByLibrary {
"dingdanyisongda" : MessageLookupByLibrary.simpleMessage("订单送达"),
"dingdanyituikuan" : MessageLookupByLibrary.simpleMessage("订单已退款"),
"dingdanyiwancheng" : MessageLookupByLibrary.simpleMessage("订单已完成"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingwei" : MessageLookupByLibrary.simpleMessage("定位"),
"dizhi" : MessageLookupByLibrary.simpleMessage("地址"),
"duihuan" : MessageLookupByLibrary.simpleMessage("兑换"),

2
lib/generated/intl/messages_zh_Hans_CN.dart

@ -185,7 +185,7 @@ class MessageLookup extends MessageLookupByLibrary {
"dingdanyisongda" : MessageLookupByLibrary.simpleMessage("订单送达"),
"dingdanyituikuan" : MessageLookupByLibrary.simpleMessage("订单已退款"),
"dingdanyiwancheng" : MessageLookupByLibrary.simpleMessage("订单已完成"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingdanyizhifu" : MessageLookupByLibrary.simpleMessage("订单支付"),
"dingwei" : MessageLookupByLibrary.simpleMessage("定位"),
"dizhi" : MessageLookupByLibrary.simpleMessage("地址"),
"duihuan" : MessageLookupByLibrary.simpleMessage("兑换"),

4
lib/generated/l10n.dart

@ -3165,10 +3165,10 @@ class S {
);
}
/// ``
/// ``
String get dingdanyizhifu {
return Intl.message(
'订单支付',
'订单支付',
name: 'dingdanyizhifu',
desc: '',
args: [],

2
lib/l10n/intl_en.arb

@ -335,7 +335,7 @@
"dingdanyisongda": "订单送达",
"dingdanyiwancheng": "订单已完成",
"dingdandaizhifu": "订单待支付",
"dingdanyizhifu": "订单支付",
"dingdanyizhifu": "订单支付",
"shangjiayifahuo": "商家已发货",
"huopinyisongda": "货品已送达",
"zhengzaipeisong": "正在配送",

2
lib/l10n/intl_zh_CN.arb

@ -336,7 +336,7 @@
"dingdanyisongda": "订单送达",
"dingdanyiwancheng": "订单已完成",
"dingdandaizhifu": "订单待支付",
"dingdanyizhifu": "订单支付",
"dingdanyizhifu": "订单支付",
"shangjiayifahuo": "商家已发货",
"huopinyisongda": "货品已送达",
"zhengzaipeisong": "正在配送",

2
lib/l10n/intl_zh_Hans_CN.arb

@ -336,7 +336,7 @@
"dingdanyisongda": "订单送达",
"dingdanyiwancheng": "订单已完成",
"dingdandaizhifu": "订单待支付",
"dingdanyizhifu": "订单支付",
"dingdanyizhifu": "订单支付",
"shangjiayifahuo": "商家已发货",
"huopinyisongda": "货品已送达",
"zhengzaipeisong": "正在配送",

9
lib/order/order_history_page.dart

@ -193,10 +193,11 @@ class _OrderHistoryList extends State<OrderHistoryList>
if (current == 1) {
orderInfos.clear();
}
baseData.data.records.forEach((element) {
if((element.orderType == 0 || element.orderType == 1 ||element.orderType == 2 ||element.orderType == 3) && element.payStatus == 1 && element.refundStatus ==0)
orderInfos.add(element);
});
orderInfos.addAll(baseData.data.records);
// baseData.data.records.forEach((element) {
// if(element.orderType==0||(element.orderType==1 && element.payStatus==1 && element.refundStatus == 0)||(element.orderType==2 && element.payStatus==1&& element.refundStatus == 0)||(element.orderType==3 && element.payStatus==1&& element.refundStatus == 0))
// orderInfos.add(element);
// });
refreshController.refreshCompleted();
refreshController.loadComplete();
if (current * 10 > int.tryParse(baseData.data.total)) {

2
lib/order/order_view/order_status.dart

@ -68,7 +68,7 @@ class _OrderStatus extends State<OrderStatus> {
? S.of(context).ziqu
: widget.isTakeOut == 1
? S.of(context).waimai
: S.of(context).kuaidi,
: "物流",
width: 42.w * AppUtils.textScale(context),
height: 20.h * AppUtils.textScale(context),
textColor: Colors.white,

8
lib/retrofit/data/activity_details.dart

@ -3,14 +3,17 @@
class ActivityDetails {
ActivityDetails({
String endTime,
ActProduct actProduct,
List<ActRecordAndJoinlDTOList> actRecordAndJoinlDTOList,
}) {
_endTime = endTime;
_actProduct = actProduct;
_actRecordAndJoinlDTOList = actRecordAndJoinlDTOList;
}
ActivityDetails.fromJson(dynamic json) {
_endTime = json['endTime'];
_actProduct = json['actProduct'] != null
? ActProduct.fromJson(json['actProduct'])
: null;
@ -22,9 +25,12 @@ class ActivityDetails {
}
}
String _endTime;
ActProduct _actProduct;
List<ActRecordAndJoinlDTOList> _actRecordAndJoinlDTOList;
String get endTime => _endTime;
ActProduct get actProduct => _actProduct;
List<ActRecordAndJoinlDTOList> get actRecordAndJoinlDTOList =>
@ -32,6 +38,8 @@ class ActivityDetails {
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['endTime'] = _endTime;
if (_actProduct != null) {
map['actProduct'] = _actProduct.toJson();
}

119
lib/settlement/settlement.dart

@ -60,7 +60,7 @@ class _Settlement extends State<Settlement> {
int payChannel = 1;
int tableId = 0;
int numberOfPeople = 0;
String pageType = "1";
String pageType;
Address address;
CouponListBean couponListBean;
PromotionInfoListBean promotion;
@ -68,6 +68,11 @@ class _Settlement extends State<Settlement> {
bool placeOrder = false;
String actProductId;
String actProductSkuId;
ActivityDetails activityDetails;
int bargainType = 0;
LaunchJoinAct launchJoinAct;
String skuPrice1;
int joinA = 0;
@override
void initState() {
@ -82,6 +87,10 @@ class _Settlement extends State<Settlement> {
pageType = widget.arguments["pageType"];
actProductId = widget.arguments["actProductId"];
actProductSkuId = widget.arguments["actProductSkuId"];
activityDetails = widget.arguments["activityDetails"];
bargainType = widget.arguments["bargainType"];
skuPrice1 = widget.arguments["skuPrice1"];
joinA = widget.arguments["joinA"];
if (tableId == 0) {
placeOrder = true;
}
@ -277,6 +286,68 @@ class _Settlement extends State<Settlement> {
PlaceOrderFirst placeOrderFirst;
DownOrder downOrder;
///
queryLaunchAct() async {
// if (minService == null)
// minService = MinApiService(
// Dio(),
// context: context,
// token: minToken,
// tenant: tenant,
// storeId: storeId,
// showLoading: false,
// );
BaseData baseData = await minService.launchAct({
"actProductId": activityDetails.actProduct.id,
"actRecordId": 0,
"actTemplateId": activityDetails.actProduct.templateId,
"actTimeId": activityDetails.actProduct.timeId,
"addressId": address == null ? null : address.id,
"isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true,
"getType": selectedBtn,
"productId": activityDetails.actProduct.productId,
"skuId": actProductSkuId ?? "",
"skuPrice": skuPrice1,
"templateType": pageType,
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
setState(() {
launchJoinAct = baseData.data;
if (bargainType == 1) {
toBargain();
} else {
activityPay();
}
});
} else {
if ((activityDetails?.actProduct?.productStock ?? 0) == 0)
SmartDialog.showToast("活动商品售罄", alignment: Alignment.center);
}
}
///
queryJoinAct() async {
BaseData baseData = await minService.joinAct({
"actProductId": activityDetails.actProduct.id,
"actRecordId": widget.arguments["indexP"],
"actTemplateId": activityDetails.actProduct.templateId,
"actTimeId": activityDetails.actProduct.timeId,
"addressId": address == null ? null : address.id,
"isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true,
"getType": selectedBtn,
"productId": activityDetails.actProduct.productId,
"skuId": actProductSkuId ?? "",
"skuPrice": skuPrice1,
"templateType": pageType
}).catchError((error) {});
if (baseData != null && baseData.isSuccess) {
launchJoinAct = baseData.data;
activityPay();
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
///
queryPlaceOrderFirst() async {
for (int i = 0; i < settleOrderInfo.orderProductList.length; i++) {
@ -330,12 +401,13 @@ class _Settlement extends State<Settlement> {
if (baseData != null && baseData.isSuccess) {
placeOrder = true;
this.downOrder = baseData.data;
pageType != null ? activityPay() : querySettlement();
querySettlement();
} else {
baseData?.isSuccess ?? false
? SmartDialog.showToast("下单失败:订单实付金额不能为0",
alignment: Alignment.center)
: SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center);
: SmartDialog.showToast(baseData?.msg ?? "",
alignment: Alignment.center);
}
} else {
///
@ -435,13 +507,7 @@ class _Settlement extends State<Settlement> {
///
activityPay() async {
placeOrderFirst.id = widget.arguments["orderId"] != ""
? widget.arguments["orderId"]
: downOrder.id;
placeOrderFirst.orderProductVOList = downOrder == null
? minOrderInfo.orderProductVOList
: downOrder.orderProductVOList;
if (placeOrderFirst.payChannel == 1) {
if (payChannel == 1) {
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调
@ -450,11 +516,10 @@ class _Settlement extends State<Settlement> {
await Min.initialize();
}
}
BaseData<WxPay> baseData = await minService
.actPay({
"orderId": widget.arguments["orderId"],
"payChannel":placeOrderFirst.payChannel
}).catchError((error) {
BaseData<WxPay> baseData = await minService.actPay({
"orderId": launchJoinAct.orderId,
"payChannel": placeOrderFirst.payChannel
}).catchError((error) {
print(error);
});
if (baseData != null && baseData.isSuccess) {
@ -476,18 +541,18 @@ class _Settlement extends State<Settlement> {
}
} else {
BaseData baseData = await minService.actPay({
"orderId": widget.arguments["orderId"],
"payChannel":placeOrderFirst.payChannel
"orderId": launchJoinAct.orderId,
"payChannel": payChannel
}).catchError((error) {
print(error);
});
if (baseData != null && baseData.isSuccess) {
toOrderDetails(placeOrderFirst.id);
toOrderDetails(launchJoinAct.orderId);
} else {
SmartDialog.show(
widget: Tips(
() {
toOrderDetails(placeOrderFirst.id);
toOrderDetails(launchJoinAct.orderId);
},
text: "${baseData.msg}",
));
@ -505,6 +570,16 @@ class _Settlement extends State<Settlement> {
// Navigator.of(context).pop();
}
///
toBargain() async {
await Navigator.of(context)
.popAndPushNamed('/router/bargain_details', arguments: {
"actRecordId": launchJoinAct.actRecordId,
// "limitNumber": limitNumber,
"storeInfo": storeInfo,
});
}
@override
Widget build(BuildContext context) {
return Container(
@ -652,7 +727,11 @@ class _Settlement extends State<Settlement> {
vertical: 5.h,
),
callback: () {
queryPlaceOrderFirst();
pageType != null
? joinA == 0
? queryJoinAct()
: queryLaunchAct()
: queryPlaceOrderFirst();
},
),
],

212
lib/store/shopping/shopping_goods_details.dart

@ -75,9 +75,14 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
bool isDispose = false;
Timer _timer;
String testTime = "2021-12-30 10:00:00";
int tempDay = 0;
int tempHour = 0;
int tempM = 0;
int tempS = 0;
LaunchJoinAct launchJoinAct;
int bargainType = 0;
String indexP;
int joinA = 0;
@override
void dispose() {
@ -238,88 +243,85 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
element.skuStock = sku.skuStock.toInt();
}
});
});
refreshController.refreshCompleted();
} else {
refreshController.refreshFailed();
}
}
///
queryLaunchAct() async {
if (minService == null)
minService = MinApiService(
Dio(),
context: context,
token: minToken,
tenant: tenant,
storeId: storeId,
showLoading: false,
);
BaseData baseData = await minService.launchAct({
"actProductId": pageType == null
? miNiDetail.productSkuVOList[0].id
: activityDetails.actProduct.id,
"actRecordId": 0,
"actTemplateId": activityDetails.actProduct.templateId,
"actTimeId": activityDetails.actProduct.timeId,
"addressId": "",
"isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true,
"getType": 1,
"productId":
pageType == null ? productId : activityDetails.actProduct.productId,
"skuId": skuId1,
"skuPrice": skuPrice1,
"templateType": pageType
}).catchError((error) {
refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) {
setState(() {
launchJoinAct = baseData.data;
if (bargainType == 1) {
toBargain();
} else {
toOrder();
}
goodsCountdownTimer();
refreshController.refreshCompleted();
});
} else {
if((activityDetails?.actProduct?.productStock ?? 0) == 0)
SmartDialog.showToast("活动商品售罄",alignment: Alignment.center);
refreshController.refreshFailed();
}
}
///
queryJoinAct() async {
BaseData baseData = await minService.joinAct({
"actProductId": pageType == null
? miNiDetail.productSkuVOList[0].id
: activityDetails.actProduct.id,
"actRecordId": indexP,
"actTemplateId": activityDetails.actProduct.templateId,
"actTimeId": activityDetails.actProduct.timeId,
"addressId": "",
"isDirectBuy": pageType == "3" ? false : true,
"getType": 1,
"productId":
pageType == null ? productId : activityDetails.actProduct.productId,
"skuId": skuId1,
"skuPrice": skuPrice1,
"templateType": pageType,
}).catchError((error) {
refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) {
launchJoinAct = baseData.data;
toOrder();
refreshController.refreshCompleted();
} else {
SmartDialog.showToast(baseData.msg,alignment: Alignment.center);
refreshController.refreshFailed();
}
}
///
// queryLaunchAct() async {
// if (minService == null)
// minService = MinApiService(
// Dio(),
// context: context,
// token: minToken,
// tenant: tenant,
// storeId: storeId,
// showLoading: false,
// );
// BaseData baseData = await minService.launchAct({
// "actProductId": pageType == null
// ? miNiDetail.productSkuVOList[0].id
// : activityDetails.actProduct.id,
// "actRecordId": 0,
// "actTemplateId": activityDetails.actProduct.templateId,
// "actTimeId": activityDetails.actProduct.timeId,
// "addressId": "",
// "isDirectBuy": (bargainType == 1 || bargainType == 2) ? false : true,
// "getType": 3,
// "productId":
// pageType == null ? productId : activityDetails.actProduct.productId,
// "skuId": skuId1,
// "skuPrice": skuPrice1,
// "templateType": pageType
// }).catchError((error) {
// refreshController.refreshFailed();
// });
// if (baseData != null && baseData.isSuccess) {
// setState(() {
// launchJoinAct = baseData.data;
// toBargain();
// refreshController.refreshCompleted();
// });
// } else {
// if((activityDetails?.actProduct?.productStock ?? 0) == 0)
// SmartDialog.showToast("活动商品售罄",alignment: Alignment.center);
// refreshController.refreshFailed();
// }
// }
//
// ///
// queryJoinAct() async {
// BaseData baseData = await minService.joinAct({
// "actProductId": pageType == null
// ? miNiDetail.productSkuVOList[0].id
// : activityDetails.actProduct.id,
// "actRecordId": indexP,
// "actTemplateId": activityDetails.actProduct.templateId,
// "actTimeId": activityDetails.actProduct.timeId,
// "addressId": "",
// "isDirectBuy": pageType == "3" ? false : true,
// "getType": 1,
// "productId":
// pageType == null ? productId : activityDetails.actProduct.productId,
// "skuId": skuId1,
// "skuPrice": skuPrice1,
// "templateType": pageType,
// }).catchError((error) {
// refreshController.refreshFailed();
// });
// if (baseData != null && baseData.isSuccess) {
// launchJoinAct = baseData.data;
// toOrder();
// refreshController.refreshCompleted();
// } else {
// SmartDialog.showToast(baseData.msg,alignment: Alignment.center);
// refreshController.refreshFailed();
// }
// }
///
showStoreSelector(MiNiDetail miNiDetail, String id, int count) async {
@ -458,6 +460,31 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
_timer = Timer.periodic(oneSec, callback);
}
///
goodsCountdownTimer() {
if (_timer != null) return;
const oneSec = const Duration(seconds: 1);
var callback = ((timer) {
if (isDispose) return;
setState(() {
var tempDateTime =
DateTime.parse(activityDetails.endTime).difference(DateTime.now());
if (tempDateTime.inSeconds < 0) {
tempDay = 0;
tempHour = 0;
tempM = 0;
tempS = 0;
return;
}
tempDay = tempDateTime.inDays;
tempHour = tempDateTime.inHours - (tempDateTime.inDays * 24);
tempM = tempDateTime.inMinutes - (tempDateTime.inHours * 60);
tempS = tempDateTime.inSeconds - (tempDateTime.inMinutes * 60);
});
});
_timer = Timer.periodic(oneSec, callback);
}
///
toDownOrder() async {
if (count1 == 0) {
@ -507,9 +534,14 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
"skuId": skuId1,
"buyNum": count1,
"skuValue1": skuValue1,
"orderId": launchJoinAct.orderId,
// "orderId": launchJoinAct.orderId,
"actProductId": actProductId,
"actProductSkuId": skuId1,
"activityDetails":activityDetails,
"bargainType":bargainType,
"skuPrice1":skuPrice1,
"joinA":joinA,
"indexP":indexP
},
).then((value) {
_onRefresh();
@ -786,11 +818,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
children: [
GestureDetector(
onTap: () {
joinA=4;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -846,11 +879,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
GestureDetector(
onTap: () {
joinA=5;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -918,11 +952,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
GestureDetector(
onTap: () {
bargainType = 0;
joinA=3;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -983,7 +1018,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -1050,11 +1085,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
children: [
GestureDetector(
onTap: () {
joinA = 2;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -1111,11 +1147,12 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
GestureDetector(
onTap: () {
bargainType = 2;
joinA = 1;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryLaunchAct();
toOrder();
},
child: Container(
alignment: Alignment.center,
@ -1396,7 +1433,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(1)),
child: Text(
"5",
tempDay.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 10.sp,
@ -1428,7 +1465,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(1)),
child: Text(
"5",
tempHour.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 10.sp,
@ -1459,7 +1496,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(1)),
child: Text(
"5",
tempM.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 10.sp,
@ -1491,7 +1528,7 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(1)),
child: Text(
"5",
tempS.toString(),
style: TextStyle(
color: Colors.white,
fontSize: 10.sp,
@ -1944,12 +1981,13 @@ class _ShoppingGoodsDetails extends State<ShoppingGoodsDetails> {
),
GestureDetector(
onTap: () {
joinA = 0;
indexP = actRecordAndJoinlDTOList.actRecord.id;
if (count1 == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
queryJoinAct();
toOrder();
},
child: Container(
alignment: Alignment.center,

Loading…
Cancel
Save