HappinessVoucherLog.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "qimall_addons_happiness_voucher_log".
  6. *
  7. * @property int $id
  8. * @property int $mall_id
  9. * @property int $store_id
  10. * @property int $level 商品标签权重
  11. * @property string $wallet_type
  12. * @property string $change_type 操作类型:add-增加,sub-减少
  13. * @property float $change_num 操作数量
  14. * @property float $after_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 string $order_no 订单号
  21. * @property int $created_at 添加时间戳
  22. * @property int $updated_at 更新时间戳
  23. * @property string $addon_name 来源插件名称
  24. */
  25. class HappinessVoucherLog extends \common\models\base\BaseActiveRecord
  26. {
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public static function tableName()
  31. {
  32. return 'qimall_addons_happiness_voucher_log';
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['mall_id', 'store_id', 'source_table_id', 'status', 'level','created_at', 'updated_at',], 'integer'],
  41. [['change_num'], 'required'],
  42. [['change_num', 'after_num'], 'number'],
  43. [['wallet_type'], 'string', 'max' => 20],
  44. [['change_type'], 'string', 'max' => 12],
  45. [['desc', 'source_table', 'from_type'], 'string', 'max' => 255],
  46. [['order_no'], 'string', 'max' => 100],
  47. [['addon_name'], 'string', 'max' => 64],
  48. ];
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'mall_id' => 'Mall ID',
  58. 'store_id' => 'Store ID',
  59. 'level'=>'Level',
  60. 'wallet_type' => 'Wallet Type',
  61. 'change_type' => 'Change Type',
  62. 'change_num' => 'Change Num',
  63. 'after_num' => 'After Num',
  64. 'desc' => 'Desc',
  65. 'source_table' => 'Source Table',
  66. 'source_table_id' => 'Source Table ID',
  67. 'from_type' => 'From Type',
  68. 'status' => 'Status',
  69. 'order_no' => 'Order No',
  70. 'created_at' => 'Created At',
  71. 'updated_at' => 'Updated At',
  72. 'addon_name' => 'Addon Name',
  73. ];
  74. }
  75. /**
  76. * 保存数据
  77. * @param array $params
  78. * @return bool
  79. */
  80. public static function setData(array $params)
  81. {
  82. try {
  83. $model = new self();
  84. $model->loadDefaultValues();
  85. if (!$model->load($params, '') || !$model->save()){
  86. throw new Exception($model->getErrorMessage());
  87. }
  88. return $model;
  89. } catch (Exception $e) {
  90. self::$static_error = $e->getMessage();
  91. return false;
  92. }
  93. }
  94. }