huangsijun
2025-09-22 a78c011de350b188afb03beb2f26a73f35f71986
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
 
namespace app\api\model\plus\table;
 
use app\common\model\plus\table\Table as TableModel;
use app\common\model\plus\table\Record as RecordModel;
/**
 * 表单模型
 */
class Table extends TableModel
{
    /**
     * 签到
     */
    public function add($user, $data)
    {
        $this->startTrans();
        try {
            $data['content'] = $data['tableData'];
            $data['user_id'] = $user['user_id'];
            $data['app_id'] = self::$app_id;
            $model = new RecordModel();
            $model->save($data);
            $this->where('table_id', '=', $data['table_id'])->inc('total_count')->update();
            $this->commit();
            return $model->table_record_id;
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            $this->rollback();
            return false;
        }
    }
 
    public static function recorDetail($table_record_id)
    {
        if ($model =  RecordModel::detail($table_record_id)) {
            $model['content'] = json_decode($model['content']);
        }
        return $model;
    }
}