ScratchSettingModel.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace addons\Scratch\common\models;
  3. use addons\Coupon\common\models\AddonsCoupon;
  4. use addons\Scratch\common\enums\ScratchEnum;
  5. use common\models\base\BaseActiveRecord;
  6. use common\models\goods\Goods;
  7. use common\models\mall\MallAddons;
  8. use common\models\user\User;
  9. /**
  10. * Class ScratchSettingModel
  11. * @package addons\Scratch\common\models
  12. */
  13. class ScratchSettingModel extends BaseActiveRecord
  14. {
  15. /** @var int 抽奖规则1每人每天一次 2每人一次*/
  16. const TYPE_DAY = 1;
  17. const TYPE_USER = 2;
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%addons_scratch_setting}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['mall_id', 'type', 'start_at', 'end_at', 'rule', 'payment_type', 'send_type'], 'required'],
  32. [['mall_id', 'type', 'probability', 'oppty', 'deplete_integral_num', 'is_sms', 'is_mail', 'is_print','is_wechat'], 'integer'],
  33. [['start_at', 'end_at', 'created_at', 'updated_at'], 'safe'],
  34. [['rule', 'payment_type', 'send_type','background_imgs'], 'string'],
  35. [['title'], 'string', 'max' => 255],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'mall_id' => 'Mall ID',
  46. 'title' => '小程序标题',
  47. 'type' => '1.天 2 用户',
  48. 'probability' => '概率',
  49. 'oppty' => '抽奖次数',
  50. 'start_at' => '开始时间',
  51. 'end_at' => '结束时间',
  52. 'deplete_integral_num' => '消耗积分',
  53. 'rule' => '规则',
  54. 'background_imgs' => '背景图',
  55. 'created_at' => 'Created At',
  56. 'updated_at' => 'Updated At',
  57. 'payment_type' => '支付方式',
  58. 'send_type' => '发货方式',
  59. 'is_sms' => '开启短信提醒',
  60. 'is_wechat' => '开启微信推送提醒',
  61. 'is_mail' => '开启邮件提醒',
  62. 'is_print' => '开启打印',
  63. ];
  64. }
  65. /**
  66. * 背景图默认配置
  67. * @throws \Exception
  68. */
  69. public static function getBackgroundImgs()
  70. {
  71. try {
  72. $background_imgs = [
  73. 'color' => '',
  74. 'image'=> \Yii::$app->request->hostInfo . '/resources/addons/scratch/img/index-bg.png'
  75. ];
  76. return $background_imgs;
  77. } catch (\Exception $exception) {
  78. throw new \Exception($exception->getMessage());
  79. }
  80. }
  81. }