| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace addons\SecondaryCard\common\models;
- use addons\Clerk\common\models\ClerkUser;
- use addons\Store\common\models\Store;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use common\models\user\User;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_secondary_card_reservation_service".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $user_id 用户ID
- * @property int $order_id 开卡记录id
- * @property int $secondary_card_id 次卡ID
- * @property string $order_no 次卡号
- * @property int $clerk_nums 单次核销数
- * @property int $type 类型:1:o2o门店;
- * @property int $store_id 核销门店id;
- * @property int $status 状态0禁用,-1删除,1正常
- * @property int $open_time 开卡时间
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- * @property float $clerk_money 订单核销金额
- * @property float $service_income 技师服务收入
- * @property int $reservation_service_order_id 预约服务插件,服务订单id
- * @property int $clerk_user_id 预约服务插件,技师user_id;
- * @property int $clerk_type 核销类型:1:门店核销;2:技师核销;
- * @property int $clerk_log_id 公共核销记录id
- */
- class SecondaryCardUseLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_secondary_card_use_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'user_id', 'order_id', 'secondary_card_id', 'clerk_nums', 'type', 'store_id', 'reservation_service_order_id', 'clerk_user_id', 'clerk_type',
- 'status', 'created_at', 'updated_at', 'open_time','clerk_log_id'], 'integer'],
- [['clerk_money', 'service_income'], 'number'],
- [['order_no'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'user_id' => '用户ID',
- 'order_id' => 'order_id',
- 'order_no' => 'order_no',
- 'clerk_nums' => 'clerk_nums',
- 'type' => 'type',
- 'store_id' => 'store_id',
- 'clerk_money' => 'clerk_money',
- 'service_income' => 'service_income',
- 'clerk_type' => 'clerk_type',
- 'reservation_service_order_id' => 'reservation_service_order_id',
- 'clerk_user_id' => 'clerk_user_id',
- 'secondary_card_id' => '绑定的次卡ID',
- 'status' => '状态0禁用,-1删除,1正常',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- 'open_time' => '开卡时间',
- 'clerk_log_id' => '公共核销记录id',
- ];
- }
- public function getSecondaryCard()
- {
- return $this->hasOne(SecondaryCard::class, ['id' => 'secondary_card_id']);
- }
- public function getSecondaryCardOrder()
- {
- return $this->hasOne(SecondaryCardOrder::class, ['order_no' => 'order_no']);
- }
- public function getClerkUser()
- {
- return $this->hasOne(User::class, ['id' => 'clerk_user_id']);
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- public static function getExportFields()
- {
- return [
- 'order_no' => '卡号',
- 'secondary_card_name' => '次卡名称',
- 'nickname' => '开卡用户',
- 'open_time' => '开卡时间',
- 'clerk_nums' => '单次核销次数',
- 'store_name' => '核销门店',
- 'clerk_nickname' => '核销人',
- 'created_at' => '核销时间',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new \Exception('服务不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|