Dun.Jason 1 year ago
parent
commit
5dd3c099a0

+ 21 - 7
src/Hotline.Api/Controllers/OrderController.cs

@@ -3739,8 +3739,12 @@ public class OrderController : BaseController
     /// <param name="file"></param>
     /// <param name="file"></param>
     /// <returns></returns>
     /// <returns></returns>
     [HttpPost("import-order")]
     [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())
         using (var stream = new MemoryStream())
         {
         {
             file.CopyTo(stream);
             file.CopyTo(stream);
@@ -3755,17 +3759,27 @@ public class OrderController : BaseController
                 {
                 {
                     try
                     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
                         else
                         {
                         {
-                            errorCount++;
+                            _mapper.Map(item, order);
+                            await _orderRepository.UpdateAsync(order,HttpContext.RequestAborted);
                         }
                         }
+                        
                     }
                     }
                     catch
                     catch
                     {
                     {

+ 7 - 0
src/Hotline.Share/Enums/Order/ESource.cs

@@ -51,6 +51,13 @@ public enum ESource
     [Description("麻辣社区")]
     [Description("麻辣社区")]
     MALASHEQU = 500,
     MALASHEQU = 500,
 
 
+    [Description("人民网")]
+    RENMINWANG = 501,
 
 
+    [Description("省长信箱")]
+    SHENGZHANGXINXIANG = 502,
+
+    [Description("问政四川")]
+    WENZHENGSC = 529,
     #endregion
     #endregion
 }
 }