| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace addons\Alitopay\backend\controllers;
- use addons\Alitopay\backend\controllers\BaseController;
- use addons\Alitopay\common\models\Apply;
- use addons\Alitopay\common\services\ApplyService;
- use app\models\MallSetting;
- use app\plugins\ali_to_pay\forms\mall\AlitopayForm;
- use app\plugins\ali_to_pay\models\AliTopay;
- use app\plugins\Controller;
- use app\services\ReturnData;
- use http\Url;
- use Yii;
- class ApplyController extends BaseController
- {
- public $enableCsrfValidation = false;
- public $service;
- public function __construct ($id, $module, $config = [])
- {
- parent::__construct($id, $module, $config);
- $this->service = new ApplyService();
- }
- public function actionIndex(){
- if(!Yii::$app->request->isAjax){
- return $this->render('index');
- }
- $data = $this->service->getApply($this->mall_id);
- return $this->success('ok',$data);
- }
- /**
- * 编辑审核
- * @desc
- * @return mixed|void
- * @throws \yii\db\Exception
- */
- public function actionEdit(){
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- if($id > 0){
- $post['status'] = 1;
- $post['reason'] = '';
- $model = Apply::findOne($id);
- }else{
- $model = new Apply();
- }
- if($model->isNewRecord){
- $post['deal_sn'] = date('YmdHis').rand(1000,9999);
- }
- $post['mall_id'] = $this->mall_id;
- $db = Yii::$app->db->beginTransaction();
- if( !($model->load($post,'') && $model->validate() && $model->save()) ){
- return $this->error($model->getFirstErrors());
- }
- $service = new ApplyService();
- $result = $service->apply($this->mall_id,$model);
- if($result){
- $db->commit();
- return $this->success('提交成功,请等待审核');
- }else{
- $db->rollBack();
- return $this->error($service->error);
- }
- }
- }
|