| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace backend\controllers;
- use common\pay\PayForm;
- use backend\models\Deposit;
- use Yii;
- class PayController extends BaseController
- {
- /**
- * 支付
- * @return \yii\web\Response
- */
- public function actionOutpay()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- $model->setAttributes($data);
- if ($model->outPay()) {
- $result['type'] = 'html';
- $result['html'] = $model->getOutPayResult();
- return $this->outJson(1, $result, 'OK');
- } else {
- return $this->outJson(0, [], $model->getErrors());
- }
- }
- /**
- * 异步回调
- * @return \yii\web\Response
- */
- public function actionNotify()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- if ($model->handleNotify($data)) {
- return $this->outJson(1, $model->getOutNotifyResult());
- } else {
- return $this->outJson(0, $model->getOutNotifyResult());
- }
- }
- /**
- * 同步回调
- * @return \yii\web\Response
- */
- public function actionReturn()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post();
- if ($model->handleReturn($data)) {
- return $this->outJson(1, $model->getOutReturnResult());
- } else {
- return $this->outJson(0, $model->getOutReturnResult());
- }
- }
-
-
- /**
- * 更新銀行數據庫信息
- * @return \yii\web\Response
- */
- public function actionUpdata()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post(); //获取到传递过来的数据
-
- $reuslt = Deposit::find()->where(['order_sn' => $data['order']])->asArray()->limit(1)->one();
- //如果状态不为1
- if($reuslt['type'] == 2){
- $res = Deposit::updateAll(['type' => 0,'rmb'=>$data['money'],'amount'=>$data['amount'],'rate'=>$data['rate']], "order_sn =".$data['order']); //更新为成功的状态
- if ($res) {
- return $this->outJson(1, "success");
- } else {
- return $this->outJson(0, "false");
- }
- }else{
- return $this->outJson(0, "false");
- }
-
- }
- /**
- * 获取銀行數據庫信息
- * @return \yii\web\Response
- */
- public function actionGetmoney()
- {
- $model = new PayForm();
- $data = Yii::$app->getRequest()->post(); //获取到传递过来的数据
-
- $reuslt = Deposit::find()->where(['order_sn' => $data['order']])->asArray()->limit(1)->one();
- //如果状态为2 则表示已经锁定过了
- if($reuslt['type'] == 0){
- return $this->outJson(1, $reuslt['rmb']);
- }else{
- return $this->outJson(0, "false");
- }
-
- }
-
-
-
-
-
-
-
-
-
-
-
- }
|