Beispiel #1
0
        static void Main(string[] args)
        {
            ulong  kdtId  = 0;
            Silent silent = new Silent("client_id", "client_appsecret", kdtId);

            OauthToken.TokenData silenToken = silent.GetToken();
            string token = silenToken.Token;

            //构建请求API
            GeneralApi generalApi = new GeneralApi();
            //设置请求参数
            GeneralApiParams apiParams = new GeneralApiParams();

            apiParams.AddParam("page_no", "1");
            apiParams.AddParam("page_size", "100");
            generalApi.SetAPIParams(apiParams);
            //设置API名称
            generalApi.SetName("youzan.ump.coupon.search");
            //设置API版本号
            generalApi.SetVersion("3.0.0");
            //指定鉴权类型
            generalApi.SetOAuthType(OAuthEnum.TOKEN);
            IYouZanClient defaultYZClient = new DefaultYZClient();
            //请求接口
            string result = defaultYZClient.Invoke(generalApi, new Token(token), null, null);

            Console.WriteLine("request result *******************" + result);
        }
Beispiel #2
0
        //有赞是否发货
        public bool GetShipments(string token, string tid)
        {
            try
            {
                Auth     auth     = new Token(token);
                YZClient yzClient = new DefaultYZClient(auth);
                Dictionary <string, object> dict = new Dictionary <string, object>();
                dict.Add("tid", tid);
                var result = yzClient.Invoke("youzan.trade.get", "4.0.0", "GET", dict, null);
                if (!string.IsNullOrEmpty(result))
                {
                    YzShipmentsResponse sr = CommonHelper.DeJson <YzShipmentsResponse>(result);
                    if (sr.response != null)
                    {
                        if (sr.response.delivery_order != null && sr.response.delivery_order.Count > 0)
                        {
                            return(sr.response.delivery_order[0].express_state == 1);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(false);
        }
Beispiel #3
0
        public bool AddExpress(string token, string tid, string oids, string out_sid, string out_stype, string outer_tid)
        {
            //if (shopService.GetShipments(token, tid))
            //{
            //    return true;
            //}
            Auth     auth     = new Token(token);
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict = new Dictionary <string, object>
            {
                { "tid", tid },
                { "is_no_express", 0 },
                { "oids", oids },
                { "out_sid", out_sid },
                { "out_stype", out_stype }
            };
            string result = yzClient.Invoke("youzan.logistics.online.confirm", "3.0.0", "GET", dict, null);

            if (!string.IsNullOrEmpty(result))
            {
                ExpressResponse expressResponse = CommonHelper.DeJson <ExpressResponse>(result);
                if (expressResponse.response != null)
                {
                    if (expressResponse.response.is_success)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
 public List <ItemsItem> GetGoods(string token)
 {
     try
     {
         var count = GetAllGoodsCount(token);
         //每页300条数据的话共有几页数据
         var pageAll = (int)Math.Ceiling((double)count / 300);
         List <ItemsItem> listSkusItem = new List <ItemsItem>();
         if (pageAll > 0)
         {
             for (int i = 1; i <= pageAll; i++)
             {
                 Auth     auth     = new Token(token);
                 YZClient yzClient = new DefaultYZClient(auth);
                 Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();
                 dict.Add("page_no", i);
                 dict.Add("page_size", 300);
                 var result = yzClient.Invoke("youzan.item.search", "3.0.0", "POST", dict, null);
                 var goods  = CommonHelper.DeJson <GoodsRoot>(result);
                 listSkusItem.AddRange(goods.response.items);
             }
         }
         return(listSkusItem);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public JsonResult GetCustomer(string id)
        {
            giftcardEntities db = new giftcardEntities();
            var app             = db.Database.SqlQuery <t_apps>("select * from t_apps where appcode='" + id + "'").FirstOrDefault();

            ViewBag.apphormurl = app.homeurl;


            Auth     auth     = new Token(getToken(id)); // Auth auth = new Sign("app_id", "app_secret");
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("page_no", 1);
            dict.Add("page_size", 50);
            var result = yzClient.Invoke("youzan.scrm.customer.search", "3.1.0", "POST", dict, null);

            JObject obj        = (JObject)JsonConvert.DeserializeObject(result);
            string  recordlist = "";
            int     total      = Convert.ToInt32(((Newtonsoft.Json.Linq.JValue)obj["response"]["total"]).Value);

            recordlist = obj["response"]["record_list"].ToString().Replace("[", "").Replace("]", "");
            int pagecount = total / 50 + 1;

            for (var i = 2; i <= pagecount; i++)
            {
                Dictionary <string, object> dict1 = new System.Collections.Generic.Dictionary <string, object>();

                dict1.Add("page_no", i);
                dict1.Add("page_size", 50);
                string  result1 = yzClient.Invoke("youzan.scrm.customer.search", "3.1.0", "POST", dict1, null);
                JObject obj1    = (JObject)JsonConvert.DeserializeObject(result1);
                recordlist += "," + obj1["response"]["record_list"].ToString().Replace("[", "").Replace("]", "");
            }
            ViewBag.result = recordlist;
            var resultreturn = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\",\"record_list\":[" + recordlist + "]}}";

            return(Json(resultreturn, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public List <AllExpress> GetExpress(string token)
        {
            Auth     auth     = new Token(token);
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict = new Dictionary <string, object>();
            var result = yzClient.Invoke("youzan.logistics.express.get", "3.0.0", "POST", dict, null);

            if (!string.IsNullOrEmpty(result))
            {
                GetExpressResponse expressResponse = CommonHelper.DeJson <GetExpressResponse>(result);
                return(expressResponse.Response.allExpress);
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
    public static string GetProdustsInventoryInfoString(int PageSise, int currentPageIndex)
    {
        Auth     auth     = new Token(GlobalInfo.Token);
        YZClient yzClient = new DefaultYZClient(auth);
        Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();

        //dict.Add("is_displays", "[1]");
        //dict.Add("measurement", 10);
        dict.Add("page_no", currentPageIndex);
        dict.Add("page_size", PageSise);
        //dict.Add("show_sold_out", 0);
        dict.Add("source", "test");

        var result = yzClient.Invoke("youzan.items.inventory.get", "3.0.0", "POST", dict, null);

        return(result);
    }
Beispiel #8
0
    public static List <DiscountCardResultJson.DiscountCardResult> GetDiscountCardsInfo()
    {
        var QueryResult = new List <DiscountCardResultJson.DiscountCardResult>();

        Auth     auth     = new Token(Token);
        YZClient yzClient = new DefaultYZClient(auth);
        Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();

        //dict.Add("is_displays", "[1]");
        //dict.Add("measurement", 10);
        dict.Add("page", 1);

        var result = yzClient.Invoke("youzan.scrm.card.list", "3.0.0", "POST", dict, null);
        var jobj   = (DiscountCardResultJson.Rootobject)Newtonsoft.Json.JsonConvert.DeserializeObject(result, typeof(DiscountCardResultJson.Rootobject));

        return(jobj.Translate());
    }
Beispiel #9
0
    public static List <ProductsDiscountResultJson.ProductsDiscountResult> QueryDiscountInfo(string temId)
    {
        var QueryResult = new List <ProductsDiscountResultJson.ProductsDiscountResult>();

        if (GlobalInfo.IsTokenValidate(AppID))
        {
            Auth auth = new Token(GlobalInfo.Token); // Auth auth = new Sign("app_id", "app_secret");

            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();
            dict.Add("item_ids", "[" + temId + "]");

            var result = yzClient.Invoke("youzan.ump.memberprice.query", "3.0.0", "POST", dict, null);
            var jobj   = (ProductsDiscountResultJson.Rootobject)Newtonsoft.Json.JsonConvert.DeserializeObject(result, typeof(ProductsDiscountResultJson.Rootobject));
            QueryResult.AddRange(jobj.Translate());
        }
        return(QueryResult);
    }
Beispiel #10
0
 public int GetAllGoodsCount(string token)
 {
     try
     {
         Auth     auth     = new Token(token);
         YZClient yzClient = new DefaultYZClient(auth);
         Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();
         dict.Add("page_no", 1);
         dict.Add("page_size", 2);
         var result = yzClient.Invoke("youzan.item.search", "3.0.0", "POST", dict, null);
         var goods  = CommonHelper.DeJson <GoodsRoot>(result);
         var count  = goods.response.count;
         return(count);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #11
0
 public OrderResponse GetOrder(OrderRequest Request, string Token)
 {
     try
     {
         Auth     auth     = new Token(Token);
         YZClient yzClient = new DefaultYZClient(auth);
         Dictionary <string, object> dict = new Dictionary <string, object>();
         dict.Add("start_update", Request.start_created);
         dict.Add("end_update", Request.end_created);
         dict.Add("page_no", Request.page_no);
         dict.Add("page_size", Request.page_size);
         dict.Add("status", Request.status);
         var result = yzClient.Invoke("youzan.trades.sold.get", "4.0.0", "POST", dict, null);
         return(JsonConvert.DeserializeObject <OrderResponse>(result));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #12
0
        public static void Main(string[] args)
        {
            //Auth auth = new Sign("app_id", "app_secret");
            Auth     auth     = new Token("xxx");
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("title", "aaaaa");
            dict.Add("price", 1.0);
            dict.Add("post_fee", 1.0);

            List <KeyValuePair <string, string> > files = new List <KeyValuePair <string, string> >();

            files.Add(new KeyValuePair <string, string>("images[]", "/xx/xx/1.jpg"));

            //var result = yzClient.Invoke("kdt.item.add", "1.0.0", "post", dict, files);
            var result = yzClient.Invoke("kdt.items.onsale.get", "1.0.0", "get", dict, null);

            Console.WriteLine(result);
        }
Beispiel #13
0
 public Sku_Root GetSku_Root(int ItemID, string token)
 {
     try
     {
         Auth     auth     = new Token(token);
         YZClient yzClient = new DefaultYZClient(auth);
         Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();
         dict.Add("item_id", ItemID);
         var result = yzClient.Invoke("youzan.item.get", "3.0.0", "POST", dict, null);
         var model  = CommonHelper.DeJson <Sku_Root>(result);
         if (model.response != null)
         {
             return(model);
         }
     }
     catch (Exception e)
     {
         return(null);
     }
     return(null);
 }
Beispiel #14
0
        /// <summary>
        /// 返回调用结果,可能抛出异常;
        /// </summary>
        /// <param name="api"></param>
        /// <returns></returns>
        internal TResult Invoke(YouzanConfig config, TParam param)
        {
            YZClient yzClient = new DefaultYZClient(config.Token);
            //var param = this.APIParams;
            var @params = param.toParams();
            List <KeyValuePair <string, string> > files = null;

            if (this.hasFiles())
            {
                files = ((FileParams)this.APIParams).toFileParams().Select(a => a.Value.Data).ToList();
            }
            var result = yzClient.Invoke(this.Name, this.Version, this.HttpMethod, @params, files);
            JsonSerializerSettings setting = new JsonSerializerSettings();

            setting.NullValueHandling = NullValueHandling.Ignore;
            var wrapper = JsonConvert.DeserializeObject <TResultWrapper <TResult> >(result, setting);

            if (wrapper.error_response != null)
            {
                throw new Exception(string.Format("错误响应:代码:{0}, 消息{1}", wrapper.error_response.code, wrapper.error_response.msg));
            }
            return(wrapper.response);
        }
        public JsonResult GetYouZanCards(string id)
        {
            giftcardEntities db = new giftcardEntities();
            var app             = db.Database.SqlQuery <t_apps>("select * from t_apps where appcode='" + id + "'").FirstOrDefault();

            ViewBag.apphormurl = app.homeurl;


            Auth     auth     = new Token(getToken(id)); // Auth auth = new Sign("app_id", "app_secret");
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict;

            dict = new System.Collections.Generic.Dictionary <string, object>();
            dict.Add("page_no", 1);
            dict.Add("page_size", 100);
            //dict.Add("status", "ON");
            dict.Add("group_type", "PROMOCODE");
            var result = yzClient.Invoke("youzan.ump.coupon.search", "3.0.0", "POST", dict, null);

            ViewBag.result = result;
            var result1 = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\",\"giftcardlist\":" + result + "}}";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #16
0
 public bool UpdateSrorage(DYGoods gd, string token)
 {
     try
     {
         Auth     auth     = new Token(token); // Auth auth = new Sign("app_id", "app_secret");
         YZClient yzClient = new DefaultYZClient(auth);
         Dictionary <string, object> dict = new System.Collections.Generic.Dictionary <string, object>();
         dict.Add("item_id", gd.ItemID);
         dict.Add("quantity", gd.Qty);
         dict.Add("type", 0);
         dict.Add("sku_id", gd.ItemSku);
         var result = yzClient.Invoke("youzan.item.quantity.update", "3.0.0", "POST", dict, null);
         var model  = CommonHelper.DeJson <UpdateSrorageResponse>(result);
         if (model.response != null)
         {
             return(model.response.is_success);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     return(false);
 }
Beispiel #17
0
        public JsonResult giftcardtake(String appcode, String openid, String mobile, String name, String cardcode)
        {
            string   result = "{\"result\":\"failed\"}";
            int      _PROMOCODEid;
            string   getsql   = "select * from giftcard where giftcardcode = '" + cardcode + "'";
            Auth     auth     = new Token(getToken(appcode)); // Auth auth = new Sign("app_id", "app_secret");
            YZClient yzClient = new DefaultYZClient(auth);
            Dictionary <string, object> dict;

            giftcardEntities db = new giftcardEntities();

            object[] obj   = new object[1];
            var      cards = db.Database.SqlQuery <AllTrustUs.Data.giftcard>(getsql, obj).ToList();

            if (cards.Count > 0)
            {
                if (cards[0].enabled == "0")
                {
                    result = "{\"response\": {\"issuccess\": 0,\"msg\": \"该礼品卡暂不可用,请联系公司负责人!\"}}";
                }
                else if (cards[0].isused == "1")
                {
                    result = "{\"response\": {\"issuccess\": 0,\"msg\": \"该礼品卡已被领用,不能重复注册!\"}}";
                }
                else
                {
                    try
                    {
                        _PROMOCODEid = Convert.ToInt32(cards[0].PromoId);

                        dict = new System.Collections.Generic.Dictionary <string, object>();
                        dict.Add("mobile", mobile);
                        dict.Add("coupon_group_id", _PROMOCODEid);

                        result = yzClient.Invoke("youzan.ump.coupon.take", "3.0.0", "POST", dict, null);

                        InvokeResponse Response = JsonUtility.Deserialize <InvokeResponse>(result);
                        if (Response.error_response == null && Response.response != null && Response.response.coupon_type == "PROMOCODE")
                        {
                            var updatecard = "update giftcard set isused='1',useddate='" + DateTime.Now.ToString("yyyy-MM-dd") + "',usedmobile='" + mobile + "',usedopenid='" + openid + "',usedname='" + name + "' where giftcardcode='" + cardcode.Replace("-", "") + "'";

                            db.Database.ExecuteSqlCommand(updatecard);

                            //MySqlHelp.ExecuteNonQuery(updatecard);
                            //string _sql="select jumpurl from giftcard where giftcardcode='" + cardcode.Replace("-", "") + "'";

                            //var returncards =  db.Database.SqlQuery<giftcard>(_sql, obj).ToList();
                            result = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\",\"jumpurl\":\"" + cards[0].jumpurl + "\"}}";
                        }
                        else
                        {
                            result = "{\"response\": {\"issuccess\": \"0\",\"msg\": \"" + Response.error_response.msg + "\"}}";
                        }
                    }
                    catch (Exception ex)
                    {
                        result = "{\"response\": {\"issuccess\": 0,\"msg\": \"" + ex.Message + "!\"}}";
                    }
                }
            }
            else
            {
                result = "{\"response\": {\"issuccess\": 0,\"msg\": \"礼品卷不存在,请验证礼品卷码是否填写正确!\"}}";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #18
0
        static void Main(string[] args)
        {
            //AuthorizationCode authorization = new AuthorizationCode("bifrost-console", "bifrost-console")
            //{
            //    Code = "ad43719a9b612347af08ac8b5e43acb8"
            //};
            //OauthToken.TokenData  tokenData=  authorization.GetToken();
            //string token = tokenData.Token;
            //Dictionary<String, String> pList = new Dictionary<String, String>();
            //List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();


            //GeneralApi generalApi = new GeneralApi();
            //GeneralApiParams apiParams = new GeneralApiParams();
            //generalApi.SetName("youzan.retail.open.online.spu.release");
            //generalApi.SetVersion("3.0.0");
            //generalApi.SetOAuthType(common.constant.OAuthEnum.TOKEN);
            //apiParams.AddParam("retail_source", "DAOYAN");
            //apiParams.AddParam("content", "<p>432<imgdata-origin-width=\\\"1224\\\"data-origin-height=\\\"924\\\"src=\\\"//img.yzcdn.cn/upload_files/2019/09/19/FtjyJv_Gr_Ti9H7rYiNn7s0OqbxW.png!730x0.jpg\\\"/></p>");
            //apiParams.AddParam("pre_sale", "False");
            //apiParams.AddParam("delivery_template_id", "782231");
            //apiParams.AddParam("is_virtual", "0");
            //apiParams.AddParam("components_extra_id", "64848302");
            //apiParams.AddParam("sold_time", "0");
            //apiParams.AddParam("purchase_right", "False");
            //apiParams.AddParam("spu_code", "BM49570907669");
            //apiParams.AddParam("price", "11.00");
            //apiParams.AddParam("title", "艾斯测试网店");
            //apiParams.AddParam("goods_no", "123");
            //apiParams.AddParam("total_stock", "1");
            //apiParams.AddParam("is_display", "0");
            //apiParams.AddParam("picture", "[{'url':'https://img.yzcdn.cn/upload_files/2017/06/19/Fme9JZz7T1rB8sSLnsnCk2gILNp_.png'}]");
            //generalApi.SetAPIParams(apiParams);
            //IYouZanClient defaultYZClient = new DefaultYZClient();
            //string result  =  defaultYZClient.Invoke(generalApi,new Token("f9650e560c2ec67fd5941f91df1db7a"), null, null,true);
            //Console.WriteLine("request result *******************"+result);


            //Console.WriteLine("Hello World!");
            //Console.WriteLine("获取Token"+token);
            //string content = "{\n    \"client_id\": \"bifrost-console\",\n    \"client_secret\": \"bifrost-console\",\n    \"authorize_type\": \"authorization_code\",\n    \"code\": \"ad43719a9b612347af08ac8b5e43acb8\"\n}";
            //var client = new RestClient("http://open.youzanyun.com");
            //var request = new RestRequest("/auth/token",Method.POST);
            //List<Parameter> parameter = request.Parameters;
            //string jsonStr = JsonConvert.SerializeObject(parameter);
            //request.AddParameter("application/json", content, ParameterType.RequestBody);
            //IRestResponse response = client.Execute(request);
            //var conterent = response.Content;
            //Console.WriteLine("request result *******************"+ conterent);

            //RefreshToken refresh = new RefreshToken("db9fe36d892719e921", "be58f76bbd80ee4af32c4f4655d20e9e")
            //{
            //    FreshToken = ""
            //};
            //OauthToken.TokenData tokenData = refresh.GetToken();

            //Silent silent = new Silent("8d47c12fa8d4914c5e", "57df61dc21c391bfc6cb6a6d3b540dfb", 43005315);
            //OauthToken.TokenData silenToken  =silent.GetToken();
            //string token = silenToken.Token;
            //Console.WriteLine("request result *******************" + token);

            GeneralApi       generalApi = new GeneralApi();
            GeneralApiParams apiParams  = new GeneralApiParams();

            generalApi.SetName("youzan.shop.get");
            generalApi.SetVersion("3.0.0");
            generalApi.SetOAuthType(common.constant.OAuthEnum.TOKEN);
            generalApi.SetAPIParams(apiParams);
            IYouZanClient defaultYZClient = new DefaultYZClient();
            //升级前
            string result = defaultYZClient.Invoke(generalApi, new Token("f9650e560c2ec67fd5941f91df1db7a"), null, null);
            //升级后
            string result2 = defaultYZClient.Invoke(generalApi, new Token("f9650e560c2ec67fd5941f91df1db7a"), null, null, true);

            Console.WriteLine("request result *******************" + result);



            //Silent silent = new Silent("bifrost-console", "bifrost-console", 2003777768);
            //OauthToken.TokenData silenToken = silent.GetToken();
            //string token = silenToken.Token;
        }
Beispiel #19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";

            string Action = context.Request["Action"].ToString();

            string result = "{\"result\":\"failed\"}";

            if (!string.IsNullOrEmpty(Action))
            {
                Auth     auth     = new Token(CurToken); // Auth auth = new Sign("app_id", "app_secret");
                YZClient yzClient = new DefaultYZClient(auth);
                Dictionary <string, object> dict;
                switch (Action)
                {
                case "getgiftcard":
                    dict = new System.Collections.Generic.Dictionary <string, object>();
                    dict.Add("page_no", 1);
                    dict.Add("page_size", 100);
                    //dict.Add("status", "ON");
                    dict.Add("group_type", "PROMOCODE");
                    result = yzClient.Invoke("youzan.ump.coupon.search", "3.0.0", "POST", dict, null);
                    break;

                case "giftcardtake":
                    string    _openid   = context.Request["openid"].ToString();
                    string    _mobile   = context.Request["mobile"].ToString();
                    string    _name     = context.Request["name"].ToString();
                    string    _cardcode = context.Request["cardcode"].ToString();
                    int       _PROMOCODEid;
                    string    getsql = "select * from giftcard where giftcardcode = '" + _cardcode + "'";
                    DataTable odDT   = MySqlHelp.ExecuteDataTable(getsql);

                    if (odDT.Rows.Count > 0)
                    {
                        if (odDT.Rows[0]["enabled"].ToString() == "0")
                        {
                            result = "{\"response\": {\"issuccess\": 0,\"msg\": \"该礼品卡暂不可用,请联系公司负责人!\"}}";
                        }
                        else if (odDT.Rows[0]["isused"].ToString() == "1")
                        {
                            result = "{\"response\": {\"issuccess\": 0,\"msg\": \"该礼品卡已被领用,不能重复注册!\"}}";
                        }
                        else
                        {
                            try
                            {
                                _PROMOCODEid = Convert.ToInt32(odDT.Rows[0]["PromoId"]);

                                dict = new System.Collections.Generic.Dictionary <string, object>();
                                dict.Add("mobile", _mobile);
                                dict.Add("coupon_group_id", _PROMOCODEid);

                                result = yzClient.Invoke("youzan.ump.coupon.take", "3.0.0", "POST", dict, null);

                                InvokeResponse Response = JsonUtility.Deserialize <InvokeResponse>(result);
                                if (Response.error_response == null && Response.response != null && Response.response.coupon_type == "PROMOCODE")
                                {
                                    var updatecard = "update giftcard set isused='1',useddate='" + DateTime.Now.ToString("yyyy-MM-dd") + "',usedmobile='" + _mobile + "',usedopenid='" + _openid + "',usedname='" + _name + "' where giftcardcode='" + _cardcode.Replace("-", "") + "'";
                                    MySqlHelp.ExecuteNonQuery(updatecard);
                                    DataTable dt = MySqlHelp.ExecuteDataTable("select jumpurl from giftcard where giftcardcode='" + _cardcode.Replace("-", "") + "'");
                                    result = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\",\"jumpurl\":\"" + dt.Rows[0]["jumpurl"].ToString() + "\"}}";
                                }
                                else
                                {
                                    result = "{\"response\": {\"issuccess\": \"0\",\"msg\": \"" + Response.error_response.msg + "\"}}";
                                }
                            }
                            catch (Exception ex)
                            {
                                result = "{\"response\": {\"issuccess\": 0,\"msg\": \"" + ex.Message + "!\"}}";
                            }
                        }
                    }
                    else
                    {
                        result = "{\"response\": {\"issuccess\": 0,\"msg\": \"礼品卷不存在,请验证礼品卷码是否填写正确!\"}}";
                    }
                    break;

                case "giftcardtakelist":
                    DataTable dttakelist = MySqlHelp.ExecuteDataTable("select * from giftcard");
                    result = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\",\"giftcardlist\":" + formatgiftcard(dttakelist) + "}}";

                    break;

                case "cardactive":
                    string _ids1 = context.Request["ids"].ToString();
                    MySqlHelp.ExecuteNonQuery("update giftcard set enabled=1 where id in (" + _ids1 + ")and isused = 0");
                    result = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\"}}";

                    break;

                case "cardinactive":
                    string _ids2 = context.Request["ids"].ToString();
                    MySqlHelp.ExecuteNonQuery("update giftcard set enabled=0 where id in (" + _ids2 + ") and isused = 0");
                    result = "{\"response\": {\"issuccess\": \"1\",\"msg\": \"验证成功!\"}}";

                    break;

                default:
                    break;
                }
            }
            context.Response.Write(result);
        }