| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: your name
- * @Date: 2021-05-08 17:30:13
- * @LastEditTime: 2021-05-08 17:30:21
- * @LastEditors: your name
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\client\models\v1\admin\MchSettingForm.php
- */
- namespace app\modules\client\models\v1\admin;
- use app\models\Mch;
- use app\models\MchCommonCat;
- class MchSettingForm extends \yii\base\Model
- {
- public $mch_id;
- public $model;
- public $is_share;
- /**
- * @return array
- */
- public function rules()
- {
- return [
- [['mch_id'], 'required'],
- [['mch_id', 'is_share'], 'integer'],
- [['is_share'], 'default', 'value'=>0]
- ];
- }
- /**
- * 保存分类
- * @return array
- */
- public function save()
- {
- if (!$this->validate()) {
- return [
- 'code' => 1,
- 'msg' => $this->getErrorSummary(false)[0]
- ];
- }
- $this->model->store_id = get_store_id();
- $this->model->mch_id = $this->mch_id;
- $this->model->attributes = $this->attributes;
- if ($this->model->save()) {
- return [
- 'code' => 0,
- 'msg' => '提交成功'
- ];
- } else {
- return [
- 'code' => 0,
- 'msg' => '保存失败'
- ];
- }
- }
- public static function getList()
- {
- $query = Mch::find()->where([
- 'is_delete' => 0,
- 'store_id' => get_store_id()
- ])->with(['user', 'setting']);
- $query->andWhere([
- 'review_status' => get_params('review_status',1)
- ]);
- $query->select(['*'])->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC]);
- $pagination = pagination_make($query);
- $pagination['data'] = $pagination['list'];
- unset($pagination['list']);
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => $pagination,
- 'common_cat' => MchCommonCat::find()->where([
- 'store_id' => get_store_id(),
- 'is_delete' => 0
- ])->select(['id', 'name'])->orderBy(['sort' => SORT_ASC, 'id' => SORT_DESC])->all()
- ];
- }
- }
|