Commit 7bf89c5b authored by liudong1993's avatar liudong1993

课程管理

parent 804d7785
using Mall.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mall.Common.Enum.Goods
{
/// <summary>
/// 商品课程附件类型枚举
/// </summary>
public enum GoodsCourseTypeEnum
{
/// <summary>
/// 视频
/// </summary>
[EnumField("视频")]
Video = 1,
/// <summary>
/// word
/// </summary>
[EnumField("WORD")]
WORD = 2,
/// <summary>
/// pdf
/// </summary>
[EnumField("PDF")]
PDF = 3,
/// <summary>
/// PPT
/// </summary>
[EnumField("PPT")]
PPT = 4
}
}
using System; using System;
using Aliyun.OSS; using Aliyun.OSS;
using Mall.Education.Common;
using Mall.Education.Helper;
namespace COSSnippet namespace COSSnippet
{ {
public class AliOSSUploadObject public class AliOSSUploadObject
{ {
public string endpoint;
public string accessKeyId;
public string accessKeySecret;
public string bucketName;
public AliOSSUploadObject(int MallBaseId) {
var ds = FileDataHelper.GetMallBaseFileInfo(MallBaseId, 2);
if (ds.Tables[0].Rows.Count > 0)
{
endpoint = ds.Tables[0].Rows[0]["Region"].ToString();
accessKeyId = ds.Tables[0].Rows[0]["SecretId"].ToString();
accessKeySecret = ds.Tables[0].Rows[0]["SecretKey"].ToString();
bucketName = ds.Tables[0].Rows[0]["Bucket"].ToString();
}
else {
//使用默认值
endpoint = Config.GetAppSetting("Ali_OSS_REGION");
accessKeyId = Config.GetAppSetting("Ali_OSS_SECRETID");
accessKeySecret = Config.GetAppSetting("Ali_OSS_SECRETKEY");
bucketName = Config.GetAppSetting("Ali_OSS_BUCKET");
}
}
/// 上传对象 /// 上传对象
public void TransferUploadFile(string filePath,string newFileName) public void TransferUploadFile(string filePath,string AliFileName)
{ {
var endpoint = "<yourEndpoint>"; var objectName = AliFileName;
var accessKeyId = "<yourAccessKeyId>"; var localFilename = filePath;
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var objectName = "<yourObjectName>";
var localFilename = "<yourLocalFilename>";
// 创建OssClient实例。 // 创建OssClient实例。
var client = new OssClient(endpoint, accessKeyId, accessKeySecret); var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try try
{ {
// 上传文件。 // 上传文件。
client.PutObject(bucketName, objectName, localFilename); client.PutObject(bucketName, objectName, localFilename);
Console.WriteLine("Put object succeeded");
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Put object failed, {0}", ex.Message); LogHelper.Write(ex, "AliOSSUploadObject");
} }
} }
/// <summary>
/// 删除文件
/// </summary>
/// <param name="Key"></param>
public void TransferUpladDel(string Key) { public void TransferUpladDel(string Key) {
var endpoint = "<yourEndpoint>"; var objectName = Key;
var accessKeyId = "<yourAccessKeyId>";
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var objectName = "<yourObjectName>";
// 创建OssClient实例。 // 创建OssClient实例。
var client = new OssClient(endpoint, accessKeyId, accessKeySecret); var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try try
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
<add key="TX_COS_SECRETID" value="AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd" /> <add key="TX_COS_SECRETID" value="AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd" />
<add key="TX_COS_SECRETKEY" value="PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob" /> <add key="TX_COS_SECRETKEY" value="PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob" />
<add key="TX_COS_BUCKET" value="viitto-1301420277" /> <add key="TX_COS_BUCKET" value="viitto-1301420277" />
<add key="Ali_OSS_REGION" value="oss-cn-chengdu" />
<add key="Ali_OSS_SECRETID" value="LTAIwE7l9dImZSa3" />
<add key="Ali_OSS_SECRETKEY" value="j47Ajn0d0WzUCIX8Biyj3P2r8QDltI" />
<add key="Ali_OSS_BUCKET" value="vt-im-bucket" />
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<!--<add name="DefaultConnection" providerName="MySql.Data.MySqlClient" connectionString="server=rm-bp1tj77h6kp0d02fb.mysql.rds.aliyuncs.com;port=3306;user id=reborn;password=Reborn@2018;database=test_reborn_mall_3;CharSet=utf8;Convert Zero Datetime=true;" />--> <!--<add name="DefaultConnection" providerName="MySql.Data.MySqlClient" connectionString="server=rm-bp1tj77h6kp0d02fb.mysql.rds.aliyuncs.com;port=3306;user id=reborn;password=Reborn@2018;database=test_reborn_mall_3;CharSet=utf8;Convert Zero Datetime=true;" />-->
......
...@@ -9,6 +9,7 @@ using System.Text.RegularExpressions; ...@@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
using Mall.Education.DBHelper; using Mall.Education.DBHelper;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Data;
namespace Mall.Education.Helper namespace Mall.Education.Helper
{ {
...@@ -24,7 +25,7 @@ namespace Mall.Education.Helper ...@@ -24,7 +25,7 @@ namespace Mall.Education.Helper
/// <param name="cookie"></param> /// <param name="cookie"></param>
public static int InsertGoodsFileImage(int CourseId, string goodsImages) public static int InsertGoodsFileImage(int CourseId, string goodsImages)
{ {
string sql = $@"update rb_goods_course set Image='{goodsImages}' where Id ={CourseId} "; string sql = $@"update rb_goods_wk_course set Image='{goodsImages}',IsImageOK=1 where Id ={CourseId} ";
var result = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sql, null); var result = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sql, null);
return result; return result;
} }
...@@ -33,12 +34,11 @@ namespace Mall.Education.Helper ...@@ -33,12 +34,11 @@ namespace Mall.Education.Helper
/// 删除课程图片记录 /// 删除课程图片记录
/// </summary> /// </summary>
/// <param name="cookie"></param> /// <param name="cookie"></param>
public static void DelGoodsFileImage() public static DataSet GetMallBaseFileInfo(int MallBaseId,int Type)
{ {
string citySql = $@"SELECT * FROM rb_destination WHERE 1=1 and Status =0 AND Name in('成都市') "; string sql = $@"SELECT * FROM rb_file_store WHERE MallBaseId ={MallBaseId} AND StoreType={Type} ";
var cityDataList = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, citySql, null); var List = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sql, null);
LogHelper.Write(JsonConvert.SerializeObject(cityDataList.Tables[0].Rows)); return List;
//var sqlOrderDetailResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sqlOrderDetail, null);
} }
/// <summary> /// <summary>
......
...@@ -64,6 +64,9 @@ ...@@ -64,6 +64,9 @@
<Reference Include="COSXML, Version=5.4.13.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="COSXML, Version=5.4.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Tencent.QCloud.Cos.Sdk.5.4.13\lib\netstandard2.0\COSXML.dll</HintPath> <HintPath>..\packages\Tencent.QCloud.Cos.Sdk.5.4.13\lib\netstandard2.0\COSXML.dll</HintPath>
</Reference> </Reference>
<Reference Include="FluentScheduler, Version=5.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentScheduler.5.5.1\lib\netstandard2.0\FluentScheduler.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=2.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=2.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.2.2.0\lib\net461\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath> <HintPath>..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.2.2.0\lib\net461\Microsoft.Diagnostics.Tracing.EventSource.dll</HintPath>
......
...@@ -23,7 +23,14 @@ namespace Mall.Education.Models ...@@ -23,7 +23,14 @@ namespace Mall.Education.Models
/// 文件地址 /// 文件地址
/// </summary> /// </summary>
public string FilePath { get; set; } public string FilePath { get; set; }
/// <summary>
/// 文件存储 1腾讯 2阿里云
/// </summary>
public int PathType { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -22,6 +22,22 @@ namespace Mall.Education ...@@ -22,6 +22,22 @@ namespace Mall.Education
// new RebornTimerServer(), // new RebornTimerServer(),
//}; //};
//ServiceBase.Run(ServicesToRun); //ServiceBase.Run(ServicesToRun);
Console.WriteLine("进来了");
string FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
string[] patharr = FilePath.Split('/');
string kjkj = "";
for (var i = 3; i < patharr.Length - 1; i++)
{
kjkj += patharr[i] + "/";
}
Console.WriteLine("2:" + kjkj);
//new TimingFileClear();
//Console.WriteLine("定时器已执行");
//RabbitConfig rabbit = new RabbitConfig() //RabbitConfig rabbit = new RabbitConfig()
//{ //{
...@@ -32,8 +48,7 @@ namespace Mall.Education ...@@ -32,8 +48,7 @@ namespace Mall.Education
// QueenName = RabbitKey.QUEEN_GENERATE_EDUCARION // QueenName = RabbitKey.QUEEN_GENERATE_EDUCARION
//}; //};
//RabbiMQManager.DealWithMessage(rabbit); //RabbiMQManager.DealWithMessage(rabbit);
//Console.WriteLine("结束了");
//new OfficeHelper().GetWordToImagePathList("C:/Users/Administrator/Desktop/testImage/网课需求(1).docx", "C:/Users/Administrator/Desktop/testImage/Image/", null); //new OfficeHelper().GetWordToImagePathList("C:/Users/Administrator/Desktop/testImage/网课需求(1).docx", "C:/Users/Administrator/Desktop/testImage/Image/", null);
//new Word2ImageConverter().ConvertToImage("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx", "C:/Users/Administrator/Desktop/testImage/Image/", System.Drawing.Imaging.ImageFormat.Png, out int PageNum); //new Word2ImageConverter().ConvertToImage("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx", "C:/Users/Administrator/Desktop/testImage/Image/", System.Drawing.Imaging.ImageFormat.Png, out int PageNum);
...@@ -45,7 +60,7 @@ namespace Mall.Education ...@@ -45,7 +60,7 @@ namespace Mall.Education
//TransferUploadObjectModel m = new TransferUploadObjectModel(); //TransferUploadObjectModel m = new TransferUploadObjectModel();
//m.TransferUploadFile("C:/Users/Administrator/Desktop/testImage/Image/网课需求(1)_001.Png", "网课需求(1)_001.Png"); //m.TransferUploadFile("C:/Users/Administrator/Desktop/testImage/Image/网课需求(1)_001.Png", "网课需求(1)_001.Png");
ImageConvertData(new GoodsModel() { CourseId = 1, GoodsId = 1, FilePath = "" }); //ImageConvertData(new GoodsModel() { CourseId = 1, GoodsId = 1, FilePath = "" });
Console.ReadKey(); Console.ReadKey();
} }
...@@ -54,61 +69,61 @@ namespace Mall.Education ...@@ -54,61 +69,61 @@ namespace Mall.Education
/// 处理文件 /// 处理文件
/// </summary> /// </summary>
/// <param name="GoodsModel"></param> /// <param name="GoodsModel"></param>
private static void ImageConvertData(GoodsModel GoodsModel) //private static void ImageConvertData(GoodsModel GoodsModel)
{ //{
string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image"); // string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
if (!Directory.Exists(tempDir)) // if (!Directory.Exists(tempDir))
Directory.CreateDirectory(tempDir); // Directory.CreateDirectory(tempDir);
//是否需要先把文件下载到服务器 // //是否需要先把文件下载到服务器
GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx"; // GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
//文件生成图片暂存本地 // //文件生成图片暂存本地
string FileExtension = Path.GetExtension(GoodsModel.FilePath); // string FileExtension = Path.GetExtension(GoodsModel.FilePath);
string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath); // string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath);
string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath); // string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath);
int PageNum; // int PageNum;
System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg; // System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
if (FileExtension == ".doc" || FileExtension == ".docx") // if (FileExtension == ".doc" || FileExtension == ".docx")
{ // {
new Word2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum); // new Word2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
} // }
else if (FileExtension == ".pdf") // else if (FileExtension == ".pdf")
{ // {
new Pdf2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum); // new Pdf2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
} // }
else if (FileExtension == ".ppt" || FileExtension == ".pptx") // else if (FileExtension == ".ppt" || FileExtension == ".pptx")
{ // {
new Ppt2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum); // new Ppt2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
} // }
else // else
{ // {
return; // return;
} // }
if (PageNum > 0) // if (PageNum > 0)
{ // {
List<GoodsImage> goodsImages = new List<GoodsImage>(); // List<GoodsImage> goodsImages = new List<GoodsImage>();
//开始上传图片至服务器 // //开始上传图片至服务器
TransferUploadObjectModel m = new TransferUploadObjectModel(); // TransferUploadObjectModel m = new TransferUploadObjectModel();
for (var i = 1; i <= PageNum; i++) // for (var i = 1; i <= PageNum; i++)
{ // {
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString(); // string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
m.TransferUploadFile(tempDir + "/" + newName, newName); // m.TransferUploadFile(tempDir + "/" + newName, newName);
//上传之后 写入商品课程图片数据 // //上传之后 写入商品课程图片数据
goodsImages.Add(new GoodsImage // goodsImages.Add(new GoodsImage
{ // {
Sort = i, // Sort = i,
Path = FileDirectory + "/" + newName // Path = FileDirectory + "/" + newName
}); // });
} // }
//更新图片数据 // //更新图片数据
bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0; // bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0;
if (flag == false) // if (flag == false)
{ // {
Console.WriteLine("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId); // Console.WriteLine("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId);
} // }
} // }
} //}
} }
} }
...@@ -9,6 +9,7 @@ using Mall.Education.Offices; ...@@ -9,6 +9,7 @@ using Mall.Education.Offices;
using COSSnippet; using COSSnippet;
using Mall.Education.Helper; using Mall.Education.Helper;
using System.Collections.Generic; using System.Collections.Generic;
using FluentScheduler;
namespace Mall.Education.RabbitMQ namespace Mall.Education.RabbitMQ
{ {
...@@ -35,6 +36,10 @@ namespace Mall.Education.RabbitMQ ...@@ -35,6 +36,10 @@ namespace Mall.Education.RabbitMQ
return factory; return factory;
} }
/// <summary>
/// 处理消息队列
/// </summary>
/// <param name="rabbitConfig"></param>
[Obsolete] [Obsolete]
public static void DealWithMessage(RabbitConfig rabbitConfig) public static void DealWithMessage(RabbitConfig rabbitConfig)
{ {
...@@ -59,13 +64,14 @@ namespace Mall.Education.RabbitMQ ...@@ -59,13 +64,14 @@ namespace Mall.Education.RabbitMQ
string msg = Encoding.UTF8.GetString(bytes); string msg = Encoding.UTF8.GetString(bytes);
try try
{ {
Console.WriteLine("进来一个:" + msg);
var GoodsModel = JsonConvert.DeserializeObject<GoodsModel>(msg); var GoodsModel = JsonConvert.DeserializeObject<GoodsModel>(msg);
//处理 //处理
if (GoodsModel != null) if (GoodsModel != null)
{ {
ImageConvertData(GoodsModel); ImageConvertData(GoodsModel);
} }
//Console.WriteLine(msg); Console.WriteLine("处理一个:" + msg);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -84,15 +90,24 @@ namespace Mall.Education.RabbitMQ ...@@ -84,15 +90,24 @@ namespace Mall.Education.RabbitMQ
/// <param name="GoodsModel"></param> /// <param name="GoodsModel"></param>
private static void ImageConvertData(GoodsModel GoodsModel) private static void ImageConvertData(GoodsModel GoodsModel)
{ {
if (string.IsNullOrEmpty(GoodsModel.FilePath)) {
return;
}
string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image"); string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
if (!Directory.Exists(tempDir)) if (!Directory.Exists(tempDir))
Directory.CreateDirectory(tempDir); Directory.CreateDirectory(tempDir);
//是否需要先把文件下载到服务器 //是否需要先把文件下载到服务器
GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx"; //GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
//文件生成图片暂存本地 //文件生成图片暂存本地
string FileExtension = Path.GetExtension(GoodsModel.FilePath); string FileExtension = Path.GetExtension(GoodsModel.FilePath);
string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath); string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath);
string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath); string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath);
string[] patharr = GoodsModel.FilePath.Split('/');
string FileDirNot = "";
for (var i = 3; i < patharr.Length - 1; i++)
{
FileDirNot += patharr[i] + "/";
}
int PageNum; int PageNum;
System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg; System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
if (FileExtension == ".doc" || FileExtension == ".docx") if (FileExtension == ".doc" || FileExtension == ".docx")
...@@ -115,26 +130,97 @@ namespace Mall.Education.RabbitMQ ...@@ -115,26 +130,97 @@ namespace Mall.Education.RabbitMQ
{ {
List<GoodsImage> goodsImages = new List<GoodsImage>(); List<GoodsImage> goodsImages = new List<GoodsImage>();
//开始上传图片至服务器 //开始上传图片至服务器
TransferUploadObjectModel m = new TransferUploadObjectModel(); if (GoodsModel.PathType == 1)
for (var i = 1; i <= PageNum; i++)
{ {
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString(); TransferUploadObjectModel m = new TransferUploadObjectModel(GoodsModel.MallBaseId);
m.TransferUploadFile(tempDir + "/" + newName, newName); for (var i = 1; i <= PageNum; i++)
{
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
m.TransferUploadFile(tempDir + "/" + newName, FileDirNot + newName);
//上传之后 写入商品课程图片数据 //上传之后 写入商品课程图片数据
goodsImages.Add(new GoodsImage goodsImages.Add(new GoodsImage
{
Sort = i,
Path = FileDirectory + "/" + newName
});
}
}
else if (GoodsModel.PathType == 2) {
AliOSSUploadObject upload = new AliOSSUploadObject(GoodsModel.MallBaseId);
for (var i = 1; i <= PageNum; i++)
{ {
Sort = i, string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
Path = FileDirectory + "/" + newName upload.TransferUploadFile(tempDir + "/" + newName, FileDirNot + newName);
});
//上传之后 写入商品课程图片数据
goodsImages.Add(new GoodsImage
{
Sort = i,
Path = FileDirectory + "/" + newName
});
}
} }
//更新图片数据 //更新图片数据
bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0; bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0;
if (flag == false) { if (flag == false) {
Console.WriteLine("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId); LogHelper.Write("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId);
} }
} }
} }
} }
/// <summary>
/// 定时器
/// </summary>
public class TimingFileClear : Registry
{
/// <summary>
/// 定时器
/// </summary>
public TimingFileClear()
{
//更新年假-删除临时文件夹
Schedule(() =>
{
try
{
DelTemporaryFile();
}
catch (System.Exception ex)
{
LogHelper.Write(ex, "DelTemporaryFile");
}
}).ToRunEvery(1).Days().At(1, 10);
}
/// <summary>
/// 删除临时文件
/// </summary>
private void DelTemporaryFile()
{
try
{
string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
DirectoryInfo dir = new DirectoryInfo(tempDir);
DirectoryInfo[] dirArr = dir.GetDirectories();
foreach (DirectoryInfo item in dirArr)
{
if (item.CreationTime < DateTime.Now.AddDays(-1))
item.Delete(true);
}
foreach (FileInfo fi in dir.GetFiles())
{
if (fi.CreationTime < DateTime.Now.AddDays(-1))
fi.Delete();
}
}
catch(Exception ex)
{
LogHelper.Write(ex, "DelTemporaryFile");
}
}
}
} }
...@@ -18,6 +18,7 @@ using System.Text; ...@@ -18,6 +18,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Mall.Education.Common; using Mall.Education.Common;
using Mall.Education.Helper;
namespace COSSnippet namespace COSSnippet
{ {
...@@ -25,20 +26,46 @@ namespace COSSnippet ...@@ -25,20 +26,46 @@ namespace COSSnippet
{ {
private CosXml cosXml; private CosXml cosXml;
private string bucketName;
public TransferUploadObjectModel() public TransferUploadObjectModel(int MallBaseId)
{ {
CosXmlConfig config = new CosXmlConfig.Builder() var ds = FileDataHelper.GetMallBaseFileInfo(MallBaseId, 1);
.SetRegion(Config.GetAppSetting("TX_COS_REGION")) //设置一个默认的存储桶地域 if (ds.Tables[0].Rows.Count > 0)
.Build(); {
string endpoint = ds.Tables[0].Rows[0]["Region"].ToString();
string accessKeyId = ds.Tables[0].Rows[0]["SecretId"].ToString();
string accessKeySecret = ds.Tables[0].Rows[0]["SecretKey"].ToString();
CosXmlConfig config = new CosXmlConfig.Builder()
.SetRegion(endpoint) //设置一个默认的存储桶地域
.Build();
string secretId = accessKeyId; //云 API 密钥 SecretId
string secretKey = accessKeySecret; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);
bucketName = ds.Tables[0].Rows[0]["Bucket"].ToString();
}
else
{
CosXmlConfig config = new CosXmlConfig.Builder()
.SetRegion(Config.GetAppSetting("TX_COS_REGION")) //设置一个默认的存储桶地域
.Build();
string secretId = Config.GetAppSetting("TX_COS_SECRETID"); //云 API 密钥 SecretId
string secretKey = Config.GetAppSetting("TX_COS_SECRETKEY"); //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
string secretId = Config.GetAppSetting("TX_COS_SECRETID"); //云 API 密钥 SecretId this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);
string secretKey = Config.GetAppSetting("TX_COS_SECRETKEY"); //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
this.cosXml = new CosXmlServer(config, qCloudCredentialProvider); bucketName = Config.GetAppSetting("TX_COS_BUCKET");
}
} }
/// 高级接口上传对象 /// 高级接口上传对象
...@@ -51,12 +78,13 @@ namespace COSSnippet ...@@ -51,12 +78,13 @@ namespace COSSnippet
// 初始化 TransferManager // 初始化 TransferManager
TransferManager transferManager = new TransferManager(cosXml, transferConfig); TransferManager transferManager = new TransferManager(cosXml, transferConfig);
String bucket = Config.GetAppSetting("TX_COS_BUCKET"); //存储桶,格式:BucketName-APPID String bucket = bucketName; //存储桶,格式:BucketName-APPID
String cosPath = "Upload/Education/"+ newFileName; //对象在存储桶中的位置标识符,即称对象键 String cosPath = newFileName; //对象在存储桶中的位置标识符,即称对象键
if (Config.GetAppSetting("IsNorServer") == "2") //String cosPath = "Upload/Education/"+ newFileName; //对象在存储桶中的位置标识符,即称对象键
{ //if (Config.GetAppSetting("IsNorServer") == "2")
cosPath = "Test/" + cosPath; //{
} // cosPath = "Test/" + cosPath;
//}
String srcPath = filePath;//本地文件绝对路径 String srcPath = filePath;//本地文件绝对路径
// 上传对象 // 上传对象
...@@ -78,11 +106,11 @@ namespace COSSnippet ...@@ -78,11 +106,11 @@ namespace COSSnippet
{ {
if (clientEx != null) if (clientEx != null)
{ {
Console.WriteLine("CosClientException: " + clientEx); LogHelper.Write("CosClientException: " + clientEx);
} }
if (serverEx != null) if (serverEx != null)
{ {
Console.WriteLine("CosServerException: " + serverEx.GetInfo()); LogHelper.Write("CosServerException: " + serverEx.GetInfo());
} }
}; };
transferManager.Upload(uploadTask); transferManager.Upload(uploadTask);
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Aliyun.OSS.SDK" version="2.11.0" targetFramework="net461" /> <package id="Aliyun.OSS.SDK" version="2.11.0" targetFramework="net461" />
<package id="FluentScheduler" version="5.5.1" targetFramework="net461" />
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="2.2.0" targetFramework="net461" /> <package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="2.2.0" targetFramework="net461" />
<package id="MySql.Data" version="8.0.14" targetFramework="net461" /> <package id="MySql.Data" version="8.0.14" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" /> <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
......
...@@ -464,7 +464,7 @@ namespace Mall.Model.Entity.Product ...@@ -464,7 +464,7 @@ namespace Mall.Model.Entity.Product
/// </summary> /// </summary>
public string SendArea { get; set; } public string SendArea { get; set; }
/// <summary> /// <summary>
/// 商品分类 0正常商品 1司导商品 /// 商品分类 0正常商品 1司导商品 2教育商品
/// </summary> /// </summary>
public int GoodsClassify { get; set; } public int GoodsClassify { get; set; }
/// <summary> /// <summary>
......
using VT.FW.DB;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Enum.Goods;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联分类表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_WK_Course
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 章节排序
/// </summary>
public int? Sort
{
get;
set;
}
/// <summary>
/// 章节排序标题
/// </summary>
public string SortName { get; set; }
/// <summary>
/// 课程名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 附件类型 枚举
/// </summary>
public GoodsCourseTypeEnum? Type { get; set; }
/// <summary>
/// 是否可以试下 1是 2否
/// </summary>
public int? IsTrySee { get; set; }
/// <summary>
/// 试看 视频秒/word pdf页
/// </summary>
public int? Number { get; set; }
/// <summary>
/// 是否可以缓存 1是 2否
/// </summary>
public int? IsCache { get; set; }
/// <summary>
/// 文件地址
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 视频封面图
/// </summary>
public string VideoImage { get; set; }
/// <summary>
/// 视频时长
/// </summary>
public int? VideoTime { get; set; }
/// <summary>
/// 非视频 转图片 json格式
/// </summary>
public string Image { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
/// <summary>
/// 图片生成是否OK 1是 2正在生成中
/// </summary>
public int? IsImageOK { get; set; }
/// <summary>
/// 文件存储 1腾讯 2阿里
/// </summary>
public int? PathType { get; set; }
}
}
using VT.FW.DB;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.Product
{
/// <summary>
/// 商品关联教师表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_WK_Teacher
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 教师id
/// </summary>
public int? TeacherId
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
}
}
...@@ -31,7 +31,7 @@ namespace Mall.Model.Entity.Product ...@@ -31,7 +31,7 @@ namespace Mall.Model.Entity.Product
set; set;
} }
/// <summary> /// <summary>
/// 类型 1图片 2视频 /// 类型 1图片 2视频 3其他word,pdf,ppf文件
/// </summary> /// </summary>
public int? Type public int? Type
{ {
......
...@@ -30,7 +30,7 @@ namespace Mall.Model.Entity.Product ...@@ -30,7 +30,7 @@ namespace Mall.Model.Entity.Product
set; set;
} }
/// <summary> /// <summary>
/// 类型 1图片 2视频 /// 类型 1图片 2视频 3其他word,pdf,ppf
/// </summary> /// </summary>
public int? Type public int? Type
{ {
......
...@@ -427,5 +427,14 @@ namespace Mall.Model.Entity.User ...@@ -427,5 +427,14 @@ namespace Mall.Model.Entity.User
/// 是否开启校园版(1-开启) /// 是否开启校园版(1-开启)
/// </summary> /// </summary>
public int IsOpenSchool { get; set; } public int IsOpenSchool { get; set; }
/// <summary>
/// 菜单栏json格式 多组模式
/// </summary>
public string MenuNavJson { get; set; }
}
public class MenuNavMoreModel {
} }
} }
...@@ -16,6 +16,14 @@ namespace Mall.Model.Extend.Product ...@@ -16,6 +16,14 @@ namespace Mall.Model.Extend.Product
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Extend : RB_Goods public class RB_Goods_Extend : RB_Goods
{ {
/// <summary>
/// 课程列表
/// </summary>
public List<RB_Goods_WK_Course_Extend> CourseList { get; set; }
/// <summary>
/// 教师列表
/// </summary>
public List<RB_Goods_WK_Teacher_Extend> TeacherList { get; set; }
/// <summary> /// <summary>
/// 可预定日期 /// 可预定日期
/// </summary> /// </summary>
...@@ -109,6 +117,10 @@ namespace Mall.Model.Extend.Product ...@@ -109,6 +117,10 @@ namespace Mall.Model.Extend.Product
public string GuideCarType { get; set; } public string GuideCarType { get; set; }
#endregion #endregion
/// <summary>
/// 教师名称
/// </summary>
public string TeacherName { get; set; }
/// <summary> /// <summary>
/// 微店id /// 微店id
/// </summary> /// </summary>
......
using VT.FW.DB;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联课程表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_WK_Course_Extend : RB_Goods_WK_Course
{
/// <summary>
/// 商品ids
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 文件类型 1腾讯 2阿里云
/// </summary>
public int PathType { get; set; }
}
/// <summary>
/// 课程图片
/// </summary>
[Serializable]
public class CourseImageModel {
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 存储地址 1腾讯云 2阿里云
/// </summary>
public int PathType { get; set; }
/// <summary>
/// 图片地址
/// </summary>
public string Path { get; set; }
}
}
using VT.FW.DB;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
namespace Mall.Model.Extend.Product
{
/// <summary>
/// 商品关联讲师表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_WK_Teacher_Extend : RB_Goods_WK_Teacher
{
/// <summary>
/// 商品IDS
/// </summary>
public string GoodsIds { get; set; }
/// <summary>
/// 教师名称
/// </summary>
public string Name { get; set; }
}
}
This diff is collapsed.
...@@ -317,7 +317,7 @@ namespace Mall.Module.Product ...@@ -317,7 +317,7 @@ namespace Mall.Module.Product
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel) public List<RB_Goods_Extend> GetProductGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{ {
var list = goodsRepository.GetPageListForCar(pageIndex, pageSize, out count, demodel); var list = goodsRepository.GetPageListForCommission(pageIndex, pageSize, out count, demodel, 1);
if (list.Any()) if (list.Any())
{ {
//查询分类 //查询分类
...@@ -364,7 +364,7 @@ namespace Mall.Module.Product ...@@ -364,7 +364,7 @@ namespace Mall.Module.Product
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetProductGoodsPageListToExcel(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel) public List<RB_Goods_Extend> GetProductGoodsPageListToExcel(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{ {
var list = goodsRepository.GetPageListForCar(pageIndex, pageSize, out count, demodel); var list = goodsRepository.GetPageListForCommission(pageIndex, pageSize, out count, demodel, 1);
if (list.Any()) if (list.Any())
{ {
//查询分类 //查询分类
...@@ -1196,7 +1196,7 @@ namespace Mall.Module.Product ...@@ -1196,7 +1196,7 @@ namespace Mall.Module.Product
/// <returns></returns> /// <returns></returns>
public bool SetGoodsBatchStatusInfo(string goodsIds, int Type, int tenantId, int mallBaseId) public bool SetGoodsBatchStatusInfo(string goodsIds, int Type, int tenantId, int mallBaseId)
{ {
var list = goodsRepository.GetSingleListForCar(new RB_Goods_Extend() { GoodsIds = goodsIds }); var list = goodsRepository.GetSingleListForCommission(new RB_Goods_Extend() { GoodsIds = goodsIds }, 1);
foreach (var goodsModel in list) foreach (var goodsModel in list)
{ {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
...@@ -1925,7 +1925,7 @@ namespace Mall.Module.Product ...@@ -1925,7 +1925,7 @@ namespace Mall.Module.Product
if (demodel.DetailList.Any()) if (demodel.DetailList.Any())
{ {
string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId)); string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
var gList = goodsRepository.GetListForCar(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var gList = goodsRepository.GetListForCommission(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, 1);
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
......
...@@ -3900,7 +3900,7 @@ namespace Mall.Module.Product ...@@ -3900,7 +3900,7 @@ namespace Mall.Module.Product
integralModel = integral_SettingsRepository.GetIntegralSettingsList(new Model.Entity.MarketingCenter.RB_Integral_Settings() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); integralModel = integral_SettingsRepository.GetIntegralSettingsList(new Model.Entity.MarketingCenter.RB_Integral_Settings() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
} }
GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId)); GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
var gList = goodsRepository.GetListForCar(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var gList = goodsRepository.GetListForCommission(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, 1);
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mallbaseModel = mallBaseRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_MallBase_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); var mallbaseModel = mallBaseRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_MallBase_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
......
...@@ -765,9 +765,9 @@ where {where} group by g.Id order by col.Id desc"; ...@@ -765,9 +765,9 @@ where {where} group by g.Id order by col.Id desc";
/// <param name="rowCount">总条数</param> /// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param> /// <param name="dmodel">查询条件</param>
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetPageListForCar(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetPageListForCommission(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel,int GoodsClassify)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify={GoodsClassify}";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -878,9 +878,9 @@ where {where} group by g.Id order by {orderBy}"; ...@@ -878,9 +878,9 @@ where {where} group by g.Id order by {orderBy}";
/// </summary> /// </summary>
/// <param name="dmodel"></param> /// <param name="dmodel"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetListForCar(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetListForCommission(RB_Goods_Extend dmodel, int GoodsClassify)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify={GoodsClassify}";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
...@@ -942,9 +942,9 @@ WHERE {where} group by g.Id order by g.CreateDate desc"; ...@@ -942,9 +942,9 @@ WHERE {where} group by g.Id order by g.CreateDate desc";
/// </summary> /// </summary>
/// <param name="dmodel"></param> /// <param name="dmodel"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Extend> GetSingleListForCar(RB_Goods_Extend dmodel) public List<RB_Goods_Extend> GetSingleListForCommission(RB_Goods_Extend dmodel, int GoodsClassify)
{ {
string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=1"; string where = $" 1=1 and g.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify={GoodsClassify}";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}"; where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
......
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联课程仓储层
/// </summary>
public class RB_Goods_WK_CourseRepository : BaseRepository<RB_Goods_WK_Course>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_WK_Course_Extend> GetList(RB_Goods_WK_Course_Extend dmodel)
{
string where = $" 1=1 and gc.{nameof(RB_Goods_WK_Course.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Course.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Course.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Course.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Course.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and gc.{nameof(RB_Goods_Category.GoodsId)} in({dmodel.GoodsIds})";
}
string sql = $@"
SELECT gc.* FROM RB_Goods_WK_Course gc
WHERE {where} ORDER BY gc.Id asc ";
return Get<RB_Goods_WK_Course_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Product;
using Mall.Model.Extend.Product;
using System.Linq;
namespace Mall.Repository.Product
{
/// <summary>
/// 商品关联讲师仓储层
/// </summary>
public class RB_Goods_WK_TeacherRepository : BaseRepository<RB_Goods_WK_Teacher>
{
/// <summary>
/// 列表
/// </summary>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_WK_Teacher_Extend> GetList(RB_Goods_WK_Teacher_Extend dmodel)
{
string where = $" 1=1 and gc.{nameof(RB_Goods_WK_Teacher.Status)}=0";
if (dmodel.TenantId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.Id)}={dmodel.Id}";
}
if (dmodel.GoodsId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.GoodsId)}={dmodel.GoodsId}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds)) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.GoodsId)} in({dmodel.GoodsIds})";
}
if (dmodel.TeacherId > 0) {
where += $@" and gc.{nameof(RB_Goods_WK_Teacher.TeacherId)}={dmodel.TeacherId}";
}
string sql = $@"
SELECT gc.*,pc.Name
FROM RB_Goods_WK_Teacher gc inner join rb_education_teacher pc on gc.TeacherId=pc.Id
WHERE {where} ORDER BY gc.Id asc ";
return Get<RB_Goods_WK_Teacher_Extend>(sql).ToList();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment