| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\modules\admin\controllers;
- use app\models\IntegralRecharge;
- use app\modules\admin\models\IntegralRechargeForm;
- use app\modules\admin\models\IntegralReOrderForm;
- use app\modules\admin\models\q_and_a\IntegralRechargeListForm;
- class IntegralRechargeController extends BaseController
- {
- public function actionList()
- {
- $form = new IntegralRechargeListForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- return $this->asJson($form->search());
- }
- public function actionInfo($id = null)
- {
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'model' => IntegralRecharge::findOne($id)
- ]
- ]);
- }
- public function actionEdit()
- {
- $id = post_params('id');
- $model = IntegralRecharge::findOne(['id' => $id, 'is_delete' => 0, 'store_id' => get_store_id()]);
- if (!$model) {
- $model = new IntegralRecharge();
- }
- if (\Yii::$app->request->isPost) {
- $form = new IntegralRechargeForm();
- $form->model = $model;
- $form->store_id = get_store_id();
- $form->attributes = post_params();
- return $this->asJson($form->save());
- }
- }
- public function actionState($id = null, $state = 1)
- {
- $id = json_decode($id, true);
- foreach ($id as $v) {
- $model = IntegralRecharge::findOne($v);
- if (!$model) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '请刷新重试'
- ]);
- }
- $model->state = $state;
- $model->save();
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '成功'
- ]);
- }
- public function actionDel($id = null)
- {
- $model = IntegralRecharge::findOne(['id' => $id, 'is_delete' => 0, 'store_id' => get_store_id()]);
- if (!$model) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '请刷新重试'
- ]);
- }
- $model->is_delete = 1;
- if ($model->save()) {
- return $this->asJson([
- 'code' => 0,
- 'msg' => '成功'
- ]);
- } else {
- foreach ($model->errors as $errors) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $errors[0],
- ]);
- }
- }
- }
- public function actionIntegralRechargeOrder()
- {
- $param = get_params();
- $form = new IntegralReOrderForm();
- $form->attributes = $param;
- $form->store_id = get_store_id();
- return $this->asJson($form->search());
- }
- }
|