AgentSupplierCommissionSyncLog.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace addons\Agent\common\models;
  3. use common\enums\StatusEnum;
  4. use Exception;
  5. use RuntimeException;
  6. use Yii;
  7. /**
  8. * This is the model class for table "qimall_addons_agent_supplier_commission_sync_log".
  9. *
  10. * @property int $id
  11. * @property int $mall_id
  12. * @property int $status -1 执行失败 0未执行 1执行成功
  13. * @property int $created_at
  14. * @property int $updated_at
  15. */
  16. class AgentSupplierCommissionSyncLog extends \common\models\base\BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return 'qimall_addons_agent_supplier_commission_sync_log';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['mall_id', 'status', 'created_at', 'updated_at'], 'integer'],
  32. ];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'mall_id' => 'Mall ID',
  42. 'status' => 'Status',
  43. 'created_at' => 'Created At',
  44. 'updated_at' => 'Updated At',
  45. ];
  46. }
  47. /**
  48. * @param array $params
  49. *
  50. * @return bool|self
  51. */
  52. public static function setData(array $params)
  53. {
  54. try {
  55. $model = self::findOne(['mall_id' => $params['mall_id']]);
  56. if (!$model) {
  57. $model = new self();
  58. $model->loadDefaultValues();
  59. }
  60. if (!$model->load($params, '')) {
  61. throw new RuntimeException($model->getErrorMessage());
  62. }
  63. if (!$model->save()) {
  64. throw new RuntimeException($model->getErrorMessage());
  65. }
  66. return $model;
  67. } catch (Exception $e) {
  68. self::$static_error = $e->getMessage();
  69. return false;
  70. }
  71. }
  72. }