/// <summary> /// 获取SN码 /// </summary> void GetSNCode() { string sncode = string.Empty; string peizeid = string.Empty; if (Request["peizeid"] != null && Request["peizeid"] != "") { peizeid = Common.Common.NoHtml(Request["peizeid"].ToString()); } if (strOpenID.Trim() != null && strOpenID.Trim() != "") { if (!AwardUserDal.ExistAwardUser(strOpenID, "", "", peizeid, strActID)) { sncode = GenerateCheckCode(7); if (AwardUserDal.UpdateUserSNCode(strOpenID, peizeid, strActID, sncode)) { string strGuid = Guid.NewGuid().ToString("N"); CouponDAL cdal = new CouponDAL(); Model.ACT.Coupon coupon = null; coupon = new Model.ACT.Coupon() { ID = strGuid, SiteCode = strSiteCode, SiteActivityID = strActID, OpenID = strOpenID, CouponCode = sncode, CouponStatus = 0 }; cdal.InsertInfo(coupon); Response.Write("{\"success\":true,\"sn\":\"" + sncode + "\"}"); } else { Response.Write("{\"error\":\"invalid\"}"); } } else { sncode = AwardUserDal.GetSNCodeByPhone(strOpenID, "", peizeid, strActID); if (sncode.Trim() != null && sncode.Trim() != "") { Response.Write("{\"error\":\"getsn\",\"sn\":\"" + sncode + "\"}"); } else { Response.Write("{\"error\":\"isdoing\"}"); } } } else { Response.Write("{\"error\":true,\"msg\":\"操作失败,请重新操作\"}"); return; } }
protected void btnCoupon_Click(object sender, EventArgs e) { string strWhere = " "; if (Session["strRoleCode"].ToString() != "ADMIN") { strWhere = " a.SiteCode = '" + Session["strSiteCode"].ToString() + "' "; } if (ddlselectName.SelectedValue.Trim() != null && ddlselectName.SelectedValue.Trim() != "" && ddlselectName.SelectedValue.Trim() != "0") { if (strWhere.Trim() != null && strWhere.Trim() != "") { strWhere = strWhere + " AND "; } strWhere = strWhere + " b.ID='" + ddlselectName.SelectedValue + "' "; } if (ddlselectName.SelectedValue.Trim() != null && ddlselectName.SelectedValue.Trim() != "" && ddlselectName.SelectedValue.Trim() != "0") { if (strWhere.Trim() != null && strWhere.Trim() != "") { strWhere = strWhere + " AND "; } string arrow = GetLoseWin(ddlselectName.SelectedValue); if (arrow == "0") { MessageBox.Show(this, "请设置正确的比赛结果再做统计!"); return; } strWhere = strWhere + " [dbo].[split](GuessScore,':',0) " + arrow + " [dbo].[split](GuessScore,':',1) "; } else { MessageBox.Show(this, "操作失败,请选择相应的赛事!"); return; } JC_ScoreDAL dal = new JC_ScoreDAL(); DataSet ds = dal.GetJCScoreListByStateNO(strWhere); //取正确比分 foreach (DataRow row in ds.Tables[0].Rows) { string strOpenID = row["OpenID"].ToString(); string strScoreID = row["ID"].ToString(); string strGuessScore = row["GuessScore"].ToString(); string strRightScore = row["RightScore"].ToString(); //修改竞猜状态; dal.UpdateJCScoreState(strScoreID); //写入优惠券 //AC87CE288FC24F23B7B68CE8F3D93D13 string strGuid = Guid.NewGuid().ToString("N"); CouponDAL cdal = new CouponDAL(); string strSiteCode = Session["strSiteCode"].ToString(); Model.ACT.Coupon coupon = null; if (strGuessScore == strRightScore) { coupon = new Model.ACT.Coupon() { ID = strGuid, SiteCode = Session["strSiteCode"].ToString(), SiteActivityID = "AC87CE288FC24F23B7B68CE8F3D93D18", OpenID = strOpenID, CouponStatus = 0 }; } else { coupon = new Model.ACT.Coupon() { ID = strGuid, SiteCode = Session["strSiteCode"].ToString(), SiteActivityID = "AC87CE288FC24F23B7B68CE8F3D93D22", OpenID = strOpenID, CouponStatus = 0 }; } cdal.InsertInfo(coupon); } MessageBox.Show(this, "优惠券发放完成!"); }
/// <summary> /// 用户注册 /// </summary> void saveUserinfo() { if (strOpenID != null && strOpenID != "") { if (!AwardUserDal.ExistAwardUser(strOpenID, "", "", "", "")) { LuckyAwardUsers usermodel = new LuckyAwardUsers(); usermodel.ID = Guid.NewGuid().ToString("N").ToUpper(); usermodel.IsDel = 0; usermodel.OpenID = strOpenID; usermodel.SendAward = 0; usermodel.ActID = strActID; if (AwardUserDal.AddAwardUsers(usermodel)) { Random ran = new Random(); int RandKey = ran.Next(0, 6); string strGuid = Guid.NewGuid().ToString("N"); string strSN = GenerateCheckCode(7); string strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04"; switch (RandKey) { case 1: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D01"; break; case 2: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D02"; break; case 3: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D03"; break; case 4: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04"; break; case 5: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D05"; break; case 6: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D06"; break; default: strCouActID = "AC87CE288FC24F23B7B68CE8F3D93D04"; break; } CouponDAL cdal = new CouponDAL(); Model.ACT.Coupon coupon = null; coupon = new Model.ACT.Coupon() { ID = strGuid, SiteCode = strSiteCode, SiteActivityID = strCouActID, OpenID = strOpenID, CouponCode = strSN, CouponStatus = 0 }; cdal.InsertInfo(coupon); Response.Write("{\"success\":\"true\",\"prizetype\":\"" + RandKey.ToString() + "\",\"sn\":\"a" + strSN + "\"}"); } else { Response.Write("{\"error\":\"invalid\"}"); } } else { //Response.Write("{\"prizetype\":\"null\",\"sn\":\"no\"}"); Response.Write("{\"error\":\"isdoing\"}"); } } else { Response.Write("{\"prizetype\":\"null\",\"sn\":\"no\"}"); } }
void PrintPhoto(string imgsrc) { string imgname = string.Empty; string[] imgarray = imgsrc.Split('.'); imgname = imgarray[0]; string openid = string.Empty; if (userid != null && userid != "") { MSCustomersDAL customerDal = new MSCustomersDAL(); try { openid = customerDal.GetCustomerValueByID("OpenID", userid).ToString(); } catch (Exception) { } } if (openid == null || openid == "") { openid = strID; } DAL.HP.PhotoDAL dalPhoto = new DAL.HP.PhotoDAL(); //照片处理 strSFilePath = "../../PalmShop/ShopCode/" + imgsrc; strFilePath = imgsrc; string[] urls = strSFilePath.Split('.'); string _url = openid + "." + urls.Last(); string saveurl = "../../HP_Photo/"; saveurl = Server.MapPath(saveurl); if (!Directory.Exists(saveurl)) { Directory.CreateDirectory(saveurl); } string inputurl = Server.MapPath("../../PalmShop/ShopCode/") + strFilePath; string outputurl = Server.MapPath("../../HP_Photo/") + _url; int width = 260; int height = 310; System.IO.FileStream fs = new System.IO.FileStream(inputurl, System.IO.FileMode.Open); //ZoomAuto(fs, outputurl,width, height, "", ""); CutForCustom(fs, outputurl, width, height, 100); fs.Close(); string SiteCode = "VYIGO"; if (Session["strSiteCode"].ToString() != null && Session["strSiteCode"].ToString() != "") { SiteCode = Session["strSiteCode"].ToString(); } // DAL.HP.PrintCodeDAL dalPrintCode = new DAL.HP.PrintCodeDAL(); // DataSet printds = dalPrintCode.AddPrintCode(1, SiteCode,"0000", "2014-01-01", "2019-12-31"); //string strPID = string.Empty; //if (printds != null && printds.Tables.Count > 0 && printds.Tables[0].Rows.Count > 0) //{ // strPID = printds.Tables[0].Rows[0]["ID"].ToString(); //} string strPID = Guid.NewGuid().ToString("N"); Model.HP.Photo modelPhoto = new Model.HP.Photo() { ID = strPID, OpenId = openid, SiteCode = SiteCode, ClientID = "WSY01", PrintCode = "1111", Img = openid + "." + imgsrc.Split('.').Last(), AttachText = AttachText.Text + "\r\n" }; dalPhoto.InsertInfo(modelPhoto); //插入V币记录 if (userid != null && userid != "" && strPID != null && strPID != "") { int award = GetAwardChance(); MSVAcct msvModel = new MSVAcct(); MSVAcctDAL msvDal = new MSVAcctDAL(); MSVAcctDetail msvdetailModel = new MSVAcctDetail(); MSVAcctDetailDAL msvdetailDal = new MSVAcctDetailDAL(); if (!msvDal.ExistMSVAcct(userid, SiteCode)) { msvModel.CustID = userid; msvModel.SiteCode = SiteCode; msvModel.V_Amont = award; msvDal.AddMSVAcct(msvModel); } else { int count = Convert.ToInt32(msvDal.GetMSVAcct("V_Amont", userid).ToString()); count = count + award; msvModel.CustID = userid; msvModel.SiteCode = SiteCode; msvModel.V_Amont = count; msvDal.UpdateMSVAcct(msvModel); } msvdetailModel.CustID = userid; msvdetailModel.Amount = award; msvdetailModel.ChargeType = "首次购物"; msvdetailModel.Ext_Fld1 = strPID; msvdetailModel.SiteCode = SiteCode; msvdetailDal.AddMSVAcctDetail(msvdetailModel); } //插入活动券 if (!string.IsNullOrEmpty(openid)) { string strGuid = Guid.NewGuid().ToString("N"); DAL.ACT.CouponDAL cdal = new DAL.ACT.CouponDAL(); if (!cdal.ExistCoupon(SiteCode, "56DBFD79AFF94FD6B0FE7E72CE7589E6", openid)) { Model.ACT.Coupon coupon = null; coupon = new Model.ACT.Coupon() { ID = strGuid, SiteCode = SiteCode, SiteActivityID = "56DBFD79AFF94FD6B0FE7E72CE7589E6", OpenID = openid, CouponStatus = 0 }; cdal.InsertInfo(coupon); } } }