From 143ee4f0b60f77d25c77ab465603003178707f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Sun, 1 Aug 2021 16:02:43 +0000 Subject: [PATCH] =?UTF-8?q?!95=20=E5=BE=AE=E4=BF=A1=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=BD=AC=E5=8F=91=E6=A8=A1=E5=BC=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=9B=BE=E7=89=87=E5=BD=A2=E5=BC=8F=E3=80=82=20*=20?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=20*=20=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=BD=AC=E5=8F=91=E7=B1=BB=E5=9E=8B=20*=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=BB=86=E8=8A=82=20*=20=E4=BF=AE=E5=A4=8Dgithub=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=20*=201=E3=80=81=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E3=80=90MediatR=E3=80=91=E5=8F=8A=E4=B8=AD=E4=BB=8B?= =?UTF-8?q?=E8=80=85=E6=A8=A1=E5=BC=8F=EF=BC=8C=E5=90=AF=E7=94=A8=E3=80=90?= =?UTF-8?q?Redis=E9=98=9F=E5=88=97=E3=80=91=E5=A4=84=E7=90=86=E3=80=82=20*?= =?UTF-8?q?=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=BACKEditor5?= =?UTF-8?q?=20*=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*?= =?UTF-8?q?=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*=20?= =?UTF-8?q?=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91=E4=BC=98=E5=8C=96=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=AE=BE=E7=BD=AE=E6=9D=83=E9=99=90=E8=A7=92=E8=89=B2?= =?UTF-8?q?=EF=BC=8C=E5=8F=8D=E5=B0=84controller=E5=92=8Caction=E7=9A=84?= =?UTF-8?q?=E6=95=88=E7=8E=87=E9=97=AE=E9=A2=98=E3=80=82=20*=20=E3=80=90?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E3=80=91=E4=BF=AE=E5=A4=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=95=86=E5=93=81=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20*=20=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=85=BE=E8=AE=AF=E4=BA=91cos=E5=AD=98=E5=82=A8=E6=9C=AA?= =?UTF-8?q?=E8=B0=83=E7=94=A8bucket=E9=97=AE=E9=A2=98=E3=80=82#I42DF0=20*?= =?UTF-8?q?=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*=20?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E6=96=B0=E5=9F=9F=E5=90=8D=E5=8F=8A=E6=BC=94?= =?UTF-8?q?=E7=A4=BA=E5=B9=B3=E5=8F=B0=20*=20Merge=20branch=20'develop'=20?= =?UTF-8?q?into=20dahuihui/develop=20*=20Merge=20branch=20'develop'=20into?= =?UTF-8?q?=20dahuihui/develop=20*=20=E8=B0=83=E6=95=B4=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=20*=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=20*=20=E4=BF=AE=E5=A4=8D=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E8=BD=AC=E5=8F=91=E8=8E=B7=E5=8F=96ip=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E8=BF=87=E9=95=BF=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20*=201=E3=80=81=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=85=A8=E5=B1=80=E9=94=99=E8=AF=AF=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD=E3=80=822=E3=80=81=E3=80=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E3=80=91=E4=BF=AE=E5=A4=8D20?= =?UTF-8?q?=E6=97=A5=E5=88=A0=E9=99=A43=E4=B8=AA=E8=A1=A8=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E6=B8=85=E7=90=86=E5=B9=B2=E5=87=80=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82=20*=20Merge=20branch=20'develop'=20into=20da?= =?UTF-8?q?huihui/develop=20*=20Merge=20branch=20'develop'=20into=20dahuih?= =?UTF-8?q?ui/develop=20*=20=E8=B0=83=E6=95=B4=E5=85=A8=E5=B1=80=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E8=BF=94=E5=9B=9E=E6=8F=90=E7=A4=BA=E8=AF=AD=20*=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E6=89=B9=E9=87=8F=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=95=E7=A4=BA=E7=95=8C=E9=9D=A2=E3=80=82?= =?UTF-8?q?#I3X8PP=20*=20Merge=20branch=20'develop'=20into=20dahuihui/deve?= =?UTF-8?q?lop=20*=20Merge=20branch=20'develop'=20into=20dahuihui/develop?= =?UTF-8?q?=20*=20=E5=A2=9E=E5=8A=A0=E8=BF=87=E6=BB=A4=E6=95=8F=E6=84=9F?= =?UTF-8?q?=E8=AF=8D=E7=9A=84=E5=8A=9F=E8=83=BD=E3=80=82#I3W6CM=20*=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0Issue=20=E5=92=8C=20Pull=20Request=20?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=20*=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=B8=8A=E4=BC=A0=E8=B7=AF=E5=BE=84=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=87=B3=E7=AB=99=E7=82=B9=E6=A0=B9=E7=9B=AE=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E9=9D=9Ewwwroot=E7=9A=84=E9=97=AE=E9=A2=98=20#I41TD1?= =?UTF-8?q?=20*=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=B7=AF=E5=BE=84=E7=9A=84=E8=A1=A8=E5=8D=95=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=20*=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93=20*=20=E3=80=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E3=80=91=E4=BF=AE=E5=A4=8Dmysql?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93decimal=E7=B1=BB=E5=9E=8B=E6=9C=AA?= =?UTF-8?q?=E5=B8=A6=E5=B0=8F=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?#I3WAUY=20*=20=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=8F=8A=E8=84=9A=E6=9C=AC=20*=202021-07-20=20*=20Merge=20bran?= =?UTF-8?q?ch=20'develop'=20into=20dahuihui/develop=20*=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dwebapi=E4=B8=8D=E8=BF=9B=E5=85=A5=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=96=AD=E7=82=B9=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=20*=20Me?= =?UTF-8?q?rge=20branch=20'develop'=20into=20dahuihui/develop=20*=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E5=89=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E5=88=86=E7=A6=BBtable=E9=9D=A2=E6=9D=BF=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9F=9F=E5=90=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82=20*=20=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E5=88=86=E7=A6=BB=E5=9F=9F=E5=90=8D=E6=9C=AA?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=B0html=E9=97=AE=E9=A2=98=E3=80=82=20*?= =?UTF-8?q?=20Merge=20branch=20'develop'=20into=20dahuihui/develop=20*=20?= =?UTF-8?q?=E3=80=90=E5=90=8E=E7=AB=AF=E3=80=91=E4=BF=AE=E5=A4=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E5=A7=93=E5=90=8D=E9=95=BF=E5=BA=A6=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20*=20=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=85=8D=E9=80=81=E6=96=B9=E5=BC=8F=E7=BB=B4=E6=8A=A4=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98=20*=201=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=B3=A8=E5=86=8C=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E4=BA=A4=E4=BA=92=E4=BA=8B=E6=83=85?= =?UTF-8?q?=E3=80=82=E4=B8=8D=E7=84=B6=E7=9B=9B=E6=B4=BE=E7=9A=84=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=9C=89bug=EF=BC=8C=E5=9C=A8=E4=B8=8D=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E5=8F=AA?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E8=BF=9B=E8=A1=8C=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=B6=88=E6=81=AF=E6=93=8D=E4=BD=9C=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=BF=98=E6=98=AF=E8=B5=B0=E7=9A=84=E6=98=AF?= =?UTF-8?q?=E5=BE=AE=E2=80=A6=20*=20=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=8D=E6=8E=A8=E9=80=81=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20*=20Merge=20branch=20'develop'=20into=20dahuihui/de?= =?UTF-8?q?velop=20*=20Merge=20branch=20'develop'=20into=20dahuihui/develo?= =?UTF-8?q?p=20*=20=E4=BF=AE=E5=A4=8D=E8=BF=87=E6=9C=9F=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E6=96=87=E6=A1=A3=20*=20=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E4=BA=8B=E5=8A=A1=20*=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=AB=AF=E6=8F=90=E7=A4=BA=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=20*=20=E4=BF=AE=E5=A4=8D=E5=BC=B9=E7=AA=97=E4=B8=8D=E5=B1=85?= =?UTF-8?q?=E4=B8=AD=E9=97=AE=E9=A2=98=20*=20=E8=B0=83=E6=95=B4=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E5=91=BD=E5=90=8D=E6=96=B9=E5=BC=8F=20*=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Duni-app=E5=89=8D=E7=AB=AF=EF=BC=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E3=80=90=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=94=B6=E8=B4=A7=E3=80=91=E6=8C=89=E9=92=AE=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20*=201=E3=80=81=E4=BF=AE=E5=A4=8Dmysql?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=8B,=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1sql=E7=9A=84=E8=AF=AD=E6=B3=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E3=80=822=E3=80=81=E4=B8=BA=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=9C=A8=E4=B8=8D=E9=83=A8=E7=BD=B2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=8A=E5=90=8E=E7=AB=AF=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E6=B5=8B=E8=AF=95uni-app=E5=89=8D=E7=AB=AF=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=E2=80=A6=20*=20Merge=20bra?= =?UTF-8?q?nch=20'develop'=20into=20dahuihui/develop=20*=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=91=BD=E5=90=8D=20*=20=E5=A2=9E=E5=8A=A0docker-comp?= =?UTF-8?q?ose=E9=83=A8=E7=BD=B2=20*=20Merge=20branch=20'develop'=20into?= =?UTF-8?q?=20dahuihui/develop=20*=20=E4=BF=AE=E5=A4=8D=E5=9B=A0linux?= =?UTF-8?q?=E4=B8=8B=E5=AD=98=E5=9C=A8=E6=95=B0=E6=8D=AE=E4=B8=8E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=A7=B0=E5=A4=A7=E5=B0=8F=E5=86=99=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E7=89=B9=E9=87=8D=E6=96=B0=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=B8=80=E4=BB=BD=E8=A1=A8=E5=90=8D=E4=B8=8E=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=80=E4=B8=80=E5=AF=B9=E5=BA=94=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E3=80=82=20*=20=E6=96=B0mysql=E8=A1=A8=E5=90=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=A4=A7=E5=B0=8F=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageMessageEventCommandHandler.cs | 67 +++++++++++++++++++ .../VoiceMessageEventCommandHandler.cs | 67 +++++++++++++++++++ .../WeChatOAuth/WxOpenController.cs | 11 +-- README.md | 4 +- 4 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 CoreCms.Net.WeChat.Service/Mediator/ImageMessageEventCommandHandler.cs create mode 100644 CoreCms.Net.WeChat.Service/Mediator/VoiceMessageEventCommandHandler.cs diff --git a/CoreCms.Net.WeChat.Service/Mediator/ImageMessageEventCommandHandler.cs b/CoreCms.Net.WeChat.Service/Mediator/ImageMessageEventCommandHandler.cs new file mode 100644 index 0000000..a2c504b --- /dev/null +++ b/CoreCms.Net.WeChat.Service/Mediator/ImageMessageEventCommandHandler.cs @@ -0,0 +1,67 @@ +/*********************************************************************** + * Project: CoreCms.Net * + * Web: https://CoreCms.Net * + * ProjectName: 核心内容管理系统 * + * Author: 大灰灰 * + * Email: JianWeie@163.com * + * CreateTime: 2020-08-13 23:57:23 + * Description: 暂无 + ***********************************************************************/ + + +using System.Threading; +using System.Threading.Tasks; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.WeChat.Service.HttpClients; +using CoreCms.Net.WeChat.Service.Models; +using MediatR; +using SKIT.FlurlHttpClient.Wechat.Api; +using SKIT.FlurlHttpClient.Wechat.Api.Events; + +namespace CoreCms.Net.WeChat.Service.Mediator +{ + /// + /// 表示 TEXT 事件的数据 + /// + public class ImageMessageEventCommand : IRequest + { + public ImageMessageEvent EventObj { get; set; } + } + + /// + /// 处理TEXT 事件的数据-以被动回复文本消息为例 + /// + public class ImageMessageEventCommandHandler : IRequestHandler + { + private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; + + + + public ImageMessageEventCommandHandler(IWeChatApiHttpClientFactory weChatApiHttpClientFactory) + { + _weChatApiHttpClientFactory = weChatApiHttpClientFactory; + } + + public async Task Handle(ImageMessageEventCommand request, CancellationToken cancellationToken) + { + + var jm = new WeChatApiCallBack() { Status = true }; + + if (request.EventObj != null) + { + var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); + var replyModel = new SKIT.FlurlHttpClient.Wechat.Api.Events.TransferCustomerServiceReply() + { + ToUserName = request.EventObj.FromUserName, + FromUserName = request.EventObj.ToUserName, + CreateTimestamp = CommonHelper.GetTimeStampByTotalSeconds() + }; + var replyXml = client.SerializeEventToXml(replyModel); + jm.Data = replyXml; + } + + return await Task.FromResult(jm); + } + } + +} diff --git a/CoreCms.Net.WeChat.Service/Mediator/VoiceMessageEventCommandHandler.cs b/CoreCms.Net.WeChat.Service/Mediator/VoiceMessageEventCommandHandler.cs new file mode 100644 index 0000000..c0141e0 --- /dev/null +++ b/CoreCms.Net.WeChat.Service/Mediator/VoiceMessageEventCommandHandler.cs @@ -0,0 +1,67 @@ +/*********************************************************************** + * Project: CoreCms.Net * + * Web: https://CoreCms.Net * + * ProjectName: 核心内容管理系统 * + * Author: 大灰灰 * + * Email: JianWeie@163.com * + * CreateTime: 2020-08-13 23:57:23 + * Description: 暂无 + ***********************************************************************/ + + +using System.Threading; +using System.Threading.Tasks; +using CoreCms.Net.Utility.Helper; +using CoreCms.Net.WeChat.Service.HttpClients; +using CoreCms.Net.WeChat.Service.Models; +using MediatR; +using SKIT.FlurlHttpClient.Wechat.Api; +using SKIT.FlurlHttpClient.Wechat.Api.Events; + +namespace CoreCms.Net.WeChat.Service.Mediator +{ + /// + /// 表示 TEXT 事件的数据 + /// + public class VoiceMessageEventCommand : IRequest + { + public VoiceMessageEvent EventObj { get; set; } + } + + /// + /// 处理TEXT 事件的数据-以被动回复文本消息为例 + /// + public class VoiceMessageEventCommandHandler : IRequestHandler + { + private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; + + + + public VoiceMessageEventCommandHandler(IWeChatApiHttpClientFactory weChatApiHttpClientFactory) + { + _weChatApiHttpClientFactory = weChatApiHttpClientFactory; + } + + public async Task Handle(VoiceMessageEventCommand request, CancellationToken cancellationToken) + { + + var jm = new WeChatApiCallBack() { Status = true }; + + if (request.EventObj != null) + { + var client = _weChatApiHttpClientFactory.CreateWxOpenClient(); + var replyModel = new SKIT.FlurlHttpClient.Wechat.Api.Events.TransferCustomerServiceReply() + { + ToUserName = request.EventObj.FromUserName, + FromUserName = request.EventObj.ToUserName, + CreateTimestamp = CommonHelper.GetTimeStampByTotalSeconds() + }; + var replyXml = client.SerializeEventToXml(replyModel); + jm.Data = replyXml; + } + + return await Task.FromResult(jm); + } + } + +} diff --git a/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs b/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs index ae12d59..4d93cd1 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/WeChatOAuth/WxOpenController.cs @@ -165,18 +165,21 @@ namespace CoreCms.Net.Web.WebApi.Controllers.WeChatOAuth switch (requestType) { + case RequestMsgType.Text: - var callbackModel = client.DeserializeEventFromXml(msgXml); - callBack = await _mediator.Send(new TextMessageEventCommand() { EventObj = callbackModel }); + var textMessageEvent = client.DeserializeEventFromXml(msgXml); + callBack = await _mediator.Send(new TextMessageEventCommand() { EventObj = textMessageEvent }); break; case RequestMsgType.Location: break; case RequestMsgType.Image: - + var imageMessageEvent = client.DeserializeEventFromXml(msgXml); + callBack = await _mediator.Send(new ImageMessageEventCommand() { EventObj = imageMessageEvent }); break; case RequestMsgType.Voice: - + var voiceMessageEvent = client.DeserializeEventFromXml(msgXml); + callBack = await _mediator.Send(new VoiceMessageEventCommand() { EventObj = voiceMessageEvent }); break; case RequestMsgType.Video: diff --git a/README.md b/README.md index bb0e825..6d13174 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@

支持可视化布局的.Net小程序商城

[![star](https://gitee.com/CoreUnion/CoreShop/badge/star.svg)](https://gitee.com/CoreUnion/CoreShop.git) [![fork](https://gitee.com/CoreUnion/CoreShop/badge/fork.svg)](https://gitee.com/CoreUnion/CoreShop.git) -[![GitHub stars](https://img.shields.io/github/stars/CoreUnion/CoreShop?logo=github)](https://gihub.com/CoreUnion/CoreShop.git) -[![GitHub forks](https://img.shields.io/github/forks/CoreUnion/CoreShop?logo=github)](https://gihub.com/CoreUnion/CoreShop.git) +[![GitHub stars](https://img.shields.io/github/stars/CoreUnion/CoreShop?logo=github)](https://github.com/CoreUnion/CoreShop) +[![GitHub forks](https://img.shields.io/github/forks/CoreUnion/CoreShop?logo=github)](https://github.com/CoreUnion/CoreShop)