|
|
@@ -0,0 +1,555 @@
|
|
|
+import 'dart:convert';
|
|
|
+import 'dart:math' as math;
|
|
|
+
|
|
|
+import 'package:bbyyy/beans/flow_bean_entity.dart';
|
|
|
+import 'package:bbyyy/beans/my_shop_bean_entity.dart';
|
|
|
+import 'package:bbyyy/beans/store_bean_entity.dart';
|
|
|
+import 'package:bbyyy/https/MyDio.dart';
|
|
|
+import 'package:bbyyy/https/url.dart';
|
|
|
+import 'package:bbyyy/my_tools/const.dart';
|
|
|
+import 'package:bbyyy/my_tools/dims.dart';
|
|
|
+import 'package:bbyyy/my_tools/my_colors.dart';
|
|
|
+import 'package:bbyyy/my_tools/my_cookie.dart';
|
|
|
+import 'package:bbyyy/my_tools/my_tools.dart';
|
|
|
+import 'package:bbyyy/my_tools/my_views.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter_svg/svg.dart';
|
|
|
+import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
+
|
|
|
+class ShopFlowPage extends StatefulWidget {
|
|
|
+ MyShopBeanDataData data;
|
|
|
+ ShopFlowPage(this.data);
|
|
|
+
|
|
|
+ @override
|
|
|
+ _ShopFlowPageState createState() => _ShopFlowPageState();
|
|
|
+}
|
|
|
+
|
|
|
+class _ShopFlowPageState extends State<ShopFlowPage> {
|
|
|
+ int page = 1;
|
|
|
+ int total = 0;
|
|
|
+ double totalAmount = 0.0;
|
|
|
+ RefreshController controller = RefreshController(initialRefresh: true);
|
|
|
+ List<FlowBeanDataDataRecords> flow = [];
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return Scaffold(
|
|
|
+ body: Column(
|
|
|
+ children: [
|
|
|
+ Stack(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(colors: MyColors.lg),
|
|
|
+ ),
|
|
|
+ height: 170,
|
|
|
+ ),
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ SafeArea(
|
|
|
+ bottom: false,
|
|
|
+ child: Container(
|
|
|
+ height: 45,
|
|
|
+ width: double.infinity,
|
|
|
+ color: Colors.transparent,
|
|
|
+ child: Stack(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ '资金流水',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 16),
|
|
|
+ ),
|
|
|
+ Positioned(
|
|
|
+ left: 0,
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Transform.rotate(
|
|
|
+ angle: math.pi,
|
|
|
+ child: Padding(
|
|
|
+ padding: EdgeInsets.only(
|
|
|
+ left: 16, right: 16, top: 8, bottom: 8),
|
|
|
+ child: SvgPicture.asset(
|
|
|
+ 'images/svg/箭头.svg',
|
|
|
+ color: Colors.white,
|
|
|
+ height: 14,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ showSelect();
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.symmetric(
|
|
|
+ vertical: 8, horizontal: 16),
|
|
|
+ child: Text(
|
|
|
+ '筛选',
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white, fontSize: 16),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Center(
|
|
|
+ child: Text(
|
|
|
+ '总额:$totalAmount',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 20),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ child: Center(
|
|
|
+ child: Text(
|
|
|
+ '共$total笔',
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 20),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: SmartRefresher(
|
|
|
+ controller: controller,
|
|
|
+ onRefresh: onRefresh,
|
|
|
+ onLoading: onLoading,
|
|
|
+ enablePullDown: true,
|
|
|
+ enablePullUp: true,
|
|
|
+ child: flow.length == 0
|
|
|
+ ? SingleChildScrollView(child: noData())
|
|
|
+ : ListView.builder(
|
|
|
+ itemBuilder: (c, index) {
|
|
|
+ return Container(
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 15),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ child: ClipRRect(
|
|
|
+ child: flow[index].userUid == 0
|
|
|
+ ? Image.asset(
|
|
|
+ 'images/app_logo.png',
|
|
|
+ width: 50,
|
|
|
+ height: 50,
|
|
|
+ )
|
|
|
+ : MyViews().netImg(imgURL(flow[index].userPic), 50, 50),
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(25)),
|
|
|
+ ),
|
|
|
+ margin: EdgeInsets.only(right: 12),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: Text(
|
|
|
+ flow[index].userUid == 0 ? '平台' : flow[index].userName,
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333, fontSize: 14),
|
|
|
+ maxLines: 1,
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
+ softWrap: true,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ '${flow[index].paidAmount}',
|
|
|
+ style: TextStyle(
|
|
|
+ color: flow[index].paidAmount > 0
|
|
|
+ ? MyColors.cff3646
|
|
|
+ : MyColors.c237C02,
|
|
|
+ fontSize: 15,
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ flow[index].userUid == 0 ? "" : 'ID:${hideUID(flow[index].userUid.toString())}',
|
|
|
+ style:
|
|
|
+ TextStyle(color: MyColors.c666666, fontSize: 12),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ flow[index].payTime,
|
|
|
+ style:
|
|
|
+ TextStyle(color: MyColors.c666666, fontSize: 11),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ '${flowType(flow[index].type)}',
|
|
|
+ style:
|
|
|
+ TextStyle(color: MyColors.c666666, fontSize: 12),
|
|
|
+ ),
|
|
|
+ if(flow[index].userUid!=0)
|
|
|
+ Text(
|
|
|
+ '${flow[index].userBalance}',
|
|
|
+ style:
|
|
|
+ TextStyle(color: MyColors.c666666, fontSize: 11),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ color: MyColors.cE7E7E7,
|
|
|
+ height: 0.5,
|
|
|
+ margin: EdgeInsets.only(top: 14, bottom: 12),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ padding: EdgeInsets.only(top: 13),
|
|
|
+ itemCount: flow.length,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ StateSetter ss;
|
|
|
+ List<String> types = ['全部', '订单', '佣金'];
|
|
|
+ int typeIndex = 0;
|
|
|
+ List<String> times = ['全部', '今天', '昨天', '本周', '上周', '本月'];
|
|
|
+ int timeIndex = 0;
|
|
|
+
|
|
|
+ void showSelect() {
|
|
|
+ showModalBottomSheet(
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ context: context,
|
|
|
+ builder: (context) {
|
|
|
+ return StatefulBuilder(builder: (c, s) {
|
|
|
+ ss = s;
|
|
|
+ return Container(
|
|
|
+ color: Colors.transparent,
|
|
|
+ height: 240 +
|
|
|
+ (MediaQuery.of(context).size.width / 3 / 2.5) *
|
|
|
+ ((types.length / 3).ceil()),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ padding:
|
|
|
+ EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 0),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topLeft: Radius.circular(8),
|
|
|
+ topRight: Radius.circular(8))),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.all(8.0),
|
|
|
+ child: Text(
|
|
|
+ '取消',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.cFF4233, fontSize: 14),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ '类型筛选',
|
|
|
+ style:
|
|
|
+ TextStyle(color: MyColors.c333333, fontSize: 16),
|
|
|
+ ),
|
|
|
+ GestureDetector(
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.all(8.0),
|
|
|
+ child: Text(
|
|
|
+ '确定',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.cFF4233, fontSize: 14),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ onTap: () {
|
|
|
+ Navigator.pop(context);
|
|
|
+ controller.requestRefresh();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ ),
|
|
|
+ height: 39.5,
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ height: 0.5,
|
|
|
+ color: MyColors.cF5F5F5,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Container(
|
|
|
+ color: Colors.white,
|
|
|
+ child: SingleChildScrollView(
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Visibility(
|
|
|
+ visible: types.length > 1,
|
|
|
+ child: Container(
|
|
|
+ height: 20 +
|
|
|
+ (MediaQuery.of(context).size.width /
|
|
|
+ 3 /
|
|
|
+ 2.5) *
|
|
|
+ ((types.length / 3).ceil()),
|
|
|
+ color: Colors.white,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ child: Text(
|
|
|
+ '类型筛选',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ fontSize: 15),
|
|
|
+ ),
|
|
|
+ margin: EdgeInsets.only(
|
|
|
+ left: 18, top: 5, bottom: 5),
|
|
|
+ height: 20,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: GridView(
|
|
|
+ gridDelegate:
|
|
|
+ SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
+ crossAxisCount: 3,
|
|
|
+ childAspectRatio: 3),
|
|
|
+ children: getTypeItems(),
|
|
|
+ physics: NeverScrollableScrollPhysics(),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Visibility(
|
|
|
+ visible: times.length > 1,
|
|
|
+ child: Container(
|
|
|
+ height: 20 +
|
|
|
+ (MediaQuery.of(context).size.width /
|
|
|
+ 3 /
|
|
|
+ 2.5) *
|
|
|
+ ((times.length / 3).ceil()),
|
|
|
+ color: Colors.white,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ child: Text(
|
|
|
+ '时间筛选',
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ fontSize: 15),
|
|
|
+ ),
|
|
|
+ margin: EdgeInsets.only(
|
|
|
+ left: 18, top: 5, bottom: 5),
|
|
|
+ height: 20,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: GridView(
|
|
|
+ gridDelegate:
|
|
|
+ SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
+ crossAxisCount: 3,
|
|
|
+ childAspectRatio: 3),
|
|
|
+ children: getTimeItems(),
|
|
|
+ physics: NeverScrollableScrollPhysics(),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ getTypeItems() {
|
|
|
+ List<Widget> item = [];
|
|
|
+ for (int i = 0; i < types.length; i++) {
|
|
|
+ item.add(GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ ss(() {
|
|
|
+ if (typeIndex == i) {
|
|
|
+ typeIndex = -1;
|
|
|
+ } else {
|
|
|
+ typeIndex = i;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // getTime(timeIndex);
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ alignment: Alignment.center,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: i == typeIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(4))),
|
|
|
+ height: 34,
|
|
|
+ width: 100,
|
|
|
+ child: Text(
|
|
|
+ types[i],
|
|
|
+ style: TextStyle(
|
|
|
+ color: i == typeIndex ? MyColors.cFF4233 : MyColors.c666666,
|
|
|
+ fontSize: 14),
|
|
|
+ ),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
+ getTimeItems() {
|
|
|
+ List<Widget> item = [];
|
|
|
+ for (int i = 0; i < times.length; i++) {
|
|
|
+ item.add(GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ ss(() {
|
|
|
+ if (timeIndex == i) {
|
|
|
+ timeIndex = -1;
|
|
|
+ } else {
|
|
|
+ timeIndex = i;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (timeIndex != 0) {
|
|
|
+ getTime(timeIndex - 1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ alignment: Alignment.center,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: i == timeIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(4))),
|
|
|
+ height: 34,
|
|
|
+ width: 100,
|
|
|
+ child: Text(
|
|
|
+ times[i],
|
|
|
+ style: TextStyle(
|
|
|
+ color: i == timeIndex ? MyColors.cFF4233 : MyColors.c666666,
|
|
|
+ fontSize: 14),
|
|
|
+ ),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
+ void myFlow() {
|
|
|
+ var conditions = [
|
|
|
+ 'shop_uid == ${widget.data.shopUid}'
|
|
|
+ ];
|
|
|
+ if (typeIndex != 0 && typeIndex != -1) {
|
|
|
+ conditions.add("type IN ${typeIndex == 1 ? [
|
|
|
+ flowTypeOrderCommodity,
|
|
|
+ flowTypeOrderAnnualFee,
|
|
|
+ flowTypeOrderVirtualProduct,
|
|
|
+ flowTypeOrderThirdPlatform,
|
|
|
+ flowTypeOrderOfflineTransfer,
|
|
|
+ flowTypeScancodeAilyPay
|
|
|
+ ] : [flowTypeShopCommission]}");
|
|
|
+ }
|
|
|
+ if (timeIndex != 0 && timeIndex != -1) {
|
|
|
+ conditions.add("pay_time between ${getTime(timeIndex - 1)}");
|
|
|
+ }
|
|
|
+ MyDio().query({
|
|
|
+ "key": "flow",
|
|
|
+ "filters": {"conditions": conditions},
|
|
|
+ "dims": flowDims,
|
|
|
+ "order_by": ["id,DESC"],
|
|
|
+ "paging": [page, 50]
|
|
|
+ }, (response, hasError) {
|
|
|
+ if (!hasError) {
|
|
|
+ FlowBeanEntity entity =
|
|
|
+ FlowBeanEntity().fromJson(json.decode(response.data.toString()));
|
|
|
+ total = entity.data.total;
|
|
|
+ totalAmount = entity.data.data.totalAmount;
|
|
|
+ if (page == 1) {
|
|
|
+ flow.clear();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ flow.addAll(entity.data.data.records);
|
|
|
+ } catch (e) {}
|
|
|
+ setState(() {});
|
|
|
+ }
|
|
|
+ endRe(controller);
|
|
|
+ }, (error) {});
|
|
|
+ }
|
|
|
+
|
|
|
+ void onRefresh() {
|
|
|
+ page = 1;
|
|
|
+ checkIfYouAreTheOwner();
|
|
|
+ myFlow();
|
|
|
+ }
|
|
|
+
|
|
|
+ void onLoading() {
|
|
|
+ page++;
|
|
|
+ myFlow();
|
|
|
+ }
|
|
|
+
|
|
|
+ void checkIfYouAreTheOwner() {
|
|
|
+ MyDio().query({
|
|
|
+ "key": "shop",
|
|
|
+ "filters": {
|
|
|
+ "conditions": ["owner_uid == ${MyCookie().getUID()}"]
|
|
|
+ },
|
|
|
+ "dims": shopDims,
|
|
|
+ "paging": [1, 5000]
|
|
|
+ }, (response, hasError) {
|
|
|
+ if (!hasError) {
|
|
|
+ StoreBeanEntity entity =
|
|
|
+ StoreBeanEntity().fromJson(json.decode(response.data.toString()));
|
|
|
+ if (entity.data.data.length == 0) {
|
|
|
+ types.remove('佣金');
|
|
|
+ }
|
|
|
+ setState(() {});
|
|
|
+ }
|
|
|
+ endRe(controller);
|
|
|
+ }, (error) {});
|
|
|
+ }
|
|
|
+}
|