Commit e88ed253 authored by 黄奎's avatar 黄奎
parents 81474c84 6c900a13
......@@ -9,6 +9,7 @@ using Mall.Repository.Assess;
using Mall.Model.Extend.Assess;
using Mall.Model.Entity.Assess;
using Mall.Repository.User;
using Mall.Module.User;
namespace Mall.Module.Miai
{
......@@ -35,6 +36,10 @@ namespace Mall.Module.Miai
/// 商品
/// </summary>
private readonly RB_Assess_GoodsRepository assess_GoodsRepository = new RB_Assess_GoodsRepository();
/// <summary>
/// 消息订阅
/// </summary>
private readonly MiniProgramMsgModule appletWeChatModule = new MiniProgramMsgModule();
#region 估价分类
......@@ -306,8 +311,12 @@ namespace Mall.Module.Miai
/// <param name="goodsId"></param>
/// <param name="replyContent"></param>
/// <returns></returns>
public bool SetGoodsReply(int goodsId, string replyContent)
public bool SetGoodsReply(int goodsId, string replyContent, UserInfo userInfo)
{
var goodsModel = assess_GoodsRepository.GetEntity(goodsId);
if (goodsModel == null) {
return false;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Assess_Goods_Extend.ReplyContent), replyContent},
{ nameof(RB_Assess_Goods_Extend.ReplyDate), DateTime.Now}
......@@ -320,6 +329,17 @@ namespace Mall.Module.Miai
}
};
bool flag = assess_GoodsRepository.Update(keyValues, wheres);
if (flag) {
//获取用户信息
var umodel = member_UserRepository.GetEntity(goodsModel.UserId);
var categoryModel = assess_CategoryRepository.GetEntity(goodsModel.CategoryId);
var brandModel = assess_BrandRepository.GetEntity(goodsModel.BrandId);
string Title = categoryModel.Name + "-" + brandModel.Name;
string Remark = "您好,您的商品估价已完成、点击可查看估价详情。";
//推送订阅消息
appletWeChatModule.SendAssessSucceedMsg(userInfo.TenantId, userInfo.MallBaseId, umodel.OpenId, Title, DateTime.Now.ToString("yyyy-MM-dd HH:mm"), Remark);
}
return flag;
}
......
......@@ -1165,6 +1165,75 @@ namespace Mall.Module.User
return false;
}
/// <summary>
/// 估价成功发送订阅消息
/// </summary>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <param name="OpenId"></param>
/// <param name="Title">标题</param>
/// <param name="AssessCreate">时间</param>
/// <param name="Remark">备注</param>
/// <returns></returns>
public bool SendAssessSucceedMsg(int TenantId, int MallBaseId, string OpenId, string Title, string AssessCreate, string Remark)
{
var appletWeChatModel = programRepository.GetListRepository(new RB_MiniProgram_Extend { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault();
string token = WeiXinReidsCache.Get(appletWeChatModel.MiniAppId);
if (string.IsNullOrEmpty(token))
{
token = Mall.Common.Pay.WeChatPat.TokenHelper.GetLXYToken(token, appletWeChatModel.MiniAppId, appletWeChatModel.MiniAppSecret);
System.Threading.Tasks.Task.Run(() => WeiXinReidsCache.Set(appletWeChatModel.MiniAppId, token));
}
if (string.IsNullOrEmpty(token))
{
return false;
}
string wenXinResult = string.Empty;
if (!string.IsNullOrWhiteSpace(token))
{
string Url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token;
var postdata = new
{
touser = OpenId,
template_id = "YPwcM9zygX9Huu44tOOJoY_lA6eqbdSBAxLHSPXbHpg", // appletWeChatModel.CourseOrderTpl,
page = "pages/order/index/index",
data = new
{
thing4 = new
{
value = Title
},
time2 = new
{
value = AssessCreate
},
thing3 = new
{
value = Remark
}
},
miniprogram_state = "developer"
};
wenXinResult = HttpHelper.HttpPost(Url, JsonHelper.Serialize(postdata), "");
LogHelper.WriteInfo("估价成功发送订阅消息:" + wenXinResult);
JObject jo = (JObject)JsonConvert.DeserializeObject(wenXinResult);
int errcode = Convert.ToInt32(jo["errcode"].ToString());
if (errcode == 0)
{
//成功
return true;
}
else
{
LogHelper.WriteInfo(string.Format("SendAssessSucceedMsg:wenXinResult:{0}", wenXinResult));
}
}
return false;
}
#endregion
#region 评论违规检测
......
......@@ -106,7 +106,10 @@ namespace Mall.WebApi.Controllers.MallBase
model.IsHot,
model.BrandImgList,
model.MoreDesc,
model.RemarkDesc
model.RemarkDesc,
TempIdList = new List<string>() {
"YPwcM9zygX9Huu44tOOJoY_lA6eqbdSBAxLHSPXbHpg"
}
});
}
......
......@@ -339,7 +339,7 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.ParamIsNull("请传递回复内容");
}
bool flag = assessModule.SetGoodsReply(GoodsId, ReplyContent);
bool flag = assessModule.SetGoodsReply(GoodsId, ReplyContent, base.UserInfo);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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