| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- use yii\helpers\ArrayHelper;
- /**
- * This is the model class for table "{{%user_string_code_area}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property integer $child_id
- * @property integer $row
- * @property integer $col
- * @property string $area_key
- * @property integer $created_at
- * @property integer $updated_at
- */
- class UserStringCodeArea extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%user_string_code_area}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
- ]
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['store_id', 'user_id', 'child_id', 'row', 'col', 'area_key', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => '店铺id',
- 'user_id' => '用户id',
- 'child_id' => '下级id',
- 'row' => '行',
- 'col' => '列',
- 'area_key' => '区域 key',
- 'created_at' => '创建时间',
- ];
- }
- public static function createUserStringCodeArea($store_id, $user_id, $parent_id, $row, $col, $area_key)
- {
- $model = new self();
- $model->store_id = $store_id;
- $model->user_id = $parent_id;
- $model->child_id = $user_id;
- $model->row = $row;
- $model->col = $col;
- $model->area_key = $area_key;
- $model->save();
- $all_parent_node_ids = UserStringCode::getAllParentNodeIds($user_id);
- // 增加所有上级对应的位置
- foreach ($all_parent_node_ids as $parent_node_id) {
- // if ($parent_node_id == $to_user_id) return;
- }
- }
- }
|