| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace addons\Scratch\common\models;
- use addons\Coupon\common\models\AddonsCoupon;
- use addons\Scratch\common\enums\ScratchEnum;
- use common\models\base\BaseActiveRecord;
- use common\models\goods\Goods;
- use common\models\mall\MallAddons;
- use common\models\order\Order;
- /**
- * Class ScratchOrderModel
- * @package addons\Scratch\common\models
- */
- class ScratchOrderModel extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_scratch_order}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'scratch_log_id', 'order_id'], 'required'],
- [['mall_id', 'scratch_log_id', 'order_id', 'order_id', 'order_id', 'status'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'status' => '状态-1 删除 0 关闭 1开启',
- ];
- }
- /**
- * @return \yii\db\ActiveQuery
- */
- public function getOrder()
- {
- return $this->hasOne(Order::className(), ['id' => 'order_id']);
- }
- /**
- * @param $mallId
- * @param $params
- * @return ScratchOrderModel
- * @throws \Exception
- */
- public static function setData($params)
- {
- try {
- $model = new self();
- $model->mall_id = $params['mall_id'] ?? '';
- $model->scratch_log_id = $params['scratch_log_id'] ?? 0;
- $model->order_id = $params['order_id'] ?? 0;
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $exception) {
- throw new \Exception($exception->getMessage());
- }
- }
- }
|