| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- namespace addons\Happiness\common\models;
- use common\enums\StatusEnum;
- use common\models\user\User;
- use Yii;
- /**
- * This is the model class for table "{{%addons_weight_bonus_pool_order_log}}".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $user_id 用户ID
- * @property float $amount 进入奖金池金额
- * @property float $before_amount 变动前金额
- * @property float $after_amount 变动后金额
- * @property float $price 订单金额(销售价)
- * @property float $pay_price 订单实付金额
- * @property int $order_id 订单ID
- * @property string $order_no 订单编号
- * @property int $status 状态[-1删除;0禁用;1正常]
- * @property string $date 日期
- * @property int $settlement_status 结算状态[0未结算;1已结算]
- * @property string $desc 备注
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class HappinessWeightPoolOrderLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_happiness_weight_pool_order_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'order_id', 'status', 'settlement_status', 'created_at', 'updated_at'], 'integer'],
- [['amount','before_amount','after_amount','price','pay_price'], 'number'],
- [['order_no'], 'string', 'max' => 100],
- [['desc'], 'string', 'max' => 100],
- [['date'], 'string', 'max' => 15],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'user_id' => '用户ID',
- 'amount' => '进入奖金池金额',
- 'price' => '订单金额(销售价)',
- 'pay_price' => '订单实付金额',
- 'before_amount' => '变动前金额',
- 'after_amount' => '变动后金额',
- 'order_id' => '订单ID',
- 'order_no' => '订单编号',
- 'status' => '状态[-1删除;0禁用;1正常]',
- 'date' => '日期',
- 'settlement_status' => '结算状态[0未结算;1已结算]',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- /**
- * @Description: 保存数据
- * @Author: zfh
- * @DateTime 2024-5-5 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']);
- }
- public static function addData($data)
- {
- try {
- $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;
- }
- }
- }
|