Commit ed63ca14 authored by 吴春's avatar 吴春

解决冲突

parents 16e0f05c 956cf337
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 Aliyun.OSS;
using Mall.Education.Common;
using Mall.Education.Helper;
namespace COSSnippet
{
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 accessKeyId = "<yourAccessKeyId>";
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var objectName = "<yourObjectName>";
var localFilename = "<yourLocalFilename>";
var objectName = AliFileName;
var localFilename = filePath;
// 创建OssClient实例。
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
{
// 上传文件。
client.PutObject(bucketName, objectName, localFilename);
Console.WriteLine("Put object succeeded");
}
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) {
var endpoint = "<yourEndpoint>";
var accessKeyId = "<yourAccessKeyId>";
var accessKeySecret = "<yourAccessKeySecret>";
var bucketName = "<yourBucketName>";
var objectName = "<yourObjectName>";
var objectName = Key;
// 创建OssClient实例。
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
......
......@@ -9,6 +9,10 @@
<add key="TX_COS_SECRETID" value="AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd" />
<add key="TX_COS_SECRETKEY" value="PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob" />
<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>
<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;" />-->
......
......@@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
using Mall.Education.DBHelper;
using System.Linq;
using Newtonsoft.Json;
using System.Data;
namespace Mall.Education.Helper
{
......@@ -24,7 +25,7 @@ namespace Mall.Education.Helper
/// <param name="cookie"></param>
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);
return result;
}
......@@ -33,12 +34,11 @@ namespace Mall.Education.Helper
/// 删除课程图片记录
/// </summary>
/// <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('成都市') ";
var cityDataList = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, citySql, null);
LogHelper.Write(JsonConvert.SerializeObject(cityDataList.Tables[0].Rows));
//var sqlOrderDetailResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sqlOrderDetail, null);
string sql = $@"SELECT * FROM rb_file_store WHERE MallBaseId ={MallBaseId} AND StoreType={Type} ";
var List = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sql, null);
return List;
}
/// <summary>
......
......@@ -64,6 +64,9 @@
<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>
</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.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>
......
......@@ -23,7 +23,14 @@ namespace Mall.Education.Models
/// 文件地址
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 文件存储 1腾讯 2阿里云
/// </summary>
public int PathType { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
}
/// <summary>
......
......@@ -22,6 +22,22 @@ namespace Mall.Education
// new RebornTimerServer(),
//};
//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()
//{
......@@ -32,8 +48,7 @@ namespace Mall.Education
// QueenName = RabbitKey.QUEEN_GENERATE_EDUCARION
//};
//RabbiMQManager.DealWithMessage(rabbit);
//Console.WriteLine("结束了");
//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);
......@@ -45,7 +60,7 @@ namespace Mall.Education
//TransferUploadObjectModel m = new TransferUploadObjectModel();
//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();
}
......@@ -54,61 +69,61 @@ namespace Mall.Education
/// 处理文件
/// </summary>
/// <param name="GoodsModel"></param>
private static void ImageConvertData(GoodsModel GoodsModel)
{
string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
if (!Directory.Exists(tempDir))
Directory.CreateDirectory(tempDir);
//是否需要先把文件下载到服务器
GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
//文件生成图片暂存本地
string FileExtension = Path.GetExtension(GoodsModel.FilePath);
string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath);
string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath);
int PageNum;
System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
if (FileExtension == ".doc" || FileExtension == ".docx")
{
new Word2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
}
else if (FileExtension == ".pdf")
{
new Pdf2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
}
else if (FileExtension == ".ppt" || FileExtension == ".pptx")
{
new Ppt2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
}
else
{
return;
}
//private static void ImageConvertData(GoodsModel GoodsModel)
//{
// string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
// if (!Directory.Exists(tempDir))
// Directory.CreateDirectory(tempDir);
// //是否需要先把文件下载到服务器
// GoodsModel.FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
// //文件生成图片暂存本地
// string FileExtension = Path.GetExtension(GoodsModel.FilePath);
// string FileName = Path.GetFileNameWithoutExtension(GoodsModel.FilePath);
// string FileDirectory = Path.GetDirectoryName(GoodsModel.FilePath);
// int PageNum;
// System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
// if (FileExtension == ".doc" || FileExtension == ".docx")
// {
// new Word2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
// }
// else if (FileExtension == ".pdf")
// {
// new Pdf2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
// }
// else if (FileExtension == ".ppt" || FileExtension == ".pptx")
// {
// new Ppt2ImageConverter().ConvertToImage(GoodsModel.FilePath, tempDir + "/", imageFormat, out PageNum);
// }
// else
// {
// return;
// }
if (PageNum > 0)
{
List<GoodsImage> goodsImages = new List<GoodsImage>();
//开始上传图片至服务器
TransferUploadObjectModel m = new TransferUploadObjectModel();
for (var i = 1; i <= PageNum; i++)
{
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
m.TransferUploadFile(tempDir + "/" + newName, newName);
//上传之后 写入商品课程图片数据
goodsImages.Add(new GoodsImage
{
Sort = i,
Path = FileDirectory + "/" + newName
});
}
//更新图片数据
bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0;
if (flag == false)
{
Console.WriteLine("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId);
}
}
}
// if (PageNum > 0)
// {
// List<GoodsImage> goodsImages = new List<GoodsImage>();
// //开始上传图片至服务器
// TransferUploadObjectModel m = new TransferUploadObjectModel();
// for (var i = 1; i <= PageNum; i++)
// {
// string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
// m.TransferUploadFile(tempDir + "/" + newName, newName);
// //上传之后 写入商品课程图片数据
// goodsImages.Add(new GoodsImage
// {
// Sort = i,
// Path = FileDirectory + "/" + newName
// });
// }
// //更新图片数据
// bool flag = FileDataHelper.InsertGoodsFileImage(GoodsModel.CourseId, JsonConvert.SerializeObject(goodsImages)) > 0;
// if (flag == false)
// {
// Console.WriteLine("更新课程图片列表失败:CourseId:" + GoodsModel.CourseId);
// }
// }
//}
}
}
......@@ -9,6 +9,7 @@ using Mall.Education.Offices;
using COSSnippet;
using Mall.Education.Helper;
using System.Collections.Generic;
using FluentScheduler;
namespace Mall.Education.RabbitMQ
{
......@@ -35,6 +36,10 @@ namespace Mall.Education.RabbitMQ
return factory;
}
/// <summary>
/// 处理消息队列
/// </summary>
/// <param name="rabbitConfig"></param>
[Obsolete]
public static void DealWithMessage(RabbitConfig rabbitConfig)
{
......@@ -59,13 +64,14 @@ namespace Mall.Education.RabbitMQ
string msg = Encoding.UTF8.GetString(bytes);
try
{
Console.WriteLine("进来一个:" + msg);
var GoodsModel = JsonConvert.DeserializeObject<GoodsModel>(msg);
//处理
if (GoodsModel != null)
{
ImageConvertData(GoodsModel);
}
//Console.WriteLine(msg);
Console.WriteLine("处理一个:" + msg);
}
catch (Exception ex)
{
......@@ -84,15 +90,24 @@ namespace Mall.Education.RabbitMQ
/// <param name="GoodsModel"></param>
private static void ImageConvertData(GoodsModel GoodsModel)
{
if (string.IsNullOrEmpty(GoodsModel.FilePath)) {
return;
}
string tempDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempfile/Image");
if (!Directory.Exists(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 FileName = Path.GetFileNameWithoutExtension(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;
System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
if (FileExtension == ".doc" || FileExtension == ".docx")
......@@ -115,26 +130,97 @@ namespace Mall.Education.RabbitMQ
{
List<GoodsImage> goodsImages = new List<GoodsImage>();
//开始上传图片至服务器
TransferUploadObjectModel m = new TransferUploadObjectModel();
for (var i = 1; i <= PageNum; i++)
if (GoodsModel.PathType == 1)
{
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
m.TransferUploadFile(tempDir + "/" + newName, newName);
TransferUploadObjectModel m = new TransferUploadObjectModel(GoodsModel.MallBaseId);
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,
Path = FileDirectory + "/" + newName
});
string newName = FileName + "_" + i.ToString("000") + "." + imageFormat.ToString();
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;
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;
using System.Threading;
using System.Threading.Tasks;
using Mall.Education.Common;
using Mall.Education.Helper;
namespace COSSnippet
{
......@@ -25,20 +26,46 @@ namespace COSSnippet
{
private CosXml cosXml;
private string bucketName;
public TransferUploadObjectModel()
public TransferUploadObjectModel(int MallBaseId)
{
CosXmlConfig config = new CosXmlConfig.Builder()
.SetRegion(Config.GetAppSetting("TX_COS_REGION")) //设置一个默认的存储桶地域
.Build();
var ds = FileDataHelper.GetMallBaseFileInfo(MallBaseId, 1);
if (ds.Tables[0].Rows.Count > 0)
{
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
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);
this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);
bucketName = Config.GetAppSetting("TX_COS_BUCKET");
}
}
/// 高级接口上传对象
......@@ -51,12 +78,13 @@ namespace COSSnippet
// 初始化 TransferManager
TransferManager transferManager = new TransferManager(cosXml, transferConfig);
String bucket = Config.GetAppSetting("TX_COS_BUCKET"); //存储桶,格式:BucketName-APPID
String cosPath = "Upload/Education/"+ newFileName; //对象在存储桶中的位置标识符,即称对象键
if (Config.GetAppSetting("IsNorServer") == "2")
{
cosPath = "Test/" + cosPath;
}
String bucket = bucketName; //存储桶,格式:BucketName-APPID
String cosPath = newFileName; //对象在存储桶中的位置标识符,即称对象键
//String cosPath = "Upload/Education/"+ newFileName; //对象在存储桶中的位置标识符,即称对象键
//if (Config.GetAppSetting("IsNorServer") == "2")
//{
// cosPath = "Test/" + cosPath;
//}
String srcPath = filePath;//本地文件绝对路径
// 上传对象
......@@ -78,11 +106,11 @@ namespace COSSnippet
{
if (clientEx != null)
{
Console.WriteLine("CosClientException: " + clientEx);
LogHelper.Write("CosClientException: " + clientEx);
}
if (serverEx != null)
{
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
LogHelper.Write("CosServerException: " + serverEx.GetInfo());
}
};
transferManager.Upload(uploadTask);
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<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="MySql.Data" version="8.0.14" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
......
......@@ -464,7 +464,7 @@ namespace Mall.Model.Entity.Product
/// </summary>
public string SendArea { get; set; }
/// <summary>
/// 商品分类 0正常商品 1司导商品
/// 商品分类 0正常商品 1司导商品 2教育商品
/// </summary>
public int GoodsClassify { get; set; }
/// <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
set;
}
/// <summary>
/// 类型 1图片 2视频
/// 类型 1图片 2视频 3其他word,pdf,ppf文件
/// </summary>
public int? Type
{
......
......@@ -30,7 +30,7 @@ namespace Mall.Model.Entity.Product
set;
}
/// <summary>
/// 类型 1图片 2视频
/// 类型 1图片 2视频 3其他word,pdf,ppf
/// </summary>
public int? Type
{
......
......@@ -427,5 +427,14 @@ namespace Mall.Model.Entity.User
/// 是否开启校园版(1-开启)
/// </summary>
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
[DB(ConnectionName = "DefaultConnection")]
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>
......@@ -109,6 +117,10 @@ namespace Mall.Model.Extend.Product
public string GuideCarType { get; set; }
#endregion
/// <summary>
/// 教师名称
/// </summary>
public string TeacherName { get; set; }
/// <summary>
/// 微店id
/// </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.
......@@ -240,8 +240,7 @@ namespace Mall.Module.Finance
[TransactionCallHandler]
public virtual bool SetFinanceRecord(RB_Finance_Record_Extend model, List<Model.Extend.Product.RB_Goods_OrderDetail_Extend> list )
{
bool flag = false;
bool flag = false;
try
{
int recordId = 0;
......@@ -253,73 +252,66 @@ namespace Mall.Module.Finance
{
model.RecordDetailList.ForEach(x => x.RecordId = recordId);
model.RecordDetailList.ForEach(x => x.FinanceId = model.FinanceId);
financeRecordDetailRepository.InsertBatch(model.RecordDetailList);
}
foreach (var item in model.RecordDetailList)
{
try
Dictionary<string, object> keyValues = new Dictionary<string, object>();
if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1) && list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 2))
{
Dictionary<string, object> keyValues = new Dictionary<string, object>();
if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1) && list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 2))
{
keyValues = new Dictionary<string, object>()
keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.CostFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.FreightFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1) && list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 3))
{
keyValues = new Dictionary<string, object>()
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1) && list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 3))
{
keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.CostFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.InsuranceFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1))
{
keyValues = new Dictionary<string, object>()
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 1))
{
keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.CostFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 2))
{
keyValues = new Dictionary<string, object>()
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 2))
{
keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.FreightFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 3))
{
keyValues = new Dictionary<string, object>()
}
else if (list.Any(x => x.Id == item.OrderDetailId && x.FinanceType == 3))
{
keyValues = new Dictionary<string, object>()
{
{ nameof(RB_Goods_OrderDetail.InsuranceFinanceId),model.FinanceId},
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
}
List<WhereHelper> whereHelpers = new List<WhereHelper>() { new WhereHelper()
{
FiledName=nameof(RB_Finance_Configurine_Extend.Id),
FiledValue=item.OrderDetailId,
OperatorEnum=OperatorEnum.Equal
}
{ nameof(RB_Goods_OrderDetail.PaidCostMoney),item.OrderDetailPaid}
};
goods_OrderDetailRepository.Update(keyValues, whereHelpers);
}
catch (Exception ex)
List<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper()
{
FiledName=nameof(RB_Finance_Configurine_Extend.Id),
FiledValue=item.OrderDetailId,
OperatorEnum=OperatorEnum.Equal
}
};
if (keyValues != null && keyValues.Count > 0)
{
goods_OrderDetailRepository.Update(keyValues, whereHelpers);
}
}
}
......
......@@ -317,7 +317,7 @@ namespace Mall.Module.Product
/// <returns></returns>
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())
{
//查询分类
......@@ -364,7 +364,7 @@ namespace Mall.Module.Product
/// <returns></returns>
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())
{
//查询分类
......@@ -1196,7 +1196,7 @@ namespace Mall.Module.Product
/// <returns></returns>
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)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -1925,7 +1925,7 @@ namespace Mall.Module.Product
if (demodel.DetailList.Any())
{
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 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
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));
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 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();
......
......@@ -765,9 +765,9 @@ where {where} group by g.Id order by col.Id desc";
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <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)
{
where += $@" and g.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
......@@ -878,9 +878,9 @@ where {where} group by g.Id order by {orderBy}";
/// </summary>
/// <param name="dmodel"></param>
/// <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)
{
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";
/// </summary>
/// <param name="dmodel"></param>
/// <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)
{
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