2025-04-24 18:31:27 +08:00

177 lines
6.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Constant;
using MyCode.Project.WebApi.Controllers;
using MyCode.Project.Domain.Config;
using MyCode.Project.Services;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Domain.Message.Request.User;
using MyCode.Project.Infrastructure.Enumeration;
using MyCode.Project.Domain.Message.Act.User;
using MyCode.Project.Domain.Message.Response.Goods;
using MyCode.Project.Domain.Model;
using MyCode.Project.Infrastructure.Extensions;
using MyCode.Project.Domain.Message.Response.Common;
using MyCode.Project.Domain.Message.Response.MaterialWarehouse;
using MyCode.Project.Domain.Message.Request.MaterialWarehouse;
using MyCode.Project.Domain.Message.Common;
using MyCode.Project.Infrastructure.Cache;
namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
{
/// <summary>
/// 素材库相关
/// </summary>
public class MaterialWarehouseController : BaseWechatController
{
private IMaterialWarehouseService _materialWarehouseService;
private IShopActionLogService _shopActionLogService;
private IMyCodeCacheService _myCodeCacheService;
private IMiniCodeScenceService _miniCodeScenceService;
public MaterialWarehouseController(IMaterialWarehouseService materialWarehouseService
, IShopActionLogService shopActionLogService
, IMyCodeCacheService myCodeCacheService
, IMiniCodeScenceService miniCodeScenceService)
{
_materialWarehouseService = materialWarehouseService;
_shopActionLogService = shopActionLogService;
_myCodeCacheService = myCodeCacheService;
_miniCodeScenceService = miniCodeScenceService;
}
#region GetMaterialThemeList()
/// <summary>
/// 获取主题列表
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public List<ItemResult> GetMaterialThemeList()
{
return _materialWarehouseService.GetMaterialThemeList();
}
#endregion
#region GetPageList()
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public PageResult<MaterialWarehousePageList> GetPageList(PagedSearch<MaterialWarehousePageQuery> request)
{
var condition = request.Condition;
if (!string.IsNullOrWhiteSpace(condition.MaterialId) && condition.MaterialId.Length==32)
{
var json2 = _miniCodeScenceService.GetScenceData("materialId" + condition.MaterialId);
string cash = "";
if (string.IsNullOrWhiteSpace(json2))
{
cash = _myCodeCacheService.Get<string>("materialId" + condition.MaterialId);
if (!string.IsNullOrWhiteSpace(cash))
{
try
{
_miniCodeScenceService.SaveDataFromRedis("materialId" + condition.MaterialId, cash, 11);
}
catch
{ }
}
}
else
{
cash = json2;
}
//var cash = _myCodeCacheService.Get<string>("materialId" + condition.MaterialId);
if (!string.IsNullOrWhiteSpace(cash))
{
condition.MaterialId = cash;
}
}
var result = _materialWarehouseService.GetPageList(request);
//try
//{
// if (this.CurrentLogin != null)
// {
// //记录小程序操作
// if (this.CurrentLogin.RoleType == LoginRoleType.Clerk || this.CurrentLogin.RoleType == LoginRoleType.StoreManager)
// _shopActionLogService.SetShopActionLog(this.CurrentLogin.ShopId.SafeValue(), this.CurrentLogin.ClerkId.SafeValue(), 2, 14);
// }
//}
//catch
//{ }
return result;
}
#endregion
#region SetDownLoadTimes()
/// <summary>
/// 设置下载人数
/// </summary>
/// <param name="act"></param>
[HttpPost]
[AllowAnonymous]
public void SetDownLoadTimes(IdAct act)
{
MemberLoginInfo memberLoginInfo = new MemberLoginInfo();
memberLoginInfo.UserId = Guid.Empty;
_materialWarehouseService.SetDownLoadTimes(act.Id, memberLoginInfo);
}
#endregion
#region SendAddMaterialWarehouseMesg(())
/// <summary>
/// 调度发送上传素材库通知(接收人是已开通智慧门店的店长、加盟商、加盟商子账号)
/// </summary>
[HttpGet]
[AllowAnonymous]
public void AddSendAddMaterialWarehouseMesgTask(string id)
{
_materialWarehouseService.AddSendAddMaterialWarehouseMesgTask(id);
}
#endregion
#region SendMaterialsStore
/// <summary>
/// 素材库
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public void SendMaterialsStoreTask(string id)
{
_materialWarehouseService.SendMaterialsStoreTask(id);
}
#endregion
#region GetShareCode()
/// <summary>
/// 获取素材的小程序码
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public string GetShareCode(string id,string key)
{
if (key == "062811FF-F365-4213-809D-82B1274327EA")
return _materialWarehouseService.GetShareCode(id);
else
return "";
}
#endregion
}
}