Esempio n. 1
0
        public HttpResponseMessage GetOtherRiders(RiderReq req)
        {
            var riderId = Convert.ToInt32(req.riderId);

            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var rider  = RiderInfoOper.Instance.GetById(riderId);
            var areaId = (int)rider.riderAreaId;
            var r      = RiderInfoOper.Instance.GetRidersInArea(areaId, riderId);

            if (r.Count < 1)
            {
                return(ControllerHelper.Instance.JsonEmptyArr(200, "无其他骑手"));
            }

            return(ControllerHelper.Instance.JsonResult(200, JsonConvert.SerializeObject(r), ""));
        }
Esempio n. 2
0
        public HttpResponseMessage GetStock(RiderReq req)
        {
            var   riderId  = Convert.ToInt32(req.riderId);
            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var list = RiderStockOper.Instance.GetRSViewByRiderId(riderId);

            list = list.Where(p => p.amount > 0).ToList();
            if (list.Count < 1)
            {
                return(ControllerHelper.Instance.JsonEmptyArr(200, "暂无库存"));
            }
            else
            {
                List <RiderStockRes> listR = new List <RiderStockRes>();
                foreach (var item in list)
                {
                    RiderStockRes res = new RiderStockRes(item, apiHost);
                    listR.Add(res);
                }
                return(ControllerHelper.Instance.JsonResult(200, JsonConvert.SerializeObject(listR), ""));
            }
        }
Esempio n. 3
0
        public HttpResponseMessage GetOtherApplyRecord(RiderReq req)
        {
            var riderId = Convert.ToInt32(req.riderId);

            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var list = CacheHelper.GetByCondition <AllocateView>("allocateview", " status=0 and targetRiderid=" + riderId);

            if (list.Count < 0)
            {
                return(ControllerHelper.Instance.JsonEmptyArr(200, "暂无请求"));
            }

            var riderIds = list.Select(p => p.riderId).Distinct().ToArray();
            List <AllocateMeRes> listR = new List <AllocateMeRes>();

            foreach (var item in riderIds)
            {
                var           temp = list.Where(p => p.riderId == item).ToList();
                AllocateMeRes res  = new AllocateMeRes(temp);
                listR.Add(res);
            }

            return(ControllerHelper.Instance.JsonResult(200, JsonConvert.SerializeObject(listR), ""));
        }
Esempio n. 4
0
        public HttpResponseMessage SetType(RiderReq req)
        {
            var riderId = Convert.ToInt32(req.riderId);

            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var rider = RiderInfoOper.Instance.GetById(riderId);

            if (rider.riderType != 2)
            {
                if (rider.riderType == 1)
                {
                    rider.riderType = 0;
                }
                else
                {
                    rider.riderType = 1;
                }
            }
            //var temp = rider.riderType + 1;
            //rider.riderType = temp > 2 ? 0 : temp;

            try
            {
                var riderHere = new RiderInfo();
                riderHere.id        = rider.id;
                riderHere.riderType = rider.riderType;
                RiderInfoOper.Instance.Update(riderHere);
                if (rider.riderType == 2)
                {
                    var ua = UserAddressOper.Instance.GetByRiderId(riderId);
                    if (ua == null)
                    {
                        ua         = new UserAddress();
                        ua.riderId = riderId;
                        var rp = CacheHelper.GetRiderPosition(riderId);
                        ua.lat        = rp.lat;
                        ua.lng        = rp.lng;
                        ua.mapAddress = rider.mapAddress;
                        ua.phone      = rider.phone;
                        UserAddressOper.Instance.Add(ua);
                    }
                }
                return(ControllerHelper.Instance.JsonResult(200, "riderType", rider.riderType.ToString(), "更换成功"));
            }
            catch (Exception e)
            {
                return(ControllerHelper.Instance.JsonResult(500, "更换失败"));
            }
        }
Esempio n. 5
0
        public HttpResponseMessage ToggleRiderStatus(RiderReq req)
        {
            var riderId = Convert.ToInt32(req.riderId);

            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var rider = RiderInfoOper.Instance.GetById(riderId);

            if ((bool)rider.riderStatus)
            {
                rider.riderStatus = false;
            }
            else
            {
                rider.riderStatus = true;
            }

            var riderHere = new RiderInfo();

            riderHere.id          = riderId;
            riderHere.riderStatus = rider.riderStatus;

            RiderInfoOper.Instance.Update(riderHere);
            JObject jo = new JObject();

            jo.Add("riderStatus", rider.riderStatus);
            return(ControllerHelper.Instance.JsonResult(200, JsonConvert.SerializeObject(jo), ""));
        }
Esempio n. 6
0
        public HttpResponseMessage GetArea(RiderReq req)
        {
            var riderId = Convert.ToInt32(req.riderId);

            var   tokenStr = req.Token;
            Token token    = CacheHelper.GetRiderToken(tokenStr);

            if (token == null)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token失效"));
            }
            if (token.Payload.UserID != riderId)
            {
                return(ControllerHelper.Instance.JsonResult(400, "token错误"));
            }

            var r = AreaInfoOper.Instance.GetAreaList();

            if (r != null)
            {
                return(ControllerHelper.Instance.JsonResult(200, JsonConvert.SerializeObject(r), ""));
            }
            return(ControllerHelper.Instance.JsonEmptyArr(200, "暂无可选区域"));
        }