예제 #1
0
        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");
                }
            }
        }