AgentCancelLog.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace addons\Agent\common\models;
  3. use common\enums\StatusEnum;
  4. use common\models\base\BaseActiveRecord;
  5. use Yii;
  6. /**
  7. * This is the model class for table "{{%addons_agent_cancel_log}}".
  8. *
  9. * @property int $id
  10. * @property int $mall_id
  11. * @property string $source_table 来源表
  12. * @property int $source_table_id 操作来源业务id
  13. * @property string $from_type 来源类型
  14. * @property int $order_status 记录时订单状态[0:支付;1:完成]
  15. * @property int $status 状态,-1:失效,1:正常,2:冻结
  16. * @property int $created_at 添加时间戳
  17. * @property int $updated_at 更新时间戳
  18. */
  19. class AgentCancelLog extends BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%addons_agent_cancel_log}}';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'source_table_id', 'order_status', 'status', 'created_at', 'updated_at'], 'integer'],
  35. [['source_table'], 'string', 'max' => 255],
  36. [['from_type'], 'string', 'max' => 50],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'source_table' => 'Source Table',
  48. 'source_table_id' => 'Source Table ID',
  49. 'from_type' => 'From Type',
  50. 'order_status' => 'Order Status',
  51. 'status' => 'Status',
  52. 'created_at' => 'Created At',
  53. 'updated_at' => 'Updated At',
  54. ];
  55. }
  56. /**
  57. * @desc:保存数据
  58. */
  59. public static function setData(array $params)
  60. {
  61. try {
  62. $model = new self();
  63. $model->loadDefaultValues();
  64. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  65. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  66. return $model;
  67. } catch (\Exception $e) {
  68. self::$static_error = $e->getMessage();
  69. return false;
  70. }
  71. }
  72. }