Ejemplo n.º 1
0
        /// <summary>
        /// 提交审核
        /// </summary>
        /// <param name="authorizerAccessToken"></param>
        /// <param name="item"></param>
        /// <param name="tempInfo"></param>
        public APIResult SubmitVersion(string authorizerAccessToken, ShopWechatOpenAuthorizer item, TemplateInfo tempInfo)
        {
            //先上传代码
            string extJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(new { ext = new { shopFlag = item.Shop.Flag } });
            var    commitResult  = CodeApi.Commit(authorizerAccessToken, tempInfo.template_id, extJsonString, tempInfo.user_version, tempInfo.user_desc);

            //如果请求成功,则将请求的参数写入到数据库进行保存
            if (commitResult.errcode != Senparc.Weixin.ReturnCode.请求成功)
            {
                return(Error("上传代码失败," + commitResult.errmsg));
            }

            //提交审核
            List <SubmitAuditPageInfo> list = new List <SubmitAuditPageInfo>();
            CategroyInfo category           = AuthorizerHelper.GetCategory(authorizerAccessToken);

            list.Add(new SubmitAuditPageInfo()
            {
                first_id     = category.first_id,
                second_id    = category.second_id,
                first_class  = category.first_class,
                second_class = category.second_class,
                third_class  = category.third_class,
                third_id     = category.third_id,
                title        = "点餐",
                tag          = category.first_class,
                address      = "pages/home/home"
            });
            try
            {
                var submitAuditResult = CodeApi.SubmitAudit(authorizerAccessToken, list);

                if (submitAuditResult.errcode != ReturnCode.请求成功)
                {
                    return(Error("提交审核失败," + submitAuditResult.errmsg));
                }
                item.CurrentTemplateExtJson     = extJsonString;
                item.CurrentAuditId             = int.Parse(submitAuditResult.auditid);
                item.CurrentAuditStatus         = 2; //审核状态,其中0为审核成功,1为审核失败,2为审核中
                item.ReleaseTemplateUserVersion = tempInfo.user_version;
                item.IsRelease = false;              //将发布状态设置为未发布
                db.SaveChanges();

                if (item.CurrentAuditStatus == 0) //审核通过则马上发布
                {
                    ReleaseVersion(authorizerAccessToken, item, tempInfo);
                }
            }
            catch (Exception ex)
            {
                return(Error("提交审核失败," + ex.Message));
            }

            return(Success());
        }