/// <summary> /// 添加到放款历史 /// </summary> /// <param name="orderNumberStr"></param> /// <returns></returns> private static (bool, string) AddToPaymentHistory(string orderNumberStr, SuperDataBase.Model.DBSandbox db) { string F_LC_Payment = SuperDataBase.Model.TableFieldCache.GetFieldList(typeof(Model.Model.LC_Payment)).Select(x => x.Name).Where((y) => { if (!y.Equals("id", StringComparison.OrdinalIgnoreCase)) { return(true); } return(false); }).ToList().ListToString(); sql = new SuperDataBase.Vo.SqlVO($"INSERT INTO {nameof(Model.Model.LC_Payment_History)} ({F_LC_Payment}) SELECT {F_LC_Payment} FROM {nameof(Model.Model.LC_Payment)} where OrderNumber in ({orderNumberStr})"); ids = db.Exec(sql); if (!ids.flag) { return(false, ids.errormsg); } if (!ids.ExecOk()) { return(false, "更新上缴历史失败!"); } return(true, string.Empty); }
/// <summary> /// 根据ID获取用户数据 /// </summary> /// <param name="id"></param> /// <param name="db"></param> /// <returns></returns> internal static Tuple <bool, string, Model.Model.LC_User> GetUserVoFromId(long id, SuperDataBase.Model.DBSandbox db) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "id=@id", new SqlParameter[] { new SqlParameter("@id", id) }, string.Empty, 1); ids = db.Read(sql); if (!ids.flag) { return(new Tuple <bool, string, Model.Model.LC_User>(false, ids.errormsg, null)); } if (!ids.ReadIsOk()) { return(new Tuple <bool, string, Model.Model.LC_User>(false, "没有任何数据!", null)); } return(new Tuple <bool, string, Model.Model.LC_User>(true, string.Empty, ids.GetVOList <Model.Model.LC_User>()[0])); }
/// <summary> /// 根据OPENID获取用户数据 /// </summary> /// <param name="openid"></param> /// <returns></returns> public static (bool, string, Model.Model.LC_User) GetUserVOFromOpenID(string openid, SuperDataBase.Model.DBSandbox db) { sql = makesql.MakeSelectSql(typeof(Model.Model.LC_User), "wx_openid=@wx_openid", new SqlParameter[] { new SqlParameter("@wx_openid", openid) }); ids = db.Read(sql); if (!ids.flag) { return(false, ids.errormsg, null); } if (!ids.ReadIsOk()) { return(false, "没有找到任何数据!", null); } return(true, string.Empty, ids.GetVOList <Model.Model.LC_User>()[0]); }
/// <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> /// <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); }