| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace addons\Store\common\models;
- use common\models\base\BaseActiveRecord;
- use common\models\user\User;
- use Yii;
- /**
- * This is the model class for table "addons_store_clerk_income".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $store_id 门店id
- * @property int $user_id 会员id
- * @property int $clerk_user_id 核销员id
- * @property int $clerk_admin_id 核销管理员id
- * @property int $proper_user_id 专有者id
- * @property int $num 数量
- * @property int $e_coupon_id 电子券id
- * @property int $user_e_coupon_id 用户电子券id
- * @property string $e_coupon_name 电子券名称
- * @property string $mobile 电话
- * @property string $order_no 订单编号
- * @property float $amount 核销金额
- * @property float $income 核销收益
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class StoreClerkIncome extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_clerk_income}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['e_coupon_id', 'user_id', 'mall_id', 'user_e_coupon_id'], 'required'],
- [['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'],
- [['mobile'], 'string', 'max' => 11],
- [['amount','income'], 'number'],
- [['order_no'], 'string', 'max' => 100],
- [['e_coupon_name'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => '门店id',
- 'user_id' => '会员id',
- 'clerk_id' => '核销员id',
- 'mobile' => '电话',
- 'order_no' => '订单编号',
- 'amount' => '核销金额',
- 'income' => '核销收益',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- 'e_coupon_id' => '电子券id',
- 'e_coupon_name' => '电子券名称',
- 'clerk_user_id' => '核销员',
- 'user_e_coupon_id'=>'用户电子券id',
- 'clerk_admin_id' => '核销员(管理员)',
- 'proper_user_id' => '专有者',
- 'num' => '兑换数量',
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- public function getStore()
- {
- return $this->hasOne(Store::class, ['id' => 'store_id']);
- }
- public static function setData(array $params)
- {
-
- $t = Yii::$app->db->beginTransaction();
- try {
- $model = new self();
- $model->loadDefaultValues();
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- $t->commit();
- return $model;
- } catch (\Exception $e) {
- $t->rollBack();
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|