You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Identity.php

82 lines
2.5 KiB

10 months ago
<?php
declare (strict_types=1);
namespace app\api\controller;
use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\response\Json;
class Identity extends Controller
{
/**
* @notes:会员身份价格列表
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException|BaseException
* @author: wanghousheng
*/
public function userPriceList(): Json
{
$client = $this->request->post('client');
$model = new \app\api\service\Identity();
10 months ago
$list = $model->userCenter($client);
10 months ago
return $this->renderSuccess(compact('list'));
}
/**
* @notes:分销身份价格列表
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException|BaseException
* @author: wanghousheng
*/
public function dealerPriceList(): Json
{
$client = $this->request->post('client');
$model = new \app\api\service\Identity();
10 months ago
$list = $model->dealerCenter($client);
10 months ago
return $this->renderSuccess(compact('list'));
}
10 months ago
/**
* 确认充值订单
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function submit(): Json
{
$data = $this->postForm();
$service = new \app\api\service\Identity();
$data = $service->setMethod($data['method'])
->setClient($data['client'])
10 months ago
->orderPay($data['identity_id']);
10 months ago
return $this->renderSuccess($data, $service->getMessage() ?: '下单成功');
}
/**
* 交易查询
* @param string $outTradeNo 商户订单号
* @param string $method 支付方式
* @param string $client 指定的客户端
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function tradeQuery(string $outTradeNo, string $method, string $client): Json
{
$service = new \app\api\service\Identity();
$result = $service->setMethod($method)->setClient($client)->tradeQuery($outTradeNo);
$message = $result ? '恭喜您,开通成功' : ($service->getError() ?: '很抱歉,订单未支付,请重新发起');
return $this->renderSuccess(['isPay' => $result], $message);
}
10 months ago
}