StoreServiceRatioLog.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\Store\common\models;
  3. use addons\Redpack\common\enums\RedpackEnum;
  4. use common\enums\RedisKeyEnum;
  5. use common\enums\StatusEnum;
  6. use common\helpers\LockHelper;
  7. use common\models\user\User;
  8. use addons\Store\common\models\Store;
  9. use Yii;
  10. use yii\db\Exception;
  11. /**
  12. * This is the model class for table "{{%addons_redpack_wallet}}".
  13. *
  14. * @property int $id
  15. * @property int $mall_id 商城id
  16. * @property int $user_id 会员id
  17. * @property string $change_type 操作类型:add-增加,sub-减少
  18. * @property int $change_num 操作数量
  19. * @property int $after_num 变动后数量
  20. * @property int $desc 变动说明
  21. * @property string $source_table 来源表
  22. * @property int $source_table_id 操作来源业务id
  23. * @property int from_type 来源类型
  24. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  25. * @property int $created_at
  26. * @property int $updated_at
  27. */
  28. class StoreServiceRatioLog extends \common\models\base\BaseActiveRecord
  29. {
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return '{{%addons_store_service_ratio_log}}';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['mall_id', 'store_id', 'created_at', 'updated_at', 'status'], 'integer'],
  44. [['before_store_service_ratio', 'after_store_service_ratio'], 'number'],
  45. ];
  46. }
  47. public function getStore()
  48. {
  49. return $this->hasOne(Store::ClassName(), ['id' => 'store_id']);
  50. }
  51. public static function setData($params)
  52. {
  53. try {
  54. $model = new self();
  55. $model->loadDefaultValues();
  56. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  57. if (!$model->save()) throw new Exception($model->getErrorMessage());
  58. return true;
  59. } catch (\Exception $e) {
  60. self::setStaticError($e->getMessage());
  61. return false;
  62. }
  63. }
  64. }