From f0226fac55f50b362d145ce969e66d41606a8b06 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期五, 30 七月 2021 14:13:16 +0800
Subject: [PATCH] 今日开发  订单优惠   下订单的时候计算优惠                访问申请

---
 zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs |   54 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs
index 8fd61ed..ba62186 100644
--- a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs
+++ b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/CooperOrderController.cs
@@ -40,13 +40,15 @@
         private readonly IFiMemberService _fiMemberService;
         private readonly IConfiguration _configuration;
         private readonly IHttpClientFactory _clientFactory;
+        private readonly IAskService _askService; 
 
 
         public CooperOrderController(ILogger<CooperOrderController> logger, ILiaotianService liaotianService, IUserService userService, ICooperOrderService cooperOrderService
             , ICooperatecustomCustomerService cooperatecustomCustomerService, IProjectService projectService, IPltPageService pltPageService, IFiBookService fiBookService
             , IFiServiceService fiServiceService, IFiMemberService fiMemberService
             , IConfiguration configuration
-            , IHttpClientFactory clientFactory)
+            , IHttpClientFactory clientFactory
+            , IAskService askService)
         {
             _logger = logger;
             _liaotianService = liaotianService;
@@ -60,6 +62,7 @@
             _fiMemberService = fiMemberService;
             _configuration = configuration;
             _clientFactory = clientFactory;
+            _askService = askService;
         }
 
         [CheckLogin]
@@ -405,12 +408,14 @@
             {
                 dto = _cooperOrderService.Get(id);
                 ViewBag.ShouliStatus = ShouliStatus;
+                //ViewBag.YouHuiList = _askService.GetAskYouHuiList(dto.Khdw, dto.OrderType);
             }
             else
             {
                 dto.XdTime = DateTime.Now;
                 dto.OrderNum = 1;
                 ViewBag.ShouliStatus = "1";
+                //ViewBag.YouHuiList = new List<AdmAskYouHuiDTO>();
             }
 
 
@@ -534,14 +539,49 @@
 
                     
                 }
-                data.ShouliStatus = "1";
-                data.Modifier = curentuser.Id;
-                data.Modifytime = DateTime.Now;
 
-                resultEntity = _cooperOrderService.save(data);
+            var youHuiDTOs = _askService.GetAskYouHuiList(data.Khdw, data.OrderType).FirstOrDefault();
+            if (youHuiDTOs != null)
+            {
+                data.Youhuier = youHuiDTOs.Id;
+                if(youHuiDTOs.Youhuistandard == "01")
+                {
+                    data.Youhui = youHuiDTOs.YouHui.Value;
+                    if(data.Money.Value < data.Youhui.Value)
+                    {
+                        data.Money = 0;
+                    }
+                    else
+                    {
+                        data.Money = data.Money.Value - data.Youhui.Value;
+                    }
+                   
+                }
+                else if (youHuiDTOs.Youhuistandard == "02")
+                {
+                    if (youHuiDTOs.YouHui.Value >= 100)
+                    {
+                        data.Youhui = data.Money.Value;
+                        data.Money = 0;
+                    }
+                    else
+                    {
+                        data.Youhui =Math.Round(data.Money.Value * youHuiDTOs.YouHui.Value * new decimal(0.01),2);
+                        data.Money = data.Money.Value - data.Youhui.Value;
+                    }
+                }
+                  
+                  
+            }
+            
+            data.ShouliStatus = "1";
+            data.Modifier = curentuser.Id;
+            data.Modifytime = DateTime.Now;
+
+            resultEntity = _cooperOrderService.save(data);
             //    scope.Complete();
             //}
-           
+
 
             return new JsonResult(resultEntity);
         }
@@ -847,7 +887,7 @@
                 result = JsonConvert.SerializeObject(shi);
             }
 
-            if (OrderType == "08" || OrderType == "10")
+            if (OrderType == "08" || OrderType == "10" || OrderType == "11")
             {
                
                 result = "[]";

--
Gitblit v1.9.1