public HttpResponseMessage GiveToOtherRider(GiveToOtherRider 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_foods = JsonConvert.DeserializeObject <List <foodId_Amount> >(req.listFoods);
            var listRs     = CacheHelper.GetByCondition <RiderStock>("RiderStock", " isdeleted=0 and riderid=" + riderId);
            var ids        = list_foods.Select(p => p.foodId).Distinct().ToArray();
            var tempList   = listRs.Where(p => ids.Contains((int)p.foodId)).ToList();

            foreach (var item in list_foods)
            {
                var amount = tempList.Where(p => p.foodId == item.foodId).First().amount;
                if (amount < item.amount)
                {
                    return(ControllerHelper.Instance.JsonResult(500, "库存不够"));
                }
            }
            var targetRiderId = Convert.ToInt32(req.targetRiderId);

            RiderStockOper.Instance.RemoveRs(riderId, list_foods);
            RiderStockOper.Instance.AddRs(targetRiderId, list_foods);
            return(ControllerHelper.Instance.JsonResult(200, "调配成功"));
        }
        public HttpResponseMessage ApplyToOtherRider(GiveToOtherRider req)
        {
            //-txy 这里要不要判断请求的人够不够呢
            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_foods = JsonConvert.DeserializeObject <List <foodId_Amount> >(req.listFoods);



            var targetRiderId   = Convert.ToInt32(req.targetRiderId);
            var targetListFoods = RiderStockOper.Instance.GetByRiderId(targetRiderId);

            if (targetListFoods.Count < 1)
            {
                return(ControllerHelper.Instance.JsonResult(500, "对方库存不足"));
            }
            foreach (var item in list_foods)
            {
                var temp = targetListFoods.Where(p => p.foodId == item.foodId).ToList();
                if (temp.Count < 1)
                {
                    return(ControllerHelper.Instance.JsonResult(500, "对方库存不足"));
                }
                if (temp.First().amount < item.amount)
                {
                    return(ControllerHelper.Instance.JsonResult(500, "对方库存不足"));
                }
            }


            var timestamp  = StringHelperHere.Instance.GetTimeStamp() + StringHelperHere.Instance.GetLastFiveStr(riderId.ToString());
            var allocateId = 0;

            foreach (var item in list_foods)
            {
                AllocateRecord ar = new AllocateRecord();
                ar.riderId       = riderId;
                ar.foodId        = item.foodId;
                ar.amount        = item.amount;
                ar.targetRiderId = targetRiderId;
                ar.status        = 0;
                ar.timestamp     = timestamp;
                allocateId       = AllocateRecordOper.Instance.Add(ar);
            }

            //推送消息
            UPushHelper.Instance.PushRiderApply(targetRiderId, list_foods, riderId, timestamp);

            return(ControllerHelper.Instance.JsonResult(200, "已发送调配请求"));
        }