UserStringCodeArea.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. use yii\helpers\ArrayHelper;
  12. /**
  13. * This is the model class for table "{{%user_string_code_area}}".
  14. *
  15. * @property integer $id
  16. * @property integer $store_id
  17. * @property integer $user_id
  18. * @property integer $child_id
  19. * @property integer $row
  20. * @property integer $col
  21. * @property string $area_key
  22. * @property integer $created_at
  23. * @property integer $updated_at
  24. */
  25. class UserStringCodeArea extends \yii\db\ActiveRecord
  26. {
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return '{{%user_string_code_area}}';
  33. }
  34. public function behaviors()
  35. {
  36. return [
  37. [
  38. 'class' => TimestampBehavior::class,
  39. 'attributes' => [
  40. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  41. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  42. ]
  43. ]
  44. ];
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function rules()
  50. {
  51. return [
  52. [['store_id', 'user_id', 'child_id', 'row', 'col', 'area_key', 'created_at', 'updated_at'], 'integer'],
  53. ];
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public function attributeLabels()
  59. {
  60. return [
  61. 'id' => 'ID',
  62. 'store_id' => '店铺id',
  63. 'user_id' => '用户id',
  64. 'child_id' => '下级id',
  65. 'row' => '行',
  66. 'col' => '列',
  67. 'area_key' => '区域 key',
  68. 'created_at' => '创建时间',
  69. ];
  70. }
  71. public static function createUserStringCodeArea($store_id, $user_id, $parent_id, $row, $col, $area_key)
  72. {
  73. $model = new self();
  74. $model->store_id = $store_id;
  75. $model->user_id = $parent_id;
  76. $model->child_id = $user_id;
  77. $model->row = $row;
  78. $model->col = $col;
  79. $model->area_key = $area_key;
  80. $model->save();
  81. $all_parent_node_ids = UserStringCode::getAllParentNodeIds($user_id);
  82. // 增加所有上级对应的位置
  83. foreach ($all_parent_node_ids as $parent_node_id) {
  84. // if ($parent_node_id == $to_user_id) return;
  85. }
  86. }
  87. }