LuckyGroupBonusPool.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace addons\LuckyGroup\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. use yii\db\Exception;
  6. /**
  7. * This is the model class for table "qimall_addons_lucky_group_bonus_pool".
  8. *
  9. * @property int $id
  10. * @property float $money 奖金池剩余金额
  11. * @property float $total_money 奖金池总额
  12. * @property float $virtual_send_money 虚拟发放金额
  13. * @property int $mall_id 商城ID
  14. * @property int $status 状态[-1:删除;0:禁用;1启用]
  15. * @property int|null $created_at
  16. * @property int|null $updated_at
  17. */
  18. class LuckyGroupBonusPool extends BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addons_lucky_group_bonus_pool}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['money', 'total_money', 'virtual_send_money'], 'number'],
  34. [['mall_id'], 'required'],
  35. [['mall_id', 'status', 'created_at', 'updated_at'], 'integer'],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'money' => '奖金池剩余金额',
  46. 'total_money' => '奖金池总额',
  47. 'virtual_send_money' => '虚拟发放金额',
  48. 'mall_id' => '商城ID',
  49. 'status' => '状态[-1:删除;0:禁用;1启用]',
  50. 'created_at' => 'Created At',
  51. 'updated_at' => 'Updated At',
  52. ];
  53. }
  54. public static function setData($bonus_pool, $mall_id, $money)
  55. {
  56. if (!isset($bonus_pool)) {
  57. $bonus_pool = new LuckyGroupBonusPool();
  58. $bonus_pool->mall_id = $mall_id;
  59. $bonus_pool->loadDefaultValues();
  60. }
  61. $bonus_pool->money += $money;
  62. $bonus_pool->total_money += $money;
  63. $res = $bonus_pool->save();
  64. if ($res == false) throw new Exception('加入奖金池失败');
  65. return true;
  66. }
  67. }