public SesJsonResult(JsonResultStatus status, object data, string message)
 {
     Status  = status;
     Message = message;
     Data    = data;
 }
 public SesJsonResult(JsonResultStatus status, string message)
 {
     Status  = status;
     Message = message;
 }
 public SesJsonResult(JsonResultStatus status)
 {
     Status = status;
 }
Esempio n. 4
0
 public JsonResultExt(JsonResultStatus code, object obj, object token) :
     this(code, obj)
 {
     Token = token;
 }
Esempio n. 5
0
 public JsonResultExt(JsonResultStatus code, object obj) :
     this(obj)
 {
     Code = code;
 }
Esempio n. 6
0
        public JsonResult CreateOrder(Orders.Dto.OrderInputDtos json)
        {
            Logger.Debug("当前json" + json.ToString());
            var    obj     = json;
            var    item    = json.Order;
            string address = json.Address;
            string remark  = json.Remark;
            string time    = json.Time;

            JsonResultStatus rstJson = new JsonResultStatus();
            var lng_lat = _orderRepository.getMapRange();

            if (lng_lat.Lat != null && lng_lat.Lat.Count >= 1 && !pointIntersect.IsPointInPolygon(json.Lat, json.Lng, lng_lat.Lat, lng_lat.Lng))
            {
                rstJson.Code = 401;
                rstJson.Msg  = "该区域未开通";

                return(Json(rstJson));
            }

            //Logger.Debug("当前用户Cookie" + Common.UserHelper.Instance.getCookie());
            Logger.Debug("当前用户Id" + Common.UserHelper.Instance.getUserId().ToString());
            List <Orders.Dto.OrderItemsInputDto> items = new List <Orders.Dto.OrderItemsInputDto>();
            string orderId = GuidToLong.OrderId();

            if (json.Order != null)
            {
                for (int index = 0; index <= json.Order.Count - 1; index++)
                {
                    items.Add(new Orders.Dto.OrderItemsInputDto()
                    {
                        F_OrderId = orderId, ProductId = json.Order[index].Id, ProductName = json.Order[index].Prod_Name, ProductNum = int.Parse(json.Order[index].Value), Unit = json.Order[index].Unit
                    });
                }
            }
            Orders.Dto.OrderInputDto orders = new Orders.Dto.OrderInputDto();
            orders.Id        = orderId;
            orders.OrderTime = DateTime.Now;
            orders.RecTime   = json.Time;
            Logger.Debug("当前用户Id" + Common.UserHelper.Instance.getUserId().ToString());
            orders.UserId = Common.UserHelper.Instance.getUserId().ToString();

            orders.Address     = json.Address;
            orders.OrderType   = json.OrderType;
            orders.RecPhone    = json.RecPhone;
            orders.RecUserName = json.RecUserName;

            if (_orderRepository.CreateOrder(orders, items))
            {
                var addressItem = _userAddressService.GetDefault(Common.UserHelper.Instance.getUserId());
                if (addressItem == null)
                {
                    UserAddress.Dto.UserAddressInputDto input = new UserAddress.Dto.UserAddressInputDto();
                    input.Address     = orders.Address;
                    input.ContactName = orders.RecUserName;
                    input.PhoneNo     = orders.RecPhone;
                    input.IsDefault   = 1;
                    input.UserId      = Common.UserHelper.Instance.getUserId();
                    input.Status      = 1;
                    _userAddressService.AddNewAddress(input);
                }
                string[] weixin = Common.UserHelper.Instance.getAccessToken();
                try
                {
                    if (weixin == null)
                    {
                        Logger.Debug("订单下发成功后无法微信推送");
                    }
                    else
                    {
                        OrderTemplateData orderData = new OrderTemplateData();
                        orderData.first    = new TemplateDataItem("亲,你的订单已提交成功");
                        orderData.keyword1 = new TemplateDataItem(DateTime.Now.ToString("yyyy-MM-dd"));
                        orderData.keyword2 = new TemplateDataItem(string.Join("、", items.Select(o => o.ProductName)));
                        orderData.keyword3 = new TemplateDataItem(orders.Id);
                        orderData.remark   = new TemplateDataItem("感谢你的支持,派单成功后,工作人员半小时内与你取得联系。");
                        Common.WeiXinHelper.SendMsgToWeUser(Common.CommonConst.AppID, weixin[4], orders.Id, orderData);
                        //Senparc.Weixin.MP.AdvancedAPIs.CustomApi.SendText(Common.CommonConst.AppID, weixin[4], string.Format("下单成功!您的订单号为{0}", orders.Id));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Debug("订单下发成功后微信推送" + ex.Message + ex.StackTrace);
                }
                rstJson.Code = 200;
                rstJson.Msg  = "下单成功!";
            }
            else
            {
                rstJson.Code = 401;
                rstJson.Msg  = "下单失败!";
            }
            return(Json(rstJson));
        }