From f366fea2c6c83020c1e6423e2c66242678b8f877 Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期四, 11 四月 2024 14:26:41 +0800
Subject: [PATCH] 修改用户推广搜索

---
 CoreCms.Net.Web.WebApi/Controllers/GoodController.cs |   87 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs b/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs
index 5eef183..420f867 100644
--- a/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs
+++ b/CoreCms.Net.Web.WebApi/Controllers/GoodController.cs
@@ -1,10 +1,9 @@
-锘�/***********************************************************************
- *            Project: CoreCms
- *        ProjectName: 鏍稿績鍐呭绠$悊绯荤粺                                
- *                Web: https://www.corecms.net                      
- *             Author: 澶х伆鐏�                                          
- *              Email: jianweie@163.com                                
- *         CreateTime: 2021/1/31 21:45:10
+锘�/*********************************************************************** 
+ *        ProjectName: 鐧惧垎鍏垫硶绠$悊绯荤粺                               
+ *                Web: http://chuanyin.com                     
+ *             Author:                                        
+ *              Email:                               
+ *         CreateTime: 202403/02   
  *        Description: 鏆傛棤
  ***********************************************************************/
 
@@ -20,11 +19,13 @@
 using CoreCms.Net.Configuration;
 using CoreCms.Net.DTO.ComponentsDTO;
 using CoreCms.Net.IServices;
+using CoreCms.Net.IServices.baifenbingfa;
 using CoreCms.Net.Model.Entities;
 using CoreCms.Net.Model.Entities.Expression;
 using CoreCms.Net.Model.FromBody;
 using CoreCms.Net.Model.ViewModels.DTO;
 using CoreCms.Net.Model.ViewModels.UI;
+using CoreCms.Net.Services.Basic;
 using CoreCms.Net.Utility.Extensions;
 using CoreCms.Net.Utility.Helper;
 using Microsoft.AspNetCore.Authorization;
@@ -33,6 +34,8 @@
 using Newtonsoft.Json;
 using NPOI.SS.Formula.Functions;
 using SqlSugar;
+using static SKIT.FlurlHttpClient.Wechat.Api.Models.ChannelsECMerchantAddFreightTemplateRequest.Types.FreightTemplate.Types;
+using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types;
 
 namespace CoreCms.Net.Web.WebApi.Controllers
 {
@@ -60,6 +63,8 @@
         private ICoreCmsAgentProductsServices _agentProductsServices;
         private ICoreCmsAgentGradeServices _agentGradeServices;
         private ICoreCmsGoodsCategoryExtendServices _goodsCategoryExtendServices;
+        private readonly ICoreCmsAreaServices _coreCmsAreaServices;
+        private readonly IBfbfComAPIService _bfbfComAPIService;
 
         /// <summary>
         /// 鏋勯�犲嚱鏁�
@@ -76,7 +81,14 @@
             , ICoreCmsGoodsParamsServices goodsParamsServices
             , ICoreCmsGoodsCollectionServices goodsCollectionServices
             , ICoreCmsUserServices userServices
-            , ICoreCmsAgentServices agentServices, ICoreCmsAgentProductsServices agentProductsServices, ICoreCmsAgentGradeServices agentGradeServices, ICoreCmsGoodsCategoryExtendServices goodsCategoryExtendServices)
+            , ICoreCmsAgentServices agentServices, 
+            ICoreCmsAgentProductsServices agentProductsServices, 
+            ICoreCmsAgentGradeServices agentGradeServices, 
+            ICoreCmsGoodsCategoryExtendServices goodsCategoryExtendServices,
+            ICoreCmsAreaServices areaServices,
+            IBfbfComAPIService bfbfComAPIService
+
+            )
         {
             _mapper = mapper;
             _user = user;
@@ -94,6 +106,8 @@
             _agentProductsServices = agentProductsServices;
             _agentGradeServices = agentGradeServices;
             _goodsCategoryExtendServices = goodsCategoryExtendServices;
+            _coreCmsAreaServices = areaServices;
+            _bfbfComAPIService = bfbfComAPIService;
         }
 
         //鍏叡鎺ュ彛====================================================================================================
@@ -133,7 +147,7 @@
                 parentTree.imageUrl = !string.IsNullOrEmpty(item.imageUrl) ? item.imageUrl : "/static/images/common/empty.png";
                 parentTree.name = item.name;
                 parentTree.sort = item.sort;
-
+               parentTree.key=item.key;
                 childTree.Add(parentTree);
 
                 parentTree.child = GetCategories(oldCategories, item.id);
@@ -155,6 +169,13 @@
             var jm = new WebApiCallBack();
 
             var where = PredicateBuilder.True<GoodListDTO>();
+            //鏄惁鏄粡閿�鍟�
+            bool isDic = false;
+            if (_user.ID > 0)
+            {
+                isDic = await _bfbfComAPIService.IsDictionary(_user.ID);
+
+            };
 
             var className = string.Empty;
             if (!string.IsNullOrWhiteSpace(entity.where))
@@ -167,6 +188,8 @@
                     brandId = "",
                     labelId = "",
                     searchName = "",
+                    areaCode=""
+
                 });
 
                 if (!string.IsNullOrWhiteSpace(obj.priceFrom))
@@ -241,13 +264,35 @@
                 {
                     where = where.And(p => p.name.Contains(obj.searchName));
                 }
+                if (!string.IsNullOrWhiteSpace(obj.areaCode))
+                {
+                    where = where.And(p => p.areaCode.Contains(obj.areaCode));
+                }
             }
+
             //鑾峰彇鏁版嵁
             var list = await _goodsServices.QueryPageByDTOAsync(where, entity.page, entity.limit, true);
+             
 
             //鑾峰彇鍝佺墝
             var brands = await _brandServices.QueryListByClauseAsync(p => p.isShow == true, p => p.sort, OrderByType.Desc, true, true);
+            foreach (var item in list)
+            {
+                var codelist = item.areaCode?.Split(",");
+                item.area = "";
+                if(codelist!=null)
+                foreach (var code in codelist)
+                {
+                  
+                    item.area+= (await _coreCmsAreaServices.GetAreaString(code)+"");
+                }
+                //璋冩暣缁忛攢鍟嗕环鏍� 鐧惧垎鍏垫硶
+                if(isDic)
+                {
+                    item.price = item.distributionPrice;
+                }
 
+            }
             //杩斿洖鏁版嵁
             jm.status = true;
             jm.data = new
@@ -278,13 +323,19 @@
         {
             var jm = new WebApiCallBack();
 
-            var model = await _goodsServices.GetGoodsDetail(entity.id, 0, false, "goods", 0, entity.data.ObjectToBool());
+            CoreCmsGoods model = await _goodsServices.GetGoodsDetail(entity.id, 0, false, "goods", 0, entity.data.ObjectToBool());
             if (model == null)
             {
                 jm.msg = "鍟嗗搧鑾峰彇澶辫触";
                 return jm;
             }
-
+            var codelist= model.areaCode.Split(",");
+            model.area = "";
+            foreach (var item in codelist)
+            {
+                 
+                model.area += (await _coreCmsAreaServices.GetAreaString(item) + "");
+            }
             jm.status = true;
             jm.msg = "鑾峰彇鍟嗗搧璇︽儏鎴愬姛";
             jm.data = model;
@@ -574,13 +625,25 @@
             }
 
             var model = await _goodsServices.GetGoodsDetail(entity.id, userId, false, "goods", 0, entity.data.ObjectToBool());
-
+           
             if (model == null)
             {
                 jm.msg = "鍟嗗搧鑾峰彇澶辫触";
                 return jm;
             }
+            if (await _bfbfComAPIService.IsDictionary(user.id))
+            {
+                //鐧惧垎鍏垫硶缁忛攢鍟�
+                model.product.price = model.product.distributionPrice;   
+            }
+            var codelist = model.areaCode?.Split(",");
+            model.area = "";
+            if(codelist!=null)
+            foreach (var item in codelist)
+            {
 
+                model.area += (await _coreCmsAreaServices.GetAreaString(item) + "");
+            }
             var userAgent = await _agentServices.QueryByClauseAsync(p => p.userId == user.id);
             var agentProducts = new List<CoreCmsAgentProducts>();
             var userAgentGrade = new CoreCmsAgentGrade();

--
Gitblit v1.9.1