Beispiel #1
0
        public async Task <BaseApiResponse> AddShopCashTransfer([FromBody] AddShopCashTransferRequest request)
        {
            request.CheckNotNull(nameof(request));

            var command = new CreateShopCashTransferCommand(
                GuidUtil.NewSequentialId(),
                request.Id,
                DateTime.Now.ToSerialNumber(),
                ShopCashTransferType.SystemOp,
                ShopCashTransferStatus.Placed,
                request.Amount,
                0,
                request.Direction,
                request.Remark);
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Beispiel #2
0
        public async Task <BaseApiResponse> AddShopCashTransfer(AddShopCashTransferRequest request)
        {
            request.CheckNotNull(nameof(request));
            var wallet = _walletQueryService.Info(request.Id);

            if (wallet == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有找到钱包"
                });
            }
            var command = new CreateShopCashTransferCommand(
                GuidUtil.NewSequentialId(),
                request.Id,
                DateTime.Now.ToSerialNumber(),
                ShopCashTransferType.SystemOp,
                ShopCashTransferStatus.Placed,
                request.Amount,
                0,
                request.Direction,
                request.Remark);
            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(), "调整钱包购物券", wallet.Id, "钱包{0},{1} {2}".FormatWith(wallet.OwnerMobile, request.Direction.ToDescription(), request.Amount));

            return(new BaseApiResponse());
        }
Beispiel #3
0
        public async Task <BaseApiResponse> WalletPay(WalletPayRequest request)
        {
            request.CheckNotNull(nameof(request));
            var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current);
            var walletinfo     = _walletQueryService.Info(currentAccount.WalletId.ToGuid());

            if (request.CashPayAmount == 0 && request.ShopCashPayAmount == 0)
            {
                return(new BaseApiResponse {
                    Code = 401, Message = "付款金额为零"
                });
            }
            if (walletinfo.IsFreeze == Freeze.Freeze)
            {
                return(new BaseApiResponse {
                    Code = 402, Message = "钱包冻结,请用其他方式支付"
                });
            }
            if (walletinfo.Cash < request.CashPayAmount || walletinfo.ShopCash < request.ShopCashPayAmount)
            {
                return(new BaseApiResponse {
                    Code = 403, Message = "错误,余额不足"
                });
            }
            if (!request.IsNotVerifyAccessCode)
            {
                //验证支付密码
                if (!walletinfo.AccessCode.Equals(request.AccessCode))
                {
                    return(new BaseApiResponse {
                        Code = 404, Message = "支付密码错误"
                    });
                }
            }

            string number = DateTime.Now.ToSerialNumber();

            var cashTransferType     = CashTransferType.Shopping;
            var shopCashTransferType = ShopCashTransferType.Shopping;

            if (request.Type == "Transfer")
            {
                cashTransferType = CashTransferType.Transfer;
            }
            if (request.Type == "Recharge")
            {
                cashTransferType = CashTransferType.Charge;
            }

            //余额付款
            if (request.CashPayAmount > 0)
            {
                var command = new CreateCashTransferCommand(
                    GuidUtil.NewSequentialId(),
                    walletinfo.Id,
                    number,                    //流水号
                    cashTransferType,
                    CashTransferStatus.Placed, //这里只是提交,只有钱包接受改记录后,才更新为成功
                    request.CashPayAmount,
                    0,
                    WalletDirection.Out,
                    request.Remark);

                var result = await ExecuteCommandAsync(command);

                if (!result.IsSuccess())
                {
                    return(new BaseApiResponse {
                        Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                    });
                }
            }
            //购物券付款
            if (request.ShopCashPayAmount > 0)
            {
                var command = new CreateShopCashTransferCommand(
                    GuidUtil.NewSequentialId(),
                    walletinfo.Id,
                    number,                        //流水号
                    shopCashTransferType,
                    ShopCashTransferStatus.Placed, //这里只是提交,只有钱包接受改记录后,才更新为成功
                    request.ShopCashPayAmount,
                    0,
                    WalletDirection.Out,
                    request.Remark);

                var result = await ExecuteCommandAsync(command);

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

            return(new BaseApiResponse());
        }