|
@@ -3739,8 +3739,12 @@ public class OrderController : BaseController
|
|
|
/// <param name="file"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("import-order")]
|
|
|
- public async Task ImportOrder([FromForm]IFormFile file,[FromBody]ESource source)
|
|
|
+ public async Task ImportOrder(/*[FromForm]*/IFormFile file,/*[FromBody]*/ESource source)
|
|
|
{
|
|
|
+ if (source< ESource.MALASHEQU || source > ESource.WENZHENGSC)
|
|
|
+ {
|
|
|
+ throw UserFriendlyException.SameMessage("不支持导入该渠道");
|
|
|
+ }
|
|
|
using (var stream = new MemoryStream())
|
|
|
{
|
|
|
file.CopyTo(stream);
|
|
@@ -3755,17 +3759,27 @@ public class OrderController : BaseController
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var order = _mapper.Map<Order>(item);
|
|
|
- order.Source = source;
|
|
|
- var id = await _orderRepository.AddAsync(order);
|
|
|
- if (!string.IsNullOrEmpty(id))
|
|
|
+ var order =await _orderRepository.GetAsync(x => x.No == item.No, HttpContext.RequestAborted);
|
|
|
+ if (order is null)
|
|
|
{
|
|
|
- successCount++;
|
|
|
+ order = _mapper.Map<Order>(item);
|
|
|
+ order.Source = source;
|
|
|
+ var id = await _orderRepository.AddAsync(order,HttpContext.RequestAborted);
|
|
|
+ if (!string.IsNullOrEmpty(id))
|
|
|
+ {
|
|
|
+ successCount++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ errorCount++;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- errorCount++;
|
|
|
+ _mapper.Map(item, order);
|
|
|
+ await _orderRepository.UpdateAsync(order,HttpContext.RequestAborted);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
catch
|
|
|
{
|