diff --git a/CoreCms.Net.Web.Admin/Controllers/Good/CoreCmsGoodsController.cs b/CoreCms.Net.Web.Admin/Controllers/Good/CoreCmsGoodsController.cs
index 6a519b9..59acfbb 100644
--- a/CoreCms.Net.Web.Admin/Controllers/Good/CoreCmsGoodsController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/Good/CoreCmsGoodsController.cs
@@ -30,6 +30,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using NPOI.HSSF.UserModel;
using SqlSugar;
+using Yitter.IdGenerator;
namespace CoreCms.Net.Web.Admin.Controllers
{
@@ -938,8 +939,8 @@ namespace CoreCms.Net.Web.Admin.Controllers
var obj = new CoreCmsProducts();
if (count == 0) obj.isDefalut = true;
- var sn = list.Find(p => p.name == "goods[sn]");
- obj.sn = sn != null ? sn.value + "_" + (count + 1) : null;
+ //var sn = list.Find(p => p.name == "goods[sn]");
+ obj.sn = "SN" + YitIdHelper.NextId();
var price = list.Find(p => p.name == "goods[price]");
obj.price = price != null && !string.IsNullOrEmpty(price.value)
? Convert.ToDecimal(price.value)
diff --git a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj
index 7c65b2e..5929028 100644
--- a/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj
+++ b/CoreCms.Net.Web.Admin/CoreCms.Net.Web.Admin.csproj
@@ -76,6 +76,7 @@
+
diff --git a/CoreCms.Net.Web.Admin/Startup.cs b/CoreCms.Net.Web.Admin/Startup.cs
index e6568f9..3052590 100644
--- a/CoreCms.Net.Web.Admin/Startup.cs
+++ b/CoreCms.Net.Web.Admin/Startup.cs
@@ -26,6 +26,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
+using Yitter.IdGenerator;
namespace CoreCms.Net.Web.Admin
{
@@ -137,6 +138,15 @@ namespace CoreCms.Net.Web.Admin
p.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
});
+
+
+ // 雪花漂移算法
+ // 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId:
+ var options = new IdGeneratorOptions(1);
+ // 保存参数(必须的操作,否则以上设置都不能生效):
+ YitIdHelper.SetIdGenerator(options);
+
+
}
///
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/create.html b/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/create.html
index 1797e6d..b79933f 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/create.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/create.html
@@ -1174,7 +1174,7 @@
if (e.data.products) {
for (var i = 0; i < e.data.products.length; i++) {
e.data.products[i].isDefalut = false;
- e.data.products[i].sn = layui.coreHelper.getSN('SN');
+ //e.data.products[i].sn = layui.coreHelper.getSN('SN');
tmpData.push(e.data.products[i]);
}
}
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/edit.html
index 924e0f9..15f4fe7 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/edit.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/good/goods/edit.html
@@ -1284,7 +1284,7 @@
if (e.data.products) {
for (var i = 0; i < e.data.products.length; i++) {
e.data.products[i].isDefalut = false;
- e.data.products[i].sn = layui.coreHelper.getSN('SN');
+ //e.data.products[i].sn = layui.coreHelper.getSN('SN');
tmpData.push(e.data.products[i]);
}
}