PlatformOrder.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace common\models\platform;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "qimall_platform_order".
  7. *
  8. *
  9. * @property int $id 订单id
  10. * @property int $order_id 订单id
  11. * @property string $order_no 订单编号
  12. * @property string|null $out_trade_no 系统支付流水号
  13. * @property string $title 订单标题
  14. * @property string $cover 订单封面
  15. * @property int $consumer_id 消费者ID
  16. * @property string|null $consumer_name 消费者名称
  17. * @property string $consumer_type 消费者类型[mall=商城,agent=代理商]
  18. * @property float|null $pay_money 订单实付金额,单位:元
  19. * @property float|null $order_price 订单价格,单位:元
  20. * @property int|null $order_status 订单状态
  21. * @property int|null $payment_type 支付方式[1=微信,2=支付宝]
  22. * @property int|null $pay_time 订单付款时间
  23. * @property int|null $expire_time 订单过期时间
  24. * @property int|null $pay_status 订单付款状态[0=未支付,1=已支付]
  25. * @property string $source_table 来源表
  26. * @property int|null $settlement_status 结算状态[0=待结算,1=已结算]
  27. * @property string|null $extra_info 额外信息
  28. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  29. * @property int|null $created_at 创建时间
  30. * @property int|null $updated_at 更新时间
  31. * @property int|null $from_type 来源类型
  32. */
  33. class PlatformOrder extends \common\models\base\BaseActiveRecord
  34. {
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public static function tableName()
  39. {
  40. return 'qimall_platform_order';
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function rules()
  46. {
  47. return [
  48. [['order_id', 'consumer_id', 'order_status', 'payment_type', 'pay_status', 'pay_time', 'expire_time', 'settlement_status', 'status', 'created_at', 'updated_at'], 'integer'],
  49. [['pay_money', 'order_price'], 'number'],
  50. [['extra_info'], 'string'],
  51. [['order_no', 'out_trade_no', 'title'], 'string', 'max' => 100],
  52. [['cover', 'consumer_name','from_type'], 'string', 'max' => 255],
  53. [['consumer_type'], 'string', 'max' => 20],
  54. [['source_table'], 'string', 'max' => 200],
  55. ];
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function attributeLabels()
  61. {
  62. return [
  63. 'id' => '订单id',
  64. 'order_id' => '订单id',
  65. 'order_no' => '订单编号',
  66. 'out_trade_no' => '系统支付流水号',
  67. 'title' => '订单标题',
  68. 'cover' => '订单封面',
  69. 'consumer_id' => '消费者ID',
  70. 'consumer_name' => '消费者名称',
  71. 'consumer_type' => '消费者类型[mall=商城,agent=代理商]',
  72. 'pay_money' => '订单实付金额,单位:元',
  73. 'order_price' => '订单价格,单位:元',
  74. 'order_status' => '订单状态',
  75. 'payment_type' => '支付方式[1=微信,2=支付宝]',
  76. 'pay_status' => '订单付款状态[0=未支付,1=已支付]',
  77. 'pay_time' => '订单付款时间',
  78. 'expire_time' => '订单过期时间',
  79. 'source_table' => '来源表',
  80. 'settlement_status' => '结算状态[0=待结算,1=已结算]',
  81. 'extra_info' => '额外信息',
  82. 'status' => '状态[-1:删除;0:禁用;1启用]',
  83. 'created_at' => '创建时间',
  84. 'updated_at' => '更新时间',
  85. 'from_type' => '来源类型',
  86. ];
  87. }
  88. /**
  89. * 保存数据
  90. * @Author: lun
  91. * @DateTime: 2022/3/3 0003 17:24
  92. * @Copyright: copyright (c) 2021 广东七件事集团
  93. * @param $params
  94. * @return bool|PlatformOrder
  95. */
  96. public static function setData($params)
  97. {
  98. try {
  99. if (!empty($params['id'])) {
  100. $model = self::findOne(['id' => $params['id']]);
  101. } else {
  102. $model = new self();
  103. $model->loadDefaultValues();
  104. }
  105. if (empty($model)) throw new Exception('查无此订单');
  106. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  107. return $model;
  108. } catch (\Exception $e) {
  109. self::setStaticError($e->getMessage());
  110. return false;
  111. }
  112. }
  113. }