cxgj/modules/admin/models/store/BoxEditForm.php
2023-11-27 09:45:13 +08:00

119 lines
2.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @author Any
* @description KISS
* @date 2020-11-5
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\admin\models\store;
use app\components\EncryptHelper;
use app\components\Oss;
use app\models\Admin;
use app\models\auth\RoleUser;
use app\models\common\CommonUserEditForm;
use app\models\Store;
use app\models\StoreUser;
use app\models\SysAdmin;
use app\models\User;
use app\modules\admin\models\AdminModel;
use yii\data\Pagination;
class BoxEditForm extends AdminModel
{
public $model;
public $store_id;
public $status;
public $name;
public $money;
public $device;
public $cover_pic;
public $pic_urls;
public $content;
public $created_at;
public $updated_at;
public $is_delete;
public $deleted_at;
public $notice;
public $sn;
public function rules()
{
return [
[['status', 'created_at', 'updated_at', 'is_delete', 'deleted_at', 'store_id'], 'integer'],
[['model'], 'safe'],
[['name', 'pic_urls', 'content', 'notice', 'cover_pic', 'sn'], 'string'],
[['name', 'store_id', 'money', 'device', 'cover_pic'], 'required'],
];
}
public function attributeLabels()
{
return [
'name' => '包厢名称',
'notice' => '包厢公告',
'status' => '包厢状态',
'money' => '包厢金额',
'device' => '包厢设备',
'created_at' => '添加时间',
'updated_at' => '修改时间',
'is_delete' => '是否删除0=否1=是',
'deleted_at' => '删除时间',
'store_id' => '所属门店',
'cover_pic' => '封面图片'
];
}
public function edit()
{
if (!$this->validate()) {
return $this->getModelError();
}
if ($this->model->isNewRecord) {
$this->model->is_delete = 0;
$this->model->deleted_at = 0;
$this->model->created_at = time();
}
$this->model->updated_at = time();
$this->model->name = $this->name;
$this->model->store_id = $this->store_id;
$this->model->money = $this->money;
$this->model->device = json_encode($this->device);
$this->model->content = $this->content;
$oss = new Oss();
if ($this->cover_pic) {
$file = $this->cover_pic;
//上传文件目录
$this->cover_pic = $oss->upload($file);
}
$this->model->cover_pic = $this->cover_pic;
$this->model->pic_urls = $this->pic_urls;
$this->model->status = $this->status;
$this->model->sn = $this->sn;
$this->model->notice = $this->notice;
if (!$this->model->save()) {
return $this->getModelError($this->model);
}
return $this->apiReturnSuccess('保存成功');
}
}