//整合随机获取的奖金信息 public Coupon_Random GetBonus(Coupon_Random CounponDetail, UserWeiXin User) { int MaxValue = CounponDetail.MaxReceive; int RandomMoney = new Random().Next(1, MaxValue); RandomMoney = CounponDetail.TotalAmount - CounponDetail.UsedAmount > RandomMoney ? RandomMoney : CounponDetail.TotalAmount - CounponDetail.UsedAmount; Coupon_Random Detail = new Coupon_Random(); Detail.id = CounponDetail.id; Detail.weixinID = CounponDetail.weixinID; Detail.Price = RandomMoney; Detail.sTime = CounponDetail.sTime; Detail.eTime = CounponDetail.eTime; Detail.weixinUserID = User.OpenId; Detail.Province = User.Province; Detail.City = User.City; Detail.Country = User.Country; Detail.NickName = User.NickName; Detail.UserImg = User.HeadImgUrl; Detail.Sex = User.Sex; return(Detail); }
//提交奖金信息 public bool SaveInfo(Coupon_Random Info) { try { #region string sql = @" INSERT INTO [WeiXin].[dbo].[UserRadomCoupons_wkn] ([id] ,[weixinID] ,[weixinUserID] ,[Price] ,[sTime] ,[eTime] ,[UserImg] ,[Province] ,[City] ,[Country] ,[Sex] ,[NickName] ,[TelPhone] ) VALUES (@id ,@weixinID ,@weixinUserID ,@Price ,@sTime ,@eTime ,@UserImg ,@Province ,@City ,@Country ,@Sex ,@NickName ,@TelPhone ) "; #endregion SQLHelper.Run_SQL(sql, SQLHelper.Open_Conn(conn), new Dictionary <string, DBParam> { { "id", new DBParam { ParamValue = Info.id.ToString() } }, { "weixinID", new DBParam { ParamValue = Info.weixinID } }, { "weixinUserID", new DBParam { ParamValue = Info.weixinUserID } }, { "Price", new DBParam { ParamValue = Info.Price.ToString() } }, { "sTime", new DBParam { ParamValue = Info.sTime.ToString() } }, { "eTime", new DBParam { ParamValue = Info.eTime.ToString() } }, { "UserImg", new DBParam { ParamValue = Info.UserImg } }, { "Province", new DBParam { ParamValue = Info.Province } }, { "City", new DBParam { ParamValue = Info.City } }, { "Country", new DBParam { ParamValue = Info.Country } }, { "Sex", new DBParam { ParamValue = Info.Sex } }, { "NickName", new DBParam { ParamValue = Info.NickName } }, { "TelPhone", new DBParam { ParamValue = Info.TelPhone } } }); return(true); } catch { } return(false); }