using DbAccess;
|
using Operater.DTO.TopMessage;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using CommonUtil;
|
using WeiXinKfSDK.Request;
|
using WeiXinKfSDK;
|
using System.Data;
|
|
namespace Api.MessageReceive.Service
|
{
|
public class MtMsgService
|
{
|
public static ISysSqlHelper dbMain = SysSqlHelper.CreateSqlHelper("db_fx");
|
public static async Task RecordPushTxt(MtReceiveTradeMsgRequest request)
|
{
|
try
|
{
|
if (request.status == "8")
|
{//订单完成 公众号提醒
|
//判断是否提醒过
|
DataTable tDt = dbMain.ExecuteDataTable($"select tid from t_takeout_push where tid='{request.orderid}' and status='8'");
|
if (!tDt.IsNull() && tDt.Rows.Count > 0 && !tDt.Rows[0]["tid"].IsNull())
|
{
|
return;
|
}
|
var token = WxKfService.GetGzhToken();
|
var obj = new { character_string4 = new { value = request.orderid }, thing5 = new { value = request.smstitle }, amount7 = new { value = request.payPrice }, thing6 = new { value = "美团" } };
|
SendTemplateMsgRequest sendReq = new SendTemplateMsgRequest()
|
{
|
template_id = "JysgGfHs9Zr_AyoazXVCEgHeGvZ2n7lRbH1xCSEFYWY",
|
touser = "oobYq6yFZhs52JIQ4zalhIJKEwy8",
|
data = obj
|
};
|
var rsp = WeiXinKfClient.SendTemplateMsg(sendReq, token);
|
}
|
|
string sql = $"replace into t_takeout_push values('{request.orderid}','{request.status}','{JSONUtil.ObjectToJson(request)}',now())";
|
dbMain.ExecuteNonQuery(sql);
|
}
|
catch (Exception e)
|
{
|
LogUtil.Info(e.ToString(), "美团入库error");
|
}
|
}
|
}
|
}
|