Commit 3aff39314a8cca9e1d694398e36da8003de2052f

Authored by wdn127929
1 parent 53ca7332

支付返券

... ... @@ -20,19 +20,19 @@ if (flutterRoot == null) {
def flutterVersionCode = "550"
def flutterVersionCode = "552"
if (flutterVersionCode == null) {
flutterVersionCode = '550'
flutterVersionCode = '552'
}
def flutterVersionName = "5.5.0"
def flutterVersionName = "5.5.2"
if (flutterVersionName == null) {
flutterVersionName = '5.5.0'
flutterVersionName = '5.5.2'
}
... ...
... ... @@ -603,18 +603,18 @@ class HttpUrl {
static const create_pay_qrcode =
"?service=App.Seller.CreatePayQrcode"; // 生成商家收款二维码
static const get_discount_orderlist =
static const get_discount_orderlist =
"?service=App.Activity.GetDiscountOrderList"; // 获取交易记录
static const get_discount_order_info =
static const get_discount_order_info =
"?service=App.Activity.GetDiscountOrderInfo"; // 通过支付订单号或退款订单号获取订单
static const discount_pay_refund_apply=
static const discount_pay_refund_apply =
"?service=App.PayOnline.DiscountPayRefundApply"; // 优惠支付订单退款
static const set_activity_config =
"?service=App.Activity.SetActivityConfig"; // 获取商家券赠送规则配置
static const get_activity_config =
"?service=App.Activity.GetActivityConfig"; // 获取商家券赠送规则配置
}
... ...
... ... @@ -71,9 +71,9 @@ class _FinanceManageHomePageState extends State<FinanceManageHomePage> {
// NavigatorUtil.goEnterpriseInformationUploadPage(context);
// }),
// _item('微信商户账户开通结果查询', () {}),
// _item('支付返券', () {
// NavigatorUtil.goPaymentGiftPage(context);
// }),
_item('支付返券', () {
NavigatorUtil.goPaymentGiftPage(context);
}),
_item('门店收款码', () {
NavigatorUtil.goPaymentCodePage(context);
}),
... ...
import 'dart:convert';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_picker_plus/picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/system_app_bar.dart';
... ... @@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget {
class _PaymentGiftPageState extends State<PaymentGiftPage> {
bool fullReduction = true;
bool ladderReduction = false;
String fromDateFull = '选择日期';
String endDateFull = '选择日期';
... ... @@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
List coupons = ['1', '2', '3'];
List ladders = ['1', '2', '3'];
List<CouponSunModel>? couponSelectFree = [];
bool rule = true;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// _getCountCommentLabel(isShowLoading: false);
});
// bus.on("refresh_discount_order_list", (args) {
// // _getReserveDetail(isShowLoading: false);
// _getDiscountOrderList(isShowLoading: false);
// });
}
_setActivityConfig() async {
Map<String, String>? fullReductionData;
if (fullReduction) {
if (fromDateFull == '选择日期') {
Utils.showToast('请选择满减返券活动的开始时间!');
return;
}
if (endDateFull == '选择日期') {
Utils.showToast('请选择满减返券活动的结束时间!');
return;
}
if (fullC.text.trim().length == '0') {
Utils.showToast('请输入门槛金额!');
return;
}
if (couponSelectFree == null || couponSelectFree!.length == 0) {
Utils.showToast('请选择优惠券!');
return;
}
List<Map> couponsData = [];
couponSelectFree!.forEach((e) {
Map<String, String> coupon = {'id': e.id!, 'name': e.aname!};
couponsData.add(coupon);
});
String fromfull = fromDateFull + ' 00:00:00';
String endfull = endDateFull + ' 23:59:59';
String sfull =
'${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
String efull =
'${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
String ruleString = rule ? '1' : '0'; //发放规则
fullReductionData = {
'stime': sfull,
'etime': efull,
'price': fullC.text,
'coupons': jsonEncode(couponsData),
'rule': ruleString
};
} else {
//阶梯返券
if (fromDateLadder == '选择日期') {
Utils.showToast('请选择阶梯返券活动的开始时间!');
return;
}
if (endDateLadder == '选择日期') {
Utils.showToast('请选择阶梯返券活动的结束时间!');
return;
}
if (fullC.text.trim().length == '0') {
Utils.showToast('请输入门槛金额!');
return;
}
// if (couponSelectFree == null || couponSelectFree!.length == 0) {
// Utils.showToast('请选择优惠券!');
// return;
// }
List<Map<String, String>> stairsData = [];
stairsData.add(
{
'price': '100',
'coupons':
"[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
},
);
stairsData.add(
{
'price': '100',
'coupons':
"[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
},
);
stairsData.add(
{
'price': '100',
'coupons':
"[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
},
);
}
Map<String, String?> pramas = {
'sellerid':
Provider.of<UserModel>(context, listen: false).user!.sellerid!,
'full_reduction': fullReduction ? '1' : '0',
'stairs': !fullReduction ? '1' : '0',
'full_reduction_data':
fullReductionData == null ? null : jsonEncode(fullReductionData)
// 'stairs_data':
};
await financeProvider!.setActivityConfig(context, pramas);
}
///是否立即启用
Widget _canUse(
... ... @@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
if (endDateFull != '选择日期') {
if (DateUtil.getDateTime(endDateFull).compareTo(
DateUtil.getDateTime(DateUtil.formatDateStr(
value,
format: DateFormats.y_mo_d))) <
0) {
Utils.showToast('满减返券的活动开始时间不能迟于活动结束时间');
return;
}
}
setState(() {
print(value);
fromDateFull = DateUtil.formatDateStr(value,
... ... @@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
if (fromDateFull != '选择日期') {
if (DateUtil.getDateTime(DateUtil.formatDateStr(
value,
format: DateFormats.y_mo_d))
.compareTo(
DateUtil.getDateTime(fromDateFull)) <
0) {
Utils.showToast('满减返券的活动结束时间不能早于活动开始时间');
return;
}
}
setState(() {
print(value);
endDateFull = DateUtil.formatDateStr(value,
... ... @@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
color: MyColours.color_515151, fontSize: font(14)),
),
Spacer(),
Container(
// width: w(100),
// height: w(30),
padding: EdgeInsets.symmetric(
horizontal: w(10), vertical: w(5)),
decoration: BoxDecoration(
color: MyColours.color_438E93,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(r(5)),
bottomLeft: Radius.circular(r(5)))),
child: Text(
'每满门槛均发放',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: font(14)),
),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: w(10), vertical: w(5)),
decoration: BoxDecoration(
color: MyColours.color_DBDBDB,
borderRadius: BorderRadius.only(
topRight: Radius.circular(r(5)),
bottomRight: Radius.circular(r(5)))),
child: Text(
'仅发放一次',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: font(14)),
),
)
InkWell(
onTap: () {
setState(() {
rule = !rule;
});
},
child: Container(
// width: w(100),
// height: w(30),
padding: EdgeInsets.symmetric(
horizontal: w(10), vertical: w(5)),
decoration: BoxDecoration(
color: rule
? MyColours.color_438E93
: MyColours.color_DBDBDB,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(r(5)),
bottomLeft: Radius.circular(r(5)))),
child: Text(
'每满门槛均发放',
style: TextStyle(
color: rule
? MyColours.color_ffffff
: MyColours.color_438E93,
fontSize: font(14)),
),
)),
InkWell(
onTap: () {
setState(() {
rule = !rule;
});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: w(10), vertical: w(5)),
decoration: BoxDecoration(
color: !rule
? MyColours.color_438E93
: MyColours.color_DBDBDB,
borderRadius: BorderRadius.only(
topRight: Radius.circular(r(5)),
bottomRight: Radius.circular(r(5)))),
child: Text(
'仅发放一次',
style: TextStyle(
color: !rule
? MyColours.color_ffffff
: MyColours.color_438E93,
fontSize: font(14)),
),
))
],
),
),
VEmptyView(22),
_canUse('开通实际支付阶梯返券【提客单】', ladderReduction, () {
_canUse('开通实际支付阶梯返券【提客单】', !fullReduction, () {
//
setState(() {
ladderReduction = !ladderReduction;
fullReduction = !fullReduction;
});
}),
_select('活动开始于', fromDateLadder, () {
... ... @@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
textColor: MyColours.color_ffffff,
isBold: true,
fontSize: 32,
onPressed: () {},
onPressed: () {
// 调用接口
_setActivityConfig();
},
),
)
],
... ...
... ... @@ -77,6 +77,124 @@ class FinanceProvider extends ChangeNotifier {
}
}
// 商家券赠送规则配置
Future<bool> setActivityConfig(
BuildContext context, Map<String, String?> params,
{bool showLoading = true, bool needToast = true}) async {
try {
BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
context, Method.post, HttpUrl.set_activity_config,
data: params, showLoading: showLoading);
if (baseResp.code == Constant.status_success) {
if (baseResp.data == 0 || baseResp.data == 1) {
if (needToast) {
Utils.showToast('设置成功');
}
return true;
} else {
if (needToast) {
Utils.showToast('设置失败,请重试');
}
}
} else {
if (needToast) {
Utils.showToast(baseResp.msg ?? '设置失败,请重试');
}
}
return false;
} catch (error) {
print(error.toString());
if (needToast) {
Utils.showToast('设置失败,请重试');
}
return false;
}
}
///获取商家券赠送规则配置 还没做--------待使用----------
// Future getActivityConfig(BuildContext context, Map<String, String?> params,
// {isShowLoading = true}) async {
// PageState pageStateTemp = PageState.Loading;
// try {
// BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
// context, Method.post, HttpUrl.get_activity_config,
// data: params, showLoading: isShowLoading);
// if (baseResp.code == Constant.status_success) {
// if (baseResp.data.isEmpty) {
// // if (isShowLoading) {
// pageStateTemp = PageState.Empty;
// // }
// } else {
// // if (isShowLoading) {
// pageStateTemp = PageState.Success;
// // }
// }
// discountOrderList =
// DiscountOrderListModel.fromJson(baseResp.responseData!).data ?? [];
// if (discountOrderList.length > 0) {
// for (var element in discountOrderList) {
// if (element?.list != null) {
// List<DiscountOrderListModelDataList?> temp = [];
// for (var elementSub in element!.list!) {
// temp.add(DiscountOrderListModelDataList.fromJson(
// elementSub!.toJson()));
// if ((elementSub.refundId != null && elementSub.status == '2') ||
// elementSub.status == '4' ||
// elementSub.status == '5') {
// //这笔数据是退款
// elementSub.status = '00';
// temp.add(elementSub);
// }
// }
// element.list = temp;
// }
// }
// }
// print(discountOrderList);
// } else {
// if (isShowLoading) {
// pageStateTemp = PageState.ConnectivityError;
// }
// if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
// }
// }
// if (from == 'home') {
// pageStateRecordHome = pageStateTemp;
// } else {
// pageStateRecordSearch = pageStateTemp;
// }
// notifyListeners();
// } catch (error) {
// print(error.toString());
// if (error is MyError) {
// if (isShowLoading) {
// switch (error.type) {
// case 1:
// pageStateTemp = PageState.ConnectivityError;
// break;
// case 2:
// pageStateTemp = PageState.ConnectivityTimeOut;
// break;
// default:
// pageStateTemp = PageState.ConnectivityError;
// break;
// }
// }
// }
// if (from == 'home') {
// pageStateRecordHome = pageStateTemp;
// } else {
// pageStateRecordSearch = pageStateTemp;
// }
// notifyListeners();
// }
// }
///获取交易记录列表
Future getDiscountOrderList(BuildContext context, Map<String, String?> params,
{String from = 'home', isShowLoading = true}) async {
... ...