Example #1
0
        /// <summary>
        /// 批量获取指定时间区间的订单
        /// (待升舱的订单)
        /// </summary>
        /// <param name="param">参数实体</param>
        /// <param name="auth">授权参数</param>
        /// <returns>订单列表</returns>
        /// <remarks>2016-6-11 杨浩 创建</remarks>
        public Result <List <UpGradeOrder> > GetOrderList(OrderParameters param, AuthorizationParameters auth)
        {
            var dealerInfo = new HytOrderDealerInfo()
            {
                DealerSysNo     = 0,
                DealerMallSysNo = 5,
                HytPayStatus    = 20,
                IsSelfSupport   = 1,
            };
            var result = new Result <List <UpGradeOrder> > {
                Status = true, Message = "", Data = null, StatusCode = 0
            };
            var orderList = new List <UpGradeOrder>();
            var _param    = new Dictionary <string, string>();

            //_param.Add("fields", "tid,title,receiver_city,outer_tid,orders");
            _param.Add("status", "WAIT_SELLER_SEND_GOODS");//等待卖家发货,即:买家已付款

            _param.Add("use_has_next", "true");
            _param.Add("page_size", "40");
            _param.Add("page_no", "1");

            _param.Add("start_update", param.StartDate.ToString("yyyy-MM-dd HH:mm:ss"));
            _param.Add("end_update", param.EndDate.ToString("yyyy-MM-dd HH:mm:ss"));
            //_param.Add("start_created", param.StartDate.ToString("yyyy-MM-dd HH:mm:ss"));
            //_param.Add("end_created", param.EndDate.ToString("yyyy-MM-dd HH:mm:ss"));

            var response = kit.get("kdt.trades.sold.get", _param);

            while (true)
            {
                var  trade    = JObject.Parse(response);
                var  trades   = trade["response"]["trades"];
                bool has_next = bool.Parse(trade["response"]["has_next"].ToString());

                trade = JObject.Parse(response);
                foreach (var i in trades)
                {
                    var order = new UpGradeOrder();

                    Map(i, order);
                    order.HytOrderDealer            = dealerInfo;
                    order.HytOrderDealer.HytPayType = YouZanPayToPayTypeSysNo(i["pay_type"].ToString());
                    orderList.Add(order);
                }

                if (has_next)
                {
                    _param["page_no"] = (int.Parse(_param["page_no"].ToString()) + 1).ToString();
                    response          = kit.get("kdt.trades.sold.get", _param);
                }
                else
                {
                    break;
                }
            }

            result.Data = orderList;
            return(result);
        }
        /// <summary>
        /// 获取所有未结束的优惠列表(包含未开始的、进行中的)
        /// </summary>
        /// <param name="appID"></param>
        /// <param name="appSecert"></param>
        /// <returns></returns>
        public ActionResult GetUnfinishedCoupons(string appID, string appSecert)
        {
            var api     = new KDTApiKit(appID, appSecert);
            var parames = new Dictionary <string, string>();
            var data    = api.get("kdt.ump.coupons.unfinished.all", parames);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        //获取所有支付的商品
        public ActionResult GetPayedOrders(string appID, string appSecert)
        {
            var api     = new KDTApiKit(appID, appSecert);
            var parames = new Dictionary <string, string>();
            var data    = api.get("kdt.trades.sold.get", parames);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        //核销虚拟商品订单
        public ActionResult UseOrderInfo(string orderId, string appID, string appSecert)
        {
            var api     = new KDTApiKit(appID, appSecert);
            var parames = new Dictionary <string, string>();

            parames.Add("code", orderId);
            var data = api.get("kdt.trade.virtualcode.apply", parames);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        //根据粉丝ID,给粉丝授权优惠码
        public ActionResult GetCouponWithWechatId(string couponGroupId, string wechatId, string appID, string appSecert)
        {
            var api     = new KDTApiKit(appID, appSecert);
            var parames = new Dictionary <string, string>();

            parames.Add("coupon_group_id", couponGroupId);
            parames.Add("fans_id", wechatId);

            var data = api.get("kdt.ump.coupon.take", parames);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }