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

142 lines
4.3 KiB

11 months ago
<?php
declare (strict_types=1);
namespace app\api\controller;
11 months ago
use app\api\model\user\IdentityOrder;
use app\common\enum\user\IdentityEnum;
11 months ago
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');
11 months ago
if (!$client) {
return $this->renderError('客户端不能为空');
}
11 months ago
$model = new \app\api\service\Identity();
11 months ago
$list = $model->userCenter($client);
11 months ago
return $this->renderSuccess(compact('list'));
}
11 months ago
/**
* @notes:会员开卡记录
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function userOpenCardLog(): Json
{
$model = new IdentityOrder();
$list = $model->cardList(['order_type' => IdentityEnum::MEMBER]);
return $this->renderSuccess($list);
}
/**
* @notes:分销商开卡记录
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function dealerOpenCardLog(): Json
{
$model = new IdentityOrder();
$list = $model->cardList(['order_type' => IdentityEnum::DEALER]);
return $this->renderSuccess($list);
}
11 months ago
/**
* @notes:分销身份价格列表
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException|BaseException
* @author: wanghousheng
*/
public function dealerPriceList(): Json
{
$client = $this->request->post('client');
11 months ago
if (!$client) {
return $this->renderError('客户端不能为空');
}
11 months ago
$model = new \app\api\service\Identity();
11 months ago
$list = $model->dealerCenter($client);
11 months ago
return $this->renderSuccess(compact('list'));
}
11 months ago
/**
* 确认充值订单
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function submit(): Json
{
11 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('缺少必要参数');
}
11 months ago
$service = new \app\api\service\Identity();
11 months ago
$data = $service->setMethod($method)
->setClient($client)
->orderPay($identityId);
11 months ago
return $this->renderSuccess($data, $service->getMessage() ?: '下单成功');
}
/**
11 months ago
* 查询第三方支付订单是否付款成功
11 months ago
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
11 months ago
public function tradeQuery(): Json
11 months ago
{
11 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('客户端不能为空');
}
11 months ago
$service = new \app\api\service\Identity();
11 months ago
$result = $service->setMethod($method)->setClient($client)->tradeQuery($order_no);
11 months ago
$message = $result ? '恭喜您,开通成功' : ($service->getError() ?: '很抱歉,订单未支付,请重新发起');
return $this->renderSuccess(['isPay' => $result], $message);
}
11 months ago
}