100], [['date'], 'string', 'max' => 8], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'user_id' => '用户ID', 'amount' => '进入奖金池金额', 'order_id' => '订单ID', 'order_no' => '订单编号', 'status' => '状态[-1删除;0禁用;1正常]', 'date' => '日期', 'settlement_status' => '结算状态[0未结算;1已结算]', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } /** * @Description: 保存数据 * @Author: zsan * @DateTime 2023-10-12 09:32:36 * @param array $data * @return bool|self */ public static function setData(array $data) { try { $model = self::findOne(['order_id' => $data['order_id'], 'mall_id' => $data['mall_id'], 'date' => $data['date'], 'status' => StatusEnum::ENABLED]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($data, '') || !$model->save()) { throw new \Exception($model->getErrorMessage()); } return $model; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } }