chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
 
class index_controller extends common{
    function public_action(){
        if($this->config['sy_redeem_web']=="2"){
            header("location:".Url('error'));
        }
    }
    function index_action(){
        $this->public_action();
        $statisM    =    $this->MODEL("statis");
        $redeemM    =    $this->MODEL("redeem");
        
        $statis    =    $statisM->getInfo($this->uid,array('usertype'=>$this->usertype,'field'=>'`integral`'));
        $this->yunset("statis",$statis);
        
        $lipin    =    $redeemM->getChangeList(array('status'=>1,'orderby'=>'id,desc','limit'=>10),array("field"=>"uid,username,name,ctime,integral,gid"));
        $this->yunset("lipin",$lipin['list']);
        
        $this->seo("redeem");
        $this->yun_tpl(array('index'));
    }
    function list_action(){
        $CacheM        =    $this->MODEL('cache');
        $CacheList    =    $CacheM->GetCache(array('redeem'));
        $this->yunset($CacheList);
        $integlist    =    array('1-300','300-1000','1000-5000','5000-10000','10000-50000','50000-100000','100000-500000');
        $this->yunset('integlist',$integlist);
        
        if($_GET['intinfo']){
            $intinfo    =    str_replace('_','-',$_GET['intinfo']);
            $this->yunset('intinfo',$intinfo);
        }
        $this->public_action();
        $this->seo("redeem");
        $this->yun_tpl(array('list'));
    }
    function show_action(){
        $this->public_action();
        $redeemM    =    $this->MODEL("redeem");
        $statisM    =    $this->MODEL("statis");
        
        $where['gid']        =    (int)$_GET['id'];
        $where['status']    =    1;
        //分页链接
        $urlarr['c']         =     $_GET['c']; 
        $urlarr['id']         =     (int)$_GET['id']; 
        $urlarr['page']     =     "{{page}}";
        $pageurl            =    Url('redeem',$urlarr);
        
        //提取分页
        $pageM                =    $this  -> MODEL('page');
        $pages                =    $pageM -> pageList('change',$where,$pageurl,$_GET['page']);
        
        //分页数大于0的情况下 执行列表查询
        if($pages['total'] > 0){
            
            
            $where['orderby']    =    'id,desc';
            
            $where['limit']        =    $pages['limit'];
            
            $List                =    $redeemM->getChangeList($where);
            
            $this->yunset("jilu",$List['list']);
        }
        $row    =    $redeemM->getInfo(array("id"=>(int)$_GET['id']));
        if($row['id']==''){
            $this->ACT_msg(Url('redeem'),"没有找到相关商品!");
        }
        $this->yunset("row",$row);
        $info    =    $statisM->getInfo($this->uid,array("usertype"=>$this->usertype,"field"=>"`integral`"));
        $this->yunset("info",$info);
        $this->seo("redeem");
        $this->yun_tpl(array('show'));
    }
    function dh_action(){
        $CacheM        =    $this->MODEL('cache');
        $CacheList    =    $CacheM->GetCache(array('city'));
        $this->yunset($CacheList);
        
        $this->public_action();
        
        $userinfoM        =    $this->MODEL("userinfo");
        $redeemM    =    $this->MODEL("redeem");
        $statisM    =    $this->MODEL("statis");
        
        if(!$this->uid && !$this->username){
             $this->ACT_msg($_SERVER['HTTP_REFERER'],"您还没有登录,请先登录!");
        }
        
        $info        =    $statisM->getInfo($this->uid,array("usertype"=>$this->usertype,"field"=>"`integral`"));
        $gift        =    $redeemM->getInfo(array("id"=>intval($_GET['id'])));
        
        $integral    =    $gift['integral']*intval($_GET['num']);
        
        if($info['integral']<$integral){
            
            $this->ACT_msg($_SERVER['HTTP_REFERER'],"您的".$this->config['integral_pricename']."是".$info['integral'].$this->config['integral_priceunit'].",不够兑换商品!");
            
        }
        $link        =    $userinfoM->getUserInfo(array("uid"=>(int)$this->uid),array('usertype'=>$this->usertype));
        
        if($this->usertype==1){
            
            $uinfo['linkman']        =    $link['name'];
            
            if($link['telphone']){
                $uinfo['moblie']    =    $link['telphone'];
            }elseif($link['telhome']){
                $uinfo['moblie']    =    $link['telhome'];
            }
        }elseif($this->usertype==2){
            
            $uinfo['linkman']        =    $link['linkman'];
            
            if($link['linktel']){
                $uinfo['moblie']    =    $link['linktel'];
            }elseif($link['linkphone']){
                $uinfo['moblie']    =    $link['linkphone'];
            }
        }elseif($this->usertype==3){
            
            $uinfo['linkman']        =    $link['realname'];
            
            if($link['moblie']){
                $uinfo['moblie']    =    $link['moblie'];
            }elseif($link['phone']){
                $uinfo['moblie']    =    $link['phone'];
            }
        }elseif($this->usertype==4){
            
            $uinfo['linkman']        =    $link['linkman'];
            
            if($link['linktel']){
                $uinfo['moblie']    =    $link['linktel'];
            }elseif($link['linkphone']){
                $uinfo['moblie']    =    $link['linkphone'];
            }
        }
        $this->yunset("uinfo",$uinfo);
        
        $row    =    $redeemM->getInfo(array("id"=>(int)$_GET['id']),array('field'=>'`id`,`name`,`pic`,`integral`'));
        $this->yunset("row",$row);
        
        $change =     $redeemM->getChangeInfo(array('uid'=>$this->uid),array('orderby'=>'id','desc'=>'desc','field'=>'body'));
        
        $body    =    explode(' ',$change['body']);
        
        if(count($body)>2){
            
            $change['province']        =    str_replace("收货地址:",'', $body['0']);
            $change['city']            =    $body['1'];
            $change['threecity']    =    $body['2'];
            $change['address']        =    $body['3'];
            $change['cityname']        =    str_replace("收货地址:",'', $body['0']).' '.$body['1'].' '.$body['2'];
            $change['body']            =    $change['cityname'].' '.$body['3'];
            $this->yunset('change',$change);
        }
        
        $this->yunset("title","兑换确认 - ".$this->config['sy_webname']);
        $this->yun_tpl(array('dh_show'));
    }
    function savedh_action(){
        $CacheM        =    $this->MODEL('cache');
        $CacheList    =    $CacheM->GetCache(array('city'));
        $post=array(
            
        );
        $data=array(
            'uid'            =>    $this->uid,
            'username'        =>    $this->username,
            'usertype'        =>    $this->usertype,
            'linkman'        =>    $_POST['linkman'],
            'linktel'        =>    $_POST['linktel'],
            'num'            =>    $_POST['num'],
            
            'id'            =>    (int)$_POST['id'],
            'provinceid'    =>    $CacheList['city_name'][$_POST['provinceid']],
            'cityid'        =>    $CacheList['city_name'][$_POST['cityid']],
            'three_cityid'    =>    $CacheList['city_name'][$_POST['three_cityid']],
            'address'        =>    $_POST['address'],
            'other'            =>    $_POST['other'],
            'password'        =>    $_POST['password'],
            'utype'            =>    'pc'
        );
        $redeemM    =    $this->MODEL("redeem");
        $return        =    $redeemM->AddChange($data);
        if($return['url']){
            $this->ACT_layer_msg($return['msg'],$return['errcode'],$return['url']);
        }else{
            $this->ACT_layer_msg($return['msg'],$return['errcode']);
        }
    }
}
?>