public static string Insert(string football_tournament_id, string year, string name, string start_datetime, string end_datetime, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("football_tournament_id", football_tournament_id); dict.Add("year", year); dict.Add("name", name); dict.Add("start_datetime", start_datetime); dict.Add("end_datetime", end_datetime); DBHelper.Insert("football_round", dict); return(string.Empty); }
public static string Update(string id, string title, string detail, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("title", title); dict.Add("detail", detail); IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("sys_question", dict, fdict, "and"); return(string.Empty); }
public static string Insert(string football_round_id, string start_datetime, string home_football_team_id, string away_football_team_id, string vote_deadline, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("football_round_id", football_round_id); dict.Add("start_datetime", start_datetime); dict.Add("home_football_team_id", home_football_team_id); dict.Add("away_football_team_id", away_football_team_id); dict.Add("vote_deadline", vote_deadline); DBHelper.Insert("football_match", dict); return(string.Empty); }
public static string Update(string id, string sys_user_id, string match_result_id, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DataSet ds = DBHelper.Select("football_round_chain_vote_invite", "sys_user_id,football_round_chain_vote_id", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("找不到接龙记录"); } if (ds.Tables[0].Rows[0][0].ToString().Length > 0 && (!ds.Tables[0].Rows[0][0].ToString().Equals(sys_user_id))) { return("别人已接龙"); } string football_round_chain_vote_id = ds.Tables[0].Rows[0][1].ToString(); using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("sys_user_id", sys_user_id); dict.Add("match_result_id", match_result_id); dict.Add("vote_datetime", DateTime.Now.ToString()); fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("football_round_chain_vote_invite", dict, fdict, "and", dbConnection, trans); dict = new Dictionary <string, string>(); dict.Add("participant_need", "数字相减-1"); fdict = new Dictionary <string, string>(); fdict.Add("id", football_round_chain_vote_id); DBHelper.Update("football_round_chain_vote", dict, fdict, "and", dbConnection, trans); trans.Commit(); } } return(string.Empty); }
public static string Insert(string title, string description, string price, string inventory, string off_shelf_datetime, string odr, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("title", title); dict.Add("description", description); dict.Add("price", price); dict.Add("inventory", inventory); dict.Add("off_shelf_datetime", off_shelf_datetime); dict.Add("odr", odr); DBHelper.Insert("gift", dict); return(string.Empty); }
public static string Update(string id, string name, string odr, string delete_flag, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("name", name); dict.Add("odr", odr); dict.Add("delete_flag", delete_flag); IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("dict_football_team", dict, fdict, "and"); return(string.Empty); }
public static string Insert(string gift_id, string title, string description, string min_bid_amount, string start_datetime, string end_datetime, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("gift_id", gift_id); dict.Add("title", title); dict.Add("description", description); dict.Add("min_bid_amount", min_bid_amount); dict.Add("start_datetime", start_datetime); dict.Add("end_datetime", end_datetime); DBHelper.Insert("gift_auction", dict); return(string.Empty); }
public static DataSet GetAll(string gift_id, string title, string pageSize, string pageIndex, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); if (gift_id.Length > 0) { fdict.Add("gift_id", gift_id); } if (title.Length > 0) { fdict.Add("title", "%" + title + "%"); } return(DBHelper.SelectPager("gift_auction_view", "*", string.Empty, fdict, "and", pageSize, pageIndex)); }
public static DataSet GetAll(string football_round_id, string pageSize, string pageIndex, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); if (football_round_id.Length > 0) { fdict.Add("football_round_id", football_round_id); } if (pageSize.Length == 0) { return(DBHelper.Select("football_round", "*", "odr,id", fdict, "and")); } return(DBHelper.SelectPager("football_round_chain", "*", "odr,id", fdict, "and", pageSize, pageIndex)); }
public static string Insert(string football_round_id, string name, string participant_amount, string gift_id, string price, string vote_deadline, string odr, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("football_round_id", football_round_id); dict.Add("name", name); dict.Add("participant_amount", participant_amount); dict.Add("gift_id", gift_id); dict.Add("price", price); dict.Add("vote_deadline", vote_deadline); dict.Add("odr", odr); DBHelper.Insert("football_round_chain", dict); return(string.Empty); }
public static DataSet GetAll(string delete_flag, string pageSize, string pageIndex, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); if (delete_flag.Length > 0) { fdict.Add("delete_flag", delete_flag); } if (pageSize.Length == 0) { return(DBHelper.Select("dict_football_team", "*", "odr,id", fdict, "and")); } return(DBHelper.SelectPager("dict_football_team", "*", "odr,id", fdict, "and", pageSize, pageIndex)); }
public static string Update(string id, string title, string description, string min_bid_amount, string start_datetime, string end_datetime, string delete_flag, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("title", title); dict.Add("description", description); dict.Add("min_bid_amount", min_bid_amount); dict.Add("start_datetime", start_datetime); dict.Add("end_datetime", end_datetime); dict.Add("delete_flag", delete_flag); IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("gift_auction", dict, fdict, "and"); return(string.Empty); }
public static string UpdateInfo(string id, string name, string phone, string address, string email, string qq, string weixin, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("name", name); dict.Add("phone", phone); dict.Add("address", address); dict.Add("email", email); dict.Add("qq", qq); dict.Add("weixin", weixin); IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("sys_user", dict, fdict, "and"); return(string.Empty); }
public static string Update(string id, string title, string description, string price, string inventory, string off_shelf_datetime, string odr, string delete_flag, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("title", title); dict.Add("description", description); dict.Add("price", price); dict.Add("inventory", inventory); dict.Add("off_shelf_datetime", off_shelf_datetime); dict.Add("odr", odr); dict.Add("delete_flag", delete_flag); IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("gift", dict, fdict, "and"); return(string.Empty); }
public static string Insert(string sys_user_id, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("sys_user_id", sys_user_id); fdict.Add("check_in_date", DateTime.Today.ToString("yyyy-MM-dd")); if (DBHelper.SelectRowCount("check_in", fdict, "and") > 0) { return("请不要重复签到"); } using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("sys_user_id", sys_user_id); dict.Add("check_in_date", DateTime.Today.ToString("yyyy-MM-dd")); DBHelper.Insert("check_in", dict, dbConnection, trans); dict = new Dictionary <string, string>(); dict.Add("balance", "数字相加+1"); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); sys_user_balance_change.Insert(sys_user_id, "5", "1", "签到赢1爱心", string.Empty, string.Empty, dbConnection, trans); trans.Commit(); } } return(string.Empty); }
public static string Insert(string name, string odr, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("name", name); if (DBHelper.SelectRowCount("dict_football_team", fdict, "or") > 0) { return("该球队已存在"); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("name", name); dict.Add("odr", odr); DBHelper.Insert("dict_football_team", dict); return(string.Empty); }
public static DataSet GetRandomMatch(string football_tournament_id, string year, string today, string amount, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("football_tournament_id", football_tournament_id); fdict.Add("year", year); fdict.Add("start_datetime", "<=" + today); fdict.Add("end_datetime", ">=" + today + " 23:59:59"); DataSet ds = DBHelper.Select("football_round", "id", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count != 1) { return(sys_dict.GetEmptyDs()); } string football_round_id = ds.Tables[0].Rows[0][0].ToString(); fdict = new Dictionary <string, string>(); fdict.Add("football_round_id", football_round_id); fdict.Add("vote_deadline", ">'" + today + "'"); ds = DBHelper.Select("football_match_view", "*", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count < Convert.ToInt32(amount)) { return(sys_dict.GetEmptyDs()); } for (int i = 0; i < ds.Tables[0].Rows.Count - Convert.ToInt32(amount); i++) { Random rd = new Random(DateTime.Now.Minute * DateTime.Now.Second * DateTime.Now.Millisecond); ds.Tables[0].Rows.RemoveAt(rd.Next(0, ds.Tables[0].Rows.Count - 1)); } return(ds); }
public static string Update(string id, string role_id, string name, string phone, string address, string email, string qq, string weixin, string reference_sys_user_login_name, string delete_flag, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = null; string reference_sys_user_id = string.Empty; if (reference_sys_user_login_name.Length > 0) { fdict = new Dictionary <string, string>(); fdict.Add("login_name", reference_sys_user_login_name); fdict.Add("delete_flag", "IS NULL"); DataSet ds = DBHelper.Select("sys_user", "id", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("推荐人不存在"); } reference_sys_user_id = ds.Tables[0].Rows[0]["id"].ToString(); } IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("role_id", role_id); dict.Add("name", name); dict.Add("phone", phone); dict.Add("address", address); dict.Add("email", email); dict.Add("qq", qq); dict.Add("weixin", weixin); dict.Add("reference_sys_user_id", reference_sys_user_id); dict.Add("delete_flag", delete_flag); fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("sys_user", dict, fdict, "and"); return(string.Empty); }
public static DataSet GetAll(string football_match_id, string sys_user_id, string match_score_type_id, string pageSize, string pageIndex, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); if (football_match_id.Length > 0) { fdict.Add("football_match_id", football_match_id); } if (sys_user_id.Length > 0) { fdict.Add("sys_user_id", sys_user_id); } if (match_score_type_id.Length > 0) { fdict.Add("match_score_type_id", match_score_type_id); } return(DBHelper.SelectPager("football_match_score_view", "*", string.Empty, fdict, "and", pageSize, pageIndex)); }
public static DataSet GetAll(string sys_user_id, string check_in_dates, string check_in_datee, string pageSize, string pageIndex, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return(sys_dict.GetEmptyDs()); } IDictionary <string, string> fdict = new Dictionary <string, string>(); if (sys_user_id.Length > 0) { fdict.Add("sys_user_id", sys_user_id); } if (check_in_dates.Length > 0) { fdict.Add("check_in_date", ">=" + check_in_dates); } if (check_in_datee.Length > 0) { fdict.Add("重复字段A重复字段check_in_date", "<=" + check_in_datee + " 23:59:59"); } return(DBHelper.SelectPager("check_in_view", "*", "id desc", fdict, "and", pageSize, pageIndex)); }
public static string Insert(string football_match_id, string sys_user_id, string match_score_type_id, string amount, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } if (amount.Length == 0 || Convert.ToInt32(amount) <= 0) { return("竞拍额异常"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); fdict.Add("delete_flag", "IS NULL"); DataSet ds = DBHelper.Select("sys_user", "balance", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("用户不存在"); } if (Convert.ToInt32(ds.Tables[0].Rows[0]["balance"]) < Convert.ToInt32(amount)) { return("爱心不足"); } fdict = new Dictionary <string, string>(); fdict.Add("id", football_match_id); fdict.Add("vote_deadline", ">='" + DateTime.Now.ToString() + "'"); ds = DBHelper.Select("football_match_view", "id,football_round_name,home_football_team_name,away_football_team_name", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("竞猜已结束"); } string round_name = ds.Tables[0].Rows[0]["football_round_name"].ToString(); string home_football_team_name = ds.Tables[0].Rows[0]["home_football_team_name"].ToString(); string away_football_team_name = ds.Tables[0].Rows[0]["away_football_team_name"].ToString(); fdict = new Dictionary <string, string>(); fdict.Add("football_match_id", football_match_id); fdict.Add("sys_user_id", sys_user_id); ds = DBHelper.Select("football_match_score", "id,match_score_type_id,amount", string.Empty, fdict, "and"); using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); if (ds.Tables[0].Rows.Count == 0) { dict.Add("football_match_id", football_match_id); dict.Add("sys_user_id", sys_user_id); dict.Add("match_score_type_id", match_score_type_id); dict.Add("amount", amount); dict.Add("vote_datetime", DateTime.Now.ToString()); DBHelper.Insert("football_match_score", dict, dbConnection, trans); } else { if (amount.Equals(ds.Tables[0].Rows[0]["amount"].ToString()) && match_score_type_id.Equals(ds.Tables[0].Rows[0]["match_score_type_id"].ToString())) { return(string.Empty); } dict.Add("match_score_type_id", match_score_type_id); dict.Add("amount", amount); dict.Add("vote_datetime", DateTime.Now.ToString()); fdict = new Dictionary <string, string>(); fdict.Add("id", ds.Tables[0].Rows[0]["id"].ToString()); DBHelper.Update("football_match_score", dict, fdict, "and", dbConnection, trans); amount = (Convert.ToInt32(amount) - Convert.ToInt32(ds.Tables[0].Rows[0]["amount"])).ToString(); } dict = new Dictionary <string, string>(); dict.Add("balance", "数字相减-" + amount); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); sys_user_balance_change.Insert(sys_user_id, "7", "-" + amount, round_name + " " + home_football_team_name + "VS" + away_football_team_name + " " + dict_match_score_type.GetName(match_score_type_id), "football_match", football_match_id, dbConnection, trans); trans.Commit(); } } return(string.Empty); }
public static string End(string id, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("football_round_chain_vote_id", id); DataSet ds = DBHelper.Select("football_round_chain_vote_invite_view", "*", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("找不到该记录"); } string price = ds.Tables[0].Rows[0]["price"].ToString(); string title = ds.Tables[0].Rows[0]["football_round_name"] + " " + ds.Tables[0].Rows[0]["football_round_chain_name"]; string chain_vote_status_id = "2"; foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["vote_sys_user_id"].ToString().Length == 0) { return("接龙未完成"); } if (dr["match_result_id"].ToString().Length == 0) { return("仍有比赛未完成"); } if (!dr["match_result_id"].Equals(dr["vote_match_result_id"])) { chain_vote_status_id = "3"; } } using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("chain_vote_status_id", chain_vote_status_id); fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("football_round_chain_vote", dict, fdict, "and", dbConnection, trans); if (chain_vote_status_id.Equals("2") && (price.Length > 0)) { foreach (DataRow dr in ds.Tables[0].Rows) { dict = new Dictionary <string, string>(); dict.Add("balance", "数字相加+" + price); fdict = new Dictionary <string, string>(); fdict.Add("id", dr["vote_sys_user_id"].ToString()); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); sys_user_balance_change.Insert(dr["vote_sys_user_id"].ToString(), "2", price, title, "football_round_chain_vote", id, dbConnection, trans); } } trans.Commit(); } } return(string.Empty); }
public static string End(string id, string end_datetime, string home_score, string away_score, string final_home_score, string final_away_score, string match_result_id, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", id); DataSet ds = DBHelper.Select("football_match_view", "*", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("找不到该赛事"); } if (ds.Tables[0].Rows[0]["end_datetime"].ToString().Length > 0) { return("赛事已结束"); } string title = ds.Tables[0].Rows[0]["football_round_name"] + " " + ds.Tables[0].Rows[0]["home_football_team_name"] + "VS" + ds.Tables[0].Rows[0]["away_football_team_name"]; fdict = new Dictionary <string, string>(); fdict.Add("football_match_id", id); DataSet vds = DBHelper.Select("football_match_vote", "*", string.Empty, fdict, "and"); string match_score_type_id = string.Empty; if ((Convert.ToInt32(final_home_score) + Convert.ToInt32(final_away_score)) % 2 > 0) { match_score_type_id = "1"; } else { match_score_type_id = "2"; } fdict = new Dictionary <string, string>(); fdict.Add("football_match_id", id); DataSet sds = DBHelper.Select("football_match_score", "*", string.Empty, fdict, "and"); IDictionary <string, double> pdict = new Dictionary <string, double>(); IDictionary <string, double> pvdict = new Dictionary <string, double>(); IDictionary <string, double> psdict = new Dictionary <string, double>(); IDictionary <string, double> cdict = new Dictionary <string, double>(); double total = 0; double vtotal = 0; foreach (DataRow dr in vds.Tables[0].Rows) { total += Convert.ToInt32(dr["amount"]); if (dr["match_result_id"].ToString().Equals(match_result_id)) { vtotal += Convert.ToInt32(dr["amount"]); cdict.Add(dr["sys_user_id"].ToString(), Convert.ToInt32(dr["amount"])); } } foreach (string sys_user_id in cdict.Keys) { pdict.Add(sys_user_id, cdict[sys_user_id] * total / vtotal); pvdict.Add(sys_user_id, cdict[sys_user_id] * total / vtotal); } cdict = new Dictionary <string, double>(); total = 0; vtotal = 0; foreach (DataRow dr in sds.Tables[0].Rows) { total += Convert.ToInt32(dr["amount"]); if (dr["match_score_type_id"].ToString().Equals(match_score_type_id)) { vtotal += Convert.ToInt32(dr["amount"]); cdict.Add(dr["sys_user_id"].ToString(), Convert.ToInt32(dr["amount"])); } } foreach (string sys_user_id in cdict.Keys) { if (pdict.ContainsKey(sys_user_id)) { pdict[sys_user_id] = pdict[sys_user_id] + cdict[sys_user_id] * total / vtotal; } else { pdict.Add(sys_user_id, cdict[sys_user_id] * total / vtotal); } psdict.Add(sys_user_id, cdict[sys_user_id] * total / vtotal); } using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("end_datetime", end_datetime); dict.Add("home_score", home_score); dict.Add("away_score", away_score); dict.Add("final_home_score", final_home_score); dict.Add("final_away_score", final_away_score); dict.Add("match_result_id", match_result_id); fdict = new Dictionary <string, string>(); fdict.Add("id", id); DBHelper.Update("football_match", dict, fdict, "and", dbConnection, trans); foreach (string sys_user_id in pdict.Keys) { dict = new Dictionary <string, string>(); dict.Add("balance", "数字相加+" + (pdict[sys_user_id] * (100.0 - sys_percent) / 100.0).ToString()); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); } foreach (string sys_user_id in pvdict.Keys) { sys_user_balance_change.Insert(sys_user_id, "3", (pvdict[sys_user_id] * (100.0 - sys_percent) / 100.0).ToString(), title + " " + dict_match_result.GetName(match_result_id), "football_match", id, dbConnection, trans); } foreach (string sys_user_id in psdict.Keys) { sys_user_balance_change.Insert(sys_user_id, "7", (psdict[sys_user_id] * (100.0 - sys_percent) / 100.0).ToString(), title + " " + dict_match_score_type.GetName(match_score_type_id), "football_match", id, dbConnection, trans); } trans.Commit(); } } return(string.Empty); }
public static string Insert(string gift_id, string sys_user_id, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", gift_id); fdict.Add("delete_flag", "IS NULL"); DataSet ds = DBHelper.Select("gift", "title,price,inventory,off_shelf_datetime", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("礼品不存在"); } string title = ds.Tables[0].Rows[0]["title"].ToString(); string price = ds.Tables[0].Rows[0]["price"].ToString(); string inventory = ds.Tables[0].Rows[0]["inventory"].ToString(); string off_shelf_datetime = ds.Tables[0].Rows[0]["off_shelf_datetime"].ToString(); if (inventory.Length > 0 && (Convert.ToInt32(inventory) < 1)) { return("礼品库存不足"); } if (off_shelf_datetime.Length > 0 && (Convert.ToDateTime(off_shelf_datetime) < DateTime.Today)) { return("礼品已下架"); } fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); fdict.Add("delete_flag", "IS NULL"); ds = DBHelper.Select("sys_user", "balance", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("用户不存在"); } if (Convert.ToInt32(ds.Tables[0].Rows[0]["balance"]) < Convert.ToInt32(price)) { return("爱心不足"); } using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("gift_id", gift_id); dict.Add("sys_user_id", sys_user_id); dict.Add("buy_datetime", DateTime.Now.ToString()); DBHelper.Insert("gift_history", dict, dbConnection, trans); dict = new Dictionary <string, string>(); dict.Add("balance", "数字相减-" + price); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); sys_user_balance_change.Insert(sys_user_id, "4", "-" + price, "兑换“" + title + "”", "gift", gift_id, dbConnection, trans); if (inventory.Length > 0) { dict = new Dictionary <string, string>(); dict.Add("inventory", "数字相减-1"); fdict = new Dictionary <string, string>(); fdict.Add("id", gift_id); DBHelper.Update("gift", dict, fdict, "and", dbConnection, trans); } trans.Commit(); } } return(string.Empty); }
public static string Insert(string football_round_chain_id, string sys_user_id, string football_match_id, string match_result_id, string football_match_ids, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", football_round_chain_id); fdict.Add("delete_flag", "IS NULL"); DataSet ds = DBHelper.Select("football_round_chain", "participant_amount,name", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("竞猜不存在"); } string participant_amount = ds.Tables[0].Rows[0]["participant_amount"].ToString(); string football_round_chain_name = ds.Tables[0].Rows[0]["name"].ToString(); string[] football_match_idarr = football_match_ids.Split(','); if (football_match_idarr.Length != Convert.ToInt32(participant_amount)) { return("接龙长度异常"); } fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); fdict.Add("delete_flag", "IS NULL"); ds = DBHelper.Select("sys_user", "balance", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("用户不存在"); } if (Convert.ToInt32(ds.Tables[0].Rows[0]["balance"]) < 6) { return("爱心不足6元"); } using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("football_round_chain_id", football_round_chain_id); dict.Add("sys_user_id", sys_user_id); dict.Add("participant_need", (Convert.ToInt32(participant_amount) - 1).ToString()); dict.Add("chain_vote_status_id", "1"); dict.Add("vote_datetime", DateTime.Now.ToString()); DBHelper.Insert("football_round_chain_vote", dict, dbConnection, trans); string football_round_chain_vote_id = DBHelper.SelectNewId(dbConnection, trans); dict = new Dictionary <string, string>(); dict.Add("football_round_chain_vote_id", football_round_chain_vote_id); dict.Add("sys_user_id", sys_user_id); dict.Add("football_match_id", football_match_id); dict.Add("match_result_id", match_result_id); dict.Add("vote_datetime", DateTime.Now.ToString()); DBHelper.Insert("football_round_chain_vote_invite", dict, dbConnection, trans); foreach (string football_match_idi in football_match_idarr) { if (football_match_idi.Equals(football_match_id)) { continue; } dict = new Dictionary <string, string>(); dict.Add("football_round_chain_vote_id", football_round_chain_vote_id); dict.Add("football_match_id", football_match_idi); DBHelper.Insert("football_round_chain_vote_invite", dict, dbConnection, trans); } dict = new Dictionary <string, string>(); dict.Add("balance", "数字相减-6"); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); sys_user_balance_change.Insert(sys_user_id, "2", "-6", "发起接龙“" + football_round_chain_name + "”", "football_round_chain_vote", football_round_chain_vote_id, dbConnection, trans); trans.Commit(); } } return(string.Empty); }
public static string Insert(string gift_auction_id, string sys_user_id, string amount, string USER, string TOKEN) { if (!AccessToken.Read(USER, TOKEN)) { return("登录超时"); } if (amount.Length == 0 || Convert.ToInt32(amount) <= 0) { return("竞拍额异常"); } IDictionary <string, string> fdict = new Dictionary <string, string>(); fdict.Add("id", gift_auction_id); fdict.Add("end_datetime", ">='" + DateTime.Now.ToString() + "'"); fdict.Add("delete_flag", "IS NULL"); DataSet ds = DBHelper.Select("gift_auction", "min_bid_amount", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("该竞拍已结束"); } string min_bid_amount = ds.Tables[0].Rows[0]["min_bid_amount"].ToString(); if (Convert.ToInt32(amount) < Convert.ToInt32(min_bid_amount)) { return("不能低于最小竞拍额"); } fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); fdict.Add("delete_flag", "IS NULL"); ds = DBHelper.Select("sys_user", "balance", string.Empty, fdict, "and"); if (ds.Tables[0].Rows.Count == 0) { return("用户不存在"); } if (Convert.ToInt32(ds.Tables[0].Rows[0]["balance"]) < Convert.ToInt32(amount)) { return("爱心不足"); } fdict = new Dictionary <string, string>(); fdict.Add("gift_auction_id", gift_auction_id); fdict.Add("sys_user_id", sys_user_id); ds = DBHelper.Select("gift_auction_sys_user_bid", "id,amount", string.Empty, fdict, "and"); using (MySqlConnection dbConnection = new MySqlConnection(DBHelper.strConnection)) { dbConnection.Open(); using (MySqlTransaction trans = dbConnection.BeginTransaction()) { IDictionary <string, string> dict = new Dictionary <string, string>(); if (ds.Tables[0].Rows.Count == 0) { dict.Add("gift_auction_id", gift_auction_id); dict.Add("sys_user_id", sys_user_id); dict.Add("amount", amount); dict.Add("gift_bid_status_id", "1"); dict.Add("bid_datetime", DateTime.Now.ToString()); DBHelper.Insert("gift_auction_sys_user_bid", dict, dbConnection, trans); } else { if (amount.Equals(ds.Tables[0].Rows[0]["amount"].ToString())) { return(string.Empty); } dict.Add("amount", amount); dict.Add("bid_datetime", DateTime.Now.ToString()); fdict = new Dictionary <string, string>(); fdict.Add("id", ds.Tables[0].Rows[0]["id"].ToString()); DBHelper.Update("gift_auction_sys_user_bid", dict, fdict, "and", dbConnection, trans); amount = (Convert.ToInt32(amount) - Convert.ToInt32(ds.Tables[0].Rows[0]["amount"])).ToString(); } dict = new Dictionary <string, string>(); dict.Add("balance", "数字相减-" + amount); fdict = new Dictionary <string, string>(); fdict.Add("id", sys_user_id); DBHelper.Update("sys_user", dict, fdict, "and", dbConnection, trans); trans.Commit(); } } return(string.Empty); }