chengkun
2025-04-27 1158f672536ba406cc4bef68aed19a6c05483ab4
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
<?php
 
class coupon_list_controller extends company
{    
    //优惠券列表
    function index_action(){
 
        $couponM    =    $this    ->    MODEL('coupon');
        $couponM    ->    upCouponList(array('uid'=>$this->uid,'validity'=>array('<',time()),'status'=>'1'),array('status'=>'3'));
        $this        ->    public_action();
        $this        ->    company_satic();
        $urlarr['c']    =    'coupon_list';
        $urlarr["page"]    =    "{{page}}";
        $pageurl        =    Url('member',$urlarr);
        $where        =    array('uid'=>$this->uid,'orderby'=>'id,desc');
        $pageM        =    $this  -> MODEL('page');
        $pages        =    $pageM -> pageList('coupon_list',$where,$pageurl,$_GET['page']);
 
        if($pages['total'] > 0){
            
            $where['limit']        =    $pages['limit'];
            $rows                =    $couponM    ->    getCouponList($where,array('source'=>1));
            $this    ->    yunset("rows",$rows);
        }
         
        $this    ->    com_tpl('coupon_list');
    }
    //赠送优惠券搜索企业
    function searchcomname_action(){
        $name    =    trim($_POST['username']);
        if($name){
            $companyM    =    $this    ->    MODEL('company');
            $where        =    array(
                'name'        =>    array('like',$name),
                'uid'        =>    array('<>',$this->uid),
                'orderby'    =>    'lastupdate,desc',
                'limit'        =>    100
            );
            $company    =    $companyM    ->    getList($where,array('field'=>'`uid`,`name`','url'=>1));
 
            echo json_encode($company['list']);die;
        
        }
    }
    //赠送优惠券给指定企业
    function save_action(){
        $data['coupon']        =    intval($_POST['coupon']);
        $data['send']        =    1;
        $addData['uid']        =    intval($_POST['buid']);
        $addData['source']    =    $this    ->    uid;
        
        $where['uid']        =    $this    ->    uid;
        $couponM            =    $this    ->    MODEL('coupon');
        $return                =    $couponM->    upCouponList($where,$addData,$data);
        $this    ->    ACT_layer_msg($return['msg'],$return['cod'],$_SERVER['HTTP_REFERER']);
    }
    //删除优惠券
    function del_action(){
        if($_GET['id']){
            $data['uid']         =    $this    ->    uid;
            $data['usertype']    =    $this    ->    usertype;
            $where['uid']        =    $this    ->    uid;
            $where['id']        =    intval($_GET['id']);
            $where['status']    =    array('in',pylode(',',array('2','3')));
            $couponM            =    $this    ->    MODEL('coupon');
            $return                =    $couponM->    delCouponList($where,$data);
            
            $this    ->    layer_msg($return['msg'],$return['cod'],0,"index.php?c=coupon_list");
        }
    }
    //暂不确定
    function getCouponList_action() {
        
        if ($_POST) {
            
            $price      =   $_POST['price'];
            $type       =   $_POST['type'];
            $couponM    =   $this->MODEL('coupon');
            $couponList =   $couponM -> getCouponList(array('uid' => $this->uid));
            
            if (!empty($couponList) && is_array($couponList)) {
                
                $html  =   '';
                
                foreach ($couponList as $v){
                    
                    if ($v['coupon_scope'] <= $price && $v['status'] == 1 && $v['validity'] > time()) {
                         
                       $html   .=  "<li data-id='".$v['id']."' data-price='".$v['coupon_amount']."' data-name='".$v['coupon_name']."' data-type='".$type."'><span class='yun_purchase_yhq_xz'></span>".$v['coupon_name']."(满".$v['coupon_scope']."元可用)</li>";
                          
                    } 
                }
                
                $html  .=  '<li><span class="yun_purchase_yhq_xz"></span>不使用优惠券</li>';
            }else{
                
                $html   =  '<li><span class="yun_purchase_yhq_xz"></span>暂无可用优惠券</li>';
            }
            
            echo $html;die; 
        }
    }
}
?>