using System;
using System.Web;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using MySystem.Models.Main;
using Library;
using System.Linq;
using LitJson;
using Microsoft.AspNetCore.Authorization;
using MySystem.Service.Main;
namespace MySystem.Areas.Api.Controllers.v1
{
[Area("Api")]
[Route("Api/v1/[controller]/[action]")]
public class PreSendStockDetailController : BaseController
{
public PreSendStockDetailController(IHttpContextAccessor accessor) : base(accessor)
{
}
#region 创客-首页-仓库管理-小分仓-确认发货
///
/// 创客-首页-仓库管理-小分仓-确认发货
///
///
[HttpPost]
[Authorize]
[Route("/main/presendstockdetail/send")]
public JsonResult Send(string value)
{
value = PublicFunction.DesDecrypt(value);
JsonData data = JsonMapper.ToObject(value);
int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //发货人Id
int ToUserId = int.Parse(function.CheckInt(data["ToUserId"].ToString())); //收货人Id
int FromStoreId = int.Parse(function.CheckInt(data["FromStoreId"].ToString())); //出货仓库Id
int BrandId = int.Parse(function.CheckInt(data["BrandId"].ToString())); //产品类型Id
string SnIds = data["SnIds"].ToString(); //机具Id
if (ToUserId <= 0)
{
return Json(new AppResultJson() { Status = "-1", Info = "收货创客不存在,请检查收货创客编号是否正确" });
}
var info = PreSendStockDetailUtil.SendDo(UserId, ToUserId, FromStoreId, BrandId, SnIds);
if (info == "success")
{
return Json(new AppResultJson() { Status = "1", Info = "发货成功", Data = "" });
}
else
{
return Json(new AppResultJson() { Status = "-1", Info = "发货失败", Data = info });
}
}
#endregion
#region 创客-首页-仓库管理-小分仓-撤回
///
/// 创客-首页-仓库管理-小分仓-撤回
///
///
[HttpPost]
[Authorize]
[Route("/main/presendstockdetail/cancel")]
public JsonResult Cancel(string value)
{
value = PublicFunction.DesDecrypt(value);
JsonData data = JsonMapper.ToObject(value);
int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //发货人Id
int Id = int.Parse(function.CheckInt(data["Id"].ToString())); //记录Id
string check = RedisDbconn.Instance.Get("SmallStoreCancel:" + UserId);
if (!string.IsNullOrEmpty(check))
{
return Json(new AppResultJson() { Status = "-1", Info = "请勿频繁操作,稍后再试" });
}
var info = PreSendStockDetailUtil.CancelDo(UserId, Id);
if (info == "success")
{
return Json(new AppResultJson() { Status = "1", Info = "撤回成功", Data = "" });
}
else
{
return Json(new AppResultJson() { Status = "-1", Info = "撤回失败", Data = info });
}
}
#endregion
}
}