From b5addd52cfb3ab5860d4f5c53422a97f7b404b9c Mon Sep 17 00:00:00 2001 From: JianWeie Date: Mon, 24 Jan 2022 02:27:26 +0800 Subject: [PATCH] =?UTF-8?q?#=202022-01-24=20###=20=20=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=89=88=EF=BC=88=E4=BC=9A=E5=91=98=E4=B8=93?= =?UTF-8?q?=E4=B8=9A=E7=89=88=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9=EF=BC=89?= =?UTF-8?q?=EF=BC=9A=20=E3=80=90=E5=AE=8C=E5=96=84=E3=80=91=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E8=90=A5=E9=94=80=E7=BB=93=E6=9E=9C=E3=80=90GOODS=5FH?= =?UTF-8?q?ALF=5FPRICE=E3=80=91=E6=8C=87=E5=AE=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=AF=8F=E7=AC=AC=E5=87=A0=E4=BB=B6=E5=87=8F=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E3=80=82=20###=200.1.2=20=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=B8=93=E4=B8=9A=E7=89=88=EF=BC=9A=20=E3=80=90=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=91=E5=BE=AE=E4=BF=A1=E7=9B=B4=E6=92=AD=E5=B8=A6?= =?UTF-8?q?=E8=B4=A7=E7=BB=84=E4=BB=B6=E6=B7=BB=E5=8A=A0=E6=94=AF=E6=8C=81?= =?UTF-8?q?base64=E4=B8=8A=E4=BC=A0=E5=88=B0=E5=BE=AE=E4=BF=A1=E4=BE=A7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82=20=E3=80=90=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=BA=BF=E7=A8=8B=E6=95=B0=E5=8F=8A=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=95=B0=E9=87=8F=E3=80=82=20=E3=80=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=91=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E9=97=B4=E5=9F=BA=E5=87=86=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BA=E6=9C=AC=E5=9C=B0loacl=E6=97=B6=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Core/Config/HangFireSetup.cs | 27 ++++++++-- .../CoreCmsPromotionResultServices.cs | 33 ++++++++++++ CoreCms.Net.Task/HangfireDispose.cs | 16 +++--- .../Controllers/Com/ToolsController.cs | 52 ++++++++++++++++++- .../transactioncomponent/goods/create.html | 28 +++++----- 5 files changed, 129 insertions(+), 27 deletions(-) diff --git a/CoreCms.Net.Core/Config/HangFireSetup.cs b/CoreCms.Net.Core/Config/HangFireSetup.cs index 57af0e7e..a051be49 100644 --- a/CoreCms.Net.Core/Config/HangFireSetup.cs +++ b/CoreCms.Net.Core/Config/HangFireSetup.cs @@ -16,6 +16,8 @@ using CoreCms.Net.Configuration; using CoreCms.Net.Utility.Extensions; using Hangfire; using Hangfire.MySql; +using Hangfire.Redis; +using Hangfire.SqlServer; using Microsoft.Extensions.DependencyInjection; using SqlSugar; @@ -34,7 +36,13 @@ namespace CoreCms.Net.Core.Config var isEnabledRedis = AppSettingsConstVars.RedisUseTimedTask; if (isEnabledRedis) { - services.AddHangfire(x => x.UseRedisStorage(AppSettingsConstVars.RedisConfigConnectionString)); + services.AddHangfire(x => x.UseRedisStorage(AppSettingsConstVars.RedisConfigConnectionString, new RedisStorageOptions() + { + Db = 10, + SucceededListSize = 500,//后续列表中的最大可见后台作业,以防止它无限增长。 + DeletedListSize = 500,//删除列表中的最大可见后台作业,以防止其无限增长。 + InvisibilityTimeout = TimeSpan.FromMinutes(30), + })); } else { @@ -48,14 +56,22 @@ namespace CoreCms.Net.Core.Config JobExpirationCheckInterval = TimeSpan.FromHours(1), //- 作业到期检查间隔(管理过期记录)。默认值为1小时。 CountersAggregateInterval = TimeSpan.FromMinutes(5), //- 聚合计数器的间隔。默认为5分钟。 PrepareSchemaIfNecessary = true, //- 如果设置为true,则创建数据库表。默认是true。 - DashboardJobListLimit = 50000, //- 仪表板作业列表限制。默认值为50000。 + DashboardJobListLimit = 500, //- 仪表板作业列表限制。默认值为50000。 TransactionTimeout = TimeSpan.FromMinutes(1), //- 交易超时。默认为1分钟。 TablesPrefix = "Hangfire" //- 数据库中表的前缀。默认为none }))); } else if (dbTypeString == DbType.SqlServer.ToString()) { - services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection)); + services.AddHangfire(x => x.UseSqlServerStorage(AppSettingsConstVars.DbSqlConnection, new SqlServerStorageOptions() + { + QueuePollInterval = TimeSpan.FromSeconds(15), //- 作业队列轮询间隔。默认值为15秒。 + JobExpirationCheckInterval = TimeSpan.FromHours(1), //- 作业到期检查间隔(管理过期记录)。默认值为1小时。 + CountersAggregateInterval = TimeSpan.FromMinutes(5), //- 聚合计数器的间隔。默认为5分钟。 + PrepareSchemaIfNecessary = true, //- 如果设置为true,则创建数据库表。默认是true。 + DashboardJobListLimit = 500, //- 仪表板作业列表限制。默认值为50000。 + TransactionTimeout = TimeSpan.FromMinutes(1), //- 交易超时。默认为1分钟。 + })); } } @@ -64,8 +80,9 @@ namespace CoreCms.Net.Core.Config options.Queues = new[] { GlobalEnumVars.HangFireQueuesConfig.@default.ToString(), GlobalEnumVars.HangFireQueuesConfig.apis.ToString(), GlobalEnumVars.HangFireQueuesConfig.web.ToString(), GlobalEnumVars.HangFireQueuesConfig.recurring.ToString() }; options.ServerTimeout = TimeSpan.FromMinutes(4); options.SchedulePollingInterval = TimeSpan.FromSeconds(15);//秒级任务需要配置短点,一般任务可以配置默认时间,默认15秒 - options.ShutdownTimeout = TimeSpan.FromMinutes(30); //超时时间 - options.WorkerCount = Math.Max(Environment.ProcessorCount, 20); //工作线程数,当前允许的最大线程,默认20 + options.ShutdownTimeout = TimeSpan.FromMinutes(5); //超时时间 + //options.WorkerCount = Math.Max(Environment.ProcessorCount, 2); //工作线程数,当前允许的最大线程,默认20 + options.WorkerCount = 2; //工作线程数,当前允许的最大线程,默认20 }); } diff --git a/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs b/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs index bdb47927..3915ff79 100644 --- a/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs +++ b/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs @@ -80,6 +80,9 @@ namespace CoreCms.Net.Services case "GOODS_ONE_PRICE": promotionModel = result_GOODS_ONE_PRICE(parameters, item, promotionInfo); break; + case "GOODS_HALF_PRICE": //todo 指定商品每第几件减指定金额 + promotionModel = result_GOODS_HALF_PRICE(parameters, item, promotionInfo); + break; default: promotionModel = 0; break; @@ -316,5 +319,35 @@ namespace CoreCms.Net.Services return promotionMoney; } + //商品第N个半价 + public decimal result_GOODS_HALF_PRICE(JObject parameters, CartProducts cartProducts, CoreCmsPromotion promotionInfo) + { + if (!parameters.ContainsKey("money")) return 0; + var objMoney = parameters["money"].ObjectToDecimal(0); + + //如果一口价比商品价格高,那么就不执行了 + decimal promotionMoney = 0; + if (cartProducts.products.price <= objMoney) + { + return promotionMoney; + } + //第几个优惠 + var num = parameters["num"].ObjectToInt(0); + //购买的数量 + var buyNum = cartProducts.nums; + //取整数,保证满足了,才优惠 ,比如设置 原价 10 第2个 减少5,购买5个产品的时候,实际只优惠2个产品的价格 + var promotionNum = buyNum / num; + var pmoney = Math.Round((decimal)promotionNum * objMoney / buyNum, 2); //单品优惠的金额 + var goodsPrice = (decimal)cartProducts.products.price; + cartProducts.products.price = goodsPrice - pmoney; //优惠后的平均价格 + promotionMoney = Math.Round(cartProducts.nums * pmoney, 2);//优惠金额 + //设置商品优惠总金额 + cartProducts.products.promotionAmount = Math.Round(cartProducts.products.promotionAmount + promotionMoney, 2); + //设置商品的实际销售总金额 + cartProducts.products.amount = Math.Round(cartProducts.products.amount - promotionMoney, 2); + return promotionMoney; + } + + } } diff --git a/CoreCms.Net.Task/HangfireDispose.cs b/CoreCms.Net.Task/HangfireDispose.cs index 69ad424b..983a5f3e 100644 --- a/CoreCms.Net.Task/HangfireDispose.cs +++ b/CoreCms.Net.Task/HangfireDispose.cs @@ -42,29 +42,29 @@ namespace CoreCms.Net.Task //自动取消订单任务 - RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Utc); // 每5分钟取消一次订单 + RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Local); // 每5分钟取消一次订单 //自动完成订单任务 - RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单 + RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Local); // 每小时自动完成订单 //自动评价订单任务 - RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单 + RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Local); // 每小时自动完成订单 //自动签收订单任务 - RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Utc); // 每小时自动完成订单 + RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Hourly, TimeZoneInfo.Local); // 每小时自动完成订单 //催付款订单 - RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Utc); // 每5分钟催付款订单 + RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/5 * * * ? ", TimeZoneInfo.Local); // 每5分钟催付款订单 //拼团自动取消到期团(每分钟执行一次) - RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Minutely, TimeZoneInfo.Utc); // 每分钟取消一次订单 + RecurringJob.AddOrUpdate(s => s.Execute(), Cron.Minutely, TimeZoneInfo.Local); // 每分钟取消一次订单 //每天凌晨5点定期清理7天前操作日志 - RecurringJob.AddOrUpdate(s => s.Execute(), "0 0 5 * * ? ", TimeZoneInfo.Utc); // 每天5点固定时间清理一次 + RecurringJob.AddOrUpdate(s => s.Execute(), "0 0 5 * * ? ", TimeZoneInfo.Local); // 每天5点固定时间清理一次 //定时刷新获取微信AccessToken - RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/2 * * * ? ", TimeZoneInfo.Utc); // 每2分钟刷新获取微信AccessToken + RecurringJob.AddOrUpdate(s => s.Execute(), "0 0/2 * * * ? ", TimeZoneInfo.Local); // 每2分钟刷新获取微信AccessToken } diff --git a/CoreCms.Net.Web.Admin/Controllers/Com/ToolsController.cs b/CoreCms.Net.Web.Admin/Controllers/Com/ToolsController.cs index 7cf7b71e..e389bf96 100644 --- a/CoreCms.Net.Web.Admin/Controllers/Com/ToolsController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/Com/ToolsController.cs @@ -1634,7 +1634,6 @@ namespace CoreCms.Net.Web.Admin.Controllers bytes = ms.ToArray(); } - string url = string.Empty; var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken(); var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); var request = new ShopImageUploadRequest(); @@ -1665,7 +1664,58 @@ namespace CoreCms.Net.Web.Admin.Controllers #endregion + #region 自定义交易组件上传图片(Base64)==================================================== + /// + /// 自定义交易组件上传图片(Base64) + /// + /// + [HttpPost] + public async Task MiNiShopOpenComponent2_UploadImgByBase64([FromBody] FMBase64Post entity) + { + var jm = new AdminUiCallBack(); + + + var filesStorageOptions = await _coreCmsSettingServices.GetFilesStorageOptions(); + + if (string.IsNullOrEmpty(entity.base64)) + { + jm.msg = "请上传合法内容"; + return jm; + } + + entity.base64 = entity.base64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换 + byte[] bytes = Convert.FromBase64String(entity.base64); + + var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken(); + var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); + var request = new ShopImageUploadRequest(); + request.AccessToken = accessToken; + request.ImageFileBytes = bytes; + request.ResponseType = 1; + + var response = await client.ExecuteShopImageUploadAsync(request); + if (response.IsSuccessful()) + { + jm.code = 0; + jm.msg = "上传成功!"; + jm.data = new + { + fileUrl = response.Image.TempImageUrl, + src = response.Image.TempImageUrl + }; + } + else + { + jm.code = 1; + jm.msg = response.ErrorMessage; + } + jm.otherData = response; + + return jm; + } + + #endregion } } \ No newline at end of file diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/wechat/transactioncomponent/goods/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/wechat/transactioncomponent/goods/create.html index 15104a6a..51cad909 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/wechat/transactioncomponent/goods/create.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/wechat/transactioncomponent/goods/create.html @@ -116,7 +116,7 @@ {{# }); }} @@ -163,7 +163,8 @@
- + + @@ -217,8 +218,6 @@ , coreHelper = layui.coreHelper; //加载编辑器 - var Authorization = layui.data(layui.setter.tableName)[layui.setter.request.tokenName]; - var Authorization = layui.data(layui.setter.tableName)[layui.setter.request.tokenName]; //重点代码 适配器 class UploadAdapter { @@ -304,14 +303,14 @@ window.editor.setData(ids.intro); - if (ids.images) { - imgs = ids.images.split(','); - $('#headImg').val(imgs); - var getTpl = image_tpl.innerHTML, viewBox = document.getElementById('upload-more-list'); - laytpl(getTpl).render(imgs, function (html) { - viewBox.innerHTML = html; - }); - } + //if (ids.images) { + // imgs = ids.images.split(','); + // $('#headImg').val(imgs); + // var getTpl = image_tpl.innerHTML, viewBox = document.getElementById('upload-more-list'); + // laytpl(getTpl).render(imgs, function (html) { + // viewBox.innerHTML = html; + // }); + //} $('#skuCount').val(ids.sku.length); @@ -365,7 +364,7 @@ aspectRatio: 1 / 1, onCrop: function (data) { var loadIndex = layer.load(2); - coreHelper.Post("api/Tools/UploadFilesFByBase64", { base64: data }, function (res) { + coreHelper.Post("api/Tools/MiNiShopOpenComponent2_UploadImgByBase64", { base64: data }, function (res) { if (0 === res.code) { imgs.push(res.data.fileUrl); $('#headImg').val(imgs); @@ -385,6 +384,9 @@ }); + + + form.verify({ verifyoutProductId: [/^.{0,50}$/, '商品序列最大只允许输入50位字符'],