mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-03-22 14:17:21 +08:00
# 2022-01-17
### 1.3.0 开源社区版: 【新增】完善商品查看详情功能。#I4QTLR 【新增】订单详情页面需要增加下单客户信息。 【新增】完善服务订单管理功能,实现订单作废、导出功能;核销码实现列表,作废,导出功能。#I4OSBK 【修复】修复普通订单查看详情,因优惠信息问题导致的异常情况。#I4QXUQ 【修复】修复门店列表下的用户编辑页面名称大小写问题(linux下大小写敏感问题)。 【修复】修复微信支付成功相应的日志记录类型有误。#I4QSNZ 【修复】修复发货日志记录sku货号错误问题。#I4PX25 【修复】修复发货单列表查看详情,提示权限不足的问题。#I4QDQR ### 0.0.8 会员专业版: 【新增】新增接龙功能营销功能,实现单个活动,可以添加多个不同商品的不同sku混合选择下单。 【新增】增加接龙数据库脚本及演示文件。 【升级】升级uView组件到2.0.20版本。 【修复】修复编辑收货地址的路径中选取区域部分可以手动输入文字。 【修复】修复【微信直播带货】组件缺少获取sku分页数据的问题。#I4QKSU 【优化】调整【微信自定义交易组件】商品类目排序方式及展示内容。#I4QE0N
This commit is contained in:
@@ -38,7 +38,6 @@ using SixLabors.ImageSharp.Processing;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services
|
||||
{
|
||||
/// <summary>
|
||||
@@ -49,9 +48,10 @@ namespace CoreCms.Net.Services
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
public static readonly string AppInterFaceUrl = AppSettingsConstVars.AppConfigAppInterFaceUrl;
|
||||
private readonly string _appInterFaceUrl = AppSettingsConstVars.AppConfigAppInterFaceUrl;
|
||||
|
||||
public readonly ICoreCmsGoodsServices GoodsServices;
|
||||
private readonly ICoreCmsGoodsServices _goodsServices;
|
||||
private readonly ICoreCmsSolitaireServices _solitaireServices;
|
||||
private readonly WeChatOptions _weChatOptions;
|
||||
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
@@ -60,13 +60,14 @@ namespace CoreCms.Net.Services
|
||||
public CoreCmsShareServices(IUnitOfWork unitOfWork
|
||||
, IWebHostEnvironment webHostEnvironment
|
||||
, ICoreCmsGoodsServices goodsServices
|
||||
, IOptions<WeChatOptions> weChatOptions, IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
|
||||
, IOptions<WeChatOptions> weChatOptions, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsSolitaireServices solitaireServices)
|
||||
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
GoodsServices = goodsServices;
|
||||
_goodsServices = goodsServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
_solitaireServices = solitaireServices;
|
||||
_weChatOptions = weChatOptions.Value;
|
||||
|
||||
}
|
||||
@@ -123,14 +124,20 @@ namespace CoreCms.Net.Services
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> PosterShare(int client, int page, int userShareCode, string url, JObject parameter)
|
||||
{
|
||||
//获取分享代码
|
||||
var res = GetCode(client, page, userShareCode, url, parameter);
|
||||
if (!res.status)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
//如果不是商品和拼团
|
||||
if (page != (int)GlobalEnumVars.UrlSharePageType.PinTuan && page != (int)GlobalEnumVars.UrlSharePageType.Goods && page != (int)GlobalEnumVars.UrlSharePageType.Seckill && page != (int)GlobalEnumVars.UrlSharePageType.Group)
|
||||
if (page != (int)GlobalEnumVars.UrlSharePageType.PinTuan &&
|
||||
page != (int)GlobalEnumVars.UrlSharePageType.Goods &&
|
||||
page != (int)GlobalEnumVars.UrlSharePageType.Seckill &&
|
||||
page != (int)GlobalEnumVars.UrlSharePageType.Solitaire &&
|
||||
page != (int)GlobalEnumVars.UrlSharePageType.Group)
|
||||
{
|
||||
//走二维码分享
|
||||
return await getQr(url, res.otherData.ToString(), client);
|
||||
}
|
||||
//生成海报图片
|
||||
@@ -196,7 +203,7 @@ namespace CoreCms.Net.Services
|
||||
//有这个二维码了
|
||||
jm.status = true;
|
||||
jm.msg = "二维码获取成功";
|
||||
jm.data = AppInterFaceUrl + fileName;
|
||||
jm.data = _appInterFaceUrl + fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -231,50 +238,22 @@ namespace CoreCms.Net.Services
|
||||
//拼团
|
||||
if (!string.IsNullOrEmpty(invite))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(teamId))
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("5", invite, id, teamId);
|
||||
}
|
||||
else
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("5", invite, id, "");
|
||||
}
|
||||
scene = ShareHelper.share_parameter_encode("5", invite, id, !string.IsNullOrEmpty(teamId) ? teamId : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(teamId))
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("5", "", id, teamId);
|
||||
}
|
||||
else
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("5", "", id, "");
|
||||
}
|
||||
scene = ShareHelper.share_parameter_encode("5", "", id, !string.IsNullOrEmpty(teamId) ? teamId : "");
|
||||
}
|
||||
}
|
||||
else if (type == 4)
|
||||
{
|
||||
//店铺首页
|
||||
if (!string.IsNullOrEmpty(invite))
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("9", invite, id, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("9", "", id, "");
|
||||
}
|
||||
scene = ShareHelper.share_parameter_encode("9", !string.IsNullOrEmpty(invite) ? invite : "", id, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
//默认首页
|
||||
if (!string.IsNullOrEmpty(invite))
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("3", invite, "", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
scene = ShareHelper.share_parameter_encode("3", "", "", "");
|
||||
}
|
||||
scene = ShareHelper.share_parameter_encode("3", !string.IsNullOrEmpty(invite) ? invite : "", "", "");
|
||||
}
|
||||
|
||||
//没有去官方请求生成
|
||||
@@ -363,7 +342,7 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
jm.status = true;
|
||||
jm.msg = "二维码获取成功";
|
||||
jm.data = AppInterFaceUrl + fileName;
|
||||
jm.data = _appInterFaceUrl + fileName;
|
||||
jm.otherData = fileNameMin;
|
||||
}
|
||||
else
|
||||
@@ -646,6 +625,17 @@ namespace CoreCms.Net.Services
|
||||
return jm;
|
||||
}
|
||||
break;
|
||||
case (int)GlobalEnumVars.UrlSharePageType.Solitaire:
|
||||
if (parameter.ContainsKey("id"))
|
||||
{
|
||||
str = parameter["id"]?.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = "参数必须传id";
|
||||
return jm;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
jm.msg = GlobalErrorCodeVars.Code10000;
|
||||
return jm;
|
||||
@@ -745,7 +735,7 @@ namespace CoreCms.Net.Services
|
||||
case (int)GlobalEnumVars.UrlSharePageType.Form:
|
||||
if (arr.Length == 1)
|
||||
{
|
||||
jm.data = new { goodsId = arr[0] };
|
||||
jm.data = new { id = arr[0] };
|
||||
jm.status = true;
|
||||
}
|
||||
break;
|
||||
@@ -778,6 +768,13 @@ namespace CoreCms.Net.Services
|
||||
jm.status = true;
|
||||
}
|
||||
break;
|
||||
case (int)GlobalEnumVars.UrlSharePageType.Solitaire:
|
||||
if (arr.Length == 1)
|
||||
{
|
||||
jm.data = new { id = arr[0] };
|
||||
jm.status = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
jm.msg = GlobalErrorCodeVars.Code10000;
|
||||
return jm;
|
||||
@@ -814,7 +811,7 @@ namespace CoreCms.Net.Services
|
||||
//有这个二维码了
|
||||
jm.status = true;
|
||||
jm.msg = "海报获取成功";
|
||||
jm.data = AppInterFaceUrl + fileName;
|
||||
jm.data = _appInterFaceUrl + fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -838,7 +835,7 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
jm.status = true;
|
||||
jm.msg = "海报生成成功";
|
||||
jm.data = AppInterFaceUrl + fileName;
|
||||
jm.data = _appInterFaceUrl + fileName;
|
||||
}
|
||||
jm.otherData = mkResult;
|
||||
}
|
||||
@@ -856,7 +853,6 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
var fileName = fileNameStr;
|
||||
|
||||
|
||||
//文件硬地址
|
||||
var savePath = _webHostEnvironment.WebRootPath + "/static/qrCode/weChat/";
|
||||
var qrCodeDir = _webHostEnvironment.WebRootPath + "/static/qrCode/weChat/" + otherData;
|
||||
@@ -871,7 +867,7 @@ namespace CoreCms.Net.Services
|
||||
}
|
||||
//2商品详情页,3拼团详情页
|
||||
var page = dataObj["page"].ObjectToInt(0);
|
||||
if (page == 2 || page == 3)
|
||||
if (page == (int)GlobalEnumVars.UrlSharePageType.Goods || page == (int)GlobalEnumVars.UrlSharePageType.PinTuan)
|
||||
{
|
||||
if (dataObj.ContainsKey("params"))
|
||||
{
|
||||
@@ -881,20 +877,19 @@ namespace CoreCms.Net.Services
|
||||
return false;
|
||||
}
|
||||
var goodId = paramsObj["goodsId"].ObjectToInt();
|
||||
var goodModel = await GoodsServices.GetGoodsDetial(goodId);
|
||||
var goodModel = await _goodsServices.GetGoodsDetial(goodId);
|
||||
if (goodModel != null)
|
||||
{
|
||||
var images = goodModel.images.Split(",");
|
||||
if (images.Any())
|
||||
{
|
||||
var image = images[0];
|
||||
//创建一个背景宽度为400X600的底图
|
||||
using var imageTemple = new SixLabors.ImageSharp.Image<Rgba32>(400, 600);
|
||||
//设置底图的背景色为白色
|
||||
imageTemple.Mutate(x => x.BackgroundColor(SixLabors.ImageSharp.Color.White));
|
||||
//绘制商品图片(网络下载图片)
|
||||
HttpClient client = new HttpClient();
|
||||
HttpResponseMessage response = await client.GetAsync(image);
|
||||
HttpResponseMessage response = await client.GetAsync(goodModel.image);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
//载入下载的图片流
|
||||
@@ -956,9 +951,88 @@ namespace CoreCms.Net.Services
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (page == (int)GlobalEnumVars.UrlSharePageType.Solitaire)
|
||||
{
|
||||
if (dataObj.ContainsKey("params"))
|
||||
{
|
||||
var paramsObj = JObject.FromObject(dataObj["params"]);
|
||||
if (!paramsObj.ContainsKey("id"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var id = paramsObj["id"].ObjectToInt();
|
||||
var solitaireModel = await _solitaireServices.QueryByClauseAsync(p => p.id == id);
|
||||
if (solitaireModel != null && !string.IsNullOrEmpty(solitaireModel.thumbnail))
|
||||
{
|
||||
//创建一个背景宽度为400X600的底图
|
||||
using var imageTemple = new SixLabors.ImageSharp.Image<Rgba32>(400, 600);
|
||||
//设置底图的背景色为白色
|
||||
imageTemple.Mutate(x => x.BackgroundColor(SixLabors.ImageSharp.Color.White));
|
||||
//绘制商品图片(网络下载图片)
|
||||
HttpClient client = new HttpClient();
|
||||
HttpResponseMessage response = await client.GetAsync(solitaireModel.thumbnail);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var stream = await response.Content.ReadAsStreamAsync();
|
||||
//载入下载的图片流
|
||||
var imageThumbnail = await SixLabors.ImageSharp.Image.LoadAsync(stream);
|
||||
//将下载的图片压缩至400X400
|
||||
imageThumbnail.Mutate(x =>
|
||||
{
|
||||
x.Resize(400, 400);
|
||||
});
|
||||
//将商品大图合并到背景图上
|
||||
imageTemple.Mutate(x => x.DrawImage(imageThumbnail, new SixLabors.ImageSharp.Point(0, 0), 1));
|
||||
//将用户的分享二维码合并大背景图上
|
||||
var imageQrcode = await SixLabors.ImageSharp.Image.LoadAsync(qrCodeDir);
|
||||
//将二维码缩略至120X120
|
||||
imageQrcode.Mutate(x =>
|
||||
{
|
||||
x.Resize(120, 120);
|
||||
});
|
||||
//将二维码图片合并到背景图上
|
||||
imageTemple.Mutate(x => x.DrawImage(imageQrcode, new SixLabors.ImageSharp.Point(275, 420), 1));
|
||||
//构建字体//装载字体(ttf)(而且字体一定要支持简体中文的)
|
||||
var fonts = new FontCollection();
|
||||
SixLabors.Fonts.FontFamily fontFamily = fonts.Install(_webHostEnvironment.WebRootPath + "/fonts/SourceHanSansK-Normal.ttf");
|
||||
//绘制商品名称
|
||||
SixLabors.Fonts.Font titleFont = new SixLabors.Fonts.Font(fontFamily, 20, SixLabors.Fonts.FontStyle.Regular);
|
||||
//商品名称可能较长,设置为多行文本输出
|
||||
var textOptions = new TextOptions()
|
||||
{
|
||||
ApplyKerning = true,
|
||||
VerticalAlignment = VerticalAlignment.Top,
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
WrapTextWidth = 230
|
||||
};
|
||||
var graphicsOptions = new GraphicsOptions()
|
||||
{
|
||||
Antialias = true
|
||||
};
|
||||
//沿着行尾的绕行路径绘制文本
|
||||
var options = new SixLabors.ImageSharp.Drawing.Processing.DrawingOptions
|
||||
{
|
||||
GraphicsOptions = graphicsOptions,
|
||||
TextOptions = textOptions
|
||||
};
|
||||
//开始绘制商品名称
|
||||
imageTemple.Mutate(ctx => ctx.DrawText(options, solitaireModel.title, titleFont, SixLabors.ImageSharp.Color.Red, new SixLabors.ImageSharp.PointF(10, 450)));
|
||||
//绘制商品金额
|
||||
SixLabors.Fonts.Font moneyFont = new SixLabors.Fonts.Font(fontFamily, 18);
|
||||
//获取该文件绘制所需的大小
|
||||
//var size = TextMeasurer.Measure(moneyText, new RendererOptions(moneyFont));
|
||||
imageTemple.Mutate(ctx => ctx.DrawText("火热接龙中", moneyFont, SixLabors.ImageSharp.Color.Crimson, new SixLabors.ImageSharp.PointF(10, 410)));
|
||||
//绘制提示语
|
||||
SixLabors.Fonts.Font tipsFont = new SixLabors.Fonts.Font(fontFamily, 10);
|
||||
imageTemple.Mutate(ctx => ctx.DrawText("扫描或长按识别二维码", tipsFont, SixLabors.ImageSharp.Color.Black, new SixLabors.ImageSharp.PointF(283, 555)));
|
||||
|
||||
//载入流存储在到文件
|
||||
await imageTemple.SaveAsync(_webHostEnvironment.WebRootPath + fileName);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user