Esempio n. 1
0
        protected void btnCreateCoupon2_Click(object sender, EventArgs e)
        {
            long   begin_timestamp = 1533052800; //2018-08-01 00:00:00
            long   end_timestamp   = 1568889428; //2018-09-30 23:59:59
            string resmsg          = NetHelper.HttpRequest(AppConfig.TokenUrl, "", "GET", 2000,
                                                           Encoding.UTF8, "application/json");

            TokeRes toke  = JsonHelper.DeserializeObject <TokeRes>(resmsg);
            string  token = toke.Access_Token;
            string  url   = "https://api.weixin.qq.com/card/create?access_token=" + token;
            string  json  = @"{ 
            ""card"": {
              ""card_type"": ""GENERAL_COUPON"",
              ""general_coupon"": {
                  ""base_info"": {
                      ""logo_url"": 
            ""https://mmbiz.qlogo.cn/mmbiz_jpg/ugkm3wzgIFILaicicIzX7hfxblXziaEUliaGk37Q0VukC4tiaWB3lfcxYopOn72bHibaKEenbsPHzqpvxppHk3NanItw/0?wx_fmt=jpeg"",
                      ""brand_name"":""佰草集心约会"",
                      ""code_type"":""CODE_TYPE_TEXT"",
                      ""title"": ""满200减60抵用券"",
                      ""sub_title"": """",
                      ""color"": ""Color020"",
                      ""notice"": ""请出示您的唯一优惠券码"",
                      ""description"": ""1)此券仅限本人使用,不可转增,每人限领1张
                                         2)凭券返店消费满200元时抵扣
                                         3)该活动仅限在佰草集专柜购买的顾客"",
                      ""date_info"": {
                                          ""type"": ""DATE_TYPE_FIX_TIME_RANGE"",
                                          ""begin_timestamp"": " + begin_timestamp + " ,"
                            + @"""end_timestamp"":  " + end_timestamp + @" },
                       ""sku"": {
                            ""quantity"": 100
                      },
                      ""get_limit"": 10,
                      ""use_custom_code"": true,
                      ""bind_openid"": true,
                      ""can_share"": false,
                      ""can_give_friend"": false,
                      ""center_title"": ""立即使用"",
                          ""center_sub_title"": """",
                          ""center_url"": """ + AppConfig.ActivityWebApp + @"wechat/XYH_2TG_Coupon_H5/html/hxcoupon.html""
                  },
                  ""default_detail"": ""满200减60抵用券""}
            }
            }";

            var            resMessage = NetHelper.HttpRequest(url, json, "POST", 2000, Encoding.UTF8, "application/json");
            CouponResponse response   = JsonConvert.DeserializeObject <CouponResponse>(resMessage);

            //pDRuD1EutQ_b25Qd8c27hJ-rl7Do
            //{"status": 1,    "message": "{\"errcode\":0,\"errmsg\":\"ok\",\"card_id\":\"pDRuD1EutQ_b25Qd8c27hJ-rl7Do\"}",    "data": null}
            if (response.errmsg == "ok")
            {
                string cardId = response.card_id;

                this.txtCreateCouponLog2.Text = "卡券创建成功,cardId = " + cardId;
            }
            else
            {
                this.txtCreateCouponLog2.Text = "卡券创建失败" + response;
            }
        }
Esempio n. 2
0
        protected void btnCreateCoupon1_Click(object sender, EventArgs e)
        {
            long begin_timestamp = 1529856000; //2018-06-25 00:00:00
            //1529856000  2018-06-25 00:00:00
            long end_timestamp = 1533052799;   //2018-07-31 23:59:59
            //1533052799   2018-07-31 23:59:59
            string resmsg = NetHelper.HttpRequest(AppConfig.TokenUrl, "", "GET", 2000,
                                                  Encoding.UTF8, "application/json");

            TokeRes toke  = JsonHelper.DeserializeObject <TokeRes>(resmsg);
            string  token = toke.Access_Token;
            string  url   = "https://api.weixin.qq.com/card/create?access_token=" + token;
            string  json  = @"{ 
            ""card"": {
              ""card_type"": ""GENERAL_COUPON"",
              ""general_coupon"": {
                  ""base_info"": {
                      ""logo_url"": 
            ""https://mmbiz.qlogo.cn/mmbiz_jpg/ugkm3wzgIFILaicicIzX7hfxblXziaEUliaGk37Q0VukC4tiaWB3lfcxYopOn72bHibaKEenbsPHzqpvxppHk3NanItw/0?wx_fmt=jpeg"",
                      ""brand_name"":""佰草集心约会"",
                      ""code_type"":""CODE_TYPE_TEXT"",
                      ""title"": ""指定产品60元抵用券"",
                      ""sub_title"": """",
                      ""color"": ""Color020"",
                      ""notice"": ""请出示您的唯一优惠券码"",
                      ""description"": ""1)此券仅限本人使用,不可转增
                                         2)凭券前往佰草集专柜注册成为会员后方可立即使用
                                         3)活动仅限入店购买指定产品「润·泽兰蕴美精华水」时抵扣"",
                      ""date_info"": {
                                          ""type"": ""DATE_TYPE_FIX_TIME_RANGE"",
                                          ""begin_timestamp"": " + begin_timestamp + " ,"
                            + @"""end_timestamp"":  " + end_timestamp + @" },
                       ""sku"": {
                            ""quantity"": 0
                      },
                      ""get_limit"": 1,
                      ""use_custom_code"": true,
                      ""get_custom_code_mode"":""GET_CUSTOM_CODE_MODE_DEPOSIT"",
                      ""bind_openid"": false,
                      ""can_share"": false,
                      ""can_give_friend"": false,
                      ""center_title"": ""立即使用"",
                          ""center_sub_title"": """",
                          ""center_url"": """ + AppConfig.ActivityWebApp + @"wechat/XYH_2TG_Coupon_H5/html/hxcoupon.html""
                  },
               ""advanced_info"": {

                           ""time_limit"": [
                               {
                            ""type"": ""MONDAY"",
                                   ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""TUESDAY"",
                               ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""WEDNESDAY"",
                                  ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""THURSDAY"",
                                   ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""FRIDAY"",
                                ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""SATURDAY"",
                                   ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               },
                                 {
                            ""type"": ""SUNDAY"",
                                    ""begin_hour"":0,
                                   ""begin_minute"":0,
                                   ""end_hour"":23,
                                   ""end_minute"":59
                               }
                           ]

                       },
                  ""default_detail"": ""指定产品60元抵用券""}
            }
            }";

            var            resMessage = NetHelper.HttpRequest(url, json, "POST", 2000, Encoding.UTF8, "application/json");
            CouponResponse response   = JsonConvert.DeserializeObject <CouponResponse>(resMessage);

            //pDRuD1EutQ_b25Qd8c27hJ-rl7Do
            //{"status": 1,    "message": "{\"errcode\":0,\"errmsg\":\"ok\",\"card_id\":\"pDRuD1EutQ_b25Qd8c27hJ-rl7Do\"}",    "data": null}
            if (response.errmsg == "ok")
            {
                string cardId = response.card_id;

                this.txtCreateCouponLog1.Text = "卡券创建成功,cardId = " + cardId;
            }
            else
            {
                this.txtCreateCouponLog1.Text = "卡券创建失败" + response;
            }
        }