CloudStockPaymentLog.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace addons\CloudStock\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use common\models\goods\Goods;
  5. use common\models\user\User;
  6. use Yii;
  7. /**
  8. * This is the model class for table "qimall_addons_cloud_stock_payment_log".
  9. *
  10. * @property int $id
  11. * @property int $mall_id
  12. * @property int $store_id
  13. * @property int $user_id 会员id
  14. * @property int $buy_user_id 来源会员id
  15. * @property int $goods_id 商品id
  16. * @property string $goods_name 商品名称
  17. * @property string $pic_url 商品主图
  18. * @property int $order_id 订单id
  19. * @property int $order_detail_id 订单详情id
  20. * @property int $num 商品件数
  21. * @property string $order_no 订单编号
  22. * @property string $type 货款类型:fill:补货货款;buy:会员买货
  23. * @property float $money 金额
  24. * @property int|null $status 状态[-1:删除;0:待结算;1已结算]
  25. * @property int $created_at
  26. * @property int $updated_at
  27. */
  28. class CloudStockPaymentLog extends BaseActiveRecord
  29. {
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return '{{%addons_cloud_stock_payment_log}}';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['mall_id', 'store_id', 'order_detail_id', 'num'], 'required'],
  44. [['mall_id', 'user_id', 'buy_user_id', 'goods_id', 'order_id', 'order_detail_id', 'num', 'status', 'created_at', 'updated_at'], 'integer'],
  45. [['money'], 'number'],
  46. [['order_no'], 'string', 'max' => 100],
  47. [['type'], 'string', 'max' => 50],
  48. [['goods_name', 'pic_url'], 'string', 'max' => 255],
  49. ];
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'mall_id' => 'Mall ID',
  59. 'store_id' => 'store_id',
  60. 'type' => 'type',
  61. 'user_id' => 'User ID',
  62. 'buy_user_id' => 'Buy User ID',
  63. 'goods_id' => 'Goods ID',
  64. 'order_id' => 'Order ID',
  65. 'order_detail_id' => 'Order Detail ID',
  66. 'num' => 'Num',
  67. 'order_no' => 'Order No',
  68. 'money' => 'Money',
  69. 'status' => 'Status',
  70. 'created_at' => 'Created At',
  71. 'updated_at' => 'Updated At',
  72. ];
  73. }
  74. public function getBuyUser()
  75. {
  76. return $this->hasOne(User::class, ['id' => 'buy_user_id']);
  77. }
  78. public static function add(array $params)
  79. {
  80. try {
  81. $model = new self();
  82. $model->loadDefaultValues();
  83. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  84. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  85. return $model;
  86. } catch (\Exception $e) {
  87. self::$static_error = $e->getMessage();
  88. return false;
  89. }
  90. }
  91. }