SeedRefund.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace addons\Seed\common\models;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "{{%addons_seed_refund}}".
  7. *
  8. * @property int $id ID
  9. * @property int $seed_order_id seed_order.id
  10. * @property int $seed_num 退款种子金数量
  11. * @property float|null $seed_cost 退款种子金总价值,单位:元
  12. * @property float|null $percent 退款比例,单位:百分比
  13. * @property int $status 状态【-1删除 0禁用,1正常】
  14. * @property int $created_at 创建时间
  15. * @property int $updated_at 更新数据时间
  16. */
  17. class SeedRefund extends \common\models\base\BaseActiveRecord
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return '{{%addons_seed_refund}}';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['seed_order_id', 'seed_num', 'status', 'created_at', 'updated_at'], 'integer'],
  33. [['seed_cost','percent'], 'number'],
  34. ];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'seed_order_id' => 'seed_order.id',
  44. 'seed_num' => '退款种子金数量',
  45. 'seed_cost' => '退款种子金总价值,单位:元',
  46. 'percent' => '退款比例,单位:百分比',
  47. 'status' => '状态【-1删除 0禁用,1正常】',
  48. 'created_at' => '创建时间',
  49. 'updated_at' => '更新数据时间',
  50. ];
  51. }
  52. /**
  53. * 保存数据
  54. * @Author: lun
  55. * @DateTime: 2022/8/30 0030 10:34
  56. * @Copyright: copyright (c) 2021 广东七件事集团
  57. * @param $params
  58. * @return bool
  59. */
  60. public static function setData($params)
  61. {
  62. try {
  63. $model = new self();
  64. $model->loadDefaultValues();
  65. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  66. return true;
  67. } catch (\Exception $e) {
  68. self::setStaticError('种子金退款记录:'.$e->getMessage());
  69. return false;
  70. }
  71. }
  72. }