| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_store_mini_code".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $store_id 门店id
- * @property int $type 1:推广码;2:收银台二维码
- * @property string $code 分享码
- * @property string $content 二维码参数
- * @property string|null $applet_code 小程序二维码图片地址
- * @property int $status 状态【1启用 0禁用 -1删除】
- * @property int $created_at 创建时间
- * @property int $updated_at 上次更新数据时间
- */
- class StoreMiniCode extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_mini_code}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'type', 'status', 'created_at', 'updated_at'], 'integer'],
- [['content','code', 'applet_code'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'store_id' => '门店id',
- 'type' => '1:推广码;2:收银台二维码',
- 'code' => '分享码',
- 'content' => '二维码参数',
- 'applet_code' => '小程序二维码图片地址',
- 'status' => '状态【1启用 0禁用 -1删除】',
- 'created_at' => '创建时间',
- 'updated_at' => '上次更新数据时间',
- ];
- }
- public static function setData($params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- $res = $model->save();
- if ($res == false) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- /**
- * 清除小程序二维码
- *
- * @param integer $mall_id
- * @return boolean
- */
- public static function cleanMiniCodeByMallId(int $mall_id)
- {
- return self::updateAll(
- ['applet_code' => ''],
- ['mall_id' => $mall_id]
- );
- }
- }
|