quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
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
<?php
 
 
namespace app\supplier\model\store;
 
use app\common\model\store\Coupon as CouponModel;
 
/**
 * 店员模型
 */
class Coupon extends CouponModel
{
    /**
     * 获取列表数据
     */
    public function getList($store_id = 0, $search = '', $params)
    {
        $model = $this;
        if ($store_id > 0) {
            $model = $model->where('clerk.store_id', '=', (int)$store_id);
        }
        if (!empty($search)) {
            $model = $model->where('clerk.real_name', 'like', '%' . $search . '%');
        }
        $model = $model->where('coupon.shop_supplier_id', '=', $params['shop_supplier_id']);
        // 查询列表数据
        $data = $model->with(['store', 'clerk', 'usercoupon'])
            ->alias('coupon')
            ->field(['coupon.*'])
            ->join('store_clerk clerk', 'clerk.clerk_id = coupon.clerk_id', 'INNER')
            ->order(['coupon.create_time' => 'desc'])
            ->paginate($params);
        foreach ($data as &$row) {
            $row['coupon_content'] = empty($row['usercoupon']['coupon_project']) ? '' : $row['usercoupon']['coupon_project'][$row['project_id']]['content'];
            $row['coupon_name'] = $row['usercoupon']['name'];
            unset($row['usercoupon']);
        }
        unset($row);
        return $data;
    }
 
}