|
|
@@ -27,7 +27,9 @@ class OrderProcessing {
|
|
|
factory OrderProcessing() => _singleton;
|
|
|
|
|
|
List<MyShopBeanDataData> shops = []; //所属货帮
|
|
|
+ List<MyShopBeanDataData> showShops = []; //展示货帮
|
|
|
List<TemplateBeanData> orderTemplate = []; //订单模板
|
|
|
+ List<TemplateBeanData> matchTemplates = []; //订单模板
|
|
|
String clipboardData = ''; //剪切板数据
|
|
|
MyShopBeanDataData shop; //选中的店铺
|
|
|
TemplateBeanData template; //匹配的模板
|
|
|
@@ -39,6 +41,7 @@ class OrderProcessing {
|
|
|
BuildContext buildContext;
|
|
|
int amountCompleted = 0;
|
|
|
bool saving = false;
|
|
|
+ Map idTemplate = Map();
|
|
|
|
|
|
//初始化变量
|
|
|
void initialization() {
|
|
|
@@ -72,6 +75,7 @@ class OrderProcessing {
|
|
|
TemplateBeanEntity entity = TemplateBeanEntity()
|
|
|
.fromJson(json.decode(response.data.toString()));
|
|
|
orderTemplate = entity.data;
|
|
|
+ // matchAllTemplates();
|
|
|
queryTheStore();
|
|
|
} else {
|
|
|
PopUpQueue().onShow = false;
|
|
|
@@ -116,17 +120,24 @@ class OrderProcessing {
|
|
|
shops.removeWhere((element) => !element.privateShop);
|
|
|
shops.removeWhere((element) => !element.innerTrade);
|
|
|
bool hasMatch = false;
|
|
|
- x:
|
|
|
+ showShops.clear();
|
|
|
for (int i = 0; i < shops.length; i++) {
|
|
|
- shop = shops[i];
|
|
|
+ if (shop == null) {
|
|
|
+ shop = shops[i];
|
|
|
+ }
|
|
|
matchTemplate();
|
|
|
if (orderHash != '') {
|
|
|
hasMatch = true;
|
|
|
- showView();
|
|
|
- break x;
|
|
|
+ showShops.add(shops[i]);
|
|
|
+ orderHash = '';
|
|
|
+ } else {
|
|
|
+ shop = null;
|
|
|
}
|
|
|
}
|
|
|
- if(!hasMatch){
|
|
|
+ if (hasMatch) {
|
|
|
+ showView();
|
|
|
+ }
|
|
|
+ if (!hasMatch) {
|
|
|
print('noMatch');
|
|
|
PopUpQueue().onShow = false;
|
|
|
PopUpQueue().showNext();
|
|
|
@@ -165,15 +176,14 @@ class OrderProcessing {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
bool parseOrder(TemplateBeanData element) {
|
|
|
// print('=======parseOrder========');
|
|
|
// print(
|
|
|
- // '=========================|${element.template}|=============================');
|
|
|
+ // '=========================|${element.template}|=============================');
|
|
|
// print(
|
|
|
- // '=========================|$clipboardData|=============================');
|
|
|
+ // '=========================|$clipboardData|=============================');
|
|
|
var res;
|
|
|
try {
|
|
|
res = parseString2(
|
|
|
@@ -186,6 +196,7 @@ class OrderProcessing {
|
|
|
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 = [];
|
|
|
@@ -230,6 +241,7 @@ class OrderProcessing {
|
|
|
if (order.length > 0) {
|
|
|
orderHash = computeOrderHash(res);
|
|
|
this.order = order;
|
|
|
+ idTemplate[element.shopUid] = order;
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
@@ -315,7 +327,7 @@ class OrderProcessing {
|
|
|
Container(
|
|
|
margin:
|
|
|
EdgeInsets.symmetric(horizontal: 7, vertical: 10),
|
|
|
- height: (shops.length * 1.0 / 2).ceil() *
|
|
|
+ height: (showShops.length * 1.0 / 2).ceil() *
|
|
|
(double.parse(
|
|
|
'${MediaQuery.of(buildContext).size.width - 74}') /
|
|
|
2 /
|
|
|
@@ -330,14 +342,14 @@ class OrderProcessing {
|
|
|
crossAxisSpacing: 10,
|
|
|
mainAxisSpacing: 8 //宽高比为1时,子widget
|
|
|
),
|
|
|
- children: shopItem(shops),
|
|
|
+ children: shopItem(showShops),
|
|
|
padding: EdgeInsets.all(0),
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
),
|
|
|
- visible: shops.length != 1,
|
|
|
+ visible: showShops.length != 1,
|
|
|
),
|
|
|
Container(
|
|
|
height: 0.5,
|
|
|
@@ -558,4 +570,162 @@ class OrderProcessing {
|
|
|
}
|
|
|
}, (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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|