89 lines
1.8 KiB
PHP
89 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\api\model\app\activity;
|
|
|
|
use think\Model;
|
|
use think\Db;
|
|
use app\api\model\app\activity\Ticket;
|
|
use app\common\exception\Exception;
|
|
use app\api\model\app\activity\UserTicket;
|
|
use fast\Random;
|
|
|
|
/**
|
|
* 线下活动-自定义表单
|
|
*/
|
|
class Signin extends Model
|
|
{
|
|
|
|
|
|
// 表名
|
|
protected $name = 'app_activity_signin';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'integer';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = false;
|
|
protected $deleteTime = false;
|
|
|
|
|
|
/**
|
|
* 签到
|
|
* @param $ticketNo
|
|
* @param $type
|
|
* @return bool
|
|
*/
|
|
public static function signin($ticketNo,$type='scan'){
|
|
|
|
$result = \app\api\model\app\activity\UserTicket::where([
|
|
'ticket_no'=>$ticketNo
|
|
])->update([
|
|
'sign'=>1,
|
|
'use_time'=>time()
|
|
]);
|
|
|
|
|
|
//消息推送收集
|
|
\app\admin\library\app\msgpush\Msg::collect('activity_sing_in',['ticket_no'=>$ticketNo]);
|
|
|
|
if($result){
|
|
self::insert([
|
|
'uniacid'=>UNIACID,
|
|
'ticket_no'=>$ticketNo,
|
|
'type'=>$type,
|
|
'createtime'=>time()
|
|
]);
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/**
|
|
* 取消签到
|
|
* @param $ticketNo
|
|
* @return bool
|
|
*/
|
|
public static function cancel($ticketNo){
|
|
$result = \app\api\model\app\activity\UserTicket::where([
|
|
'ticket_no'=>$ticketNo
|
|
])->update([
|
|
'sign'=>0,
|
|
'use_time'=>''
|
|
]);
|
|
|
|
if($result){
|
|
self::where([
|
|
'ticket_no'=>$ticketNo
|
|
])->delete();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
} |