| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace addons\Mch\client\controllers;
- use addons\Mch\common\models\MchRefundAddress;
- use common\enums\StatusEnum;
- use Yii;
- /**
- *
- * @Author bing
- * @DateTime 2021-08-16 13:12:44
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- class RefundAddressController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * @Author bing
- * @DateTime 2021-08-20 14:49:55
- * @copyright: Copyright (c) 2020 广东七件事集团
- * @return void
- */
- public function actionIndex(){
- if (Yii::$app->request->isAjax) {
- $params = [
- 'where'=>[
- ['mall_id'=>$this->mall_id],
- ['mch_id'=>$this->mch_id],
- ['status'=>[StatusEnum::ENABLED,StatusEnum::DISABLED]],
- ],
- 'order'=>'id desc'
- ];
- $list = MchRefundAddress::listPage($params);
- if($list === false) return $this->error(MchRefundAddress::getStaticError());
- return $this->success('ok',$list);
- }
- return $this->render($this->action->id);
- }
- public function actionEdit()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isGet) {
- $id = Yii::$app->request->get('id', '');
- $data = MchRefundAddress::getOne([['id'=>$id],['mall_id'=>$this->mall_id],['mch_id'=>$this->mch_id]],true);
- return $this->success('操作成功', ['data'=>$data]);
- }
- try {
- if ($request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['refund_name', 'name','mobile','address'], 'required'],
- [['id'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['mch_id'] = $this->mch_id;
- $res = MchRefundAddress::setData($params);
- if ($res === false) return $this->error(MchRefundAddress::getStaticError());
- return $this->success('操作成功');
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage(), []);
- }
- }
- }
- /**
- * 删除
- * @param null $keyword
- * @param int $is_recycle
- * @return mixed|void
- */
- public function actionDel()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isGet) {
- $params = Yii::$app->request->get();
- $params['status'] = StatusEnum::DELETE;
- $params['mall_id'] = $this->mall_id;
- $params['mch_id'] = $this->mch_id;
- $res = MchRefundAddress::setData($params);
- if ($res === false) return $this->error(MchRefundAddress::getStaticError());
- return $this->success('操作成功');
- }
- }
- }
- }
|