Commit f367d62e authored by 黄奎's avatar 黄奎

分销海报

parent 890e8ef5
......@@ -13,5 +13,58 @@ namespace Mall.Model.Extend.User
[DB(ConnectionName = "DefaultConnection")]
public class RB_MiniProgram_GoodPoster_Extend : Model.Entity.User.RB_MiniProgram_GoodPoster
{
/// <summary>
/// 海报样式
/// </summary>
public List<int> PosterStyleList
{
get
{
List<int> posters = new List<int>();
if (this.PosterStyle != null && !string.IsNullOrWhiteSpace(this.PosterStyle))
{
var array = this.PosterStyle.Split(",");
if (array != null && array.Length > 0)
{
foreach (var item in array)
{
Int32.TryParse(item, out int presult);
if (presult > 0)
{
posters.Add(presult);
}
}
}
}
return posters;
}
}
/// <summary>
/// 商品样式
/// </summary>
public List<int> GoodsImgCountList
{
get
{
List<int> goods = new List<int>();
if (this.GoodsImgCount != null && !string.IsNullOrWhiteSpace(this.GoodsImgCount))
{
var array = this.GoodsImgCount.Split(",");
if (array != null && array.Length > 0)
{
foreach (var item in array)
{
Int32.TryParse(item, out int result);
if (result > 0)
{
goods.Add(result);
}
}
}
}
return goods;
}
}
}
}
......@@ -142,7 +142,10 @@ namespace Mall.Module.Product
/// </summary>
private readonly RB_Distributor_HPGradeRatioRepository distributor_HPGradeRatioRepository = new RB_Distributor_HPGradeRatioRepository();
/// <summary>
/// 商品分销
/// </summary>
private readonly RB_MiniProgram_GoodPosterRepository miniProgram_GoodPosterRepository = new RB_MiniProgram_GoodPosterRepository();
#region 小程序接口
......@@ -876,9 +879,31 @@ namespace Mall.Module.Product
string QRPath = GetWeiXinQRCode(path, 430, mallBaseId);
var umodel = member_UserRepository.GetEntity(userId);
var goodsModel = goodsRepository.GetEntity(goodsId);
//商品海报配置信息
var config = new object();
//商品信息
var info = new object();
var goodsPoster = miniProgram_GoodPosterRepository.GetEntityExtRepository(new RB_MiniProgram_GoodPoster_Extend() { MallBaseId = mallBaseId });
config = new
{
poster_style = goodsPoster?.PosterStyleList ?? new List<int>() { 1 },
image_style = goodsPoster?.GoodsImgCountList ?? new List<int>() { 1 },
color = new List<string>()
{
"#fc4a3b",
"#ff7b22",
"#ffc73f",
"#3e9b6a",
"#4bb1ff",
"#8548ef",
"#000000",
"#a0a0a0",
"#FFFFFF"
}
};
if (goodsModel == null)
{
return new
info= new
{
goods_name = "",
multi_map = new List<string>(),
......@@ -891,23 +916,28 @@ namespace Mall.Module.Product
sign = ""
};
}
else {
else
{
//商品图片处理
var imgList = new List<string>();
if (!string.IsNullOrEmpty(goodsModel.CarouselImage) && goodsModel.CarouselImage != "[]") {
if (!string.IsNullOrEmpty(goodsModel.CarouselImage) && goodsModel.CarouselImage != "[]")
{
imgList = JsonConvert.DeserializeObject<List<string>>(goodsModel.CarouselImage);
}
if (imgList.Any()) {
if (imgList.Count() < 8) {
if (imgList.Any())
{
if (imgList.Count() < 8)
{
var imgList2 = new List<string>();
int Num = 8 / imgList.Count();
for (var i = 0; i < Num + 1; i++) {
for (var i = 0; i < Num + 1; i++)
{
imgList2.AddRange(imgList);
}
imgList = imgList2.Take(8).ToList();
}
}
return new
info = new
{
goods_name = goodsModel.Name,
multi_map = imgList,
......@@ -920,6 +950,12 @@ namespace Mall.Module.Product
sign = ""
};
}
var obj = new
{
config,
info
};
return obj;
}
#region 获取小程序码
......
......@@ -578,5 +578,38 @@ namespace Mall.WebApi.Controllers.MallBase
}
return ApiResult.Success(data: openId);
}
/// <summary>
/// 获取用户信息
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult GetGoosPoster()
{
string MiniAppId = "";
try
{
//小程序Id
MiniAppId = RequestParm.MiniAppId;
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Error("GetGoosPoster", ex);
}
//获取小程序信息
var miniProgram = new RB_MiniProgram_Extend();
if (MiniAppId != null && !string.IsNullOrEmpty(MiniAppId))
{
miniProgram = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend() { MiniAppId = MiniAppId }, isGetHomeData: true, isGetNav: 1);
}
JObject parms = JObject.Parse(RequestParm.msg.ToString());
int goodsId = parms.GetInt("goodsId");
string path = parms.GetStringValue("path");
var obj = productModule.GetAppletGoodsShareInfo(goodsId, RequestParm.UserId, path, (miniProgram?.MallBaseId ?? 0));
return ApiResult.Success(data: obj);
}
}
}
\ No newline at end of file
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