150], [['background', 'font_color', 'reservation_day', 'applet_code'], 'string', 'max' => 255], [['reservation_time'], 'string',], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'name' => '次卡名称', 'background_type' => '次卡背景类型,0:默认背景,1:自定义', 'font_color' => '字体颜色', 'background' => '次卡背景', 'total_redemption' => '累计兑卡张数', 'total_sales' => '累计售卡数', 'total_sales_price' => '累计售卡金额', 'sell_time_start' => '售卖开始时间', 'sell_time_end' => '售卖结束时间', 'expire_type' => '次卡有效期类型:1=购买时起N天内有效,2=指定有效期', 'begin_at' => '有效期开始时间', 'end_at' => '有效期结束时间', 'expire_day' => '有效天数,expire_type=1时', 'price' => '售价', 'original_price' => '原价', 'verifiable_times' => '可核销次数', 'max_times' => '最大开卡数', 'virtual_sales' => '虚拟销量', 'service' => '卡服务设置', 'reservation_type' => '是否需要预约,0:不需要,1:需要', 'reservation_model' => '预约模式:1:预约门店;2:预约服务人', 'reservation_service_type' => '服务方式:1:上门服务;2:到店服务;3:上门/到店', 'reservation_day' => '可预约日期:1-7对应周一至周日', 'reservation_time_type' => '可预约时间段类型:1:指定时间段;2:整天', 'reservation_time' => '可预约时间段', 'appointment_interval_duration' => '项目时间', 'reservation_cancel_type' => '预约取消:1:不允许取消;2:服务开始前N小时,取消并扣除m次可服务数', 'reservation_cancel_hour' => '服务开始前N小时', 'reservation_cancel_deduct' => '取消并扣除m次可服务数', 'reservation_limit_people' => '同时段可预约N人', 'reservation_limit_repeat' => '反复预约限制N次', 'refund_type' => '退款类型,0:未使用到期自动退,1:不允许退款,2:允许退款', 'limit_type' => '限购类型,0:不限开卡次数(用户可重复开卡,不限制领卡次数),1:有效期内限开卡次数', 'limit_times' => 'limit_type==1,次数,领取次数仅统计用户领卡的次数,不统计商家发卡', 'create_source_type' => '创建来源类型:0:平台;1:门店', 'create_source_id' => '创建来源id', 'is_on_sales' => '卡次状态:0:下架;1:正常', 'rule' => '使用规则', 'store_type' => '店铺类型:1:o2o门店', 'use_type' => '使用范围:0:全部店铺;1:指定店铺', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'created_at' => '创建时间', 'updated_at' => 'Updated At', 'applet_code' => '微信小程序推广码', ]; } 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('服务不存在或已删除'); if ($model->create_source_type != $params['create_source_type']) { throw new \Exception('创建来源不一致,无法编辑'); } } else { $model = new self(); $model->loadDefaultValues(); } if (empty($params['expire_day'])) $params['expire_day'] = 0; if (empty($params['sell_time_start'])) $params['sell_time_start'] = 0; if (empty($params['sell_time_end'])) $params['sell_time_end'] = 0; if (empty($params['limit_times'])) $params['limit_times'] = 0; 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; } } }