| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <?php
- namespace common\models\mall;
- use common\enums\StatusEnum;
- use common\enums\WhetherEnum;
- use Yii;
- use yii\helpers\Json;
- /**
- * This is the model class for table "{{%poster}}".
- *
- *
- * @property int $mall_id 商城id
- * @property string $name 名称
- * @property string|null $key_word 关键词
- * @property int|null $look_num 浏览次数
- * @property int $scan_code_num 扫码次数
- * @property string $poster_content 海报内容
- * @property int $status 状态【1启用 0禁用 -1删除】
- * @property string|null $share_url 分享图片
- * @property int $created_at
- * @property int $updated_at
- */
- class Poster extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%poster}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'name', 'poster_content'], 'required'],
- [['mall_id', 'look_num', 'scan_code_num', 'status', 'created_at', 'updated_at','sort'], 'integer'],
- [['poster_content'], 'string'],
- [['name', 'key_word'], 'string', 'max' => 10],
- [['share_url'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'name' => '名称',
- 'key_word' => '关键词',
- 'look_num' => '浏览次数',
- 'scan_code_num' => '扫码次数',
- 'poster_content' => '海报内容',
- 'sort' => '海报排序',
- 'status' => '状态【1启用 0禁用 -1删除】',
- 'share_url' => '分享图片',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * 保存数据
- * @Author lun
- * @DateTime 2021-09-16 14:16:24
- * @copyright: Copyright (c) 2020 广东七件事集团
- * @param array $params
- * @return object|boolean
- */
- public static function setData($mall_id, array $params){
- try{
- if(!empty($params['id'])){
- $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status',StatusEnum::DELETE]]);
- if(empty($model)) throw new \Exception('海报不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- }
- // 将内容转为json字符串
- $params['poster_content'] = Json::encode($params['poster_content']);
- if(!$model->load($params,'') || !$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- /**
- * 海报默认参数
- * @return array[]
- */
- public static function getDefaultPoster()
- {
- $urlPrefix = \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl .
- '/resources/img/mall/poster/';
- return [
- 'share' => [
- 'bg_pic' => [
- 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png',
- 'is_show' => '1',
- ],
- 'head' => [
- 'is_show' => '1',
- 'size' => 60 * 2,
- 'top' => 10 * 2,
- 'left' => 10 * 2,
- 'file_type' => 'image',
- ],
- 'qr_code' => [
- 'is_show' => '1',
- 'size' => 120 * 2,
- 'top' => 150 * 2,
- 'left' => 127 * 2,
- 'type' => '1',
- 'file_type' => 'image',
- ],
- 'name' => [
- 'is_show' => '1',
- 'font' => 20,
- 'top' => 30 * 2,
- 'left' => 80 * 2,
- 'color' => '#000',
- 'file_type' => 'text',
- ],
- ],
- 'goods' => [
- 'bg_pic' => [
- 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png',
- 'is_show' => '1',
- ],
- 'pic' => [
- 'url' => $urlPrefix . 'default_goods.jpg',
- 'is_show' => '1',
- 'width' => 375 * 2,
- 'height' => 375 * 2,
- 'top' => 0,
- 'left' => 0,
- 'file_type' => 'image',
- ],
- 'head' => [
- 'is_show' => '1',
- 'size' => 30 * 2,
- 'top' => 550 * 2,
- 'left' => 20 * 2,
- 'file_type' => 'image',
- ],
- 'nickname' => [
- 'is_show' => '1',
- 'font' => 18,
- 'top' => 557 * 2,
- 'left' => 59 * 2,
- 'color' => '#000',
- 'file_type' => 'text',
- ],
- 'name' => [
- 'is_show' => '1',
- 'font' => 20,
- 'top' => 390 * 2,
- 'left' => 20 * 2,
- 'color' => '#000',
- 'file_type' => 'text',
- ],
- 'price' => [
- 'is_show' => '1',
- 'font' => 20,
- 'top' => 420 * 2,
- 'left' => 20 * 2,
- 'color' => 'rgb(255, 69, 68)',
- 'file_type' => 'text',
- ],
- 'qr_code' => [
- 'is_show' => '1',
- 'size' => 120 * 2,
- 'top' => 515 * 2,
- 'left' => 230 * 2,
- 'type' => '1',
- 'file_type' => 'image',
- ],
- 'desc' => [
- 'is_show' => '1',
- 'width' => 200 * 2,
- 'font' => 16,
- 'top' => 595,
- 'left' => 20 * 2,
- 'color' => 'rgb(169, 169, 169)',
- 'text' => '长按识别小程序码进入',
- 'file_type' => 'text',
- ],
- ],
- 'topic' => [
- 'bg_pic' => [
- 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/mall/poster_bg.png',
- 'is_show' => '1',
- ],
- 'pic' => [
- 'url' => $urlPrefix . 'default_goods.jpg',
- 'is_show' => '1',
- 'width' => 335 * 2,
- 'height' => 167 * 2,
- 'top' => 90 * 2,
- 'left' => 20 * 2,
- 'file_type' => 'image',
- ],
- 'title' => [
- 'is_show' => '1',
- 'font' => 26,
- 'top' => 40 * 2,
- 'left' => 20 * 2,
- 'color' => '#000',
- 'file_type' => 'text',
- ],
- 'look' => [
- 'is_show' => '1',
- 'font' => 16,
- 'top' => 280 * 2,
- 'left' => 20 * 2,
- 'color' => '#999',
- 'file_type' => 'text',
- ],
- 'content' => [
- 'is_show' => '1',
- 'font' => 18,
- 'top' => 320 * 2,
- 'left' => 20 * 2,
- 'color' => '#666666',
- 'file_type' => 'text',
- ],
- 'open_desc' => [
- 'is_show' => '1',
- 'font' => 20,
- 'top' => 410 * 2,
- 'left' => 85 * 2,
- 'color' => '#D68543',
- 'text' => '打开小程序阅读全文',
- 'file_type' => 'text',
- ],
- 'desc' => [
- 'is_show' => '1',
- 'width' => 205 * 2,
- 'font' => 18,
- 'top' => 550 * 2,
- 'left' => 20 * 2,
- 'color' => '#000',
- 'text' => '长按识别小程序码进入',
- 'file_type' => 'text',
- ],
- 'qr_code' => [
- 'is_show' => '1',
- 'size' => 114 * 2,
- 'top' => 510 * 2,
- 'left' => 234 * 2,
- 'type' => '1',
- 'file_type' => 'image',
- ],
- 'line' => [
- 'is_show' => '1',
- 'width' => 335 * 2,
- 'height' => 1,
- 'top' => 480 * 2,
- 'left' => 20 * 2,
- 'color' => '#e2e2e2',
- 'file_type' => 'line',
- ]
- ],
- 'footprint' => [
- 'bg_pic' => [
- 'url' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/resources/img/app/footprint/footprint_poster_bg.png',
- 'is_show' => '1',
- ],
- 'qr_code' => [
- 'is_show' => '1',
- 'size' => 160 * 2,
- 'top' => 1140 * 2,
- 'left' => 540 * 2,
- 'type' => '1',
- 'file_type' => 'image',
- ],
- 'text_one' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 380 * 2,
- 'left' => 124 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '1',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- 'text_1' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 380 * 2,
- 'left' => 148 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '.您在本店共购买',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_2' => [
- 'is_show' => '1',
- 'font' => 36,
- 'top' => 443 * 2,
- 'left' => 124 * 2,
- 'color' => '#FF4544',
- 'file_type' => 'text',
- 'text' => '590',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- 'text_3' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 455 * 2,
- 'left' => 295 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '件商品',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_two' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 535 * 2,
- 'left' => 124 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '2',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- 'text_4' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 535 * 2,
- 'left' => 148 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '.您在本店共消费',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_5' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 600 * 2,
- 'left' => 124 * 2,
- 'color' => '#FF4544',
- 'file_type' => 'text',
- 'text' => '¥',
- // 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_6' => [
- 'is_show' => '1',
- 'font' => 36,
- 'top' => 588 * 2,
- 'left' => 157 * 2,
- 'color' => '#FF4544',
- 'file_type' => 'text',
- 'text' => '888888',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- 'text_three' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 677 * 2,
- 'left' => 124 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '3',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- 'text_7' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 677 * 2,
- 'left' => 148 * 2,
- 'color' => '#252525',
- 'file_type' => 'text',
- 'text' => '.您在本店最高一次消费达',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_8' => [
- 'is_show' => '1',
- 'font' => 24,
- 'top' => 742 * 2,
- 'left' => 124 * 2,
- 'color' => '#FF4544',
- 'file_type' => 'text',
- 'text' => '¥',
- // 'font_path' => \Yii::$app->basePath . '/web/resources/font/hanyicuyuanti.ttf',
- ],
- 'text_9' => [
- 'is_show' => '1',
- 'font' => 36,
- 'top' => 730 * 2,
- 'left' => 157 * 2,
- 'color' => '#FF4544',
- 'file_type' => 'text',
- 'text' => '168888',
- 'font_path' => \Yii::$app->basePath . '/web/resources/font/DIN-Medium.otf',
- ],
- ],
- ];
- }
- /**
- * 修改状态
- *
- * @return boolean
- */
- public function changeStatus()
- {
- $this->status = (int)!$this->status;
- return $this->save();
- }
- }
|