zhaojs
2023-09-15 fc13938ff90213060532d99a600dea4a84456885
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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");
            }
        }
    }
}