商品选品准备工作

This commit is contained in:
wule committed 2025-07-15 19:09:45 +08:00
1 parent dda4fdfc5f
commit a77278c6d1
34 files changed
+2336 -48

No files matched your search

@@ -0,0 +1,57 @@
using KJD_Web.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.BLL
{
public class ProductManage
{
public string AddProduct(string inputData)
{
if (!string.IsNullOrEmpty(inputData))
{
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id");
string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id");
string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id");
string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name"));
string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name"));
string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json"));
string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img"));
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
//string sss = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json"));
int r2 = 0;
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
if (string.IsNullOrEmpty(user_name))
{
return "{\"code\":500,\"msg\":\"没有用户名\"}";
}
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
MysqlUtils mySql = new MysqlUtils(conn);
string sql = "";
sql = "insert into kjd.product (spu_id,skc_id,cat_id,cat_name,product_name,product_json,size_json,main_img,notes,add_time,mdy_time) " +
"values ('" + spu_id + "','" + skc_id + "','" + cat_id + "','" + cat_name + "','" + product_name + "','" +
product_json + "','" + size_json + "','" + main_img + "','" + notes + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
var rst = mySql.ExecuteNonQuery(sql);
mySql.Close();
if (rst)
{
return "{\"code\":200,\"msg\":\"success\"}";
}
else
{
return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}";
}
}
return "{\"code\":19999,\"msg\":\"未知错误\"}";
}
}
}
+5
View File
@@ -38,6 +38,11 @@ namespace KJD_Web
hPath = hPath.Replace("/update/", "/UpdateService.asmx/");
Context.RewritePath(hPath);
}
else if (!hPath.Contains(".asmx") && hPath.Contains("/product/"))
{
hPath = hPath.Replace("/product/", "/ProductService.asmx/");
Context.RewritePath(hPath);
}
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
@@ -77,12 +77,14 @@
</ItemGroup>
<ItemGroup>
<Content Include="Global.asax" />
<Content Include="ProductService.asmx" />
<Content Include="ShopService.asmx" />
<Content Include="UpdateService.asmx" />
<Content Include="UserService.asmx" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="BLL\ProductManage.cs" />
<Compile Include="BLL\ShopManage.cs" />
<Compile Include="BLL\UpadteManage.cs" />
<Compile Include="BLL\UserManage.cs" />
@@ -91,9 +93,14 @@
</Compile>
<Compile Include="Model\CommentParam.cs" />
<Compile Include="Model\OrderParam.cs" />
<Compile Include="Model\ProductResultParam.cs" />
<Compile Include="Model\ShopModel\ShopParam.cs" />
<Compile Include="Model\UserLoginResultParam.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProductService.asmx.cs">
<DependentUpon>ProductService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="ShopService.asmx.cs">
<DependentUpon>ShopService.asmx</DependentUpon>
<SubType>Component</SubType>
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.Model
{
public class ProductResultParam
{
public int id { get; set; }
public string spu_id { get; set; }
public string skc_id { get; set; }
public string cat_id { get; set; }
public string cat_name { get; set; }
public string product_name { get; set; }
public string product_json { get; set; }
public string size_json { get; set; }
public string main_img { get; set; }
public DateTime add_time { get; set; }
public DateTime mdy_time { get; set; }
public string notes { get; set; }
}
}
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="ProductService.asmx.cs" Class="KJD_Web.ProductService" %>
@@ -0,0 +1,99 @@
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>
/// ProductService 的摘要说明
/// </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 ProductService : System.Web.Services.WebService
{
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 get_product_list()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
//result = new ShopManage().GetShop(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void add_product()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
result = new ProductManage().AddProduct(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void del_product()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
//result = new ShopManage().DelShop(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
[WebMethod]
public void mdy_product()
{
string jsontext = GetRequestJsonString();
var result = jsontext;
//result = new ShopManage().MdyShop(jsontext);
Context.Response.Write(result);
Context.Response.End();
}
}
}