/// <summary> /// 查询用户租赁信息 /// </summary> /// <param name="Row"></param> /// <returns></returns> public string RentalHistoryList(DataRow Row) { string backstr = ""; DataTable dt = null; try { string ConnStr = ConnectionDb.GetUnifiedConnectionString(); string UserId = Row["UserId"].ToString(); IDbConnection com = new SqlConnection(ConnStr); //Tb_User User = com.Query<Tb_User>("select * from Tb_User where Id=@Id", new { Id = UserId }).ToList<Tb_User>().SingleOrDefault(); //if (User==null) //{ // return JSONHelper.FromString(false, "该用户不存在"); //} int page = AppGlobal.StrToInt(Row["Page"].ToString()); int row = AppGlobal.StrToInt(Row["PageSize"].ToString()); dt = BaseGetData.GetList(ConnStr, " and UserId='" + UserId + "'", page, row, "RegisterDate", 0, "View_Tb_Rental", "Id").Tables[0]; } catch (Exception ex) { backstr = ex.Message; } if (backstr == "") { return(JSONHelper.FromString(dt)); } else { return(JSONHelper.FromString(false, backstr)); } }
//新增房屋出租或房屋转让 public string RentalNew(DataRow Row) { string backstr = ""; try { decimal Amount = 0.0m, Rent = 0.0m; if (Row.Table.Columns.Contains("Price") && !string.IsNullOrEmpty(Row["Price"].ToString())) { Amount = AppGlobal.StrToDec(Row["Price"].ToString()); } if (Row["BussType"].ToString() == "租售") { Rent = Amount; Amount = 0.0m; } string ConnStr = ConnectionDb.GetUnifiedConnectionString(); IDbConnection Conn = new SqlConnection(ConnStr); string Query = @"INSERT INTO Tb_Rental (Id,CommunityId,BussType,LinkMan,Province,City,Area,Address,Mobile,Img,UserId,ProcessState,Amount,Rent,RegisterDate,RegisterMan) VALUES (@Id,@CommunityId,@BussType,@LinkMan,@Province,@City,@Area,@Address,@Mobile,@Img,@UserId,'受理',@Amount,@Rent,getdate(),@LinkMan)"; Conn.Execute(Query, new { Id = Guid.NewGuid().ToString(), CommunityId = Row["CommunityId"].ToString(), BussType = Row["BussType"].ToString(), LinkMan = Row["LinkMan"].ToString(), Province = Row["Province"].ToString(), City = Row["City"].ToString(), Area = Row["Area"].ToString(), Address = Row["Address"].ToString(), Mobile = Row["Mobile"].ToString(), Img = Row["Img"].ToString(), UserId = Row["UserId"].ToString(), Amount = Amount, Rent = Rent }); } catch (Exception ex) { backstr = ex.Message; } if (backstr == "") { return(JSONHelper.FromString(true, "success")); } else { return(JSONHelper.FromString(false, backstr)); } }
private string GetRentalTop(DataRow Row) { string backstr = ""; DataTable dt = null; try { string ConnStr = ConnectionDb.GetUnifiedConnectionString(); StringBuilder sb = new StringBuilder(); if (Row.Table.Columns.Contains("AppleBundleID") && Row["AppleBundleID"].ToString() != "")//苹果包名 { sb.AppendFormat(" AND CommunityId in(select Id from Tb_Community where AppleBundleID = '{0}') ", Row["AppleBundleID"]); } if (Row.Table.Columns.Contains("AndroidPackageName") && Row["AndroidPackageName"].ToString() != "")//安桌包名 { sb.AppendFormat(" AND CommunityId in(select Id from Tb_Community where AndroidPackageName = '{0}') ", Row["AndroidPackageName"]); } sb.AppendFormat(" AND ProcessState='发布' AND BussType='{0}'", Row["BussType"].ToString()); if (Row["BussType"].ToString() == "租售") { sb.AppendFormat(@" AND (convert(NVARCHAR(20),Rent) <> '面议' OR (convert(DECIMAL(18,2), replace(rent, '面议', '0'))>=0 AND convert(DECIMAL(18,2), replace(rent, '面议', '0'))<=99999999) OR Rent IS NULL)"); } if (Row["BussType"].ToString() == "转让") { sb.AppendFormat(" AND ((Amount>=0 AND Amount<=99999999) OR Amount IS NULL)"); } int page = 1; int row = 5; dt = BaseGetData.GetList(ConnStr, sb.ToString(), page, row, "RegisterDate", 1, "View_Tb_Rental", "Id").Tables[0]; } catch (Exception ex) { backstr = ex.Message; } if (backstr == "") { return(JSONHelper.FromString(dt)); } else { return(JSONHelper.FromString(false, backstr)); } }
//房屋租赁列表 public string RentalList(DataRow Row) { string backstr = ""; DataTable dt = null; try { string ConnStr = ConnectionDb.GetUnifiedConnectionString(); StringBuilder sb = new StringBuilder(); if (Row.Table.Columns.Contains("CommunityId") && Row["CommunityId"].ToString() != "") { sb.AppendFormat(" AND CommunityId='{0}'", Row["CommunityId"].ToString()); } else { if (string.IsNullOrEmpty(Row["City"].ToString()) == false) { sb.AppendFormat(" AND (City LIKE '%{0}%' OR Province LIKE '%{0}%')", Row["City"].ToString().Replace("市", "")); } if (Row.Table.Columns.Contains("AppleBundleID") && Row["AppleBundleID"].ToString() != "")//苹果包名 { sb.AppendFormat(" AND CommunityId in(select Id from Tb_Community where AppleBundleID = '{0}') ", Row["AppleBundleID"]); } if (Row.Table.Columns.Contains("AndroidPackageName") && Row["AndroidPackageName"].ToString() != "")//安桌包名 { sb.AppendFormat(" AND CommunityId in(select Id from Tb_Community where AndroidPackageName = '{0}') ", Row["AndroidPackageName"]); } } sb.AppendFormat(" AND ProcessState='发布' AND BussType='{0}'", Row["BussType"].ToString()); if (string.IsNullOrEmpty(Row["HouseType"].ToString()) == false) { sb.AppendFormat(" AND HouseType LIKE '%{0}%'", Row["HouseType"].ToString()); } if (Row["BussType"].ToString() == "租售") { sb.AppendFormat(@" AND (convert(NVARCHAR(20),Rent) <> '面议' AND (convert(DECIMAL(18,2), replace(rent, '面议', '0'))>={0} AND convert(DECIMAL(18,2), replace(rent, '面议', '0'))<={1}) OR Rent IS NULL)", Row["StartAmount"].ToString(), Row["EndAmount"].ToString()); } if (Row["BussType"].ToString() == "转让") { sb.AppendFormat(" AND ((Amount>={0} AND Amount<={1}) OR Amount IS NULL)", Row["StartAmount"].ToString(), Row["EndAmount"].ToString()); } int page = AppGlobal.StrToInt(Row["Page"].ToString()); int row = AppGlobal.StrToInt(Row["PageSize"].ToString()); dt = BaseGetData.GetList(ConnStr, sb.ToString(), page, row, "RegisterDate", 1, "View_Tb_Rental", "Id").Tables[0]; } catch (Exception ex) { backstr = ex.Message; } if (backstr == "") { return(JSONHelper.FromString(dt)); } else { return(JSONHelper.FromString(false, backstr)); } }
/// <summary> /// 生成商家订单 /// </summary> /// <param name="Ds"></param> /// <param name="BussId"></param> /// <param name="UserId"></param> /// <param name="txnTime"></param> /// <param name="IsOk"></param> /// <param name="Amount"></param> /// <param name="OrderId"></param> /// <returns></returns> public string GenerateBusinessOrder(DataSet Ds, string communityId, string BussId, string UserId, string txnTime, ref bool IsOk, ref string Amount, ref string OrderId, WxPayConfig wxPayConfig) { DataRow Row = Ds.Tables[0].Rows[0]; IDbConnection Conn = new SqlConnection(ConnectionDb.GetBusinessConnection()); string BusinessOrderId = Guid.NewGuid().ToString(); //生成商家收款订单 string Id = Guid.NewGuid().ToString(); Tb_Charge_Receipt EntityReceipt = new Tb_Charge_Receipt(); EntityReceipt.Id = Id; EntityReceipt.BussId = BussId.ToString(); EntityReceipt.OrderId = BusinessOrderId; // 是否使用抵扣券 if (Row.Table.Columns.Contains("UseCoupon")) { EntityReceipt.IsUseCoupon = AppGlobal.StrToInt(Row["UseCoupon"].ToString()); } OrderId = BusinessOrderId; string ReceiptSign = "";//获得订单号 //获取票据号 DynamicParameters dp = new DynamicParameters(); dp.Add("@Id", BussId); dp.Add("@OrderLength", 32); dp.Add("@Num", "", DbType.String, ParameterDirection.Output); using (IDbConnection IDbConn = new SqlConnection(ConnectionDb.GetBusinessConnection())) { IDbConn.Execute("Proc_GetOrderNum", dp, null, null, CommandType.StoredProcedure); ReceiptSign = dp.Get <string>("@Num"); } EntityReceipt.ReceiptSign = ReceiptSign.ToString(); EntityReceipt.UserId = UserId.ToString(); IDbConnection ConnUnified = new SqlConnection(ConnectionDb.GetUnifiedConnectionString()); string QueryUser = "******"; Tb_User EntityUser = ConnUnified.Query <Tb_User>(QueryUser, new { UserId = UserId }).SingleOrDefault(); //查找用户名称 EntityReceipt.Name = EntityUser.Name.ToString(); EntityReceipt.Mobile = EntityUser.Mobile.ToString(); EntityReceipt.IsPay = "未付款"; EntityReceipt.IsReceive = "未收货"; EntityReceipt.Amount = 0; EntityReceipt.ReceiptMemo = Row["ReceiptMemo"].ToString(); EntityReceipt.ReceiptType = "通用票据"; EntityReceipt.ReceiptDate = DateTime.Now; EntityReceipt.MchId = wxPayConfig.MCHID; EntityReceipt.Partner = wxPayConfig.MCHID; EntityReceipt.PrepayStr = ""; EntityReceipt.txnTime = txnTime.ToString(); EntityReceipt.ReturnCode = ""; EntityReceipt.ReturnMsg = ""; EntityReceipt.IsDeliver = "未发货"; EntityReceipt.Express = ""; EntityReceipt.ExpressNum = ""; EntityReceipt.DeliverAddress = ""; EntityReceipt.PayDate = DateTime.Now; EntityReceipt.IsDelete = 0; Conn.Insert(EntityReceipt); if (!string.IsNullOrEmpty(communityId)) { Conn.Execute("UPDATE Tb_Charge_Receipt SET CommunityId=@CommunityId WHERE ID=@IID", new { CommunityId = communityId, IID = EntityReceipt.Id }); } decimal TotalAmount = 0.00M; //收成商家收款明细 foreach (DataRow DetailRow in Ds.Tables[1].Rows) { Tb_Charge_ReceiptDetail EntityReceiptDetail = new Tb_Charge_ReceiptDetail(); EntityReceiptDetail.RpdCode = Guid.NewGuid().ToString(); EntityReceiptDetail.ReceiptCode = Id; EntityReceiptDetail.ResourcesID = DetailRow["Id"].ToString(); EntityReceiptDetail.Quantity = DataSecurity.StrToInt(DetailRow["Quantity"].ToString()); string QueryResourcesSql = "SELECT * FROM Tb_Resources_Details WHERE ResourcesID=@ResourcesID"; Tb_Resources_Details T = Conn.Query <Tb_Resources_Details>(QueryResourcesSql, new { ResourcesID = DetailRow["Id"].ToString() }).SingleOrDefault(); EntityReceiptDetail.SalesPrice = T.ResourcesSalePrice; EntityReceiptDetail.DiscountPrice = T.ResourcesDisCountPrice; EntityReceiptDetail.GroupPrice = T.GroupBuyPrice; EntityReceiptDetail.DetailAmount = T.ResourcesSalePrice - T.ResourcesDisCountPrice; EntityReceiptDetail.RpdMemo = DetailRow["RpdMemo"].ToString(); Conn.Insert(EntityReceiptDetail); //计算订单的总金额 TotalAmount = TotalAmount + DataSecurity.StrToDecimal(EntityReceiptDetail.DetailAmount.ToString()); } //更新订单总金额 EntityReceipt.Amount = TotalAmount; Amount = Convert.ToString(TotalAmount * 100); IsOk = true; Conn.Update(EntityReceipt); return("生成订单成功"); }