protected void Page_Load(object sender, EventArgs e) { BLL.Card_wx.Card_BaseInfo bll = new BLL.Card_wx.Card_BaseInfo(); string cardtype = Request.Params["cardtype"]; string cardid = Request.QueryString["cardid"]; string acctoken = Token(); if (!IsPostBack) { Label1.Text = cardtype; Label2.Text = cardid; Model.Card_wx.Card_BaseInfo dd = bll.Getmodel(cardid); brand_name.Text = dd.brand_name.ToString(); title.Text = dd.title; sub_title.Text = dd.sub_title; imagetext.Text = dd.logo_url; Card_color.Text = dd.color; notice.Text = dd.notice; description.InnerText = dd.description; service_phone.Text = dd.service_phone; url_name.Text = dd.custom_url_name; custom_url.Text = dd.custom_url; sub_url_name.Text = dd.custom_url_sub_title; pro_url.Text = dd.promotion_url; pro_url_name.Text = dd.promotion_url_name; time_day.Text = dd.end_timestamp; user_limit.Text = dd.use_limit.ToString(); get_limit.Text = dd.get_limit.ToString(); share_page.Checked = dd.can_share; share_card.Checked = dd.can_give_friend; paycell.Checked = dd.Paycell; hexiao.Checked = dd.hexiao; imgbjurl.ImageUrl = imagetext.Text; } }
protected void sub_save_Click(object sender, EventArgs e) { if (imagetext.Text.Length == 0 || notice.Text.Length == 0 || user_limit.Text.Length == 0 || get_limit.Text.Length == 0) { JscriptMsg("参数不能为空!", "back", "Error"); } else { BLL.Card_wx.Card_BaseInfo exit = new BLL.Card_wx.Card_BaseInfo(); Model.wx_userweixin weixin = GetWeiXinCode(); int wid = weixin.id; Model.Card_wx.Card_BaseInfo Fros = new Card_BaseInfo(); _BaseInfo.logo_url = imagetext.Text; Fros.logo_url = imagetext.Text; _BaseInfo.color = Card_color.Text; Fros.color = Card_color.Text; _BaseInfo.notice = notice.Text; Fros.notice = notice.Text; _BaseInfo.service_phone = service_phone.Text; Fros.service_phone = service_phone.Text; _BaseInfo.description = description.InnerText; Fros.description = description.InnerText; _BaseInfo.use_limit = int.Parse(user_limit.Text); Fros.use_limit = int.Parse(user_limit.Text); _BaseInfo.get_limit = int.Parse(get_limit.Text); Fros.get_limit = int.Parse(get_limit.Text); _BaseInfo.can_share = share_page.Checked; Fros.can_share = share_page.Checked; _BaseInfo.can_give_friend = share_card.Checked; Fros.can_give_friend = share_card.Checked; _BaseInfo.custom_url_name = url_name.Text; Fros.custom_url_name = url_name.Text; _BaseInfo.custom_url_sub_title = sub_url_name.Text; Fros.custom_url_sub_title = sub_url_name.Text; _BaseInfo.custom_url = custom_url.Text; Fros.custom_url = custom_url.Text; _BaseInfo.promotion_url_name = pro_url_name.Text; Fros.promotion_url_name = pro_url_name.Text; _BaseInfo.promotion_url = pro_url.Text; Fros.promotion_url = pro_url.Text; if (Label1.Text == "团购券") { var data = new Model.Card_wx.CardMange.Card_groupon() { base_info = _BaseInfo, }; var result = Cardupdate(Token(), Label1.Text, data, Label2.Text); if (result.errmsg == "ok") { if (paycell.Checked == true) { // CardApi.PayCellSet(Token(), Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { // CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Fros.wid = wid; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; Fros.Wx_Card_id = Label2.Text; Fros.Card_type = Label1.Text; exit.Exit_card(Fros); Console.Write(result); JscriptMsg("编辑卡券成功!", "Card_wx_QR.aspx", "Success"); } } else if (Label1.Text == "代金券") { var data = new Model.Card_wx.CardMange.Card_cash() { base_info = _BaseInfo, }; var result = Cardupdate(Token(), Label1.Text, data, Label2.Text); if (result.errmsg == "ok") { if (paycell.Checked == true) { // CardApi.PayCellSet(Token(), Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { // CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Fros.wid = wid; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; Fros.Wx_Card_id = Label2.Text; Fros.Card_type = Label1.Text; exit.Exit_card(Fros); Console.Write(result); JscriptMsg("编辑卡券成功!", "Card_wx_QR.aspx", "Success"); } } else if (Label1.Text == "折扣券") { var data = new Model.Card_wx.CardMange.Card_discount() { base_info = _BaseInfo, }; var result = Cardupdate(Token(), Label1.Text, data, Label2.Text); if (result.errmsg == "ok") { if (paycell.Checked == true) { // CardApi.PayCellSet(Token(), Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { // CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Fros.wid = wid; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; Fros.Wx_Card_id = Label2.Text; Fros.Card_type = Label1.Text; exit.Exit_card(Fros); Console.Write(result); JscriptMsg("编辑卡券成功!", "Card_wx_QR.aspx", "Success"); } if (paycell.Checked == true) { } } else if (Label1.Text == "优惠券") { var data = new Model.Card_wx.CardMange.Card_general_coupon() { base_info = _BaseInfo, }; var result = Cardupdate(Token(), Label1.Text, data, Label2.Text); if (result.errmsg == "ok") { if (paycell.Checked == true) { // CardApi.PayCellSet(Token(), Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { // CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Fros.wid = wid; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; Fros.Wx_Card_id = Label2.Text; Fros.Card_type = Label1.Text; exit.Exit_card(Fros); Console.Write(result); JscriptMsg("编辑卡券成功!", "Card_wx_QR.aspx", "Success"); } } } }
protected void sub_save_Click(object sender, EventArgs e) { Model.Card_wx.Card_BaseInfo Fros = new Card_BaseInfo(); if (Card_type.Text.Length == 0 || title.Text.Length == 0 || brand_name.Text.Length == 0 || imagetext.Text.Length == 0 || Card_color.Text.Length == 0 || notice.Text.Length == 0 || description.InnerText.Length == 0 || time_day.Text.Length == 0 || Cardnumber.Text.Length == 0) { JscriptMsg("参数不能为空!", "back", "Error"); } else { _BaseInfo.code_type = Senparc.Weixin.MP.Card_CodeType.CODE_TYPE_QRCODE; Fros.logo_url = MyCommFun.getWebSite() + imagetext.Text; _BaseInfo.logo_url = MyCommFun.getWebSite() + imagetext.Text.ToString(); _BaseInfo.brand_name = brand_name.Text; Fros.brand_name = brand_name.Text; _BaseInfo.title = title.Text; Fros.title = title.Text; _BaseInfo.sub_title = sub_title.Text; Fros.sub_title = sub_title.Text; _BaseInfo.color = Card_color.Text; Fros.color = Card_color.Text; _BaseInfo.notice = notice.Text; Fros.notice = notice.Text; _BaseInfo.service_phone = service_phone.Text; Fros.service_phone = service_phone.Text; _BaseInfo.description = description.InnerText; Fros.description = description.InnerText; _BaseInfo.date_info.begin_timestamp = DateTimeHelper.GetWeixinDateTime(DateTime.Now); Fros.begin_timestamp = (DateTimeHelper.GetWeixinDateTime(DateTime.Now)).ToString();; _BaseInfo.date_info.end_timestamp = DateTimeHelper.GetWeixinDateTime(DateTime.Now.AddDays(int.Parse(time_day.Text))); Fros.end_timestamp = time_day.Text.ToString(); _BaseInfo.sku.quantity = int.Parse(Cardnumber.Text); Fros.quantity = int.Parse(Cardnumber.Text);; _BaseInfo.use_limit = int.Parse(user_limit.Text); Fros.use_limit = int.Parse(user_limit.Text); _BaseInfo.get_limit = int.Parse(get_limit.Text); Fros.get_limit = int.Parse(get_limit.Text); _BaseInfo.use_custom_code = code.Checked; Fros.use_custom_code = code.Checked; _BaseInfo.bind_openid = false; Fros.bind_openid = false; _BaseInfo.can_share = share_page.Checked; Fros.can_share = share_page.Checked; _BaseInfo.can_give_friend = share_card.Checked; _BaseInfo.url_name_type = Senparc.Weixin.MP.Card_UrlNameType.URL_NAME_TYPE_RESERVATION; Fros.can_give_friend = share_card.Checked; _BaseInfo.custom_url_name = url_name.Text; Fros.custom_url_name = url_name.Text; _BaseInfo.location_id_list = fghj(); _BaseInfo.custom_url_sub_title = sub_url_name.Text; Fros.custom_url_sub_title = sub_url_name.Text; _BaseInfo.custom_url = custom_url.Text; Fros.custom_url = custom_url.Text; _BaseInfo.promotion_url_name = pro_url_name.Text; Fros.promotion_url_name = pro_url_name.Text; _BaseInfo.promotion_url = pro_url.Text; Fros.promotion_url = pro_url.Text; if (Card_type.Text == "团购券") { Model.wx_userweixin weixin = GetWeiXinCode(); int wid = weixin.id; string accessToken = Token(); var data = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_GrouponData() { base_info = _BaseInfo, deal_detail = deal_detail.Text.ToString() }; BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo(); Fros.wid = wid; Fros.deal_detail = deal_detail.Text; Fros.Card_type = Card_type.Text; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; var result = CardApi.CreateCard(accessToken, data); Fros.Wx_Card_id = result.card_id; Add.Add(Fros); if (paycell.Checked == true) { CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Console.Write(result); JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success"); } else if (Card_type.Text == "代金券") { Model.wx_userweixin weixin = GetWeiXinCode(); int wid = weixin.id; string accessToken = Token(); var data = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_CashData() { base_info = _BaseInfo, least_cost = int.Parse(least_cost.Text), reduce_cost = int.Parse(reduce_cost.Text) }; BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo(); Fros.wid = wid; Fros.Card_type = Card_type.Text; Fros.least_cost = least_cost.Text; Fros.reduce_cost = reduce_cost.Text; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; var result = CardApi.CreateCard(accessToken, data); Fros.Wx_Card_id = result.card_id; Add.Add(Fros); if (paycell.Checked == true) { CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核 销接口 } Console.Write(result); JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success"); } else if (Card_type.Text == "折扣券") { Model.wx_userweixin weixin = GetWeiXinCode(); int wid = weixin.id; string accessToken = Token(); var data = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_DisCountData() { base_info = _BaseInfo, discount = float.Parse(discount.Text.ToString()) }; BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo(); Fros.wid = wid; Fros.Card_type = Card_type.Text; Fros.discount = discount.Text; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; var result = CardApi.CreateCard(accessToken, data); Fros.Wx_Card_id = result.card_id; Add.Add(Fros); if (paycell.Checked == true) { CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Console.Write(result); JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success"); } else if (Card_type.Text == "优惠券") { Model.wx_userweixin weixin = GetWeiXinCode(); int wid = weixin.id; string accessToken = Token(); var data = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_GeneralCouponData() { base_info = _BaseInfo, default_detail = default_detail.Text }; BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo(); Fros.wid = wid; Fros.Card_type = Card_type.Text; Fros.default_detail = default_detail.Text; Fros.Paycell = paycell.Checked; Fros.hexiao = hexiao.Checked; var result = CardApi.CreateCard(accessToken, data); Fros.Wx_Card_id = result.card_id; Add.Add(Fros); if (paycell.Checked == true) { CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true); ///设置微信买单功能 } if (hexiao.Checked == true) { CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true); ///设置自助核销接口 } Console.Write(result); JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success"); } } }