PlatformFinanceLog.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace common\models\finance;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "qimall_platform_finance_log".
  7. *
  8. * @property int $id
  9. * @property string|null $out_trade_no 系统支付流水号
  10. * @property int $consumer_id 消费者ID
  11. * @property string $consumer_type 消费者类型[mall=商城,agent=代理商]
  12. * @property string $change_type 操作类型:add-增加,sub-减少
  13. * @property float $change_num 操作数量
  14. * @property float $current_num 当前数量
  15. * @property string $desc 变动说明
  16. * @property string $source_table 来源表
  17. * @property int $source_table_id 操作来源业务id
  18. * @property string $from_type 来源类型
  19. * @property int $status 状态,-1:失效,1:正常,2:冻结
  20. * @property int $created_at 添加时间戳
  21. * @property int $updated_at 更新时间戳
  22. * @property int $payment_type 支付类型
  23. */
  24. class PlatformFinanceLog extends \common\models\base\BaseActiveRecord
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return 'qimall_platform_finance_log';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['consumer_id', 'source_table_id', 'status', 'created_at', 'updated_at','payment_type'], 'integer'],
  40. [['change_num', 'current_num'], 'number'],
  41. [['out_trade_no'], 'string', 'max' => 100],
  42. [['consumer_type'], 'string', 'max' => 20],
  43. [['change_type'], 'string', 'max' => 12],
  44. [['desc', 'source_table', 'from_type'], 'string', 'max' => 255],
  45. ];
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'id' => 'ID',
  54. 'out_trade_no' => '系统支付流水号',
  55. 'consumer_id' => '消费者ID',
  56. 'consumer_type' => '消费者类型[mall=商城,agent=代理商]',
  57. 'change_type' => '操作类型:add-增加,sub-减少',
  58. 'change_num' => '操作数量',
  59. 'current_num' => '当前数量',
  60. 'desc' => '变动说明',
  61. 'source_table' => '来源表',
  62. 'source_table_id' => '操作来源业务id',
  63. 'from_type' => '来源类型',
  64. 'status' => '状态,-1:失效,1:正常,2:冻结',
  65. 'created_at' => '添加时间戳',
  66. 'updated_at' => '更新时间戳',
  67. 'payment_type' => '支付类型',
  68. ];
  69. }
  70. /**
  71. * @Author: ltm
  72. * @DateTime: 2022/3/3 0003 18:06
  73. * @Copyright: copyright (c) 2021 广东七件事集团
  74. * @param $data
  75. * @return string
  76. */
  77. public static function setData($params)
  78. {
  79. try {
  80. if (!empty($params['id'])) {
  81. $model = self::findOne(['id' => $params['id']]);
  82. } else {
  83. $model = new self();
  84. $model->loadDefaultValues();
  85. }
  86. if (empty($model)) throw new Exception('查无此订单');
  87. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  88. return $model;
  89. } catch (\Exception $e) {
  90. self::setStaticError($e->getMessage());
  91. return false;
  92. }
  93. }
  94. }