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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
 
namespace app\shop\controller\user;
 
use app\shop\controller\Controller;
use app\shop\model\user\Card as CardModel;
use app\shop\model\user\CardRecord as CardRecordModel;
use app\shop\model\plus\coupon\Coupon as CouponModel;
 
/**
 * 会员卡
 */
class Card extends Controller
{
    /**
     * 会员卡列表
     */
    public function index()
    {
        $model = new CardModel;
        $list = $model->getList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 领取会员卡记录
     */
    public function record()
    {
        $model = new CardRecordModel;
        $list = $model->getList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 会员卡删除记录
     */
    public function deleterecord()
    {
        $model = new CardModel;
        $list = $model->getDeleteList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 发卡
     */
    public function put()
    {
        $model = new CardModel;
        if ($model->put($this->postData())) {
            return $this->renderSuccess('添加成功');
        }
        return $this->renderError($model->getError() ?: '添加失败');
    }
 
    /**
     * 撤销
     */
    public function cancel()
    {
        $model = new CardModel;
        if ($model->cancel($this->postData())) {
            return $this->renderSuccess('撤销成功');
        }
        return $this->renderError($model->getError() ?: '撤销失败');
    }
 
    /**
     * 延期
     */
    public function delay($order_id)
    {
        $model = CardRecordModel::detail($order_id);
        if ($model->delay($this->postData())) {
            return $this->renderSuccess('更新成功');
        }
        return $this->renderError($model->getError() ?: '更新失败');
    }
 
    /**
     * 添加会员卡
     */
    public function add()
    {
        $model = new CardModel;
        // get请求
        if ($this->request->isGet()) {
            //优惠券
            $couponList = [];
            //卡片样式
            $image = $model::getImage();
            return $this->renderSuccess('', compact('couponList', 'image'));
        }
        // 新增记录
        if ($model->add($this->postData()['params'])) {
            return $this->renderSuccess('添加成功');
        }
        return $this->renderError('添加失败');
    }
 
    /**
     * 编辑会员卡
     */
    public function edit($card_id)
    {
        $model = CardModel::detail($card_id);
        // get请求
        if ($this->request->isGet()) {
            //优惠券
            $couponList = [];
            //卡片样式
            $image = $model::getImage();
            return $this->renderSuccess('', compact('couponList', 'model', 'image'));
        }
        // 修改记录
        if ($model->edit($this->postData()['params'])) {
            return $this->renderSuccess();
        }
        return $this->renderError();
    }
 
    /**
     * 删除会员卡
     */
    public function delete($card_id)
    {
        // 会员卡详情
        $model = CardModel::detail($card_id);
        if (!$model->setDelete()) {
            return $this->renderError($model->getError() ?: '已存在用户,删除失败');
        }
        return $this->renderSuccess('删除成功');
    }
 
}