|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
|
|
|
|
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
import 'package:fluwx/fluwx.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/activity_details.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/address.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/down_order.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/launch_join_act.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/min_order_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/placeOrderFirst.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/store_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/wx_pay.dart';
|
|
|
|
import 'package:huixiang/retrofit/min_api.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_model.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/activity_coupon_remarks.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/distribution.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/pay_method.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/settlement_activity.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/settlement_coupon.dart';
|
|
|
|
import 'package:huixiang/settlement/settlement_view/settlement_order_commodity.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/utils/min.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
import '../retrofit/data/shoppingCart.dart';
|
|
|
|
import '../view_widget/settlement_tips_dialog.dart';
|
|
|
|
|
|
|
|
class Settlement extends StatefulWidget {
|
|
|
|
final arguments;
|
|
|
|
|
|
|
|
Settlement({this.arguments});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _Settlement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Settlement extends State<Settlement> {
|
|
|
|
MinApiService minService;
|
|
|
|
Function(int type) callback;
|
|
|
|
StoreInfo storeInfo;
|
|
|
|
SettleOrderInfo settleOrderInfo;
|
|
|
|
MinOrderInfo minOrderInfo;
|
|
|
|
int selectedBtn = 0;
|
|
|
|
String remakers = "";
|
|
|
|
String parentCode = "";
|
|
|
|
String parentId = "";
|
|
|
|
int payChannel = 1;
|
|
|
|
int tableId = 0;
|
|
|
|
int numberOfPeople = 0;
|
|
|
|
String pageType;
|
|
|
|
Address address;
|
|
|
|
CouponListBean couponListBean;
|
|
|
|
PromotionInfoListBean promotion;
|
|
|
|
String mobile;
|
|
|
|
bool placeOrder = false;
|
|
|
|
String actProductId;
|
|
|
|
String actProductSkuId;
|
|
|
|
ActivityDetails activityDetails;
|
|
|
|
BargainType bargainType = BargainType.BargainZBug;
|
|
|
|
LaunchJoinAct launchJoinAct;
|
|
|
|
String skuPrice1;
|
|
|
|
JoinActivity joinA = JoinActivity.GoJoin;
|
|
|
|
String bargainOrderId;
|
|
|
|
String productSkuId;
|
|
|
|
int count1 = 0;
|
|
|
|
String productId;
|
|
|
|
bool orderButton = false;
|
|
|
|
bool useVipPriceSelect = true;
|
|
|
|
bool showVipTips = false;
|
|
|
|
bool useBenefitSelect = true;
|
|
|
|
bool isRaiseChannel = false;
|
|
|
|
ShoppingCart shopCarGoods;
|
|
|
|
String vipLevelName;
|
|
|
|
bool isVips = false;
|
|
|
|
SubscribeParam subscribeParam;
|
|
|
|
String reservationTime;
|
|
|
|
String subscribeStoresName;
|
|
|
|
String subTime;
|
|
|
|
int storesIndex = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
tableId = widget.arguments["tableId"] ?? 0;
|
|
|
|
parentCode = widget.arguments["parentCode"] ?? "";
|
|
|
|
parentId = widget.arguments["parentId"] ?? "";
|
|
|
|
storeInfo = widget.arguments["storeInfo"];
|
|
|
|
numberOfPeople = widget.arguments["numberOfPeople"] ?? 0;
|
|
|
|
promotions = widget.arguments["pName"] ?? "";
|
|
|
|
coupons = widget.arguments["cName"] ?? "";
|
|
|
|
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"];
|
|
|
|
bargainOrderId = widget.arguments["bargainOrderId"];
|
|
|
|
productSkuId = widget.arguments["productSkuId"];
|
|
|
|
count1 = widget.arguments["buyNum"];
|
|
|
|
productId = widget.arguments["productId"];
|
|
|
|
shopCarGoods = widget.arguments["shoppingCart"];
|
|
|
|
vipLevelName = widget.arguments["vipLevelName"];
|
|
|
|
isVips = widget.arguments["isVips"];
|
|
|
|
|
|
|
|
subscribeParam = widget?.arguments["subscribeParam"] ?? null;
|
|
|
|
if (tableId == 0) {
|
|
|
|
placeOrder = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) {
|
|
|
|
String minToken = value.getString("minToken");
|
|
|
|
String tenant = value.getString("tenant");
|
|
|
|
String storeId = value.getString("storeId");
|
|
|
|
minService = MinApiService(Dio(),
|
|
|
|
context: context,
|
|
|
|
token: minToken,
|
|
|
|
tenant: tenant,
|
|
|
|
storeId: storeId,
|
|
|
|
showLoading: false);
|
|
|
|
queryMemberInfo();
|
|
|
|
if (promotions != null && promotions != "" && tableId <= 0) {
|
|
|
|
queryOrderInfo(
|
|
|
|
address != null ? address.id : null,
|
|
|
|
selectedBtn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
widget.arguments["pid"] ?? (productId ?? 0),
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
} else if (coupons != null && coupons != "" && tableId <= 0) {
|
|
|
|
queryOrderInfo(
|
|
|
|
address != null ? address.id : null,
|
|
|
|
selectedBtn,
|
|
|
|
widget.arguments["cid"],
|
|
|
|
0,
|
|
|
|
productId ?? 0,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
} else
|
|
|
|
queryOrderInfo(
|
|
|
|
null,
|
|
|
|
selectedBtn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
productId ?? 0,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
(useVipPriceSelect == true && isVips) ? false:useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
});
|
|
|
|
|
|
|
|
weChatResponseEventHandler.listen((event) async {
|
|
|
|
print("payCallback: ${event.errCode}");
|
|
|
|
toOrderDetails(placeOrderFirst.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///订单结算信息
|
|
|
|
queryOrderInfo(
|
|
|
|
addressId,
|
|
|
|
isTake,
|
|
|
|
memberCouponId,
|
|
|
|
orderId,
|
|
|
|
promotionId,
|
|
|
|
productSkuId,
|
|
|
|
actProductId,
|
|
|
|
actProductSkuId,
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
buyNum,
|
|
|
|
payChannel,
|
|
|
|
tableId) async {
|
|
|
|
try {
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai);
|
|
|
|
|
|
|
|
BaseData<SettleOrderInfo> baseData = await minService.getOrderInfo({
|
|
|
|
"addressId": addressId,
|
|
|
|
"isTake": isTake,
|
|
|
|
"memberCouponId": memberCouponId,
|
|
|
|
"orderId": orderId,
|
|
|
|
"promotionId": promotionId,
|
|
|
|
"productSkuId": productSkuId,
|
|
|
|
"actProductId": actProductId,
|
|
|
|
"actProductSkuId": actProductSkuId,
|
|
|
|
"useVipPrice":useVipPriceSelect,
|
|
|
|
"useBenefit": useBenefitSelect,
|
|
|
|
"buyNum": buyNum,
|
|
|
|
"payChannel":payChannel,
|
|
|
|
"tableId": tableId
|
|
|
|
}).catchError((error) {});
|
|
|
|
this.promotion = null;
|
|
|
|
promotions = "";
|
|
|
|
this.couponListBean = null;
|
|
|
|
coupons = "";
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
settleOrderInfo = baseData.data;
|
|
|
|
if ((settleOrderInfo?.promotionId ?? "") != "") {
|
|
|
|
settleOrderInfo.promotionInfoList.forEach((element) {
|
|
|
|
if (element.id == settleOrderInfo.promotionId) {
|
|
|
|
this.promotion = element;
|
|
|
|
promotions = promotion?.name ?? "";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if ((settleOrderInfo?.memberCouponId ?? "") != "") {
|
|
|
|
settleOrderInfo.couponList.forEach((element) {
|
|
|
|
if (element.id == settleOrderInfo.memberCouponId) {
|
|
|
|
this.couponListBean = element;
|
|
|
|
coupons = couponListBean?.promotionName ?? "";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (settleOrderInfo.orderProductList == null ||
|
|
|
|
settleOrderInfo.orderProductList.length == 0) {
|
|
|
|
placeOrder = true;
|
|
|
|
queryOrderDetails(
|
|
|
|
pageType != null ? widget.arguments["orderId"] : parentId);
|
|
|
|
}
|
|
|
|
if(!isRaiseChannel && ((tableId > 0 ? (minOrderInfo?.isRaise ??false): settleOrderInfo.isRaise))){
|
|
|
|
isRaiseChannel = true;
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
couponListBean?.id,
|
|
|
|
0,
|
|
|
|
promotion?.id ?? productId,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
(tableId > 0 ? minOrderInfo.isRaise : settleOrderInfo.isRaise) ? 7 :payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData?.msg ?? "", alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}finally{
|
|
|
|
setState(() {});
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///会员信息
|
|
|
|
queryMemberInfo() async {
|
|
|
|
BaseData baseData = await minService.memberInfo().catchError((error) {
|
|
|
|
debugPrint(error);
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
SharedPreferences.getInstance().then(
|
|
|
|
(value) => {
|
|
|
|
value.setString('minMember', jsonEncode(baseData.data)),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///查看订单详情
|
|
|
|
queryOrderDetails(id) async {
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai);
|
|
|
|
BaseData<MinOrderInfo> baseData = await minService.getOrderDetails({
|
|
|
|
"id": pageType != null ? widget.arguments["orderId"] : id ?? parentId,
|
|
|
|
}).catchError((error) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
setState(() {
|
|
|
|
minOrderInfo = baseData.data;
|
|
|
|
coupons = minOrderInfo?.couponName ?? "";
|
|
|
|
});
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center);
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///取消优惠券
|
|
|
|
queryCancelMemberCoupon(orderId) async {
|
|
|
|
BaseData baseData =
|
|
|
|
await minService.cancelMemberCoupon(orderId).catchError((error) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
// SmartDialog.showToast(baseData.data, alignment: Alignment.center);
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///使用该优惠券
|
|
|
|
queryUseMemberCoupon(memberCouponId) async {
|
|
|
|
BaseData baseData = await minService.useMemberCoupon({
|
|
|
|
"memberCouponId": memberCouponId,
|
|
|
|
"orderId": parentId,
|
|
|
|
"phone": minOrderInfo.orderInfoVo.memberVO.phone
|
|
|
|
}).catchError((error) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
queryAddress(int selectedBtn) async {
|
|
|
|
setState(() {
|
|
|
|
this.selectedBtn = selectedBtn;
|
|
|
|
});
|
|
|
|
if (address != null) {
|
|
|
|
queryOrderInfo(
|
|
|
|
address.id,
|
|
|
|
selectedBtn,
|
|
|
|
null,
|
|
|
|
0,
|
|
|
|
productId ?? null,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
BaseData<List<Address>> baseDate =
|
|
|
|
await minService.queryAddress().catchError((error) {});
|
|
|
|
|
|
|
|
BMFCoordinate bmfCoordinate = BMFCoordinate(
|
|
|
|
double.tryParse(storeInfo.latitude),
|
|
|
|
double.tryParse(storeInfo.longitude),
|
|
|
|
);
|
|
|
|
if (baseDate != null && baseDate.isSuccess) {
|
|
|
|
setState(() {
|
|
|
|
address = baseDate.data[0];
|
|
|
|
});
|
|
|
|
for (int i = 1; i < baseDate.data.length; i++) {
|
|
|
|
Address address1 = baseDate.data[i];
|
|
|
|
|
|
|
|
BMFCoordinate coordinate = await BMFCalculateUtils.coordConvert(
|
|
|
|
coordinate: BMFCoordinate(
|
|
|
|
double.tryParse(address.longitude),
|
|
|
|
double.tryParse(address.latitude),
|
|
|
|
),
|
|
|
|
fromType: BMF_COORD_TYPE.COMMON,
|
|
|
|
toType: BMF_COORD_TYPE.BD09LL);
|
|
|
|
BMFCoordinate coordinate1 = await BMFCalculateUtils.coordConvert(
|
|
|
|
coordinate: BMFCoordinate(
|
|
|
|
double.tryParse(address1.longitude),
|
|
|
|
double.tryParse(address1.latitude),
|
|
|
|
),
|
|
|
|
fromType: BMF_COORD_TYPE.COMMON,
|
|
|
|
toType: BMF_COORD_TYPE.BD09LL);
|
|
|
|
|
|
|
|
double mi = await BMFCalculateUtils.getLocationDistance(
|
|
|
|
bmfCoordinate, coordinate);
|
|
|
|
double mi1 = await BMFCalculateUtils.getLocationDistance(
|
|
|
|
bmfCoordinate, coordinate1);
|
|
|
|
if (mi1 < mi) {
|
|
|
|
address = address1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await queryOrderInfo(
|
|
|
|
address.id,
|
|
|
|
selectedBtn,
|
|
|
|
null,
|
|
|
|
0,
|
|
|
|
productId ?? null,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///选择收货地址
|
|
|
|
selectedAddress(String addId) async {
|
|
|
|
BaseData<List<Address>> baseDate =
|
|
|
|
await minService.queryAddress().catchError((error) {});
|
|
|
|
|
|
|
|
if (baseDate != null && baseDate.isSuccess) {
|
|
|
|
setState(() {
|
|
|
|
baseDate.data.forEach((element) {
|
|
|
|
if (element.id == addId) address = element;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
queryOrderInfo(
|
|
|
|
address.id,
|
|
|
|
selectedBtn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
productId ?? 0,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlaceOrderFirst placeOrderFirst;
|
|
|
|
DownOrder downOrder;
|
|
|
|
|
|
|
|
///发起活动
|
|
|
|
queryLaunchAct() async {
|
|
|
|
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 == BargainType.BargainBug ||
|
|
|
|
bargainType == BargainType.CollageBug)
|
|
|
|
? false
|
|
|
|
: true,
|
|
|
|
"getType": selectedBtn,
|
|
|
|
"productId": activityDetails.actProduct.productId,
|
|
|
|
"skuId": actProductSkuId ?? "",
|
|
|
|
"skuPrice": settleOrderInfo.price,
|
|
|
|
"templateType": pageType,
|
|
|
|
}).catchError((error) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
setState(() {
|
|
|
|
launchJoinAct = baseData.data;
|
|
|
|
if (bargainType == BargainType.BargainBug) {
|
|
|
|
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 == BargainType.BargainBug ||
|
|
|
|
bargainType == BargainType.CollageBug)
|
|
|
|
? 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++) {
|
|
|
|
// settleOrderInfo.orderProductList.forEach((element1) {
|
|
|
|
// if (settleOrderInfo.orderProductList[i].productId ==
|
|
|
|
// element1.productId) {
|
|
|
|
// settleOrderInfo.orderProductList[i].skuId = element1.skuId;
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
placeOrderFirst = PlaceOrderFirst();
|
|
|
|
placeOrderFirst.cartNum = settleOrderInfo.orderNum;
|
|
|
|
placeOrderFirst.cartSum = settleOrderInfo.price;
|
|
|
|
placeOrderFirst.addressId = address == null ? null : address.id;
|
|
|
|
placeOrderFirst.isSubscribe =
|
|
|
|
((subscribeParam?.isEnableSubscribe ?? false) == true)
|
|
|
|
? true
|
|
|
|
: false; //是否预约
|
|
|
|
placeOrderFirst.isTakeOut = selectedBtn;
|
|
|
|
placeOrderFirst.notes = remakers +
|
|
|
|
(reservationTime ?? "") +
|
|
|
|
((subscribeParam?.isEnableSubscribe ?? false) == true
|
|
|
|
? "预约门店:${((subscribeParam?.stores?.length ?? 0) == 1 ? (subscribeParam.stores[0]) : (subscribeStoresName ?? ""))}"
|
|
|
|
: "");
|
|
|
|
placeOrderFirst.numberOfPeople = "$numberOfPeople";
|
|
|
|
placeOrderFirst.orderSource = 2;
|
|
|
|
placeOrderFirst.orderType = "0";
|
|
|
|
placeOrderFirst.orderTypeId = 0;
|
|
|
|
placeOrderFirst.parentCode = parentCode; // 火锅加菜
|
|
|
|
placeOrderFirst.parentId = parentId; // 火锅加菜
|
|
|
|
placeOrderFirst.payChannel = ((placeOrderFirst.cartSum == "0.00") ? payChannel = 0 : (((tableId > 0 ? (minOrderInfo?.isRaise ?? false) : (settleOrderInfo?.isRaise ?? false))) ? 7:payChannel));
|
|
|
|
placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean();
|
|
|
|
placeOrderFirst.promotionInfoDTO.promotionId =
|
|
|
|
(promotion != null && tableId <= 0) ? promotion.id : "";
|
|
|
|
// : widget.arguments["pid"] ?? "";
|
|
|
|
placeOrderFirst.promotionInfoDTO.couponId =
|
|
|
|
(couponListBean != null && tableId <= 0) ? couponListBean.id : "";
|
|
|
|
// : widget.arguments["cid"] ?? "";
|
|
|
|
placeOrderFirst.promotionInfoDTO.useVipPrice = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && (settleOrderInfo.usePlateMoney == false))) ) ? false : useVipPriceSelect;
|
|
|
|
placeOrderFirst.promotionInfoDTO.useBenefit = (settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false : useBenefitSelect;
|
|
|
|
placeOrderFirst.recMobile =
|
|
|
|
(mobile == null || mobile == "") ? mobile : storeInfo.headMobile;
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList = settleOrderInfo.orderProductList;
|
|
|
|
placeOrderFirst.skuItemDTOList = [];
|
|
|
|
placeOrderFirst.source = 1;
|
|
|
|
placeOrderFirst.storeId = storeInfo.id;
|
|
|
|
placeOrderFirst.subcribeTime = subTime ?? ""; //预约时间
|
|
|
|
placeOrderFirst.tableId = "$tableId";
|
|
|
|
for (int i = 0; i < shopCarGoods.shoppingCartSkuItemList.length; i++) {
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList[i].setMealDataList =
|
|
|
|
shopCarGoods.shoppingCartSkuItemList[i].setMealDataList;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tableId == 0) {
|
|
|
|
///正常的商店下单
|
|
|
|
BaseData<dynamic> baseData = await minService
|
|
|
|
.placeOrderFirst(placeOrderFirst.toJson())
|
|
|
|
.catchError((error) {
|
|
|
|
print("error: $error");
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai);
|
|
|
|
placeOrder = true;
|
|
|
|
this.downOrder = DownOrder.fromJson(baseData.data);
|
|
|
|
querySettlement();
|
|
|
|
} else {
|
|
|
|
// orderButton = false;
|
|
|
|
SmartDialog.showToast(baseData?.msg, alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
///火锅店下单, 等待结算
|
|
|
|
BaseData<dynamic> baseData;
|
|
|
|
if (placeOrder) {
|
|
|
|
// 结算
|
|
|
|
querySettlement();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (parentId == "") {
|
|
|
|
// 下单
|
|
|
|
baseData = await minService
|
|
|
|
.placeOrderFirst(placeOrderFirst.toJson())
|
|
|
|
.catchError((error) {
|
|
|
|
print("error: $error");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
//加菜
|
|
|
|
baseData = await minService
|
|
|
|
.addOrder(placeOrderFirst.toJson())
|
|
|
|
.catchError((error) {
|
|
|
|
print("error: $error");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// orderButton = false;
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
placeOrder = true;
|
|
|
|
this.downOrder = DownOrder.fromJson(baseData.data);
|
|
|
|
parentId = this.downOrder.id ?? this.downOrder.parentId;
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
setState(() {});
|
|
|
|
} else {
|
|
|
|
// orderButton = false;
|
|
|
|
SmartDialog.showToast(baseData?.msg, alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///结算
|
|
|
|
querySettlement() async {
|
|
|
|
placeOrderFirst.id = ((parentId != "") ? parentId : downOrder.id);
|
|
|
|
placeOrderFirst.orderProductVOList = ((downOrder == null)
|
|
|
|
? minOrderInfo.orderProductVOList
|
|
|
|
: downOrder.orderProductVOList);
|
|
|
|
|
|
|
|
if (placeOrderFirst.payChannel == 1) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (!(await Min.isInitialize())) {
|
|
|
|
// 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调,
|
|
|
|
// 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针,
|
|
|
|
// 故而在此初始化一下
|
|
|
|
await Min.initialize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BaseData<WxPay> baseData = await minService
|
|
|
|
.settlementWx(placeOrderFirst.toJson())
|
|
|
|
.catchError((error) {
|
|
|
|
print(error);
|
|
|
|
});
|
|
|
|
// orderButton = false;
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
WxPay wxPay = baseData.data;
|
|
|
|
await registerWxApi(
|
|
|
|
appId: wxPay.appId,
|
|
|
|
doOnAndroid: true,
|
|
|
|
universalLink: "https://hx.lotus-wallet.com/app/",
|
|
|
|
);
|
|
|
|
payWithWeChat(
|
|
|
|
appId: wxPay.appId,
|
|
|
|
partnerId: wxPay.partnerId,
|
|
|
|
prepayId: wxPay.prepayId,
|
|
|
|
packageValue: wxPay.packageValue,
|
|
|
|
nonceStr: wxPay.nonceStr,
|
|
|
|
timeStamp: int.tryParse(wxPay.timeStamp),
|
|
|
|
sign: wxPay.sign,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
BaseData baseData = await minService
|
|
|
|
.settlementApi(placeOrderFirst.toJson())
|
|
|
|
.catchError((error) {
|
|
|
|
print(error);
|
|
|
|
});
|
|
|
|
// orderButton = false;
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
SmartDialog.showToast(baseData.data, alignment: Alignment.center);
|
|
|
|
toOrderDetails(placeOrderFirst.id);
|
|
|
|
} else {
|
|
|
|
SmartDialog.show(
|
|
|
|
clickBgDismissTemp: false,
|
|
|
|
widget: SettlementTips(
|
|
|
|
() {
|
|
|
|
toOrderDetails(placeOrderFirst.id);
|
|
|
|
},
|
|
|
|
text: "${baseData?.msg}",
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///活动结算
|
|
|
|
activityPay() async {
|
|
|
|
if (payChannel == 1) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (!(await Min.isInitialize())) {
|
|
|
|
// 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调,
|
|
|
|
// 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针,
|
|
|
|
// 故而在此初始化一下
|
|
|
|
await Min.initialize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BaseData<WxPay> baseData = await minService.actPay({
|
|
|
|
"orderId":
|
|
|
|
bargainOrderId != null ? bargainOrderId : launchJoinAct.orderId,
|
|
|
|
"payChannel": placeOrderFirst.payChannel
|
|
|
|
}).catchError((error) {
|
|
|
|
print(error);
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
WxPay wxPay = baseData.data;
|
|
|
|
await registerWxApi(
|
|
|
|
appId: wxPay.appId,
|
|
|
|
doOnAndroid: true,
|
|
|
|
universalLink: "https://hx.lotus-wallet.com/app/",
|
|
|
|
);
|
|
|
|
payWithWeChat(
|
|
|
|
appId: wxPay.appId,
|
|
|
|
partnerId: wxPay.partnerId,
|
|
|
|
prepayId: wxPay.prepayId,
|
|
|
|
packageValue: wxPay.packageValue,
|
|
|
|
nonceStr: wxPay.nonceStr,
|
|
|
|
timeStamp: int.tryParse(wxPay.timeStamp),
|
|
|
|
sign: wxPay.sign,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
BaseData baseData = await minService.actPay({
|
|
|
|
"orderId":
|
|
|
|
bargainOrderId != null ? bargainOrderId : launchJoinAct.orderId,
|
|
|
|
"payChannel": payChannel
|
|
|
|
}).catchError((error) {
|
|
|
|
print(error);
|
|
|
|
});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
toOrderDetails(
|
|
|
|
bargainOrderId != null ? bargainOrderId : launchJoinAct.orderId);
|
|
|
|
} else {
|
|
|
|
SmartDialog.show(
|
|
|
|
widget: SettlementTips(
|
|
|
|
() {
|
|
|
|
toOrderDetails(bargainOrderId != null
|
|
|
|
? bargainOrderId
|
|
|
|
: launchJoinAct.orderId);
|
|
|
|
},
|
|
|
|
text: "${baseData.msg}",
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toOrderDetails(String orderId) {
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
Navigator.of(context).pushReplacementNamed(
|
|
|
|
'/router/order_details',
|
|
|
|
arguments: {
|
|
|
|
"id": orderId,
|
|
|
|
"jumpState": 1,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
///去砍价详情页面
|
|
|
|
toBargain() async {
|
|
|
|
await Navigator.of(context)
|
|
|
|
.pushReplacementNamed('/router/bargain_details', arguments: {
|
|
|
|
"actRecordId": launchJoinAct.actRecordId,
|
|
|
|
// "limitNumber": limitNumber,
|
|
|
|
"storeInfo": storeInfo,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
color: Colors.white,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: 175.h,
|
|
|
|
// color: Color(0xFF3A405A),
|
|
|
|
// width: MediaQuery.of(context).size.width,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
image: AssetImage("assets/image/settlement_bg.webp"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
width: double.infinity,
|
|
|
|
height: 375.h,
|
|
|
|
),
|
|
|
|
Scaffold(
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
appBar: MyAppBar(
|
|
|
|
background: Colors.transparent,
|
|
|
|
leadingColor: Colors.white,
|
|
|
|
title: S.of(context).dingdanjiesuan,
|
|
|
|
titleColor: Colors.white,
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
titleSize: 18.sp,
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
DistributionMode((addressId, isTake,
|
|
|
|
memberCouponId, orderId, promotionId) {
|
|
|
|
setState(() {
|
|
|
|
this.selectedBtn = 0;
|
|
|
|
});
|
|
|
|
queryOrderInfo(
|
|
|
|
addressId,
|
|
|
|
isTake,
|
|
|
|
memberCouponId,
|
|
|
|
orderId,
|
|
|
|
promotionId ?? (productId ?? 0),
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId ?? 0);
|
|
|
|
},
|
|
|
|
queryAddress,
|
|
|
|
storeInfo,
|
|
|
|
address,
|
|
|
|
selectedAddress,
|
|
|
|
pageType,
|
|
|
|
widget.arguments["distance"]),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
|
|
|
|
/// 预留的手机号, 可修改
|
|
|
|
// EditPhoneWidget(
|
|
|
|
// storeInfo,
|
|
|
|
// mobileChange,
|
|
|
|
// ),
|
|
|
|
|
|
|
|
///订单商品
|
|
|
|
if (settleOrderInfo != null ||
|
|
|
|
minOrderInfo != null)
|
|
|
|
SettlementOrderCommodity(
|
|
|
|
selectedBtn,
|
|
|
|
settleOrderInfo,
|
|
|
|
minOrderInfo,
|
|
|
|
tableId,
|
|
|
|
pageType,
|
|
|
|
(coupons != "" || promotions != "")
|
|
|
|
? false
|
|
|
|
: useVipPriceSelect,
|
|
|
|
this.showVipTips),
|
|
|
|
|
|
|
|
///优惠券/备注/会员优惠金额
|
|
|
|
if (settleOrderInfo != null ||
|
|
|
|
minOrderInfo != null)
|
|
|
|
ActivityCouponRemarks(
|
|
|
|
couponCart,
|
|
|
|
activityCart,
|
|
|
|
settleOrderInfo,
|
|
|
|
minOrderInfo,
|
|
|
|
coupons,
|
|
|
|
promotions,
|
|
|
|
couponCount(),
|
|
|
|
placeOrder,
|
|
|
|
remakers,
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
'/router/edit_remarks_page',
|
|
|
|
arguments: {
|
|
|
|
"remake": remakers
|
|
|
|
}).then((value) => {
|
|
|
|
setState(() {
|
|
|
|
if (value != null) remakers = value;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
},
|
|
|
|
tableId,
|
|
|
|
vipPriceSelect,
|
|
|
|
() {
|
|
|
|
setState(() {
|
|
|
|
this.showVipTips = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
vipBenefitSelect,
|
|
|
|
payChannel,
|
|
|
|
vipLevelName,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
subscribeParam,
|
|
|
|
showDateSelector,
|
|
|
|
reservationTime,
|
|
|
|
showAlertDialog,
|
|
|
|
subscribeStoresName,
|
|
|
|
),
|
|
|
|
|
|
|
|
if (settleOrderInfo != null && placeOrder && joinA != JoinActivity.BargainBug)
|
|
|
|
///支付方式
|
|
|
|
PayMethod(payChannelCheck,coupons,promotions,useVipPriceSelect,settleOrderInfo,useBenefitSelect,tableId,minOrderInfo),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 58.h,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color(0x08213303).withAlpha(12),
|
|
|
|
offset: Offset(0, -1),
|
|
|
|
blurRadius: 8,
|
|
|
|
spreadRadius: 0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Spacer(),
|
|
|
|
Text(
|
|
|
|
S.of(context).heji,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
(minOrderInfo != null
|
|
|
|
? "¥${minOrderInfo.finalPayPrice}"
|
|
|
|
: "¥${settleOrderInfo == null ? "0" : settleOrderInfo.price}"),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20.sp,
|
|
|
|
fontWeight: MyFontWeight.medium,
|
|
|
|
fontFamily: 'JDZhengHT',
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 28,
|
|
|
|
),
|
|
|
|
RoundButton(
|
|
|
|
width: 88.w,
|
|
|
|
height: 32.h,
|
|
|
|
radius: 16,
|
|
|
|
text: joinA == JoinActivity.BargainBug
|
|
|
|
? "发起砍价"
|
|
|
|
: (placeOrder ? "提交订单" : "下单"),
|
|
|
|
textColor: Colors.white,
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
backgroup: Color(0xFF32A060),
|
|
|
|
fontSize: 15.sp,
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: 5.h,
|
|
|
|
),
|
|
|
|
callback: () {
|
|
|
|
// if (orderButton) {
|
|
|
|
// SmartDialog.showToast("订单正在提交中...",
|
|
|
|
// alignment: Alignment.center);
|
|
|
|
// return;
|
|
|
|
// } else
|
|
|
|
// orderButton = true;
|
|
|
|
if (subscribeParam != null && ((subscribeParam.isEnableSubscribe ?? false) ==
|
|
|
|
true) &&
|
|
|
|
(reservationTime == null ||
|
|
|
|
((subscribeParam.stores.length ==1 ? subscribeParam.stores[0] : subscribeStoresName) == null))) {
|
|
|
|
SmartDialog.showToast(
|
|
|
|
(reservationTime == null)
|
|
|
|
? "请选择预约时间"
|
|
|
|
: "请选择预约门店",
|
|
|
|
alignment: Alignment.center);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pageType != null
|
|
|
|
? bargainOrderId != null
|
|
|
|
? activityPay()
|
|
|
|
: joinA == JoinActivity.GoJoin
|
|
|
|
? queryJoinAct()
|
|
|
|
: queryLaunchAct()
|
|
|
|
: queryPlaceOrderFirst();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 17,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
payChannelCheck(int payChannel) {
|
|
|
|
this.payChannel = payChannel;
|
|
|
|
if (tableId > 0) {
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
} else {
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
(settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? "" :couponListBean?.id,
|
|
|
|
0,
|
|
|
|
(settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? "" :promotion?.id ?? productId,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
(settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false))) ? false :useVipPriceSelect,
|
|
|
|
(settleOrderInfo.isRaise || payChannel == 5 || ((payChannel == 4 && settleOrderInfo.usePlateMoney == false)) || useVipPriceSelect == true) ? false :useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vipPriceSelect(bool useVipPriceSelect) {
|
|
|
|
this.useVipPriceSelect = useVipPriceSelect;
|
|
|
|
if (tableId > 0) {
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
} else {
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
productId ?? 0,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useVipPriceSelect == true ? false :useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);}
|
|
|
|
}
|
|
|
|
|
|
|
|
vipBenefitSelect(bool useBenefitSelect) {
|
|
|
|
this.useBenefitSelect = useBenefitSelect;
|
|
|
|
if (tableId > 0) {
|
|
|
|
queryOrderDetails(parentId);
|
|
|
|
} else {
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
null,
|
|
|
|
0,
|
|
|
|
productId ?? null,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mobileChange(String mobile) {
|
|
|
|
this.mobile = mobile;
|
|
|
|
}
|
|
|
|
|
|
|
|
int couponCount() {
|
|
|
|
if (settleOrderInfo == null ||
|
|
|
|
settleOrderInfo.couponList == null ||
|
|
|
|
settleOrderInfo.couponList.length == 0) return 0;
|
|
|
|
int count = 0;
|
|
|
|
settleOrderInfo.couponList.forEach((element) {
|
|
|
|
if (element.tenantCode == "") {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
String coupons = "";
|
|
|
|
String promotions = "";
|
|
|
|
|
|
|
|
///优惠券弹窗
|
|
|
|
couponCart() async {
|
|
|
|
CouponListBean couponBean = await showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
builder: (context) {
|
|
|
|
return SettlementCoupon(
|
|
|
|
settleOrderInfo, minOrderInfo, tableId, storeInfo,
|
|
|
|
couponBean: couponListBean);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
// if (couponBean != null) {
|
|
|
|
// this.couponListBean = couponBean;
|
|
|
|
// coupons = couponListBean?.promotionName ?? "";
|
|
|
|
// promotions = "";
|
|
|
|
// this.promotion = null;
|
|
|
|
if (tableId > 0) {
|
|
|
|
if (couponBean == null) queryCancelMemberCoupon(parentId);
|
|
|
|
if (couponBean.id != null) queryUseMemberCoupon(couponBean.id);
|
|
|
|
} else {
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
couponBean?.id,
|
|
|
|
0,
|
|
|
|
productId ?? 0,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
///活动弹窗
|
|
|
|
activityCart() async {
|
|
|
|
// if (couponListBean != null) return;
|
|
|
|
PromotionInfoListBean pro = await showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
builder: (context) {
|
|
|
|
return SettlementActivity(settleOrderInfo, storeInfo);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
// if (pro != null) {
|
|
|
|
// this.promotion = pro;
|
|
|
|
// promotions = promotion?.name ?? "";
|
|
|
|
// coupons = "";
|
|
|
|
// this.couponListBean = null;
|
|
|
|
queryOrderInfo(
|
|
|
|
address?.id,
|
|
|
|
selectedBtn,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(pro.id ?? "") ?? productId,
|
|
|
|
productSkuId ?? "",
|
|
|
|
actProductId ?? "",
|
|
|
|
actProductSkuId ?? "",
|
|
|
|
useVipPriceSelect,
|
|
|
|
useBenefitSelect,
|
|
|
|
count1,
|
|
|
|
payChannel,
|
|
|
|
tableId);
|
|
|
|
}
|
|
|
|
|
|
|
|
///立即预约时间选择
|
|
|
|
showDateSelector() {
|
|
|
|
var minTime = DateTime.now().isAfter(
|
|
|
|
DateTime.tryParse(subscribeParam?.subscribeStartTime ?? ""))
|
|
|
|
? DateTime.now()
|
|
|
|
: DateTime.tryParse(subscribeParam?.subscribeStartTime ?? "");
|
|
|
|
DatePicker.showDateTimePicker(context,
|
|
|
|
showTitleActions: true,
|
|
|
|
minTime: minTime,
|
|
|
|
maxTime: DateTime.tryParse(subscribeParam?.subscribeEndTime ?? ""),
|
|
|
|
theme: DatePickerTheme(
|
|
|
|
headerColor: Colors.white,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
itemStyle: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: MyFontWeight.bold,
|
|
|
|
fontSize: 18),
|
|
|
|
doneStyle: TextStyle(color: Color(0xFF32A060), fontSize: 16.sp)),
|
|
|
|
onChanged: (date) {
|
|
|
|
print('change $date in time zone ' +
|
|
|
|
date.timeZoneOffset.inHours.toString());
|
|
|
|
}, onConfirm: (date) {
|
|
|
|
reservationTime = date.toString().substring(0, 16);
|
|
|
|
subTime = date.toUtc().toIso8601String().toString();
|
|
|
|
setState(() {});
|
|
|
|
}, currentTime: minTime, locale: LocaleType.zh);
|
|
|
|
}
|
|
|
|
|
|
|
|
///预约店铺
|
|
|
|
showAlertDialog() {
|
|
|
|
showModalBottomSheet(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return StatefulBuilder(builder: (
|
|
|
|
context,
|
|
|
|
state,
|
|
|
|
) {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: 280.h,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 16.h),
|
|
|
|
decoration: new BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(8),
|
|
|
|
topRight: Radius.circular(8),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// Container(
|
|
|
|
// padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 14.w),
|
|
|
|
// child: Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
// children: [
|
|
|
|
// GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
// },
|
|
|
|
// child: Text(
|
|
|
|
// S.of(context).quxiao,
|
|
|
|
// style:
|
|
|
|
// TextStyle(fontSize: 18.sp, color: Colors.black),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// setState(() {
|
|
|
|
// subscribeStoresName =
|
|
|
|
// subscribeParam.stores[storesIndex];
|
|
|
|
// });
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
// },
|
|
|
|
// child: Text(
|
|
|
|
// S.of(context).queding,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 18.sp, color: Color(0xFF32A060)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
margin: EdgeInsets.symmetric(vertical:5.h),
|
|
|
|
child: Text(
|
|
|
|
"请选择预约门店",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: MyFontWeight.bold,
|
|
|
|
fontSize: 15.sp,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Icon(
|
|
|
|
Icons.clear,
|
|
|
|
color: Colors.black,
|
|
|
|
size: 18,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// SizedBox(width:4.w),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: subscribeParam.stores.length ?? 0,
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
state(() {
|
|
|
|
storesIndex = position;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: storesNameItem(position),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: (){
|
|
|
|
setState(() {
|
|
|
|
subscribeStoresName = subscribeParam.stores[storesIndex];
|
|
|
|
});
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: 40.h,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
color:Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
margin: EdgeInsets.only(bottom: 10.h,),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).queding,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: MyFontWeight.bold,
|
|
|
|
fontSize: 16.sp,
|
|
|
|
color: Color(0xFFFFFFFF),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
context: context);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget storesNameItem(index) {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
margin: EdgeInsets.symmetric(vertical:8.h),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.h),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius:BorderRadius.circular(6),
|
|
|
|
border: Border.all(
|
|
|
|
color: storesIndex == index ? Color(0xFF32A060):Color(0xFFF7F7F7),
|
|
|
|
width: storesIndex == index ? 1 :0,
|
|
|
|
),
|
|
|
|
color: storesIndex == index ? Color(0xFFF0FAF4) :Color(0xFFF7F7F7),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
subscribeParam.stores[index],
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: MyFontWeight.medium,
|
|
|
|
fontSize: 16.sp,
|
|
|
|
color: storesIndex == index ? Color(0xFF32A060) : Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|