Parcourir la source

feature:手机端小程序查询经销商区域是否窜货的逻辑,增加多区域的逻辑

yingjian.wu il y a 3 mois
Parent
commit
a21b344375
1 fichiers modifiés avec 118 ajouts et 67 suppressions
  1. 118 67
      src/main/java/com/qlm/controller/jinzai/MobileController.java

+ 118 - 67
src/main/java/com/qlm/controller/jinzai/MobileController.java

@@ -123,16 +123,16 @@ public class MobileController extends Controller{
 					status = true;
 					Record fahuoInfo = Db.findFirst("select * from deliveryorders where CaseCode =? order by id desc",master_code);
 					if(fahuoInfo != null){
-						String CustomerNo = fahuoInfo.getStr("CustomerNo");
+						String customerNo = fahuoInfo.getStr("CustomerNo");
 						
 						
 						result.set("fahuoInfo", fahuoInfo);
-						List<Record> list = Db.find("select * from jinzai_jxs_area where code = ?",CustomerNo);
+						List<Record> list = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where code = ?)", customerNo);
 						String realCity = "";
 						for (Record jxsInfo : list) {
 							String saleCity = jxsInfo.getStr("city");
 							String saleProvince = jxsInfo.getStr("province");
-							
+
 							if(realCity.length()>0){
 								realCity+=",";
 							}
@@ -144,7 +144,6 @@ public class MobileController extends Controller{
 									}
 								}
 							}
-						
 						}
 						result.set("saleLocation", realCity);
 						
@@ -177,10 +176,10 @@ public class MobileController extends Controller{
 					Record fahuoInfo = Db.findFirst("select * from deliveryorders where CaseCode =? order by id desc",master_code);
 					result.set("fahuoInfo", fahuoInfo);
 					if(fahuoInfo != null){
-						String CustomerNo = fahuoInfo.getStr("CustomerNo");
+						String customerNo = fahuoInfo.getStr("CustomerNo");
 						
 						result.set("fahuoInfo", fahuoInfo);
-						List<Record> list = Db.find("select * from jinzai_jxs_area where code = ?",CustomerNo);
+						List<Record> list = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where code = ?)", customerNo);
 						String realCity = "";
 						for (Record jxsInfo : list) {
 							String saleCity = jxsInfo.getStr("city");
@@ -250,20 +249,32 @@ public class MobileController extends Controller{
 				Record fahuoInfo = new Record();
 				fahuoInfo.set("DeliveryTime", operateDate).set("CustomerName", distributorName);
 
+				List<Record> jxsAreas = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where jxs = ?)", distributorName);
 
-				Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where jxs = ?",distributorName);
-				
-				if(jxsInfo != null){
-					String saleCity = jxsInfo.getStr("city");
-					String saleProvince = jxsInfo.getStr("province");
-					
-					if(saleCity!=null&&saleCity.equals(compareCity)){
+				if(jxsAreas != null && !jxsAreas.isEmpty()){
+					StringBuilder realCity = new StringBuilder();
+					// 添加一个标志来判断是否匹配
+					boolean areaMatched = false;
+					for (Record area : jxsAreas) {
+						String saleCity = area.getStr("city");
+						String saleProvince = area.getStr("province");
+						if(realCity.length() > 0){
+							realCity.append(",");
+						}
+						realCity.append(saleProvince).append(saleCity);
+						// 检查当前区域是否匹配,只要有一个匹配就标记为true
+						if(saleCity != null && saleCity.equals(compareCity)){
+							areaMatched = true;
+						}
+					}
+					// 如果有任何一个区域匹配,就表示没有跨区域
+					if(areaMatched){
 						cuan = false;
 					}
-					result.set("saleLocation", saleProvince+saleCity);
-					
-					searchInfo.set("kehu", saleProvince+saleCity);
-				}else{
+
+					result.set("saleLocation", realCity.toString());
+					searchInfo.set("kehu", realCity.toString());
+				} else {
 					result.set("saleLocation", "未发货");
 				}
 				result.set("fahuoInfo", fahuoInfo);
@@ -306,20 +317,30 @@ public class MobileController extends Controller{
 				result.set("pinxiang", productName);
 				Record fahuoInfo = new Record();
 				fahuoInfo.set("DeliveryTime", operateDate).set("CustomerName", distributorName);
-				
-				Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where jxs = ?",distributorName);
-				
-				if(jxsInfo != null){
-					String saleCity = jxsInfo.getStr("city");
-					String saleProvince = jxsInfo.getStr("province");
-					
-					if(saleCity.equals(compareCity)){
+
+				List<Record> jxsAreas = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where jxs = ?)", distributorName);
+
+				if(jxsAreas != null && !jxsAreas.isEmpty()){
+					StringBuilder realCity = new StringBuilder();
+					boolean areaMatched = false;
+					for (Record area : jxsAreas) {
+						String saleCity = area.getStr("city");
+						String saleProvince = area.getStr("province");
+						if(realCity.length() > 0){
+							realCity.append(",");
+						}
+						realCity.append(saleProvince).append(saleCity);
+						// 检查当前区域是否匹配,只要有一个匹配就标记为true
+						if(saleCity != null && saleCity.equals(compareCity)){
+							areaMatched = true;
+						}
+					}
+					// 如果有任何一个区域匹配,就表示没有跨区域
+					if(areaMatched){
 						cuan = false;
 					}
-					result.set("saleLocation", saleProvince+saleCity);
-					
-					searchInfo.set("kehu", saleProvince+saleCity);
-
+					result.set("saleLocation", realCity.toString());
+					searchInfo.set("kehu", realCity.toString());
 				}
 				result.set("fahuoInfo", fahuoInfo);
 				status = true;
@@ -357,19 +378,30 @@ public class MobileController extends Controller{
 				fahuoInfo.set("DeliveryTime", operateDate).set("CustomerName", distributorName);
 
 
-				Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where jxs = ?",distributorName);
-				
-				if(jxsInfo != null){
-					String saleCity = jxsInfo.getStr("city");
-					String saleProvince = jxsInfo.getStr("province");
-					
-					if(saleCity!=null&&saleCity.equals(compareCity)){
+				List<Record> jxsAreas = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where jxs = ?)", distributorName);
+
+				if(jxsAreas != null && !jxsAreas.isEmpty()){
+					StringBuilder realCity = new StringBuilder();
+					boolean areaMatched = false;
+					for (Record area : jxsAreas) {
+						String saleCity = area.getStr("city");
+						String saleProvince = area.getStr("province");
+						if(realCity.length() > 0){
+							realCity.append(",");
+						}
+						realCity.append(saleProvince).append(saleCity);
+						// 检查当前区域是否匹配,只要有一个匹配就标记为true
+						if(saleCity != null && saleCity.equals(compareCity)){
+							areaMatched = true;
+						}
+					}
+					// 如果有任何一个区域匹配,就表示没有跨区域
+					if(areaMatched){
 						cuan = false;
 					}
-					result.set("saleLocation", saleProvince+saleCity);
-					
-					searchInfo.set("kehu", saleProvince+saleCity);
-				}else{
+					result.set("saleLocation", realCity.toString());
+					searchInfo.set("kehu", realCity.toString());
+				} else {
 					result.set("saleLocation", "未发货");
 				}
 				result.set("fahuoInfo", fahuoInfo);
@@ -402,26 +434,35 @@ public class MobileController extends Controller{
 					status = true;
 					Record fahuoInfo = Db.findFirst("select * from deliveryorders where CaseCode =? order by id desc",master_code);
 					if(fahuoInfo != null){
-						String CustomerNo = fahuoInfo.getStr("CustomerNo");
+						String customerNo = fahuoInfo.getStr("CustomerNo");
 						
 						String ProductName = fahuoInfo.getStr("ProductName");
-						
-						Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where code = ? order by id desc",CustomerNo);
-						if(jxsInfo != null){
-							String saleCity = jxsInfo.getStr("city");
-							String saleProvince = jxsInfo.getStr("province");
-							
-							if(compareProvice.contains(saleProvince)){
-								if(compareCity.contains(saleCity)){
-									cuan = false;
+
+						List<Record> jxsAreas = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where code = ?)", customerNo);
+
+						if(jxsAreas != null && !jxsAreas.isEmpty()){
+							StringBuilder realCity = new StringBuilder();
+							boolean areaMatched = false;
+							for (Record area : jxsAreas) {
+								String saleCity = area.getStr("city");
+								String saleProvince = area.getStr("province");
+								if(realCity.length() > 0){
+									realCity.append(",");
+								}
+								realCity.append(saleProvince).append(saleCity);
+								// 检查当前区域是否匹配,只要有一个匹配就标记为true
+								if(compareProvice.contains(saleProvince) && compareCity.contains(saleCity)){
+									areaMatched = true;
 								}
 							}
-							result.set("saleLocation", saleProvince+saleCity);
-							
-							searchInfo.set("kehu", saleProvince+saleCity);
+							// 如果有任何一个区域匹配,就表示没有跨区域
+							if(areaMatched){
+								cuan = false;
+							}
+							result.set("saleLocation", realCity.toString());
+							searchInfo.set("kehu", realCity.toString());
 							result.set("fahuoInfo", fahuoInfo);
 						}
-						
 					}
 					
 					
@@ -452,23 +493,33 @@ public class MobileController extends Controller{
 					status = true;
 					Record fahuoInfo = Db.findFirst("select * from deliveryorders where CaseCode =? order by id desc",master_code);
 					if(fahuoInfo != null){
-						String CustomerNo = fahuoInfo.getStr("CustomerNo");
+						String customerNo = fahuoInfo.getStr("CustomerNo");
 						
 						String ProductName = fahuoInfo.getStr("ProductName");
-						
-						Record jxsInfo = Db.findFirst("select * from jinzai_jxs_area where code = ?",CustomerNo);
-						if(jxsInfo != null){
-							String saleCity = jxsInfo.getStr("city");
-							String saleProvince = jxsInfo.getStr("province");
-							
-							if(compareProvice.contains(saleProvince)){
-								if(compareCity.contains(saleCity)){
-									cuan = false;
+
+						List<Record> jxsAreas = Db.find("select * from t_dealer_area where dealer_id = (select id from jinzai_jxs_area where code = ?)", customerNo);
+
+						if(jxsAreas != null && !jxsAreas.isEmpty()){
+							StringBuilder realCity = new StringBuilder();
+							boolean areaMatched = false;
+							for (Record area : jxsAreas) {
+								String saleCity = area.getStr("city");
+								String saleProvince = area.getStr("province");
+								if(realCity.length() > 0){
+									realCity.append(",");
+								}
+								realCity.append(saleProvince).append(saleCity);
+								// 检查当前区域是否匹配,只要有一个匹配就标记为true
+								if(compareProvice.contains(saleProvince) && compareCity.contains(saleCity)){
+									areaMatched = true;
 								}
 							}
-							result.set("saleLocation", saleProvince+saleCity);
-							
-							searchInfo.set("kehu", saleProvince+saleCity);
+							// 如果有任何一个区域匹配,就表示没有跨区域
+							if(areaMatched){
+								cuan = false;
+							}
+							result.set("saleLocation", realCity.toString());
+							searchInfo.set("kehu", realCity.toString());
 							result.set("fahuoInfo", fahuoInfo);
 						}