rm -rf amount in db
This commit is contained in:
1 parent
45378559ca
commit
87e4b33322
11 files changed
+48
-35
No files matched your search
@@ -72,20 +72,16 @@ func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int6
|
||||
|
||||
func (r *repository) Quote(ctx context.Context, orderID int64) (visamasterpay.PaymentQuoteDTO, error) {
|
||||
var orderType *string
|
||||
var amountUsd *float64
|
||||
var paid bool
|
||||
err := r.client.QueryRow(ctx,
|
||||
`SELECT type, amount_usd, paid FROM visa_master_payment_orders WHERE id = $1 AND deleted_at IS NULL`, orderID,
|
||||
).Scan(&orderType, &amountUsd, &paid)
|
||||
`SELECT type, paid FROM visa_master_payment_orders WHERE id = $1 AND deleted_at IS NULL`, orderID,
|
||||
).Scan(&orderType, &paid)
|
||||
if err != nil {
|
||||
return visamasterpay.PaymentQuoteDTO{}, err
|
||||
}
|
||||
if paid {
|
||||
return visamasterpay.PaymentQuoteDTO{}, visamasterpay.ErrAlreadyPaid
|
||||
}
|
||||
if amountUsd == nil {
|
||||
return visamasterpay.PaymentQuoteDTO{}, visamasterpay.ErrAmountNotSet
|
||||
}
|
||||
|
||||
usdRate, err := r.fetchRate(ctx, "USD")
|
||||
if err != nil {
|
||||
@@ -100,7 +96,7 @@ func (r *repository) Quote(ctx context.Context, orderID int64) (visamasterpay.Pa
|
||||
quote := visamasterpay.PaymentQuoteDTO{
|
||||
Type: derefOrEmpty(orderType),
|
||||
ExchangeRateUsd: usdRate,
|
||||
MaxAmountTmt: round2(*amountUsd * usdRate),
|
||||
MaxAmountTmt: round2(settings.MaxAmountUsd * usdRate),
|
||||
PayableToday: isPayableDay(time.Now()),
|
||||
}
|
||||
|
||||
@@ -132,14 +128,13 @@ func (r *repository) Quote(ctx context.Context, orderID int64) (visamasterpay.Pa
|
||||
// passes back except to look up our own row.
|
||||
func (r *repository) Pay(ctx context.Context, orderID int64, dto visamasterpay.PayOrderDTO) (visamasterpay.PaymentInitResultDTO, error) {
|
||||
var orderType *string
|
||||
var amountUsd *float64
|
||||
var paid bool
|
||||
var branchID int64
|
||||
var userID int64
|
||||
err := r.client.QueryRow(ctx,
|
||||
`SELECT type, amount_usd, paid, branch_id, user_id FROM visa_master_payment_orders WHERE id = $1 AND deleted_at IS NULL`,
|
||||
`SELECT type, paid, branch_id, user_id FROM visa_master_payment_orders WHERE id = $1 AND deleted_at IS NULL`,
|
||||
orderID,
|
||||
).Scan(&orderType, &amountUsd, &paid, &branchID, &userID)
|
||||
).Scan(&orderType, &paid, &branchID, &userID)
|
||||
if err != nil {
|
||||
return visamasterpay.PaymentInitResultDTO{}, err
|
||||
}
|
||||
@@ -151,10 +146,6 @@ func (r *repository) Pay(ctx context.Context, orderID int64, dto visamasterpay.P
|
||||
r.logStep(ctx, orderID, dto.CreatedBy, "rejected", map[string]string{"reason": "already_paid"})
|
||||
return visamasterpay.PaymentInitResultDTO{}, visamasterpay.ErrAlreadyPaid
|
||||
}
|
||||
if amountUsd == nil {
|
||||
r.logStep(ctx, orderID, dto.CreatedBy, "rejected", map[string]string{"reason": "amount_not_set"})
|
||||
return visamasterpay.PaymentInitResultDTO{}, visamasterpay.ErrAmountNotSet
|
||||
}
|
||||
|
||||
usdRate, err := r.fetchRate(ctx, "USD")
|
||||
if err != nil {
|
||||
@@ -166,7 +157,7 @@ func (r *repository) Pay(ctx context.Context, orderID int64, dto visamasterpay.P
|
||||
return visamasterpay.PaymentInitResultDTO{}, err
|
||||
}
|
||||
|
||||
maxAmountTmt := round2(*amountUsd * usdRate)
|
||||
maxAmountTmt := round2(settings.MaxAmountUsd * usdRate)
|
||||
amountTmt := maxAmountTmt
|
||||
if dto.AmountTmt != nil {
|
||||
if *dto.AmountTmt <= 0 || *dto.AmountTmt > maxAmountTmt {
|
||||
@@ -179,7 +170,7 @@ func (r *repository) Pay(ctx context.Context, orderID int64, dto visamasterpay.P
|
||||
}
|
||||
|
||||
r.logStep(ctx, orderID, dto.CreatedBy, "validated", map[string]interface{}{
|
||||
"orderType": derefOrEmpty(orderType), "amountUsd": *amountUsd, "amountTmt": amountTmt, "exchangeRateUsd": usdRate,
|
||||
"orderType": derefOrEmpty(orderType), "maxAmountUsd": settings.MaxAmountUsd, "amountTmt": amountTmt, "exchangeRateUsd": usdRate,
|
||||
})
|
||||
|
||||
sber := isSber(orderType)
|
||||
|
||||
Reference in new issue
Block a user