DoubleCopyPoolSource.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace addons\DoubleCopy\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "{{%addons_double_copy_pool_source}}".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城ID
  10. * @property int $level 等级(权重)
  11. * @property int $order_detail_id 订单详情ID
  12. * @property float $money 插入金额,单位:元
  13. * @property int $status 状态[-1:删除;0:禁用;1启用]
  14. * @property int|null $created_at 创建时间
  15. * @property int|null $updated_at 更新时间
  16. * @property string $reward_currency 奖励类型:佣金-commission,积分-score
  17. * @property string $remark 备注
  18. */
  19. class DoubleCopyPoolSource extends \common\models\base\BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%addons_double_copy_pool_source}}';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'level', 'order_detail_id', 'status', 'created_at', 'updated_at'], 'integer'],
  35. [['money'], 'number'],
  36. [['reward_currency'],'string'],
  37. [['remark'],'string']
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'mall_id' => '商城ID',
  48. 'level' => '等级(权重)',
  49. 'order_detail_id' => '订单详情ID',
  50. 'money' => '插入金额,单位:元',
  51. 'status' => '状态[-1:删除;0:禁用;1启用]',
  52. 'created_at' => '创建时间',
  53. 'updated_at' => '更新时间',
  54. ];
  55. }
  56. public static function setData($params)
  57. {
  58. try {
  59. $model = self::findOne(['id' => $params['id'], 'status' => StatusEnum::ENABLED]);
  60. if (empty($model)) {
  61. $model = new self();
  62. $model->loadDefaultValues();
  63. } else {
  64. }
  65. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  66. return $model->toArray();
  67. } catch (\Exception $e) {
  68. self::setStaticError($e->getMessage());
  69. return false;
  70. }
  71. }
  72. }