Ejemplo n.º 1
0
        public APIResult InitQRCodeJump([FromBody] InitQRCodeJumpArgsModel args)
        {
            if (!args.ShopId.HasValue)
            {
                throw new ArgumentNullException("ShopId");
            }
            CheckShopActor(args.ShopId.Value, ShopActorType.超级管理员);

            var authorizerAccessToken = GetAuthorizerAccessToken(args.ShopId.Value);

            var host = _options.Host.Trim('/');
            var url  = $"{host}/qrcodeJump/{args.ShopId}/shopPart/";


            var getResult = CodeApiExt.QRCodeJumpGet(authorizerAccessToken);

            //说明没有对应的规则
            if (getResult.rule_list.Where(m => m.prefix == url).Count() <= 0)
            {
                //先下载验证文件
                var prefix   = new Uri(url);
                var fileInfo = CodeApiExt.QRCodeJumpDownload(authorizerAccessToken);

                var filePath = hostingEnvironment.MapWebPath(Path.Combine(prefix.PathAndQuery, fileInfo.file_name));
                Common.FileUtils.CreateDirectory(filePath);
                //System.IO.File.Create(filePath);
                System.IO.File.WriteAllText(filePath, fileInfo.file_content);

                if (args.DebugUrl == null)
                {
                    args.DebugUrl = new List <string>();
                }
                if (args.DebugUrl.Count <= 0)
                {
                    args.DebugUrl.Add($"{url}abcde");
                }

                if (string.IsNullOrEmpty(args.OpenVersion))
                {
                    args.OpenVersion = "2";
                }
                if (string.IsNullOrEmpty(args.Path))
                {
                    args.Path = "pages/order/home";
                }

                var permitSubRule = "1";

                var result = CodeApiExt.QRCodeJumpAdd(authorizerAccessToken, url, permitSubRule, args.Path, args.OpenVersion, args.DebugUrl.ToArray(), false);
                return(Success(result));
            }
            return(Success());
        }
Ejemplo n.º 2
0
        public APIResult QRCodeJumpAdd([FromBody] QRCodeJumpAddArgsModel args)
        {
            if (string.IsNullOrEmpty(args.Path))
            {
                throw new ArgumentNullException("Path");
            }
            if (!args.ShopId.HasValue)
            {
                throw new ArgumentNullException("ShopId");
            }
            CheckShopActor(args.ShopId.Value, ShopActorType.超级管理员);

            var authorizerAccessToken = GetAuthorizerAccessToken(args.ShopId.Value);

            //先下载验证文件
            var prefix = new Uri(args.Prefix);



            var fileInfo = CodeApiExt.QRCodeJumpDownload(authorizerAccessToken.authorizer_access_token);

            var filePath = hostingEnvironment.MapWebPath(Path.Combine(prefix.PathAndQuery, fileInfo.file_name));

            Common.FileUtils.CreateDirectory(filePath);
            //System.IO.File.Create(filePath);
            System.IO.File.WriteAllText(filePath, fileInfo.file_content);

            if (args.DebugUrl == null)
            {
                args.DebugUrl = new List <string>();
            }
            if (string.IsNullOrEmpty(args.PermitSubRule))
            {
                args.PermitSubRule = "1";
            }

            var result = CodeApiExt.QRCodeJumpAdd(authorizerAccessToken.authorizer_access_token, args.Prefix, args.PermitSubRule, args.Path, args.OpenVersion, args.DebugUrl.ToArray(), args.IsEdit);

            return(Success(result));
        }