quanwei
2025-10-31 7a27a1d4d0038abe2115adb1753f897f56d66323
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
 
namespace app\admin\model;
 
use app\admin\model\page\Page as PageModel;
use app\common\model\shop\Client as ClientModel;
 
class Client extends ClientModel
{
    /**
     * 获取小程序列表
     */
    public function getList($limit, $is_recycle = false)
    {
        return $this->alias('client')->field(['client.*,agent.agent_name'])->where('client.is_recycle', '=', (int)$is_recycle)
            ->join('dl_agent agent', 'agent.agent_id = client.agent_id','left')
            ->where('client.is_delete', '=', 0)
            ->order(['client.create_time' => 'asc'])
            ->paginate($limit);
    }
 
    /**
     * 新增记录
     */
    public function add($data)
    {
        $this->startTrans();
        try {
            // 添加小程序记录
            $this->save($data);
           
            $this->commit();
            return true;
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            $this->rollback();
            return false;
        }
    }
 
    /**
     * 修改记录
     */
    public function edit($data)
    {
        $this->startTrans();
        try {
            $save_data = [
                'client_name' => $data['client_name'],
                'company' => $data['company'],
                'mark_manager' => $data['mark_manager'],
                'handrate_wx'=>$data['handrate_wx'],
                'commissionrate_wx' => $data['commissionrate_wx'],
                'agent_id' => $data['agent_id'],
            ];
            $this->save($save_data);
            
            $this->commit();
            return true;
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            $this->rollback();
            return false;
        }
    }
    /**
     * 移入移出回收站
     */
    public function recycle($is_recycle = true)
    {
        return $this->save(['is_recycle' => (int)$is_recycle]);
    }
 
    /**
     * 软删除
     */
    public function setDelete()
    {
        return $this->save(['is_delete' => 1]);
    }
 
}