PromoterQrcode.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 $back_size
  22. * @property string $qrcode_position
  23. * @property string $font_position
  24. * @property string $font
  25. * @property string $preview
  26. * @property integer $is_delete
  27. * @property integer $created_at
  28. * @property integer $updated_at
  29. * @property integer $type
  30. */
  31. class PromoterQrcode extends \yii\db\ActiveRecord
  32. {
  33. // 分销海报
  34. const TYPE_SHARE = 0;
  35. // 门店海报
  36. const TYPE_MD = 1;
  37. // 门店海报
  38. const TYPE_MCH = 12;
  39. // 门店海报
  40. const STORE_IMG = 20;
  41. /**
  42. * @inheritdoc
  43. */
  44. public static function tableName()
  45. {
  46. return '{{%promoter_qrcode}}';
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function rules()
  52. {
  53. return [
  54. [['store_id', 'qrcode_bg', 'avatar_size', 'avatar_position', 'qrcode_size', 'qrcode_position',
  55. 'font_position', 'font', 'preview'], 'required'],
  56. [['store_id', 'is_delete', 'created_at', 'updated_at','type'], 'integer'],
  57. [['qrcode_bg', 'font', 'preview'], 'string'],
  58. [['avatar_size', 'avatar_position', 'qrcode_size', 'qrcode_position', 'font_position','back_size'], 'string', 'max' => 255],
  59. ['type', 'default', 'value'=>0]
  60. ];
  61. }
  62. public function behaviors()
  63. {
  64. return [
  65. [
  66. 'class' => TimestampBehavior::class,
  67. 'attributes' => [
  68. ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
  69. ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
  70. ]
  71. ]
  72. ];
  73. }
  74. /**
  75. * @inheritdoc
  76. */
  77. public function attributeLabels()
  78. {
  79. return [
  80. 'id' => 'ID',
  81. 'store_id' => 'Store ID',
  82. 'qrcode_bg' => '背景图片',
  83. 'avatar_size' => '头像大小{\"w\":\"\",\"h\":\"\"}',
  84. 'avatar_position' => '头像坐标{\"x\":\"\",\"y\":\"\"}',
  85. 'qrcode_size' => '二维码大小{\"w\":\"\",\"h\":\"\"}',
  86. 'qrcode_position' => '二维码坐标{\"x\":\"\",\"y\":\"\"}',
  87. 'font_position' => '字体坐标{\"x\":\"\",\"y\":\"\"}',
  88. 'font' => '字体设置
  89. {
  90. \"size\":大小,
  91. \"color\":\"r,g,b\"
  92. }',
  93. 'preview'=>'预览图',
  94. 'is_delete' => 'Is Delete',
  95. 'created_at' => 'add time',
  96. 'updated_at' => 'modify time',
  97. 'type' => '海报类型'
  98. ];
  99. }
  100. public function afterSave($insert, $changedAttributes)
  101. {
  102. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  103. if (!$insert) {
  104. if ($this->type === PromoterQrcode::TYPE_SHARE) {
  105. (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_SHARE_CONFIG, ['share_qrcode']);
  106. }
  107. }
  108. }
  109. }