Coupon.php 2.4 KB
<?php

namespace Lackoxygen\TiktokOpen\Wap\Life;

use Lackoxygen\TiktokOpen\Base\ServiceManager;
use Lackoxygen\TiktokOpen\Base\Signer\LifeSigner;

class Coupon extends ServiceManager
{
    /**
     * 验券准备
     *
     * @param string $encryptedData
     * @param string $code
     *
     * @return mixed
     */
    public function prepare(string $encryptedData = '', string $code = '')
    {
        return $this->app['client']
            ->asForm()
            ->withSession()
            ->signVia(new LifeSigner())
            ->post('/goodlife/v1/fulfilment/certificate/prepare/',
                ['encrypted_data' => $encryptedData, 'code' => $code]);
    }

    /**
     * 验券
     *
     * @param array $body
     *
     * @return mixed
     */
    public function verify(array $body = [])
    {
        return $this->app['client']
            ->asForm()
            ->withSession()
            ->signVia(new LifeSigner())
            ->post('/goodlife/v1/fulfilment/certificate/verify/', $body);
    }

    /**
     * 撤销核销
     *
     * @link https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/life-service-open-ability/life.capacity/life.capacity.fulfilment/certificate.verify
     *
     * @param array $body
     *
     * @return mixed
     */
    public function cancel(array $body = [])
    {
        return $this->app['client']
            ->asForm()
            ->withSession()
            ->signVia(new LifeSigner())
            ->post('/goodlife/v1/fulfilment/certificate/cancel/', $body);
    }

    /**
     * 券状态查询
     *
     * @param string $encryptedCode
     *
     * @return mixed
     */
    public function get(string $encryptedCode)
    {
        return $this->app['client']
            ->asForm()
            ->withSession()
            ->signVia(new LifeSigner())
            ->get('/goodlife/v1/fulfilment/certificate/get/', ['encrypted_code' => $encryptedCode]);
    }

    /**
     * 券状态批量查询
     *
     * @param string $encryptedCode
     * @param string $orderId
     *
     * @return mixed
     */
    public function query(string $encryptedCode = '', string $orderId = '')
    {
        return $this->app['client']
            ->asForm()
            ->withSession()
            ->signVia(new LifeSigner())
            ->get('/goodlife/v1/fulfilment/certificate/query/',
                ['encrypted_code' => $encryptedCode, 'order_id' => $orderId]);
    }
}