| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace addons\Happiness\common\models;
- use addons\Happiness\common\enums\HappinessPvEnum;
- use common\models\base\BaseActiveRecord;
- /**
- * This is the model class for table "{{%addons_happiness_pv_order}}".
- *
- * @property int $id
- * @property float $score 获得积分
- * @property int $mall_id 商城ID
- * @property int $order_id 订单ID
- * @property string $order_no 订单号
- * @property float $free_num 已释放数量
- * @property int $wait_num 剩余释放数量
- * @property int $user_id 用户ID
- * @property int $updated_at
- * @property int $created_at
- * @property int $status 状态:0 禁用 1启用
- * @property int $is_settled 是否已结算
- * @property int $is_update 是否调整过
- * @property string $updated_log 调整记录
- */
- class HappinessPvOrder extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_happiness_pv_order}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['score', 'mall_id','user_id', 'order_id'], 'required'],
- [['score'], 'number'],
- [['mall_id', 'order_id', 'user_id', 'updated_at', 'created_at', 'status', 'is_settled', 'settled_time'], 'integer'],
- [['goods_price'], 'safe'],
- [['order_no'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'score' => 'Score',
- 'mall_id' => 'Mall ID',
- 'order_id' => 'Order ID',
- 'order_no' => 'Order No',
- 'user_id' => 'User ID',
- 'updated_at' => 'Updated At',
- 'created_at' => 'Created At',
- 'status' => 'Status',
- 'is_settled' => 'Is Settled',
- 'goods_price' => '商品金额',
- 'settled_time' => 'settled_time',
- ];
- }
- public static function setData($params)
- {
- try {
- $model = self::findOne(['order_id' => $params['order_id'], 'mall_id' => $params['mall_id']]);
- if (!$model) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- /**
- * 获取可结算的订单列表
- */
- public static function settledList($where,$select, $order, $isArray = true)
- {
- return self::find()->select($select)->where($where)->orderBy($order)->asArray($isArray)->all();
- }
-
- }
|