Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task <APIResult <CodeResultJson> > ReleaseAsync([FromBody] ShopIdArgsModel args)
        {
            if (!args.ShopId.HasValue)
            {
                throw new ArgumentNullException("ShopId");
            }
            CheckShopActor(args.ShopId.Value, ShopActorType.超级管理员);

            var authorizerAccessToken = GetAuthorizerAccessToken(args.ShopId.Value);
            var result = await CodeApi.ReleaseAsync(authorizerAccessToken.authorizer_access_token);


            //如果请求成功,则将请求的结果写入到数据库中
            if (result.errcode == Senparc.Weixin.ReturnCode.请求成功)
            {
                var authorizer = db.Query <ShopWechatOpenAuthorizer>()
                                 .Where(m => !m.IsDel)
                                 .Where(m => m.ShopId == args.ShopId.Value)
                                 .FirstOrDefault();

                authorizer.IsRelease = true;
                await db.SaveChangesAsync();

                //这里尝试添加二唯码规则
                try
                {
                    CodeApiExt.QRCodeJumpAddPublish(args.ShopId.Value, authorizerAccessToken.authorizer_access_token, hostingEnvironment);
                }
                catch (Exception)
                {
                }
            }
            return(Success(result));
        }
Ejemplo n.º 2
0
        public override IResponseMessageBase OnEvent_WeAppAuditSuccessRequest(RequestMessageEvent_WeAppAuditSuccess requestMessage)
        {
            var shopAuthorizer =
                db.Query <ShopWechatOpenAuthorizer>()
                .Where(m => !m.IsDel)
                .Where(m => m.WechatOpenAuthorizer.AuthorizerUsername == requestMessage.ToUserName)
                .FirstOrDefault();

            if (shopAuthorizer != null)
            {
                //logger.LogInformation("OnEvent_WeAppAuditSuccessRequest:{0}", Newtonsoft.Json.JsonConvert.SerializeObject(requestMessage));
                shopAuthorizer.CurrentAuditStatus = 0;//审核状态,其中0为审核成功,1为审核失败,2为审核中

                #region 审核成功后自动发布
                var authorizerAccessToken = GetAuthorizerAccessToken(shopAuthorizer.ShopId);
                var result = CodeApi.ReleaseAsync(authorizerAccessToken);
                result.Wait();
                //如果请求成功,则将请求的结果写入到数据库中
                if (result.Result.errcode == Senparc.Weixin.ReturnCode.请求成功)
                {
                    var authorizer = db.Query <ShopWechatOpenAuthorizer>()
                                     .Where(m => !m.IsDel)
                                     .Where(m => m.ShopId == shopAuthorizer.ShopId)
                                     .FirstOrDefault();
                    authorizer.IsRelease = true;
                    logger.LogInformation("自动发布成功,信息:{0}", result.Result.errmsg);
                }
                else
                {
                    logger.LogInformation("自动发布失败,信息:{0}", result.Result.errmsg);
                }
                #endregion
                db.SaveChanges();
            }

            return(base.OnEvent_WeAppAuditSuccessRequest(requestMessage));
        }