LuckyGroupLotteryPeriod.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace addons\LuckyGroup\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use common\models\user\User;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_lucky_group_lottery_period".
  8. *
  9. * @property int $id
  10. * @property int $mall_id 商城ID
  11. * @property int $open_reward_log_id 开团日志id
  12. * @property int $activity_id 活动D
  13. * @property int $goods_id 商品ID
  14. * @property int $user_id 会员ID
  15. * @property int $order_id 订单id
  16. * @property int $number 期数
  17. * @property string|null $win_order_ids 拼中订单集
  18. * @property string|null $loss_order_ids 拼不中订单集
  19. * @property int $status 状态[-1:删除;0:禁用;1启用]
  20. * @property int $created_at
  21. * @property int $updated_at 更新时间
  22. */
  23. class LuckyGroupLotteryPeriod extends BaseActiveRecord
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return '{{%addons_lucky_group_lottery_period}}';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['mall_id','open_reward_log_id', 'activity_id', 'goods_id', 'user_id', 'order_id', 'number', 'status', 'created_at', 'updated_at'], 'integer'],
  39. [['win_order_ids', 'loss_order_ids'], 'string', 'max' => 1000],
  40. ];
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function attributeLabels()
  46. {
  47. return [
  48. 'id' => 'ID',
  49. 'mall_id' => '商城ID',
  50. 'open_reward_log_id' => '开团日志id',
  51. 'activity_id' => '活动D',
  52. 'goods_id' => '商品ID',
  53. 'user_id' => '会员ID',
  54. 'order_id' => '订单id',
  55. 'number' => '期数',
  56. 'win_order_ids' => '拼中订单集',
  57. 'loss_order_ids' => '拼不中订单集',
  58. 'status' => '状态[-1:删除;0:禁用;1启用]',
  59. 'created_at' => 'Created At',
  60. 'updated_at' => '更新时间',
  61. ];
  62. }
  63. public function getUser()
  64. {
  65. return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,avatar_url');
  66. }
  67. public static function setData($params)
  68. {
  69. $field = ['mall_id','open_reward_log_id', 'activity_id','goods_id','user_id','order_id','number','win_order_ids','loss_order_ids','status','created_at','updated_at'];
  70. // 批量插入数据
  71. Yii::$app->db->createCommand()->batchInsert(self::tableName(), $field, $params)->execute();
  72. }
  73. }