huxiaoqiang 4 years ago
parent
commit
8b073b822a

+ 181 - 11
lib/my_tools/order_processing/order_processing.dart

@@ -27,7 +27,9 @@ class OrderProcessing {
   factory OrderProcessing() => _singleton;
   factory OrderProcessing() => _singleton;
 
 
   List<MyShopBeanDataData> shops = []; //所属货帮
   List<MyShopBeanDataData> shops = []; //所属货帮
+  List<MyShopBeanDataData> showShops = []; //展示货帮
   List<TemplateBeanData> orderTemplate = []; //订单模板
   List<TemplateBeanData> orderTemplate = []; //订单模板
+  List<TemplateBeanData> matchTemplates = []; //订单模板
   String clipboardData = ''; //剪切板数据
   String clipboardData = ''; //剪切板数据
   MyShopBeanDataData shop; //选中的店铺
   MyShopBeanDataData shop; //选中的店铺
   TemplateBeanData template; //匹配的模板
   TemplateBeanData template; //匹配的模板
@@ -39,6 +41,7 @@ class OrderProcessing {
   BuildContext buildContext;
   BuildContext buildContext;
   int amountCompleted = 0;
   int amountCompleted = 0;
   bool saving = false;
   bool saving = false;
+  Map idTemplate = Map();
 
 
   //初始化变量
   //初始化变量
   void initialization() {
   void initialization() {
@@ -72,6 +75,7 @@ class OrderProcessing {
         TemplateBeanEntity entity = TemplateBeanEntity()
         TemplateBeanEntity entity = TemplateBeanEntity()
             .fromJson(json.decode(response.data.toString()));
             .fromJson(json.decode(response.data.toString()));
         orderTemplate = entity.data;
         orderTemplate = entity.data;
+        // matchAllTemplates();
         queryTheStore();
         queryTheStore();
       } else {
       } else {
         PopUpQueue().onShow = false;
         PopUpQueue().onShow = false;
@@ -116,17 +120,24 @@ class OrderProcessing {
         shops.removeWhere((element) => !element.privateShop);
         shops.removeWhere((element) => !element.privateShop);
         shops.removeWhere((element) => !element.innerTrade);
         shops.removeWhere((element) => !element.innerTrade);
         bool hasMatch = false;
         bool hasMatch = false;
-        x:
+        showShops.clear();
         for (int i = 0; i < shops.length; i++) {
         for (int i = 0; i < shops.length; i++) {
-          shop = shops[i];
+          if (shop == null) {
+            shop = shops[i];
+          }
           matchTemplate();
           matchTemplate();
           if (orderHash != '') {
           if (orderHash != '') {
             hasMatch = true;
             hasMatch = true;
-            showView();
-            break x;
+            showShops.add(shops[i]);
+            orderHash = '';
+          } else {
+            shop = null;
           }
           }
         }
         }
-        if(!hasMatch){
+        if (hasMatch) {
+          showView();
+        }
+        if (!hasMatch) {
           print('noMatch');
           print('noMatch');
           PopUpQueue().onShow = false;
           PopUpQueue().onShow = false;
           PopUpQueue().showNext();
           PopUpQueue().showNext();
@@ -165,15 +176,14 @@ class OrderProcessing {
         }
         }
       }
       }
     }
     }
-
   }
   }
 
 
   bool parseOrder(TemplateBeanData element) {
   bool parseOrder(TemplateBeanData element) {
     // print('=======parseOrder========');
     // print('=======parseOrder========');
     // print(
     // print(
-        // '=========================|${element.template}|=============================');
+    // '=========================|${element.template}|=============================');
     // print(
     // print(
-        // '=========================|$clipboardData|=============================');
+    // '=========================|$clipboardData|=============================');
     var res;
     var res;
     try {
     try {
       res = parseString2(
       res = parseString2(
@@ -186,6 +196,7 @@ class OrderProcessing {
       print('json.encode(res) =============\n${json.encode(res)}');
       print('json.encode(res) =============\n${json.encode(res)}');
       var order = parse2(res);
       var order = parse2(res);
       print('order.toString()=============\n${order.toString()}');
       print('order.toString()=============\n${order.toString()}');
+      print('order.length=============\n${order.length}');
       var maxAmount = 0.0;
       var maxAmount = 0.0;
       int maxAmountNum = 0;
       int maxAmountNum = 0;
       List<String> maxAmountOwner = [];
       List<String> maxAmountOwner = [];
@@ -230,6 +241,7 @@ class OrderProcessing {
       if (order.length > 0) {
       if (order.length > 0) {
         orderHash = computeOrderHash(res);
         orderHash = computeOrderHash(res);
         this.order = order;
         this.order = order;
+        idTemplate[element.shopUid] = order;
         return true;
         return true;
       } else {
       } else {
         return false;
         return false;
@@ -315,7 +327,7 @@ class OrderProcessing {
                       Container(
                       Container(
                         margin:
                         margin:
                             EdgeInsets.symmetric(horizontal: 7, vertical: 10),
                             EdgeInsets.symmetric(horizontal: 7, vertical: 10),
-                        height: (shops.length * 1.0 / 2).ceil() *
+                        height: (showShops.length * 1.0 / 2).ceil() *
                                 (double.parse(
                                 (double.parse(
                                             '${MediaQuery.of(buildContext).size.width - 74}') /
                                             '${MediaQuery.of(buildContext).size.width - 74}') /
                                         2 /
                                         2 /
@@ -330,14 +342,14 @@ class OrderProcessing {
                                   crossAxisSpacing: 10,
                                   crossAxisSpacing: 10,
                                   mainAxisSpacing: 8 //宽高比为1时,子widget
                                   mainAxisSpacing: 8 //宽高比为1时,子widget
                                   ),
                                   ),
-                          children: shopItem(shops),
+                          children: shopItem(showShops),
                           padding: EdgeInsets.all(0),
                           padding: EdgeInsets.all(0),
                         ),
                         ),
                       ),
                       ),
                     ],
                     ],
                     crossAxisAlignment: CrossAxisAlignment.start,
                     crossAxisAlignment: CrossAxisAlignment.start,
                   ),
                   ),
-                  visible: shops.length != 1,
+                  visible: showShops.length != 1,
                 ),
                 ),
                 Container(
                 Container(
                   height: 0.5,
                   height: 0.5,
@@ -558,4 +570,162 @@ class OrderProcessing {
       }
       }
     }, (error) {});
     }, (error) {});
   }
   }
+
+  //匹配所有模板
+  void matchAllTemplates() {
+    orderTemplate.forEach((element) {
+      if (parseOrder2(element)) {
+        print(
+            '==============parseOrder(element)\n${element.template}\n===================');
+        matchTemplates.add(element);
+      }
+    });
+    checkMyStore();
+  }
+
+  void checkMyStore() {
+    MyDio().query({
+      "key": "shop_user",
+      "filters": {
+        "or": true,
+        "conditions": [
+          "role!=0",
+          "user_uid==${MyCookie().getUID()}",
+          "review_state==1"
+        ],
+        "filters": [
+          {
+            "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
+          }
+        ]
+      },
+      "dims": shopUserDims,
+      "paging": [1, 20000]
+    }, (response, hasError) {
+      if (!hasError) {
+        MyShopBeanEntity entity =
+            MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
+        if (entity.data.data == null || entity.data.data.isEmpty) {
+          PopUpQueue().onShow = false;
+          PopUpQueue().showNext();
+          return;
+        }
+        shops = entity.data.data;
+        shops.removeWhere((element) => !element.privateShop);
+        shops.removeWhere((element) => !element.innerTrade);
+
+        List<MyShopBeanDataData> showShows = [];
+        if (idTemplate.length == 0) {
+          PopUpQueue().onShow = false;
+          PopUpQueue().showNext();
+          return;
+        }
+        if (idTemplate[0] == null) {
+          shops.forEach((shop) {
+            idTemplate.keys.forEach((element) {
+              print('idTemplate.keys$element-------${shop.shopUid}');
+              if (shop.shopUid == element) {
+                showShows.add(shop);
+              }
+            });
+          });
+          shops = showShows;
+          print('shops.length${shops.length}');
+        }
+        shop = shops[0];
+        matchTemplate();
+        showView();
+        // bool hasMatch = false;
+        // x:
+        // for (int i = 0; i < shops.length; i++) {
+        //   shop = shops[i];
+        //   matchTemplate();
+        //   if (orderHash != '') {
+        //     hasMatch = true;
+        //     showView();
+        //     break x;
+        //   }
+        // }
+        // if (!hasMatch) {
+        //   print('noMatch');
+        //   PopUpQueue().onShow = false;
+        //   PopUpQueue().showNext();
+        // }
+      } else {
+        PopUpQueue().onShow = false;
+        PopUpQueue().showNext();
+      }
+    }, (error) {
+      PopUpQueue().onShow = false;
+      PopUpQueue().showNext();
+    });
+  }
+
+  bool parseOrder2(TemplateBeanData element) {
+    var res;
+    try {
+      res = parseString2(
+          element.template.replaceAll('\r', ''), '''$clipboardData''');
+    } catch (e) {}
+    print(res.toString());
+    if (res != null) {
+      print('-----------data[i].template-----------');
+      print(element.template);
+      print('json.encode(res) =============\n${json.encode(res)}');
+      var order = parse2(res);
+      print('order.toString()=============\n${order.toString()}');
+      print('order.length=============\n${order.length}');
+      var maxAmount = 0.0;
+      int maxAmountNum = 0;
+      List<String> maxAmountOwner = [];
+      res.forEach((key, value) {
+        if (key.contains('amount')) {
+          try {
+            if (double.parse(value) > maxAmount) {
+              maxAmount = double.parse(value);
+              maxAmountNum = 1;
+              maxAmountOwner.clear();
+              maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
+            } else if (double.parse(value) == maxAmount) {
+              maxAmountNum++;
+              maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
+            }
+          } catch (e) {}
+        }
+      });
+      if (maxAmountOwner.isNotEmpty) {
+        maxAmountOwner.forEach((element) {
+          if (MyCookie().getName().contains(element) ||
+              element.contains(MyCookie().getName())) {
+            commissionPayerNum = maxAmountNum;
+          }
+        });
+      }
+      print('maxAmount============\n$maxAmount\n==============');
+      print('maxAmountNum==============\n$maxAmountNum\n==============');
+      print(
+          'maxAmountOwner==============\n${maxAmountOwner.toString()}\n==============');
+      print(
+          'commissionPayerNum================  \n$commissionPayerNum\n==============');
+      order.removeWhere((element) =>
+          !element.seller.name
+              .contains(MyCookie().loginInformation.data.extra.name) &&
+          !MyCookie()
+              .loginInformation
+              .data
+              .extra
+              .name
+              .contains(element.seller.name));
+      if (order.length > 0) {
+        orderHash = computeOrderHash(res);
+        this.order = order;
+        idTemplate[element.shopUid] = order;
+        return true;
+      } else {
+        return false;
+      }
+    } else {
+      return false;
+    }
+  }
 }
 }

+ 4 - 3
lib/paegs/map_demo/map_demo_page.dart

@@ -243,9 +243,10 @@ class _MapDemoPageState extends State<MapDemoPage> {
   }
   }
 
 
   void _onPoiTouched(AMapPoi poi) {
   void _onPoiTouched(AMapPoi poi) {
-    setState(() {
-      _poiInfo = showPoiInfo(poi);
-    });
+    print('_onPoiTouched');
+    print('================|${poi.latLng.latitude},${poi.latLng.longitude}|===================');
+    markTheClickLocation(poi.latLng);
+
   }
   }
 
 
   void inquirePOI() {
   void inquirePOI() {

+ 21 - 8
lib/paegs/mine_page/mine_page.dart

@@ -22,6 +22,7 @@ import 'package:bbyyy/paegs/mine_page/set_page/set_page.dart';
 import 'package:bbyyy/paegs/mine_page/wallet_page/wallet_page.dart';
 import 'package:bbyyy/paegs/mine_page/wallet_page/wallet_page.dart';
 import 'package:bbyyy/paegs/mine_page/wallet_page/withdraw_page/withdraw_page.dart';
 import 'package:bbyyy/paegs/mine_page/wallet_page/withdraw_page/withdraw_page.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
 import 'package:flutter_svg/flutter_svg.dart';
 import 'package:flutter_svg/flutter_svg.dart';
 import 'package:pull_to_refresh/pull_to_refresh.dart';
 import 'package:pull_to_refresh/pull_to_refresh.dart';
 
 
@@ -166,15 +167,27 @@ class _MinePageState extends State<MinePage> {
                                   ),
                                   ),
                                   Row(
                                   Row(
                                     children: [
                                     children: [
-                                      Text(
-                                        'ID:${MyCookie().getUID()}',
-                                        style: TextStyle(
-                                          color: Colors.white,
-                                          fontSize: 14,
+                                      GestureDetector(
+                                        onTap: (){
+                                          showToast('已复制到剪切板');
+                                          Clipboard.setData(ClipboardData(text: '${MyCookie().getUID()}'));
+                                        },
+                                        behavior: HitTestBehavior.translucent,
+                                        child: Row(
+                                          children: [
+                                            Text(
+                                              'ID:${MyCookie().getUID()}',
+                                              style: TextStyle(
+                                                color: Colors.white,
+                                                fontSize: 14,
+                                              ),
+                                              maxLines: 1,
+                                              overflow: TextOverflow.ellipsis,
+                                              softWrap: true,
+                                            ),
+                                            Container(margin: EdgeInsets.only(left: 10),child: Icon(Icons.copy,color: Colors.white,size: 14,))
+                                          ],
                                         ),
                                         ),
-                                        maxLines: 1,
-                                        overflow: TextOverflow.ellipsis,
-                                        softWrap: true,
                                       ),
                                       ),
                                       GestureDetector(
                                       GestureDetector(
                                         onTap: () {
                                         onTap: () {

+ 1 - 1
pubspec.yaml

@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # Read more about iOS versioning at
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.1.11+1
+version: 1.1.12+1
 
 
 environment:
 environment:
   sdk: ">=2.7.0 <3.0.0"
   sdk: ">=2.7.0 <3.0.0"