AddonsHandBouns.php 2.9 KB

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