| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\Clockin\common\models;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%addons_clockin_reward_log}}".
- *
- * @property int $id
- * @property int|null $mall_id 商城ID
- * @property int|null $user_id 会员ID
- * @property int|null $apply_id 关联clockin_apply.id
- * @property float|null $reward 奖励
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class ClockinRewardLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_clockin_reward_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'apply_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['reward'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'user_id' => '会员ID',
- 'apply_id' => '关联clockin_apply.id',
- 'reward' => '奖励',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- /**
- * 添加记录
- * @Author: lun
- * @DateTime: 2023/7/26 0026 15:17
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $apply
- * @param $reward_score
- * @return bool
- * @throws Exception
- */
- public static function addLog($apply, $reward_score)
- {
- $model = new self();
- $model->mall_id = $apply['mall_id'];
- $model->user_id = $apply['user_id'];
- $model->apply_id = $apply['id'];
- $model->reward = $reward_score;
- if (!$model->save()) throw new Exception($model->getErrorMessage());
- return true;
- }
- }
|