Commit 39c85f48 by 泽锋 李

新增下首单推送接口

parent 2a3994a6
using AutoTurnOver.Models;
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
namespace AutoTurnOver.DB
{
/// <summary>
/// 下首单
/// </summary>
public class dc_auto_first_order_sku_dao : connectionHelper
{
public static void Add(dc_auto_first_order_sku_input_dto input_data)
{
var now = DateTime.Now;
if (input_data.detailed == null || input_data.detailed.Count <= 0)
{
throw new Exception("sku必填");
}
if (input_data.sendtype <= 0)
{
throw new Exception("运输方式必填");
}
if (string.IsNullOrWhiteSpace(input_data.warehouse_code))
{
throw new Exception("仓库编码必填");
}
using (var conn = _connection)
{
conn.Open();
using (var t = conn.BeginTransaction())
{
foreach (var item in input_data.detailed)
{
var old_data = conn.QuerySingleOrDefault<dc_auto_first_order_sku>(" select * from dc_auto_first_order_sku where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ", new { bailun_sku = item, warehouse_code = input_data.warehouse_code });
if (old_data != null) throw new Exception($" sku {item} , 仓库编码 :{ input_data.warehouse_code} 已存在 ");
conn.Insert(new dc_auto_first_order_sku
{
bailun_sku = item,
push_date = now,
warehouse_code = input_data.warehouse_code,
sendtype = input_data.sendtype
}, t);
}
t.Commit();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 下首单的sku
/// </summary>
public class dc_auto_first_order_sku
{
public int id { get; set; }
public string bailun_sku { get; set; }
public DateTime push_date { get; set; }
public string warehouse_code { get; set; }
/// <summary>
/// 运输方式 1=陆运 2=海运 3=空运 4=铁路运输
/// </summary>
public int sendtype { get; set; }
public DateTime? order_time { get; set; }
}
public class dc_auto_first_order_sku_input_dto
{
public string warehouse_code { get; set; }
public int sendtype { get; set; }
public List<string> detailed { get; set; }
}
}
using AutoTurnOver.DB;
using AutoTurnOver.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Services
{
public class FirstOrderService
{
public void Add(dc_auto_first_order_sku_input_dto input_data)
{
dc_auto_first_order_sku_dao.Add(input_data);
}
}
}
......@@ -81,5 +81,26 @@ namespace AutoTurnOver.Controllers
});
}
}
[HttpPost("FirstOrderSkuAdd")]
public JsonResult FirstOrderSkuAdd([FromBody]dc_auto_first_order_sku_input_dto inputData)
{
try
{
new FirstOrderService().Add(inputData);
return new JsonResult(new
{
success = true,
});
}
catch (Exception ex)
{
return new JsonResult(new
{
message = ex.Message,
success = false,
});
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment