4], [['month', 'date'], 'string', 'max' => 2], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'order_id' => '订单ID', 'activity_id' => '活动ID', 'share_user_id' => '分享者用户ID', 'mall_id' => '商城ID', 'buyer_id' => '下单者', 'money' => '订单实际支付金额', 'activity_type' => '类型【1 个人PK 2战队PK】', 'year' => '年', 'month' => '月', 'date' => '日', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'buyer_id'])->select('id,mobile,nickname,avatar_url,parent_id,username'); } /** * 保存数据 * @Author: ltm * @DateTime: 2022/6/8 0015 9:26 * @Copyright: copyright (c) 2021 * @param $mall_id * @param array $params * @return Rebate|bool */ public static function setData(array $params){ try{ $mall_id = $params['mall_id']; if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status', StatusEnum::ENABLED]]); if(empty($model)) throw new \Exception('活动不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } if(!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::setStaticError($e->getMessage()); return false; } } }