|
|
|
@ -557,124 +557,135 @@ class _Settlement extends State<Settlement> {
|
|
|
|
|
|
|
|
|
|
///小程序下单 |
|
|
|
|
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 = |
|
|
|
|
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && |
|
|
|
|
(subscribeParam?.isEnableSubscribe ?? false) == false && |
|
|
|
|
selectedBtn != 1 && |
|
|
|
|
selectedBtn != 2) |
|
|
|
|
? diningStatus |
|
|
|
|
: 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.promotionInfoDTO.discountType = (!placeOrder) ? "AUTO" :settleOrderInfo?.discountType ?? ""; |
|
|
|
|
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 ?? 0); |
|
|
|
|
i++) { |
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList[i].setMealDataList = |
|
|
|
|
shopCarGoods.shoppingCartSkuItemList[i].setMealDataList; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai, |
|
|
|
|
maskType: EasyLoadingMaskType.black); |
|
|
|
|
// 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; |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
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,maskType: EasyLoadingMaskType.black); |
|
|
|
|
placeOrder = true; |
|
|
|
|
this.downOrder = DownOrder.fromJson(baseData.data); |
|
|
|
|
querySettlement(); |
|
|
|
|
} else { |
|
|
|
|
// orderButton = false; |
|
|
|
|
SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); |
|
|
|
|
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 = |
|
|
|
|
((storeInfo?.pickupType?.dineInTakeStatus ?? false) == true && |
|
|
|
|
(subscribeParam?.isEnableSubscribe ?? false) == false && |
|
|
|
|
selectedBtn != 1 && |
|
|
|
|
selectedBtn != 2) |
|
|
|
|
? diningStatus |
|
|
|
|
: 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.promotionInfoDTO.discountType = |
|
|
|
|
(!placeOrder) ? "AUTO" : settleOrderInfo?.discountType ?? ""; |
|
|
|
|
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 ?? 0); |
|
|
|
|
i++) { |
|
|
|
|
placeOrderFirst.shoppingCartSkuItemList[i].setMealDataList = |
|
|
|
|
shopCarGoods.shoppingCartSkuItemList[i].setMealDataList; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
///火锅店下单, 等待结算 |
|
|
|
|
BaseData<dynamic> baseData; |
|
|
|
|
if (placeOrder) { |
|
|
|
|
// 结算 |
|
|
|
|
querySettlement(); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
if (parentId == "") { |
|
|
|
|
// 下单 |
|
|
|
|
baseData = await minService |
|
|
|
|
.placeOrderFirst(placeOrderFirst.toJson()) |
|
|
|
|
.catchError((error) { |
|
|
|
|
print("error: $error"); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
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, |
|
|
|
|
// maskType: EasyLoadingMaskType.black); |
|
|
|
|
placeOrder = true; |
|
|
|
|
this.downOrder = DownOrder.fromJson(baseData.data); |
|
|
|
|
await querySettlement(); |
|
|
|
|
} else { |
|
|
|
|
//加菜 |
|
|
|
|
baseData = await minService |
|
|
|
|
.addOrder(placeOrderFirst.toJson()) |
|
|
|
|
.catchError((error) { |
|
|
|
|
print("error: $error"); |
|
|
|
|
}); |
|
|
|
|
// orderButton = false; |
|
|
|
|
SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 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 { |
|
|
|
|
///火锅店下单, 等待结算 |
|
|
|
|
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; |
|
|
|
|
SmartDialog.showToast(baseData?.msg, alignment: Alignment.center); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}finally{ |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|