测试数据库服务接口文件, 店铺活动报名功能

This commit is contained in:
wule committed 2025-08-06 19:09:59 +08:00
1 parent 85ed4137d2
commit 7556b63d10
18 files changed
+687 -158

No files matched your search

+16 -3
View File
@@ -394,11 +394,18 @@ namespace KJD_Web.BLL
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
var add_times = RegexUtils.GetStringQuery(ref inputData, "add_times")?.Replace("'", "\\'");
long l_draft_id = draft_id.ParseToLong();
long l_table_id = l_draft_id % 128;
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
// 使用事务一次提交多个sql操作
//sql += "set @@autocommit=0;\r\n";
sql += "START TRANSACTION;\r\n";
if (!string.IsNullOrEmpty(up_spu_id) && !string.IsNullOrEmpty(draft_id))
sql += "insert into kjd.spu_map (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');";
sql += "insert into kjd_map.spu_map_" + l_table_id +
" (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');\r\n";
sql += "update kjd.product_select set";
if (draft_id != null)
sql += " draft_id='" + draft_id + "',";
@@ -408,8 +415,14 @@ namespace KJD_Web.BLL
sql += " add_times=add_times+1,";
sql += " mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + ";";
sql += " where id=" + id + ";\r\n";
var rst = mySql.ExecuteNonQuery(sql);
string errMsg = mySql.Message;
if (string.IsNullOrEmpty(errMsg))
sql = "COMMIT;";
else
sql = "ROLLBACK;";
mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
@@ -417,7 +430,7 @@ namespace KJD_Web.BLL
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
return "{\"code\":500,\"msg\":\"" + errMsg + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
@@ -357,11 +357,18 @@ namespace KJD_Web.BLL
var status = RegexUtils.GetStringQuery(ref inputData, "status")?.Replace("'", "\\'");
var add_times = RegexUtils.GetStringQuery(ref inputData, "add_times")?.Replace("'", "\\'");
long l_draft_id = draft_id.ParseToLong();
long l_table_id = l_draft_id % 128;
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
// 使用事务一次提交多个sql操作
//sql += "set @@autocommit=0;\r\n";
sql += "START TRANSACTION;\r\n";
if (!string.IsNullOrEmpty(up_spu_id) && !string.IsNullOrEmpty(draft_id))
sql += "insert into kjd.spu_map (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');";
sql += "insert into kjd_map.spu_map_" + l_table_id +
" (draft_id,from_spu_id,shop_id) values(" + draft_id + "," + up_spu_id + ",'" + shop_id + "');\r\n";
sql += "update kjd.third_product_select set";
if (draft_id != null)
sql += " draft_id='" + draft_id + "',";
@@ -371,8 +378,14 @@ namespace KJD_Web.BLL
sql += " add_times=add_times+1,";
sql += " mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
sql = sql.TrimEnd(',');
sql += " where id=" + id + ";";
sql += " where id=" + id + ";\r\n";
var rst = mySql.ExecuteNonQuery(sql);
string errMsg = mySql.Message;
if (string.IsNullOrEmpty(errMsg))
sql = "COMMIT;";
else
sql = "ROLLBACK;";
mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
@@ -380,7 +393,7 @@ namespace KJD_Web.BLL
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
return "{\"code\":500,\"msg\":\"" + errMsg + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"输入为空\"}";
@@ -0,0 +1,60 @@
using KJD_Web.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.BLL
{
public class ToolManage
{
//mysql workbench 存储过程,可以使用分隔符重定义
// string 存储过程1 = @"
//DELIMITER $
//DROP PROCEDURE IF EXISTS add_spu_map;
//CREATE PROCEDURE add_spu_map()
//BEGIN
//insert into kjd_map.spu_map_0 (draft_id,from_spu_id,shop_id) values(9122600878,727585921,'3049342434562');
//update kjd.third_product_select set draft_id='9122600878', status='已上传', add_times=add_times+1, mdy_time='2025-08-06 11:54:50' where id=6532;
//END $
//DELIMITER ;
//CALL add_spu_map();";
//腾讯云服务器存储过程,不能使用分隔符重定义
// string 存储过程2 = @"
//DROP PROCEDURE IF EXISTS add_spu_map;
//CREATE PROCEDURE add_spu_map()
//BEGIN
//insert into kjd_map.spu_map_1 (draft_id,from_spu_id,shop_id) values(9122600878,727585921,'3049342434562');
//update kjd.third_product_select set draft_id='9122600878', status='已上传', add_times=add_times+1, mdy_time='2025-08-06 11:54:50' where id=6532;
//END ;
//CALL add_spu_map();";
public void CreateTable()
{
// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
// MysqlUtils mySql = new MysqlUtils(conn);
// string sql = "";
// string sql1 = "";
// for (int i = 0; i < 69; i++)
// {
// //sql = @"drop table if exists kjd_map.spu_map_" + i + ";\r\n";
// sql = @"CREATE TABLE IF NOT EXISTS kjd_map.spu_map_" + i + @" (
// `id` int NOT NULL AUTO_INCREMENT,
// `draft_id` bigint NOT NULL COMMENT '草稿箱/商品Id',
// `from_spu_id` bigint NOT NULL COMMENT '母店来源商品Id',
// `shop_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上传的店铺',
// PRIMARY KEY (`id`)
//) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '上传商品与母店商品spu映射关系';";
// sql += @"
//ALTER TABLE
// kjd_map.spu_map_" + i + @"
//ADD
// COLUMN `add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP";
// var rst = mySql.ExecuteNonQuery(sql);
// }
// mySql.Close();
}
}
}
@@ -1,5 +1,5 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -46,6 +46,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="MySql.Data">
<HintPath>..\Dll\MySql.Data.dll</HintPath>
@@ -70,17 +73,13 @@
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Global.asax" />
<Content Include="ProductThirdService.asmx" />
<Content Include="ProductService.asmx" />
<Content Include="ShopService.asmx" />
<Content Include="UpdateService.asmx" />
<Content Include="ToolService.asmx" />
<Content Include="UserService.asmx" />
<Content Include="Web.config" />
</ItemGroup>
@@ -88,6 +87,7 @@
<Compile Include="BLL\ProductThirdManage.cs" />
<Compile Include="BLL\ProductManage.cs" />
<Compile Include="BLL\ShopManage.cs" />
<Compile Include="BLL\ToolManage.cs" />
<Compile Include="BLL\UpadteManage.cs" />
<Compile Include="BLL\UserManage.cs" />
<Compile Include="Global.asax.cs">
@@ -116,6 +116,10 @@
<DependentUpon>UpdateService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolService.asmx.cs">
<DependentUpon>ToolService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="UserService.asmx.cs">
<DependentUpon>UserService.asmx</DependentUpon>
<SubType>Component</SubType>
@@ -174,7 +178,7 @@
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="ToolService.asmx.cs" Class="KJD_Web.ToolService" %>
@@ -0,0 +1,64 @@
using KJD_Web.BLL;
using KJD_Web.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
namespace KJD_Web
{
/// <summary>
/// UserService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class ToolService : System.Web.Services.WebService
{
[WebMethod]
public string hello_world()
{
return "Hello World";
}
private string GetRequestJsonString()
{
Context.Response.ContentType = "text/html;charset=utf-8";
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
using (Stream s = HttpContext.Current.Request.InputStream) // 获得json 字符流
{
// 还原数据流
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
string jsonText = Encoding.UTF8.GetString(b); // JSON字符串
if (string.IsNullOrEmpty(jsonText))
{
var qs = HttpContext.Current.Request.QueryString;
if (qs != null && qs.Keys.Count > 0)
{
jsonText = "{";
foreach (var key in qs.Keys)
{
jsonText += "\"" + key + "\":" + "\"" + qs[key.ToString()] + "\";";
}
jsonText = jsonText.TrimEnd(';') + "}";
}
}
return jsonText;
}
}
[WebMethod]
public void create_table()
{
//return;
new ToolManage().CreateTable();
}
}
}
+24 -18
View File
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ConnKJD" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-hl51pkfr.sql.tencentcdb.com';Port=27660;User Id='kjd';Password='Temukjd0625';Charset=utf8mb4;" />
<add name="UpdateVersion" connectionString="100"/>
<add name="UpdateExe" connectionString="http://1.13.195.131:9000/Download/Update.exe"/>
<add name="UpdateFiles" connectionString="http://1.13.195.131:9000/Download/Update.zip"/>
<add name="UpdateExeChk" connectionString="2CDEA1FB"/>
<add name="ConnKJD" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-hl51pkfr.sql.tencentcdb.com';Port=27660;User Id='kjd';Password='Temukjd0625';Charset=utf8mb4;"/>
<add name="UpdateVersion" connectionString="100"/>
<add name="UpdateExe" connectionString="http://1.13.195.131:9000/Download/Update.exe"/>
<add name="UpdateFiles" connectionString="http://1.13.195.131:9000/Download/Update.zip"/>
<add name="UpdateExeChk" connectionString="2CDEA1FB"/>
</connectionStrings>
<!--
有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。
@@ -20,29 +20,35 @@
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
<add name="Documentation" />
<add name="HttpGet"/>
<add name="HttpPost"/>
<add name="Documentation"/>
</protocols>
</webServices>
<pages controlRenderingCompatibilityVersion="4.0" />
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="9.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.webServer>
<directoryBrowse enabled="true" />
<staticContent>
<mimeMap fileExtension=".asmx" mimeType="application/octet-stream" />
</staticContent>
<directoryBrowse enabled="true"/>
<staticContent>
<mimeMap fileExtension=".asmx" mimeType="application/octet-stream"/>
</staticContent>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net452" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net46" requireReinstallation="true" />
</packages>