StoreClerkIncome.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use common\models\user\User;
  5. use Yii;
  6. /**
  7. * This is the model class for table "addons_store_clerk_income".
  8. *
  9. * @property int $id
  10. * @property int $mall_id
  11. * @property int $store_id 门店id
  12. * @property int $user_id 会员id
  13. * @property int $clerk_user_id 核销员id
  14. * @property int $clerk_admin_id 核销管理员id
  15. * @property int $proper_user_id 专有者id
  16. * @property int $num 数量
  17. * @property int $e_coupon_id 电子券id
  18. * @property int $user_e_coupon_id 用户电子券id
  19. * @property string $e_coupon_name 电子券名称
  20. * @property string $mobile 电话
  21. * @property string $order_no 订单编号
  22. * @property float $amount 核销金额
  23. * @property float $income 核销收益
  24. * @property int $status 状态[0禁用 1启用 -1删除]
  25. * @property int $created_at 创建时间
  26. * @property int $updated_at 修改时间
  27. */
  28. class StoreClerkIncome extends BaseActiveRecord
  29. {
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return '{{%addons_store_clerk_income}}';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['e_coupon_id', 'user_id', 'mall_id', 'user_e_coupon_id'], 'required'],
  44. [['mall_id', 'store_id', 'user_id','status', 'created_at', 'updated_at','e_coupon_id', 'user_e_coupon_id', 'clerk_user_id', 'clerk_admin_id', 'proper_user_id', 'num'], 'integer'],
  45. [['mobile'], 'string', 'max' => 11],
  46. [['amount','income'], 'number'],
  47. [['order_no'], 'string', 'max' => 100],
  48. [['e_coupon_name'], 'string'],
  49. ];
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'mall_id' => 'Mall ID',
  59. 'store_id' => '门店id',
  60. 'user_id' => '会员id',
  61. 'clerk_id' => '核销员id',
  62. 'mobile' => '电话',
  63. 'order_no' => '订单编号',
  64. 'amount' => '核销金额',
  65. 'income' => '核销收益',
  66. 'status' => '状态[0禁用 1启用 -1删除]',
  67. 'created_at' => '创建时间',
  68. 'updated_at' => '修改时间',
  69. 'e_coupon_id' => '电子券id',
  70. 'e_coupon_name' => '电子券名称',
  71. 'clerk_user_id' => '核销员',
  72. 'user_e_coupon_id'=>'用户电子券id',
  73. 'clerk_admin_id' => '核销员(管理员)',
  74. 'proper_user_id' => '专有者',
  75. 'num' => '兑换数量',
  76. ];
  77. }
  78. public function getUser()
  79. {
  80. return $this->hasOne(User::class, ['id' => 'user_id']);
  81. }
  82. public function getStore()
  83. {
  84. return $this->hasOne(Store::class, ['id' => 'store_id']);
  85. }
  86. public static function setData(array $params)
  87. {
  88. $t = Yii::$app->db->beginTransaction();
  89. try {
  90. $model = new self();
  91. $model->loadDefaultValues();
  92. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  93. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  94. $t->commit();
  95. return $model;
  96. } catch (\Exception $e) {
  97. $t->rollBack();
  98. self::$static_error = $e->getMessage();
  99. return false;
  100. }
  101. }
  102. }