コード例 #1
0
        /// <summary>
        /// 取商户信息
        /// </summary>
        /// <returns></returns>
        public EleResult GetUser(string token)
        {
            object     obj     = new object();
            SignParams sign    = GetSign(token, obj, "eleme.user.getUser");
            string     content = MakeNopEntity(sign, obj);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #2
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="_orderId"></param>
        /// <param name="_type"></param>
        /// <param name="_remark"></param>
        /// <returns></returns>
        public EleResult CancelOrderLite(string token, string orderId, JObject data)
        {
            var        model   = new { orderId = orderId, type = data["Code"], remark = data["Reason"] };
            SignParams sign    = GetSign(token, model, "eleme.order.cancelOrderLite");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #3
0
        /// <summary>
        /// 取消单_同意退单
        /// </summary>
        /// <param name="_orderId"></param>
        /// <returns></returns>
        public EleResult AgreeRefundLite(string token, string orderId)
        {
            var        model   = new { orderId = orderId };
            SignParams sign    = GetSign(token, model, "eleme.order.agreeRefundLite");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #4
0
        /// <summary>
        /// 获取订单
        /// </summary>
        /// <param name="businNo"></param>
        /// <param name="shopNo"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public EleResult GetAllOrders(string token, long shopId, int pageNo, int pageSize, string date)
        {
            var        model   = new { shopId = shopId, pageNo = pageNo, pageSize = pageSize, date = date };
            SignParams sign    = GetSign(token, model, "eleme.order.getAllOrders");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #5
0
        /// <summary>
        /// 获取订单配状态
        /// </summary>
        /// <param name="_orderIds"></param>
        /// <returns></returns>
        public EleResult BatchGetDeliveryStates(string token, string[] orderIds)
        {
            var        model   = new { orderIds = orderIds };
            SignParams sign    = GetSign(token, model, "eleme.order.batchGetDeliveryStates");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #6
0
ファイル: EleFoodApiService.cs プロジェクト: MyLegendLife/O2O
        /// <summary>
        /// 批量更新商品库存
        /// </summary>
        /// <param name="listItem"></param>
        /// <returns></returns>
        public EleResult BatchUpdateStock(string token, Dictionary <long, int> stockMap)
        {
            var        model   = new { stockMap = stockMap };
            SignParams sign    = GetSign(token, model, "eleme.product.item.batchUpdateStock");
            string     content = MakeNopEntity(sign, model);
            string     ret     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(ret));
        }
コード例 #7
0
        /// <summary>
        /// 更新店信息
        /// </summary>
        /// <param name="_shopId"></param>
        /// <param name="pShopInfo"></param>
        /// <returns></returns>
        public EleResult UpdateShop(string token, long _shopId, object obj)
        {
            var        model   = new { shopId = _shopId, properties = obj };
            SignParams sign    = GetSign(token, model, "eleme.shop.updateShop");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #8
0
ファイル: EleFoodApiService.cs プロジェクト: MyLegendLife/O2O
        /// <summary>
        /// 更新菜品
        /// eleme.product.item.updateItem
        ///
        /// </summary>
        public EleResult UpdateItem(string token, dynamic product)
        {
            var        model   = new { itemId = product.itemId, categoryId = product.categoryId, properties = product.properties };
            SignParams sign    = GetSign(token, model, "eleme.product.item.updateItem");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #9
0
ファイル: EleFoodApiService.cs プロジェクト: MyLegendLife/O2O
        /// <summary>
        /// 查看商品详情
        /// </summary>
        /// <param name="_itemId"></param>
        /// <returns></returns>
        public EleResult GetItem(string token, long itemId)
        {
            var        model   = new { itemId = itemId };
            SignParams sign    = GetSign(token, model, "eleme.product.item.getItem");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #10
0
ファイル: EleFoodApiService.cs プロジェクト: MyLegendLife/O2O
        /// <summary>
        /// 分页获取店铺下的商品
        /// </summary>
        /// <param name="_shopId"></param>
        /// <returns></returns>
        public EleResult QueryItemByPage(string token, long shopId, long offset = 0, long limit = 300)
        {
            var        model   = new { queryPage = new { limit = limit, offset = offset, shopId = shopId } };
            SignParams sign    = GetSign(token, model, "eleme.product.item.queryItemByPage");
            string     content = MakeNopEntity(sign, model);
            string     res     = HttpCommon.Post(EleConfig.API_URL, "application/json;charset=utf-8", null, content);

            return(JsonConvert.DeserializeObject <EleResult>(res));
        }
コード例 #11
0
        /// <summary>
        /// 取Sign
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected SignParams GetSign(string token, object obj, string action)
        {
            long    timestamp = ToolsCommon.GetTimestamp();
            JObject jObj      = JObject.FromObject(obj);

            jObj.Add("app_key", EleConfig.APP_KEY);
            jObj.Add("timestamp", timestamp);
            string sortJson = JsonSort.SortJson(jObj, null);

            ////替换掉属性排序关键字
            //Regex reg = new Regex("[a-z]__");
            //sortJson = reg.Replace(sortJson, "");
            jObj = JObject.Parse(sortJson);
            List <JProperty> listProperty = jObj.Properties().ToList();
            StringBuilder    buff         = new StringBuilder();

            foreach (JProperty attr in listProperty)
            {
                string pKey   = attr.Name;
                string pValue = attr.Value.ToString(Newtonsoft.Json.Formatting.None);
                if (attr.Value.Type == JTokenType.String)
                {
                    pValue = "\"" + attr.Value.ToString() + "\"";
                }
                else if (attr.Value.Type == JTokenType.Float)
                {
                    pValue = float.Parse(pValue).ToString();
                }
                else if (attr.Value.Type == JTokenType.Object)
                {
                }
                buff.Append(pKey + "=" + pValue);
            }

            //完整拼接字符串
            string     fullParams  = action + token + buff.ToString() + EleConfig.APP_SECRET;
            string     sign        = ToolsCommon.GetMD5(fullParams).ToUpper();
            SignParams pSignParams = new SignParams();

            pSignParams.sign      = sign;
            pSignParams.timestamp = timestamp;
            pSignParams.token     = token;
            pSignParams.action    = action;
            return(pSignParams);
        }
コード例 #12
0
 /// <summary>
 /// 构建NOP对象
 /// </summary>
 /// <param name="sign"></param>
 /// <param name="params_repl_"></param>
 /// <returns></returns>
 protected string MakeNopEntity(SignParams sign, object params_repl_)
 {
     return(MakeNopEntity(sign.action, sign.token, sign.timestamp, params_repl_, sign.sign));
 }