/// <summary> /// 获取指定运输公司,指定区域的价格 /// </summary> /// <returns></returns> public static Lebi_Transport_Price GetAreaPrice(int transport_id, int area_id, int supplierid) { Lebi_Transport_Price price = B_Lebi_Transport_Price.GetModel("Transport_id=" + transport_id + " and Area_id=" + area_id + " and Supplier_id=" + supplierid + ""); if (price == null) { Lebi_Area area = B_Lebi_Area.GetModel(area_id); if (area != null) { if (area.Parentid > 0) { return(GetAreaPrice(transport_id, area.Parentid, supplierid)); } return(null); } return(null); } return(price); }
/// <summary> /// 递归处理运费价格 /// </summary> /// <param name="area"></param> /// <param name="trans"></param> /// <returns></returns> private static List <Lebi_Transport_Price> TransportPrice(Lebi_Area area, List <Lebi_Transport_Price> trans, int supplierid) { if (trans == null) { trans = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", ""); } else { string pids = ""; List <Lebi_Transport_Price> models = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", ""); foreach (Lebi_Transport_Price model in models) { //排除包含的关系 //跳过儿子,孙子在列表中的情况 bool flag = false; foreach (Lebi_Transport_Price tran in trans) { pids = EX_Area.Parentids_Get(tran.Area_id); pids = "," + pids + ","; if (pids.Contains("," + model.Area_id + ",") && model.Transport_id == tran.Transport_id) { flag = true; } } if (!flag) { trans.Add(model); } } } if (area.Parentid > 0) { area = B_Lebi_Area.GetModel(area.Parentid); if (area != null) { trans = TransportPrice(area, trans, supplierid); } } return(trans); }