CardSecretImportLog.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace addons\CardSecret\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_CardSecret_import_log}}".
  6. *
  7. * @property int $id
  8. * @property int|null $cate_id 卡密分类ID
  9. * @property int $mall_id 商城ID
  10. * @property string $file 导入文件路径
  11. * @property string $operator_name 操作人昵称
  12. * @property int $operator_id 操作人ID
  13. * @property int $export_count 总导入数量
  14. * @property int $export_success_count 导入成功数量
  15. * @property int $export_fail_count 导入失败数量
  16. * @property int $status 0是禁用,1是正常,-1是删除
  17. * @property int $created_at 创建时间
  18. * @property int $updated_at 修改时间
  19. * @property int $export_status 0是正在处理中,1是导入完成
  20. */
  21. class CardSecretImportLog extends \common\models\base\BaseActiveRecord
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return '{{%addons_card_secret_import_log}}';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['cate_id', 'mall_id', 'operator_id', 'export_count', 'export_success_count', 'export_fail_count', 'status', 'created_at', 'updated_at', 'export_status'], 'integer'],
  37. [['file'], 'string', 'max' => 200],
  38. [['operator_name'], 'string', 'max' => 100],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'cate_id' => '卡密分类ID',
  49. 'mall_id' => '商城ID',
  50. 'file' => '导入文件路径',
  51. 'operator_name' => '操作人昵称',
  52. 'operator_id' => '操作人ID',
  53. 'export_count' => '总导入数量',
  54. 'export_success_count' => '导入成功数量',
  55. 'export_fail_count' => '导入失败数量',
  56. 'status' => '0是禁用,1是正常,-1是删除',
  57. 'created_at' => '创建时间',
  58. 'updated_at' => '修改时间',
  59. 'export_status' => '0是正在处理中,1是导入完成',
  60. ];
  61. }
  62. /**
  63. * @Author: ltm
  64. * @DateTime: 2022/5/6 0007 11:31
  65. * @Copyright: copyright (c) 2021 广东七件事集团
  66. * @param $data
  67. * @return string
  68. */
  69. public static function setData(array $params){
  70. try{
  71. if (!empty($params['id'])) {
  72. $model = self::findOne(['id'=>$params['id'],'mall_id'=>$params['mall_id']]);
  73. if (empty($model)) throw new Exception('记录不存在或已删除');
  74. }else{
  75. $model = new self();
  76. $model->loadDefaultValues();
  77. }
  78. $model->mall_id = $params['mall_id'];
  79. if(!$model->load($params,'') || !$model->save()){
  80. throw new Exception($model->getErrorMessage());
  81. }
  82. return $model;
  83. }catch(\Exception $e){
  84. self::$static_error = $e->getMessage();
  85. return false;
  86. }
  87. }
  88. }