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

108 lines
3.4 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');
10 months ago
if (!$client) {
return $this->renderError('客户端不能为空');
}
10 months ago
$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');
10 months ago
if (!$client) {
return $this->renderError('客户端不能为空');
}
10 months ago
$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
{
10 months ago
$method = $this->request->post('method');
if (!$method) {
return $this->renderError('支付方式不能为空');
}
$client = $this->request->post('client');
if (!$client) {
return $this->renderError('客户端不能为空');
}
$identityId = intval($this->request->post('identity_id'));
if (!$identityId) {
return $this->renderError('缺少必要参数');
}
10 months ago
$service = new \app\api\service\Identity();
10 months ago
$data = $service->setMethod($method)
->setClient($client)
->orderPay($identityId);
10 months ago
return $this->renderSuccess($data, $service->getMessage() ?: '下单成功');
}
/**
10 months ago
* 查询第三方支付订单是否付款成功
10 months ago
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
10 months ago
public function tradeQuery(): Json
10 months ago
{
10 months ago
$method = $this->request->post('method');
if (!$method) {
return $this->renderError('支付方式不能为空');
}
$order_no = $this->request->post('order_no');
if (!$order_no) {
return $this->renderError('订单号不能为空');
}
$client = $this->request->post('client');
if (!$client) {
return $this->renderError('客户端不能为空');
}
10 months ago
$service = new \app\api\service\Identity();
10 months ago
$result = $service->setMethod($method)->setClient($client)->tradeQuery($order_no);
10 months ago
$message = $result ? '恭喜您,开通成功' : ($service->getError() ?: '很抱歉,订单未支付,请重新发起');
return $this->renderSuccess(['isPay' => $result], $message);
}
10 months ago
}