| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace addons\BlindBox\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_blind_box_bonus_log".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $user_id 会员id
- * @property int $type 类型:1:消费订单;2:直推消费;3:推荐新人
- * @property int is_feedback 类型:1:消费订单;2:直推消费;3:推荐新人
- * @property string $order_no 订单编号
- * @property int $total_times 总分红次数
- * @property int $divided_times 已分次数
- * @property float $divided_money 已分金额
- * @property float $contribution 贡献值
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class BlindBoxBonusLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_blind_box_bonus_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id','type', 'total_times', 'divided_times', 'status','is_feedback', 'created_at', 'updated_at'], 'integer'],
- [['divided_money', 'contribution'], 'number'],
- [['order_no'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'user_id' => '会员id',
- 'type' => '类型:1:消费订单;2:直推消费;3:推荐新人',
- 'order_no' => '订单编号',
- 'total_times' => '总分红次数',
- 'divided_times' => '已分次数',
- 'divided_money' => '已分金额',
- 'contribution' => '贡献值',
- 'is_feedback' => '是否退款:0:否:1:是',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function addData(array $params)
- {
- try {
- $model = self::findOne([
- 'mall_id' => $params['mall_id'],
- 'user_id' => $params['user_id'],
- 'order_no' => $params['order_no'],
- 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- $res = $model->save();
- if ($res == false) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|