
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using XYY.Core.Standard.Mvc;
using XYY.Service.Standard.Finance.Charging.CustomerAccount;
using XYY.Service.Standard.Finance.Charging.Express;

namespace XYY.Api.Finance.Charges.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PaymentController : ApiControllerBase
    {
        ICustomerAccountService _accountService;

        public PaymentController(ICustomerAccountService accountService)
        {
            _accountService = accountService;
        }

        public async Task<IActionResult> Payment(PaymentModel model)
        {
            if (model.TransactionTime.Kind == DateTimeKind.Utc)
                model.TransactionTime = model.TransactionTime.ToLocalTime();

            var result = await _accountService.Payment(model);
            return Ok(result.error ?? result.message);
        }
    }
}
