Exemplo n.º 1
0
        public async Task <BaseApiResponse> Edit([FromBody] EditThirdCurrencyRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var thirdCurrency = _thirdCurrencyQueryService.Find(request.Id);

            if (thirdCurrency == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该外币"
                });
            }

            var command = new UpdateThirdCurrencyCommand(
                request.Name,
                request.Icon,
                request.CompanyName,
                request.Conversion,
                request.IsLocked,
                request.Remark
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Exemplo n.º 2
0
        public async Task <BaseApiResponse> Edit(EditThirdCurrencyRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var thirdCurrency = _thirdCurrencyQueryService.Find(request.Id);

            if (thirdCurrency == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该外币"
                });
            }

            var command = new UpdateThirdCurrencyCommand(
                request.Name,
                request.Icon,
                request.CompanyName,
                request.Conversion,
                request.IsLocked,
                request.Remark
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "编辑外币", request.Id, request.Name);
            return(new BaseApiResponse());
        }
Exemplo n.º 3
0
        public async Task <BaseApiResponse> ImportCurrency(ImportCurrencyRequest request)
        {
            request.CheckNotNull(nameof(request));
            var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current);
            var userInfo       = _userQueryService.FindUser(currentAccount.UserId.ToGuid());

            var thirdCurrency = _thirdCurrencyQueryService.Find(request.Id);

            if (thirdCurrency == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有找到该外币"
                });
            }
            if (thirdCurrency.IsLocked)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "外币锁定,无法导入"
                });
            }
            //这里要访问第三方系统账号
            return(new BaseApiResponse {
                Code = 400, Message = "接口未开放,暂时无法导入"
            });

            //外币导入
            var command = new AcceptNewImportCommand(
                userInfo.WalletId,
                userInfo.Id,
                userInfo.Mobile,
                request.Account,
                request.Amount
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }