BusinessCardFollowLog.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace addons\BusinessCard\common\models;
  3. use common\enums\StatusEnum;
  4. use Exception;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_business_card_follow_log".
  8. *
  9. * @property int $id
  10. * @property int $mall_id
  11. * @property int $user_id
  12. * @property int $operate_id 操作者ID
  13. * @property int $log_type 类型,1:修改意向,2:添加跟进记录
  14. * @property string $remark 记录说明
  15. * @property int $status 状态[1启用 0禁用 -1删除]
  16. * @property int $created_at 创建时间
  17. * @property int $updated_at 更新事件
  18. */
  19. class BusinessCardFollowLog extends \common\models\base\BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'qimall_addons_business_card_follow_log';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'user_id', 'operate_id', 'log_type', 'status', 'created_at', 'updated_at'], 'integer'],
  35. [['remark'], 'string', 'max' => 255],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'mall_id' => 'Mall ID',
  46. 'user_id' => 'User ID',
  47. 'operate_id' => 'Operate ID',
  48. 'log_type' => 'Log Type',
  49. 'remark' => 'Remark',
  50. 'status' => 'Status',
  51. 'created_at' => 'Created At',
  52. 'updated_at' => 'Updated At',
  53. ];
  54. }
  55. /**
  56. * 保存数据
  57. *
  58. * @author hpei
  59. * @return bool|Exception
  60. */
  61. public static function setData($params) {
  62. try {
  63. if (empty($params['id'])) {
  64. $model = new self();
  65. $model->loadDefaultValues();
  66. } else {
  67. $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
  68. if (empty($model)) throw new \Exception('数据不存在或者已删除');
  69. }
  70. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  71. return $model->id;
  72. } catch (\Exception $e) {
  73. self::$static_error = $e->getMessage();
  74. return false;
  75. }
  76. }
  77. }