| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- use Yii;
- /**
- * This is the model class for table "{{%verify_card_sale}}".
- *
- * @property int $id
- * @property int $store_id
- * @property int $verify_card_id 核销卡id
- * @property int $user_id 用户id
- * @property int $use_num 核销次数
- * @property int $left_num 剩余次数
- * @property int $sale_time 售卖时间
- * @property int $end_time 有效期
- * @property int $is_delete 状态
- * @property int $status 状态
- * @property int $goods_id 商品id
- * @property int $order_type 订单类型
- * @property int $created_at 核销卡创建时间
- * @property int|null $updated_at 更新时间
- * @property string $account_id 卡密账号id
- * @property int $is_trans_send 是否是转赠卡
- * @property int $video_status 视频卡是否过期
- * @property int $is_cash 是否折现:0=否,1=是
- */
- class VerifyCardSale extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%verify_card_sale}}';
- }
- const IS_DELETE_YES = 1;//已删除
- const IS_DELETE_NO = 0;//未删除
- const ORDER_TYPE_MIAOSHA = 1; //秒杀
- const ORDER_TYPE_PINTUAN = 2; //拼团
- const ORDER_TYPE_STORE = 0; //商城
- const STATUS_YES = 0;//正常使用
- const STATUS_USED = 1;//已使用
- const STATUS_EXPIRED = 2;//已过期
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
- ]
- ]
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['store_id', 'verify_card_id', 'user_id', 'use_num', 'left_num', 'sale_time', 'end_time', 'is_delete', 'status', 'goods_id', 'order_type', 'account_id', 'is_trans_send', 'video_status', 'is_cash'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => 'Store ID',
- 'verify_card_id' => '核销卡id',
- 'user_id' => '用户id',
- 'use_num' => '核销次数',
- 'left_num' => '剩余次数',
- 'sale_time' => '售卖时间',
- 'end_time' => '有效期',
- 'is_delete' => '状态(0、正常1、已使用2、已过期)',
- 'status' => '状态',
- 'goods_id' => '商品id',
- 'order_type' => '订单类型(0、商城,1、秒杀,2、拼团)',
- 'account_id' => '卡密账号id',
- 'video_status' => '视频卡是否过期',
- 'is_cash' => '是否折现:0=否,1=是',
- ];
- }
- // 取消下单时送的核销卡
- public static function cancelCard($order)
- {
- if (!empty($order->get_verify_id)) {
- $ids = \explode(',', $order->get_verify_id);
- foreach ($ids as $id) {
- $card = self::findOne($id);
- if ($card) {
- $card->status = 2;
- $card->save();
- }
- }
- }
- }
- }
|