203 lines
5.5 KiB
PHP
203 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace app\modules\api\controllers;
|
|
|
|
use app\components\SiteHelper;
|
|
use app\components\TongLianPay;
|
|
use app\modules\api\models\SigningForm;
|
|
use app\modules\api\behaviors\LoginBehavior;
|
|
|
|
|
|
class SigningController extends Controller
|
|
{
|
|
public $enableCsrfValidation = false;
|
|
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
'ignore' => [
|
|
'api/signing/signing-pay-notify',
|
|
'api/signing/signing',
|
|
// 'api/signing/signing-detail',
|
|
]
|
|
]
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 业务类型
|
|
* @description 本接口用于签约订单
|
|
* @method get
|
|
* @url /api/signing/signing-type
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
public function actionSigningType()
|
|
{
|
|
$type = SiteHelper::getCustomiseOptionByKey("siteSigningType", "hump");
|
|
|
|
return $this->responseHandler(['data' => explode('|', $type)]);
|
|
}
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 签约协议
|
|
* @description 本接口用于签约订单
|
|
* @method get
|
|
* @url /api/signing/signing
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
public function actionSigning()
|
|
{
|
|
$type = SiteHelper::getCustomiseOptionByKey("siteSigning", "hump");
|
|
|
|
return $this->responseHandler(['data' => $type]);
|
|
}
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 签约
|
|
* @description 本接口用于签约订单
|
|
* @method post
|
|
* @url /api/signing/signing-add
|
|
* @param goods_hub_id 必选 int 签约商品id
|
|
* @param company_name 必选 string 公司名称
|
|
* @param brand_name 必选 string 品牌名称
|
|
* @param product 必选 string 主营产品
|
|
* @param type 必选 int 业务类型
|
|
* @param number 必选 int 签约年限
|
|
* @param remark 必选 int 备注
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
public function actionSigningAdd()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$signingForm = new SigningForm();
|
|
|
|
$signingForm->attributes = \Yii::$app->request->post();
|
|
$signingForm->user_id = \Yii::$app->user->identity->id;
|
|
|
|
return $this->responseHandler($signingForm->add());
|
|
|
|
}
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 签约详情
|
|
* @description 本接口用于签约订单
|
|
* @method get
|
|
* @url /api/signing/signing-detail
|
|
* @param order_no 必选 int 订单号
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
|
|
public function actionSigningDetail()
|
|
{
|
|
$orderNo = \Yii::$app->request->get('order_no');
|
|
|
|
$signingForm = new SigningForm();
|
|
$signingForm->user_id = \Yii::$app->user->identity->id;
|
|
return $this->responseHandler($signingForm->orderDetail($orderNo));
|
|
}
|
|
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 签约详情
|
|
* @description 本接口用于签约订单
|
|
* @method get
|
|
* @url /api/signing/signing-cancel
|
|
* @param order_no 必选 int 订单号
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
|
|
public function actionSigningCancel()
|
|
{
|
|
$order_id = \Yii::$app->request->get('order_id');
|
|
$signingForm = new SigningForm();
|
|
$signingForm->order_id = $order_id;
|
|
return $this->responseHandler($signingForm->status_no());
|
|
}
|
|
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 签约列表
|
|
* @description 本接口用于签约订单
|
|
* @method get
|
|
* @url /api/signing/signing-list
|
|
* @param status 可选 int 订单状态
|
|
* @return {"code":0,"msg":"ok","data":[]}
|
|
* @remark
|
|
*/
|
|
public function actionSigningList()
|
|
{
|
|
$signingForm = new SigningForm();
|
|
$signingForm->user_id = \Yii::$app->user->identity->id;
|
|
|
|
$status = \Yii::$app->request->get('status', null);
|
|
$limit = \Yii::$app->request->get('limit', 10);
|
|
$page = \Yii::$app->request->get('page', 1);
|
|
|
|
return $this->responseHandler($signingForm->orderList($status, $limit, $page));
|
|
}
|
|
|
|
/**
|
|
* showdoc
|
|
* @catalog 签约订单
|
|
* @title 支付
|
|
* @description 本接口用于签约订单支付
|
|
* @method post
|
|
* @url /api/signing/signing-pay
|
|
* @param order_no 必填 string 订单号
|
|
* @param front_url 必填 string 支付成功回调地址
|
|
* @return {"code":0,"msg":"ok","data":[]}javascript:;
|
|
* @remark
|
|
*/
|
|
public function actionSigningPay()
|
|
{
|
|
if (!\Yii::$app->request->isPost) {
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
$tongLianPayForm = new TongLianPay();
|
|
|
|
return $this->responseHandler($tongLianPayForm->pay(
|
|
\Yii::$app->request->post('order_no'),
|
|
\Yii::$app->request->post('front_url'),
|
|
\Yii::$app->user->identity->id)
|
|
);
|
|
|
|
}
|
|
|
|
|
|
public function actionSigningPayNotify()
|
|
{
|
|
$tongLianPayForm = new TongLianPay();
|
|
|
|
$data = \Yii::$app->request->post();
|
|
|
|
file_put_contents('test.text', json_encode($data));
|
|
|
|
return $tongLianPayForm->notify($data) ? 'success' : 'error';
|
|
}
|
|
|
|
|
|
} |