| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\CloudStock\common\models;
- use common\models\base\BaseActiveRecord;
- use PHPUnit\Util\Exception;
- use Yii;
- /**
- * This is the model class for table "addons_cloud_stock_import_stock_log".
- *
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $counts 导入数量
- * @property int $success_counts 导入成功数量
- * @property int $fail_counts 导入失败数量
- * @property int $status 状态:1:导入成功;2导入失败;3:导入中;4:导入中断
- * @property int $updated_at
- * @property int $created_at
- */
- class CloudStockImportStockLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_cloud_stock_import_stock_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'counts', 'success_counts', 'fail_counts', 'status', 'updated_at', 'created_at'], 'integer'],
- [['upload_file'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'counts' => '导入数量',
- 'success_counts' => '导入成功数量',
- 'fail_counts' => '导入失败数量',
- 'status' => '状态:1:导入成功;2导入失败;3:导入中;4:导入中断',
- 'updated_at' => 'Updated At',
- 'created_at' => 'Created At',
- ];
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool|object
- */
- public static function setData(array $params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- empty($fail_counts) ? $param['status'] = 1 : $param['status'] = 2;
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|