/// <summary> /// 检测电话是否存在 /// </summary> /// <param name="myuservo"></param> /// <param name="phone"></param> /// <returns></returns> public static (bool, string, object) CheckDriverIsHaveFromPhone(UserLoginVO myuservo, string phone) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "phone=@phone", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@phone", phone) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "检测电话不存在!", false); } Model.Model.LC_User lcu_vo = ids.GetVOList <Model.Model.LC_User>()[0]; if (lcu_vo.ZType.ConvertData <GlobalBLL.AccountTypeEnum>() != AccountTypeEnum.物流公司员工账号) { return(false, "绑定账号类型不是司机的电话!", null); } if (lcu_vo.PositionID.ConvertData <PositionEnum>() != PositionEnum.驾驶员) { return(false, "绑定账号类型不是司机的电话!", null); } if (lcu_vo.State.ConvertData <UserStateEnum>() != GlobalBLL.UserStateEnum.正常) { return(false, "您要绑定的司机还没有通过授权!", null); } return(true, string.Empty, true); }
/// <summary> /// 添加车辆等待物流模式 /// </summary> /// <param name="myuservo"></param> /// <param name="lcv"></param> /// <returns></returns> public static (bool, string, object) AddVehicleWait(UserLoginVO myuservo, Model.Model.LC_Vehicle lcv) { //查看车号是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_Vehicle), "VehicleNo=@VehicleNo and UID=@UID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@VehicleNo", lcv.VehicleNo), new System.Data.SqlClient.SqlParameter("@UID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (ids.Count() > 0) { return(false, "已经存在相同车号车辆,无法进行添加!", null); } //添加一个绑定车辆 sql = makesql.MakeInsertSQL(lcv); ids = db.Exec(sql, true); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ExecOk()) { return(false, "添加车辆不能为空!", null); } return(true, string.Empty, new { ID = ids.index_id, region = GlobalBLL.PositionEnum.驾驶员.EnumToInt(), logistics = myuservo.uid }); }
/// <summary> /// 获取线路数据 /// </summary> /// <param name="myuservo"></param> /// <param name="id"></param> /// <returns></returns> public static (bool, string, object) GetLineData(UserLoginVO myuservo, long id) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_Line), "id=@id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", id) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(false, "没有找到任何数据!", null); } var vo = ids.GetVOList <Model.Model.LC_Line>()[0]; return(true, string.Empty, new { vo.DFPhone, vo.DFResponsibleName, vo.MyPhone, vo.MyResponsibleName, StartName = DAL.DALBase.GetAllAddressToString(vo.Start.ConvertData <int>()).Replace(" ", ""), EndName = DAL.DALBase.GetAllAddressToString(vo.End.ConvertData <int>()).Replace(" ", ""), vo.OpenTime }); }
/// <summary> /// 获取运营统计 /// </summary> /// <param name="myuservo"></param> /// <param name="starttime"></param> /// <param name="endtime"></param> /// <param name="startuid"></param> /// <param name="enduid"></param> /// <returns></returns> public static (bool, string, object) GetOperationStatistics(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { GlobalBLL.VO.OperationStatisticsVO osvo = new GlobalBLL.VO.OperationStatisticsVO() { HDTJ_JieDanShu = 获取接单数(myuservo, starttime, endtime), HDTJ_YunShuDanShu = 获取运输订单(myuservo, starttime, endtime, startuid, enduid), HDTJ_KuCunDanShu = 获取库存单数(myuservo, starttime, endtime, startuid, enduid), HDTJ_JieWanHuoDan = 获取接完货单(myuservo, starttime, endtime, startuid, enduid), JieJianNumber = 获取接件数(myuservo, starttime, endtime, startuid, enduid), YunShuZongJianShu = 获取运输总件数(myuservo, starttime, endtime, startuid, enduid), KuCunJianShu = 获取库存件数(myuservo, starttime, endtime, startuid, enduid), JieWanJianShu = 获取接完件数(myuservo, starttime, endtime, startuid, enduid), JieCheCheShu = 获取接车车数(myuservo, starttime, endtime, startuid, enduid), YunShuZongShu = 获取运输总数(myuservo, starttime, endtime, startuid, enduid), FaHuoKeHu = 获取发货客户数(myuservo, starttime, endtime, startuid, enduid), SuoHuoKeHu = 获取收货客户数(myuservo, starttime, endtime, startuid, enduid), }; osvo.HuiCheTongJi = osvo.JieCheCheShu + osvo.YunShuZongShu; //汇总车次 return(true, string.Empty, osvo); }
private static long 获取上缴汇总(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { string where = string.Empty; if (!starttime.IsNull() && !endtime.IsNull()) { where += " and {0}.LastOperationTime between @starttime and @endtime"; } if (startuid.StrIsNotNull() && enduid.StrIsNotNull()) { where += " and {1}.beginUID=@beginUID and {1}.finishUID=@finishUID"; } else { startuid = string.Empty; enduid = string.Empty; } //获取上缴汇总 sql = makesql.MakeCount(new Type[] { typeof(Model.Model.LC_Payment_History), typeof(Model.Model.LC_Customer) }, "{0}.OrderNumber={1}.OrderID and {0}.LastOperatorsUID=@LastOperatorsUID and {0}.LocationLogisticsUID<>LastOperatorsUID and {0}.LastState<>2" + where, new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LastOperatorsUID", myuservo.uid) }, "{0}.id"); ids = db.Read(sql); if (!ids.flag) { return(0); } return(ids.Count()); }
/// <summary> /// 获取库存件数 /// </summary> /// <param name="myuservo"></param> /// <param name="starttime"></param> /// <param name="endtime"></param> /// <param name="startuid"></param> /// <param name="enduid"></param> /// <returns></returns> private static long 获取库存件数(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { string where = string.Empty; if (!starttime.IsNull() && !endtime.IsNull()) { where += " and HistoryTime between @starttime and @endtime"; } if (startuid.StrIsNotNull() && enduid.StrIsNotNull()) { where += " and beginUID=@beginUID and finishUID=@finishUID"; } else { startuid = string.Empty; enduid = string.Empty; } //获取接单数 sql = makesql.MakeSelectFieldSql(typeof(Model.Model.LC_History), new string[] { "count(Number)" }, $"State in({OrderStateEnum.已到收货地可提货.EnumToInt()},{OrderStateEnum.货物已中转.EnumToInt()}) and logisticsID=@logisticsID {where}", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logisticsID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@beginUID", startuid), new System.Data.SqlClient.SqlParameter("@finishUID", enduid) }); ids = db.Read(sql); if (!ids.flag) { return(0); } if (!ids.ReadIsOk()) { return(0); } return(ids.GetFristData <long>(0)); }
private static long 大车运费(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { string where = string.Empty; if (!starttime.IsNull() && !endtime.IsNull()) { where += " and HistoryTime between @starttime and @endtime"; } if (startuid.StrIsNotNull() && enduid.StrIsNotNull()) { where += " and beginUID=@beginUID and finishUID=@finishUID"; } else { startuid = string.Empty; enduid = string.Empty; } //获取回收汇总 sql = makesql.MakeSelectFieldSql(typeof(Model.Model.LC_History), new string[] { "sum(largeCar)" }, $"State<>@State {where}", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logisticsID", myuservo.uid), //与我相关 new System.Data.SqlClient.SqlParameter("@State", GlobalBLL.OrderStateEnum.已装车运输中.EnumToInt()) }); ids = db.Read(sql); if (!ids.flag) { return(0); } return(ids.GetFristData <long>(0)); }
public static (bool, string, object) GetPaidCount(UserLoginVO myuservo, int state, int page, int num) { var tlist = new Type[] { typeof(Model.Model.LC_Payment), typeof(Model.Model.LC_Customer), }; sql = makesql.MakeSelectFieldSql(tlist, new string[] { " SUM(LC_Customer.Freight) as Freight", "SUM(LC_Customer.GReceivables) as GReceivables" }, "{0}.OrderNumber={1}.OrderID and {0}.LocationLogisticsUID=@LocationLogisticsUID and {0}.LastState=@state", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@state", state), new System.Data.SqlClient.SqlParameter("@LocationLogisticsUID", myuservo.uid), }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new object[] { }); } return(true, string.Empty, new { Freight = ids.dt.Rows[0]["Freight"].ConvertData <decimal>(), GReceivables = ids.dt.Rows[0]["GReceivables"].ConvertData <decimal>() }); }
/// <summary> /// 员工授权 /// </summary> /// <param name="myuservo"></param> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public static (bool, string) EmployeeEmpowerment(UserLoginVO myuservo, long id, UserStateEnum state) { //查看此账号是否为您的账号 sql = makesql.MakeCount(nameof(Model.Model.LC_User), "id=@id and LCID=@LCID and ZType=@ZType", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", id), new System.Data.SqlClient.SqlParameter("@LCID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@ZType", GlobalBLL.AccountTypeEnum.物流公司员工账号.EnumToInt()) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { return(false, "当前数据错误,无法进行操作!"); } sql = makesql.MakeUpdateSQL(new Model.Model.LC_User() { State = state.EnumToInt() }, "id=@id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", id) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "操作失败!"); } return(true, string.Empty); }
/// <summary> /// 根据电话绑定物流 /// </summary> /// <param name="myuservo"></param> /// <param name="phone"></param> /// <returns></returns> public static Tuple <bool, string> UserAddFromPhone(UserLoginVO myuservo, string phone) { string LogisticsUid = string.Empty; //获取当前物流是否存在并获取数据 sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "Phone=@Phone", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Phone", phone) }, string.Empty, 1); ids = db.Read(sql); if (!ids.flag) { return(new Tuple <bool, string>(false, ids.errormsg)); } if (!ids.ReadIsOk()) { return(new Tuple <bool, string>(false, "当前电话号码的物流信息不存在!")); } Model.Model.LC_User lcu = ids.GetVOList <Model.Model.LC_User>()[0]; //判断是否为物流 if (lcu.ZType.ConvertData <GlobalBLL.AccountTypeEnum>() != AccountTypeEnum.物流账号) { return(new Tuple <bool, string>(false, "此电话并非物流公司电话,请检查电话是否正确!")); } LogisticsUid = lcu.UID; //检查此物流是否已经绑定过了 sql = makesql.MakeCount(nameof(Model.Model.LC_UserBindLogisticsList), "uid=@uid and LogisticsUid=@LogisticsUid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid), new System.Data.SqlClient.SqlParameter("@LogisticsUid", LogisticsUid) }); ids = db.Read(sql); if (!ids.flag) { return(new Tuple <bool, string>(false, ids.errormsg)); } if (ids.Count() > 0) { return(new Tuple <bool, string>(false, "当前物流已经绑定过了,无需重新绑定!")); } //开始绑定 Model.Model.LC_UserBindLogisticsList ubll = new Model.Model.LC_UserBindLogisticsList() { CreateTime = DateTime.Now, LogisticsUid = LogisticsUid, Uid = myuservo.uid }; sql = makesql.MakeInsertSQL(ubll); ids = db.Exec(sql); if (!ids.flag) { return(new Tuple <bool, string>(false, ids.errormsg)); } if (!ids.ExecOk()) { return(new Tuple <bool, string>(false, "绑定失败请重试!")); } return(new Tuple <bool, string>(true, string.Empty)); }
/// <summary> /// 根据电话添加物流 /// </summary> /// <param name="myuservo"></param> /// <param name="phone">电话号码</param> /// <returns></returns> public static Tuple <bool, string> UserAddFromPhone(UserLoginVO myuservo, string phone) { if (myuservo.accountType != AccountTypeEnum.普通用户账号) { return(new Tuple <bool, string>(false, "您的账号权限无法添加物流!")); } return(DAL.DAL.LC_UserBindLogisticsList.UserAddFromPhone(myuservo, phone)); }
/// <summary> /// 获取员工授权列表 /// </summary> /// <param name="myuservo"></param> /// <param name="page"></param> /// <param name="num"></param> /// <returns></returns> public static (bool, string, object) GetEmployeeEmpowermentList(UserLoginVO myuservo, int page, int num) { var tlist = new Type[] { typeof(Model.Model.LC_User), typeof(Model.Model.LC_Position) }; fysql = makesql.MakeSelectFY(tlist, "{0}.PositionID={1}.id and {0}.ZType=@ZType and {0}.LCID=@LCID and {0}.State=0", "{0}.id desc", page, num, "{0}.id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LCID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@ZType", GlobalBLL.AccountTypeEnum.物流公司员工账号.EnumToInt()) }); ids = db.Read(fysql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有获取到任何数据!", new { allcount = fysql.count, pagenum = 0, data = new object[] { } }); } return(true, string.Empty, new { allcount = fysql.count, pagenum = fysql.GetTotalPage(num), data = ids.GetVOList(tlist).Select((x) => { var lcu = x.GetDicVO <Model.Model.LC_User>(); var lcp = x.GetDicVO <Model.Model.LC_Position>(); return new { lcu.AreaID, lcu.CityID, lcu.CreateTime, lcu.ID, lcu.LogisticsName, lcu.Phone, lcu.PositionID, lcu.ProvincesID, lcu.UID, lcu.UserName, lcu.WX_City, lcu.WX_Country, lcu.WX_HeadPic, lcu.WX_NickName, lcu.WX_Province, lcu.WX_Sex, lcu.ZType, lcu.State, lcp.PositionName, }; }) }); }
/// <summary> /// 放款 /// </summary> /// <param name="myuservo"></param> /// <param name="orderList"></param> /// <returns></returns> public static (bool, string, object) LendersPayment(UserLoginVO myuservo, List <string> orderList) { var box = db.CreateTranSandbox((db) => { string ordernumberstr = orderList.Select(x => $"'{x}'").ToList().ListToString(); //检测这些订单我是否可以操作 sql = makesql.MakeSelectSql(typeof(Model.Model.LC_Payment), $"OrderNumber in ({ordernumberstr}) and StartLogisticsUID=@StartLogisticsUID and LocationLogisticsUID=@LocationLogisticsUID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LocationLogisticsUID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@StartLogisticsUID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (ids.num != orderList.Count) { return(false, "当前订单号中存在无法操作的数据!", null); } List <Model.Model.LC_Payment> pm_list = ids.GetVOList <Model.Model.LC_Payment>(); //更新这些数据为正常 sql = makesql.MakeUpdateSQL(new Model.Model.LC_Payment() { LastState = 2, LastOperationTime = DateTime.Now, LastOperatorsUID = myuservo.uid }, $"OrderNumber in ({ordernumberstr})"); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ExecOk()) { return(false, "更新状态失败!", null); } //更新到历史表 var atp = AddToPaymentHistory(ordernumberstr, db); if (!atp.Item1) { return(false, ids.errormsg, null); } db.Commit(); //提交事务 return(true, string.Empty, pm_list.Sum(x => x.PaymentAllAmount)); }); return(box); }
//日结账列表 public static (bool, string, object) GetPaymentDay(UserLoginVO myuservo, DateTime starttime, DateTime endtime) { var tlist = new Type[] { typeof(Model.Model.LC_Customer), typeof(Model.Model.LC_History), }; string where = string.Empty; where = " and {1}.HistoryTime between @starttime and @endtime"; string dqstarttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); string dqsendtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59"); if (starttime.IsNull() && endtime.IsNull()) { sql = makesql.MakeSelectArrSql(tlist, "{0}.OrderID={1}.OrderID and {1}.logisticsID=@logisticsID and {1}.State=@State" + where, new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logisticsID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@State", "6"), new System.Data.SqlClient.SqlParameter("@starttime", dqstarttime), new System.Data.SqlClient.SqlParameter("@endtime", dqsendtime) }); } else { sql = makesql.MakeSelectArrSql(tlist, "{0}.OrderID={1}.OrderID and {1}.logisticsID=@logisticsID and {1}.State=@State" + where, new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logisticsID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@State", "6"), new System.Data.SqlClient.SqlParameter("@starttime", starttime), new System.Data.SqlClient.SqlParameter("@endtime", endtime) }); } ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new object[] { }); } return(true, string.Empty, ids.GetVOList(tlist).Select(x => { var lcc = x.GetDicVO <Model.Model.LC_Customer>(); var lch = x.GetDicVO <Model.Model.LC_History>(); return new { lcc, lch, freightModeName = lcc.freightMode.ConvertData <GlobalBLL.YFFSEnum>().EnumToName() }; }).ToList()); }
/// <summary> /// 获取财务统计 /// </summary> /// <param name="myuservo"></param> /// <param name="starttime"></param> /// <param name="endtime"></param> /// <param name="startuid"></param> /// <param name="enduid"></param> /// <returns></returns> public static (bool, string, object) GetFinancialStatistics(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { GlobalBLL.VO.FinancialStatisticsVO fsvo = new GlobalBLL.VO.FinancialStatisticsVO() { ShangJiaoHuiZong = 获取上缴汇总(myuservo, starttime, endtime, startuid, enduid), WeiShangJiaoHuiZong = 获取未上缴汇总(myuservo, starttime, endtime, startuid, enduid), HuiShouHuiZong = 获取回收汇总(myuservo, starttime, endtime, startuid, enduid), WeiHuiShouHuiZong = 未回收汇总(myuservo, starttime, endtime, startuid, enduid), //更具总订单-已经回收订单,来计算的总数 YiJieSuanYunFei = 已结算运费(myuservo, starttime, endtime, startuid, enduid), WeiJieSuanYunFei = 未结算运费(myuservo, starttime, endtime, startuid, enduid), DaCheYunFei = 大车运费(myuservo, starttime, endtime, startuid, enduid), }; return(true, string.Empty, fsvo); }
/// <summary> /// 上缴货款或放款 /// </summary> /// <param name="myuservo"></param> /// <param name="orderlist"></param> /// <param name="model">1为上缴,2回收</param> /// <returns></returns> public static (bool, string) TurnedOrRecoveryPayment(UserLoginVO myuservo, List <string> orderlist, int model) { var box = db.CreateTranSandbox((db) => { //检测所有订单号是否我可以操作 sql = makesql.MakeSelectSql(typeof(Model.Model.LC_Payment), $"OrderNumber in ({orderlist.Where(y => y.StrIsNotNull()).Select(x=>$"'{x}'").ToList().ListToString()}) and LocationLogisticsUID=@LocationLogisticsUID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LocationLogisticsUID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.num != orderlist.Count) { return(false, "订单中存在您无法操作的数据!"); } //先判断这些订单是否都是需要上缴的订单(需要上缴则走上缴流程,不需要上缴则走放款流程) switch (model) { case 1: //上缴 var tup = TurnedPayment(myuservo, ids.GetVOList <Model.Model.LC_Payment>(), db); if (!tup.Item1) { return(false, tup.Item2); } break; case 2: //回收货款 var rp = RecoveryPayment(myuservo, ids.GetVOList <Model.Model.LC_Payment>(), db); if (!rp.Item1) { return(false, rp.Item2); } break; default: return(false, "状态不正确无法进行操作!"); } db.Commit(); return(true, string.Empty); }); return(box); }
/// <summary> /// 获取司机列表 /// </summary> /// <param name="myuservo"></param> /// <returns></returns> public static (bool, string, object) GetDriverList(UserLoginVO myuservo) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "PositionID=@PositionID and State=1 and LCID=@LCID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@PositionID", PositionEnum.驾驶员.EnumToInt()), new System.Data.SqlClient.SqlParameter("@LCID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new object[] { }); } return(true, string.Empty, ids.GetVOList <Model.Model.LC_User>()); }
/// <summary> /// 根据ID获取车辆数据 /// </summary> /// <param name="myuservo"></param> /// <param name="id"></param> /// <returns></returns> public static (bool, string, object) GetVehicleDataFromID(UserLoginVO myuservo, long id) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_Vehicle), "ID=@ID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", id) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(false, "没有获取到任何数据!", null); } Model.Model.LC_Vehicle lcv = ids.GetVOList <Model.Model.LC_Vehicle>()[0]; if (!lcv.UID.Equals(myuservo.uid, StringComparison.OrdinalIgnoreCase)) { return(false, "此车辆不在您的管辖范围内,无法进行查阅!", null); } List <Dictionary <string, I_ModelBase> > lcc_list = new List <Dictionary <string, I_ModelBase> >(); //获取数据 sql = makesql.MakeSelectArrSql(new Type[] { typeof(Model.Model.LC_VehicleBinding), typeof(Model.Model.LC_User) }, "{0}.DriverUID={1}.UID and {0}.VehicleID=@VehicleID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@VehicleID", id) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (ids.ReadIsOk()) { lcc_list = ids.GetVOList(new Type[] { typeof(Model.Model.LC_VehicleBinding), typeof(Model.Model.LC_User) }); } return(true, string.Empty, new { lcv, lcc_list }); }
/// <summary> /// 获取账号数据 /// </summary> /// <param name="myuservo"></param> /// <param name="id"></param> /// <returns></returns> public static (bool, string, object) GetAccountData(UserLoginVO myuservo, long id) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "id=@id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", id) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(false, "没有找到任何数据!", null); } var vo = ids.GetVOList <Model.Model.LC_User>()[0]; return(true, string.Empty, new { vo.AreaID, vo.CityID, vo.CreateTime, vo.ID, vo.LCID, vo.LogisticsName, vo.Phone, vo.PositionID, vo.ProvincesID, PositionName = GetPosition(vo.PositionID).Item3?.PositionName, vo.State, vo.UID, vo.UserName, vo.WX_City, vo.WX_Country, vo.WX_HeadPic, vo.WX_NickName, vo.WX_Province, vo.WX_Sex, vo.ZNumber, vo.ZType }); }
/// <summary> /// 获取线路授权列表 /// </summary> /// <param name="myuservo"></param> /// <param name="page"></param> /// <param name="num"></param> /// <returns></returns> public static (bool, string, object) GetLineAuthorizationList(UserLoginVO myuservo, int page, int num) { fysql = makesql.MakeSelectFY(typeof(Model.Model.LC_Line), "UID=@UID and State=0 and UID!=ApplicantUID", "id desc", page, num, "id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@UID", myuservo.uid) }); ids = db.Read(fysql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new { allcount = fysql.count, data = new object[] { } }); } return(true, string.Empty, new { allcount = fysql.count, data = ids.GetVOList <Model.Model.LC_Line>().Select((x) => { return new { x.ID, CreateTime = x.CreateTime.ConvertData <DateTime>().ToString("yyyy年MM月dd"), x.Lineletter, x.Start, x.End, StartName = DAL.DALBase.GetAllAddressToString(x.Start.ConvertData <int>()).Replace(" ", ""), EndName = DAL.DALBase.GetAllAddressToString(x.End.ConvertData <int>()).Replace(" ", ""), x.DFPhone, x.DFResponsibleName, x.State }; }) }); }
/// <summary> /// 获取我的线路列表 /// </summary> /// <param name="myuservo"></param> /// <returns></returns> public static (bool, string, object) GetMyLineList(UserLoginVO myuservo) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_Line), "UID=@UID and State=1", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@UID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new object[] { }); } return(true, string.Empty, ids.GetVOList <Model.Model.LC_Line>().Select((x) => { var startvo = DAL.DALBase.GetAllAddressNames(x.Start); var endvo = DAL.DALBase.GetAllAddressNames(x.End); return new { x.DFPhone, x.DFResponsibleName, x.Start, x.End, x.BindLogisticsUid, x.ID, x.LineID, x.Lineletter, x.MyPhone, x.MyResponsibleName, x.State, x.UID, start_sheng = startvo.sheng, start_shi = startvo.shi, start_qu = startvo.qu, end_sheng = endvo.sheng, end_shi = endvo.shi, end_qu = endvo.qu }; })); }
/// <summary> /// 上缴流程 /// </summary> /// <param name="myuservo"></param> /// <param name="orderlist"></param> private static (bool, string) TurnedPayment(UserLoginVO myuservo, List <Model.Model.LC_Payment> paymentlist, SuperDataBase.Model.DBSandbox db) { //检测是否有不是上缴货款的数据 var f = paymentlist.Where(x => x.StartLogisticsUID.Equals(x.LocationLogisticsUID, StringComparison.OrdinalIgnoreCase)).ToList(); if (f.Count > 0) { return(false, "当前操作存在非上缴货款项,操作失败!"); } //更新到上缴人 sql = new SuperDataBase.Vo.SqlVO($@"update a set LocationLogisticsIndex=(select top 1 ID from {nameof(Model.Model.LC_History)} where state in ({GlobalBLL.OrderStateEnum.已发货.EnumToInt()},{OrderStateEnum.已到收货地可提货.EnumToInt()}) and logisticsID=b.beginUID order by id asc) LocationLogisticsUID=b.beginUID , a.LastOperationTime=@LastOperationTime,a.LastOperatorsUID='{myuservo.uid}',a.LastState=0 FROM {nameof(Model.Model.LC_Payment)} a,{nameof(Model.Model.LC_History)} b where a.OrderNumber in ({paymentlist.Select(x => $"'{x.OrderNumber}'").ToList().ListToString()}) and a.OrderNumber=b.OrderID and b.State = {GlobalBLL.OrderStateEnum.订单完成.EnumToInt()} and LocationLogisticsUID=@LocationLogisticsUID;", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LocationLogisticsUID", myuservo.uid), new System.Data.SqlClient.SqlParameter("@LastOperationTime", DateTime.Now), //new System.Data.SqlClient.SqlParameter("@PaidTime",DateTime.Now) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "更新邀请人失败!"); } var atp = AddToPaymentHistory(paymentlist.Select(x => $"'{x.OrderNumber}'").ToList().ListToString(), db); if (!atp.Item1) { return(false, atp.Item2); } return(true, string.Empty); }
/// <summary> /// 验证是否需要注册 /// </summary> /// <param name="myuservo"></param> /// <returns></returns> public static (bool, string, object) GetToRegUser(UserLoginVO myuservo) { var vo = GetUserVoFromId(myuservo.id); if (!vo.Item1) { return(false, vo.Item2, null); } if (vo.Item3.ZNumber.StrIsNull()) { switch (myuservo.accountType) { case AccountTypeEnum.普通用户账号: case AccountTypeEnum.物流公司员工账号: case AccountTypeEnum.物流账号: break; default: return(false, "账号类型不符无法进行注册操作!", null); } return(true, string.Empty, new { IsReg = false, vo.Item3.ZType, vo.Item3.PositionID, }); } else { return(true, "不需要注册!", new { IsReg = true, //已注册 vo.Item3.ZType, vo.Item3.PositionID, }); } }
/// <summary> /// 获取接单数 /// </summary> /// <param name="myuservo"></param> /// <param name="starttime"></param> /// <param name="endtime"></param> /// <param name="startuid"></param> /// <param name="enduid"></param> /// <returns></returns> private static long 获取接单数(UserLoginVO myuservo, DateTime starttime, DateTime endtime) { string where = string.Empty; if (!starttime.IsNull() && !endtime.IsNull()) { where += " and HistoryTime between @starttime and @endtime"; } //获取接单数 sql = makesql.MakeSelectFieldSql(typeof(Model.Model.LC_History), new string[] { "count(Number)" }, $"State=@State and logisticsID=@logisticsID {where}", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@State", GlobalBLL.OrderStateEnum.物流已收货.EnumToInt()), new System.Data.SqlClient.SqlParameter("@logisticsID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(0); } if (!ids.ReadIsOk()) { return(0); } return(ids.GetFristData <long>(0)); }
/// <summary> /// 回收货款 /// </summary> /// <param name="myuservo"></param> /// <param name="paymentlist"></param> /// <returns></returns> private static (bool, string) RecoveryPayment(UserLoginVO myuservo, List <Model.Model.LC_Payment> paymentlist, SuperDataBase.Model.DBSandbox db) { string orderNumberStr = paymentlist.Select(x => $"'{x.OrderNumber}'").ToList().ListToString(); //检测是否有不是可回收货款的数据 var f = paymentlist.Where(x => x.LastState != 0).ToList(); if (f.Count > 0) { return(false, "当前操作存在不可回收的货款项,操作失败!"); } //执行回收操作 sql = makesql.MakeUpdateSQL(new Model.Model.LC_Payment() { LastState = 1, LastOperatorsUID = myuservo.uid }, $"OrderNumber in ({orderNumberStr})"); ids = db.Exec(sql); if (!ids.flag) { return(false, "修改回收数据失败!"); } if (!ids.ExecOk()) { return(false, "回收失败,请重试!"); } //添加历史记录 var atp = AddToPaymentHistory(orderNumberStr, db); if (!atp.Item1) { return(false, atp.Item2); } return(true, string.Empty); }
private static long 未回收汇总(UserLoginVO myuservo, DateTime starttime, DateTime endtime, string startuid, string enduid) { string where = string.Empty; if (!starttime.IsNull() && !endtime.IsNull()) { where += " and a.LastOperationTime between @starttime and @endtime"; } if (startuid.StrIsNotNull() && enduid.StrIsNotNull()) { where += " and b.beginUID=@beginUID and b.finishUID=@finishUID"; } else { startuid = string.Empty; enduid = string.Empty; } //获取与我相关的全部订单 sql = new SuperDataBase.Vo.SqlVO($@"SELECT count(OrderNumber) FROM {nameof(Model.Model.LC_Payment_History)} a, {nameof(Model.Model.LC_Customer)} b WHERE a.OrderNumber = b.OrderID AND b.finishUID ='{myuservo.uid}' {where} group by OrderNumber"); ids = db.Read(sql); if (!ids.flag) { return(0); } long allnum = ids.Count(); long yssnum = 获取回收汇总(myuservo, starttime, endtime, startuid, enduid); return(allnum - yssnum); }
public static (bool, string, object) GetMyVehicleList(UserLoginVO myuservo, int page, int num) { fysql = makesql.MakeSelectFY(typeof(Model.Model.LC_Vehicle), "UID=@UID and State=1", "id asc", page, num, "id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@UID", myuservo.uid) }); ids = db.Read(fysql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(true, "没有任何数据!", new { allcount = fysql.count, data = new object[] { } }); } return(true, string.Empty, new { allcount = fysql.count, data = ids.GetVOList <Model.Model.LC_Vehicle>() }); }
/// <summary> /// 普通账号绑定 /// </summary> /// <param name="nickName"></param> /// <param name="phone"></param> /// <param name="logistics"></param> /// <param name="sheng"></param> /// <param name="shi"></param> /// <param name="qu"></param> /// <returns></returns> public static (bool, string) OrdinaryAccountBind(UserLoginVO myuservo, string nickName, long phone, string logistics, int sheng, int shi, int qu) { var box = db.CreateTranSandbox((db) => { //检测此物流是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_User), "uid=@logistics and ztype=@ztype", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logistics", logistics), new System.Data.SqlClient.SqlParameter("@ztype", GlobalBLL.AccountTypeEnum.物流账号.EnumToInt()) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { return(false, "您要绑定的物流不存在!"); } //查看电话号是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_User), "Phone=@Phone", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Phone", phone) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() > 0) { return(false, "当前手机号已被使用!"); } //开始绑定 Model.Model.LC_User user = new Model.Model.LC_User() { UserName = nickName, ZNumber = phone.ToString(), State = 1, //默认开通 Phone = phone.ToString(), ProvincesID = sheng, CityID = shi, AreaID = qu, }; sql = makesql.MakeUpdateSQL(user, "uid=@uid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "绑定失败请重试!"); } //添加一个绑定记录 //查看是否已经绑定过当前物流UID sql = makesql.MakeCount(nameof(Model.Model.LC_UserBindLogisticsList), "uid=@uid and LogisticsUid=@LogisticsUid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LogisticsUid", logistics), new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { //添加一个物流绑定 sql = makesql.MakeInsertSQL(new Model.Model.LC_UserBindLogisticsList() { CreateTime = DateTime.Now, LogisticsUid = logistics, Uid = myuservo.uid }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "添加绑定失败请重试!"); } } db.Commit(); return(true, string.Empty); }); return(box); }
/// <summary> /// 员工账号绑定 /// </summary> /// <param name="myuservo"></param> /// <param name="nickName"></param> /// <param name="phone"></param> /// <param name="logistics">要绑定到的物流公司</param> /// <param name="bindvehicleid">绑定的车辆ID</param> /// <returns></returns> public static (bool, string) EmployeeAccountBind(UserLoginVO myuservo, string nickName, long phone, string logistics, long bindvehicleid) { var box = db.CreateTranSandbox((db) => { //检测此物流是否存在 sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "uid=@logistics and ztype=@ztype", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@logistics", logistics), new System.Data.SqlClient.SqlParameter("@ztype", GlobalBLL.AccountTypeEnum.物流账号.EnumToInt()) }, string.Empty, 1); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ReadIsOk()) { return(false, "您要绑定的物流不存在!"); } Model.Model.LC_User wl_user = ids.GetVOList <Model.Model.LC_User>()[0]; //查看电话号是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_User), "Phone=@Phone", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Phone", phone) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() > 0) { return(false, "当前手机号已被使用!"); } //开始绑定 Model.Model.LC_User user = new Model.Model.LC_User() { UserName = nickName, ZNumber = phone.ToString(), Phone = phone.ToString(), ProvincesID = wl_user.ProvincesID, CityID = wl_user.CityID, AreaID = wl_user.AreaID, LCID = logistics }; sql = makesql.MakeUpdateSQL(user, "uid=@uid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "绑定失败请重试!"); } //绑定车辆 if (bindvehicleid > 0) { //检测车辆是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_Vehicle), "id=@id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", bindvehicleid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() > 0) { //检测我是否绑定过此车辆 sql = makesql.MakeCount(nameof(Model.Model.LC_VehicleBinding), "VehicleID=@VehicleID and DriverUID=@DriverUID", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@VehicleID", bindvehicleid), new System.Data.SqlClient.SqlParameter("@DriverUID", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { //创建一个绑定 sql = makesql.MakeInsertSQL(new Model.Model.LC_VehicleBinding() { BindingTime = DateTime.Now, DriverUID = myuservo.uid, VehicleID = bindvehicleid }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "添加绑定失败,请重试!"); } //更新车辆为可用 sql = makesql.MakeUpdateSQL(new Model.Model.LC_Vehicle() { State = 1 }, "id=@id", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@id", bindvehicleid) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "更新车辆状态失败!"); } } } } db.Commit(); return(true, string.Empty); }); return(box); }
/// <summary> /// 物流公司账号绑定 /// </summary> /// <param name="myuservo"></param> /// <param name="nickName"></param> /// <param name="phone"></param> /// <param name="logistics">要绑定的物流总公司UID</param> /// <param name="sheng"></param> /// <param name="shi"></param> /// <param name="qu"></param> /// <param name="lineletter">货号字母</param> /// <returns></returns> public static (bool, string) LogisticsAccountBind(UserLoginVO myuservo, string nickName, long phone, string logistics, int sheng, int shi, int qu, string lineletter) { var box = db.CreateTranSandbox((db) => { //查看电话号是否存在 sql = makesql.MakeCount(nameof(Model.Model.LC_User), "Phone=@Phone", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@Phone", phone) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() > 0) { return(false, "当前手机号已被使用!"); } //开始绑定 Model.Model.LC_User user = new Model.Model.LC_User() { UserName = nickName, ZNumber = phone.ToString(), LogisticsName = nickName, Phone = phone.ToString(), LCID = logistics, ProvincesID = sheng, CityID = shi, AreaID = qu, State = 1 //State = logistics.StrIsNotNull() ? 0 : 1 }; sql = makesql.MakeUpdateSQL(user, "uid=@uid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid) }); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "绑定失败请重试!"); } //判断是否需要绑定线路 if (logistics.StrIsNotNull()) { //获取物流账号是否存在 sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "uid=@uid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", logistics) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ReadIsOk()) { return(false, "获取总公司账号错误无法进行操作!"); } Model.Model.LC_User df_user = ids.GetVOList <Model.Model.LC_User>()[0]; if (df_user.ZType.ConvertData <GlobalBLL.AccountTypeEnum>() != AccountTypeEnum.物流账号) { return(false, "权限错误,无法绑定到总公司!"); } //开始双方绑定 //查看我是否绑定过此物流 sql = makesql.MakeCount(nameof(Model.Model.LC_Line), "uid=@uid and BindLogisticsUid=@BindLogisticsUid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", myuservo.uid), new System.Data.SqlClient.SqlParameter("@BindLogisticsUid", logistics) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { //绑定自己的 Model.Model.LC_Line myline = new Model.Model.LC_Line() { CreateTime = DateTime.Now, Start = qu, End = df_user.AreaID, LineID = Tools.NewGuid.GuidTo16String(), Lineletter = lineletter, MyPhone = phone.ConvertData(), MyResponsibleName = nickName, DFPhone = df_user.Phone, DFResponsibleName = df_user.UserName, UID = myuservo.uid, BindLogisticsUid = logistics, State = 0, ApplicantUID = myuservo.uid }; sql = makesql.MakeInsertSQL(myline); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "绑定对方物流数据失败!"); } } //查看对方是否绑定过我的物流 sql = makesql.MakeCount(nameof(Model.Model.LC_Line), "uid=@uid and BindLogisticsUid=@BindLogisticsUid", new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@uid", logistics), new System.Data.SqlClient.SqlParameter("@BindLogisticsUid", myuservo.uid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg); } if (ids.Count() == 0) { //绑定对方物流 Model.Model.LC_Line dfline = new Model.Model.LC_Line() { Start = df_user.AreaID, End = qu, Lineletter = string.Empty, DFPhone = phone.ConvertData(), DFResponsibleName = nickName, MyPhone = df_user.Phone, MyResponsibleName = df_user.UserName, UID = logistics, BindLogisticsUid = myuservo.uid, State = 0, CreateTime = DateTime.Now, LineID = Tools.NewGuid.GuidTo16String(), ApplicantUID = myuservo.uid }; sql = makesql.MakeInsertSQL(dfline); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "绑定您的物流数据失败!"); } } } db.Commit(); return(true, string.Empty); }); return(box); }