Qrcode.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\jobs\storeSync\DiyCommon;
  9. use Yii;
  10. use yii\db\ActiveRecord;
  11. use yii\behaviors\TimestampBehavior;
  12. /**
  13. * This is the model class for table "{{%qrcode}}".
  14. *
  15. * @property integer $id
  16. * @property integer $store_id
  17. * @property string $qrcode_bg
  18. * @property string $avatar_size
  19. * @property string $avatar_position
  20. * @property string $qrcode_size
  21. * @property string $qrcode_position
  22. * @property string $font_position
  23. * @property string $font
  24. * @property string $preview
  25. * @property integer $is_delete
  26. * @property integer $created_at
  27. * @property integer $updated_at
  28. * @property integer $type
  29. */
  30. class Qrcode extends \yii\db\ActiveRecord
  31. {
  32. // 分销海报
  33. const TYPE_SHARE = 0;
  34. // 门店海报
  35. const TYPE_MD = 1;
  36. // 门店海报
  37. const TYPE_MCH = 12;
  38. // 门店海报
  39. const STORE_IMG = 20;
  40. /**
  41. * @inheritdoc
  42. */
  43. public static function tableName()
  44. {
  45. return '{{%qrcode}}';
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function rules()
  51. {
  52. return [
  53. [['store_id', 'qrcode_bg', 'avatar_size', 'avatar_position', 'qrcode_size', 'qrcode_position',
  54. 'font_position', 'font', 'preview'], 'required'],
  55. [['store_id', 'is_delete', 'created_at', 'updated_at','type'], 'integer'],
  56. [['qrcode_bg', 'font', 'preview'], 'string'],
  57. [['avatar_size', 'avatar_position', 'qrcode_size', 'qrcode_position', 'font_position'], 'string', 'max' => 255],
  58. ['type', 'default', 'value'=>0]
  59. ];
  60. }
  61. public function behaviors()
  62. {
  63. return [
  64. [
  65. 'class' => TimestampBehavior::class,
  66. 'attributes' => [
  67. ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
  68. ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
  69. ]
  70. ]
  71. ];
  72. }
  73. /**
  74. * @inheritdoc
  75. */
  76. public function attributeLabels()
  77. {
  78. return [
  79. 'id' => 'ID',
  80. 'store_id' => 'Store ID',
  81. 'qrcode_bg' => '背景图片',
  82. 'avatar_size' => '头像大小{\"w\":\"\",\"h\":\"\"}',
  83. 'avatar_position' => '头像坐标{\"x\":\"\",\"y\":\"\"}',
  84. 'qrcode_size' => '二维码大小{\"w\":\"\",\"h\":\"\"}',
  85. 'qrcode_position' => '二维码坐标{\"x\":\"\",\"y\":\"\"}',
  86. 'font_position' => '字体坐标{\"x\":\"\",\"y\":\"\"}',
  87. 'font' => '字体设置
  88. {
  89. \"size\":大小,
  90. \"color\":\"r,g,b\"
  91. }',
  92. 'preview'=>'预览图',
  93. 'is_delete' => 'Is Delete',
  94. 'created_at' => 'add time',
  95. 'updated_at' => 'modify time',
  96. 'type' => '海报类型'
  97. ];
  98. }
  99. public function afterSave($insert, $changedAttributes)
  100. {
  101. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  102. if (!$insert) {
  103. if ($this->type === Qrcode::TYPE_SHARE) {
  104. (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_SHARE_CONFIG, ['share_qrcode']);
  105. }
  106. }
  107. }
  108. }