| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_store_cate".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $store_id 门店id
- * @property int $province_id 省id
- * @property int $city_id 市id
- * @property int $district_id 区id
- * @property int $street_id 街道id
- * @property string $community_name 社区名称
- * @property int $sort 排序
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class StoreCommunity extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_community}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'province_id', 'city_id', 'district_id', 'street_id', 'created_at', 'updated_at','status'], 'integer'],
- [['community_name'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'province_id' => '省级ID',
- 'city_id' => '市级ID',
- 'district_id' => '区级ID',
- 'street_id' => '街道ID',
- 'community_name' => '社区名称',
- 'status' => '是否删除',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- /**
- * @desc:保存数据
- * @Author: hua
- * @Date: 2024/08/21
- * @Time: 18:07
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $params
- * @return StoreClerk|false|null
- */
- public static function setData(array $params)
- {
- try {
- if (!empty($params['mall_id']) && !empty($params['user_id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'],'province_id' => $params['province_id'], 'city_id'=>$params['city_id'],'district_id' => $params['district_id'], 'street_id' => $params['street_id'],'community_name'=>$params['community_name'],'status' => 0]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- }
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|