正在显示
4 个修改的文件
包含
94 行增加
和
28 行删除
此 diff 太大无法显示。
@@ -20,6 +20,18 @@ use think\Validate; | @@ -20,6 +20,18 @@ use think\Validate; | ||
20 | */ | 20 | */ |
21 | class OrderController extends RestBaseController | 21 | class OrderController extends RestBaseController |
22 | { | 22 | { |
23 | + | ||
24 | + public function _initialize() | ||
25 | + { | ||
26 | + $user_id = $this->getUserId(); | ||
27 | + $data = Db::name('integral') | ||
28 | + ->where('user_id',$user_id) | ||
29 | + ->find(); | ||
30 | + if(empty($data)){ | ||
31 | + $this->error(['code'=>40005,'msg'=>'请先注册']); | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
23 | /** | 35 | /** |
24 | * @title 创建订单 | 36 | * @title 创建订单 |
25 | * @description | 37 | * @description |
@@ -36,12 +48,6 @@ class OrderController extends RestBaseController | @@ -36,12 +48,6 @@ class OrderController extends RestBaseController | ||
36 | */ | 48 | */ |
37 | public function createOrder(){ | 49 | public function createOrder(){ |
38 | $user_id = $this->getUserId(); | 50 | $user_id = $this->getUserId(); |
39 | - $data = Db::name('integral') | ||
40 | - ->where('user_id',$user_id) | ||
41 | - ->find(); | ||
42 | - if(empty($data)){ | ||
43 | - $this->error('请先注册!'); | ||
44 | - } | ||
45 | $total = $this->request->param('total'); | 51 | $total = $this->request->param('total'); |
46 | $pay_id = $this->request->param('pay_id'); | 52 | $pay_id = $this->request->param('pay_id'); |
47 | if(empty($total)){ | 53 | if(empty($total)){ |
@@ -107,4 +113,53 @@ class OrderController extends RestBaseController | @@ -107,4 +113,53 @@ class OrderController extends RestBaseController | ||
107 | return $openid; | 113 | return $openid; |
108 | } | 114 | } |
109 | 115 | ||
116 | + /** | ||
117 | + * @title 提现 | ||
118 | + * @author Guosheng | ||
119 | + * @url /index/order/pay | ||
120 | + * @method GET | ||
121 | + * | ||
122 | + * @header name:XX-Token require:1 default: desc:token | ||
123 | + * | ||
124 | + * @param name:order_id type:int require:1 other: desc:订单id | ||
125 | + */ | ||
126 | + public function deposit() | ||
127 | + { | ||
128 | + $id = $this->getUserId(); | ||
129 | + | ||
130 | + } | ||
131 | + | ||
132 | + /** | ||
133 | + * @title 积分明细 | ||
134 | + * @description | ||
135 | + * @author GuoSheng | ||
136 | + * @url /index/Order/detail | ||
137 | + * @method GET | ||
138 | + * | ||
139 | + * @header name:XX-Token require:1 default: desc:token | ||
140 | + * | ||
141 | + * @param name:page type:int require:0 other: desc:当前页(默认1) | ||
142 | + * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10) | ||
143 | + * | ||
144 | + * @return type:类型(1充值,2兑换商品,3获得奖励,4提现) | ||
145 | + * @return total: 变动的积分 | ||
146 | + * @return create_time: 创建时间 | ||
147 | + */ | ||
148 | + public function detail() | ||
149 | + { | ||
150 | + $user_id = $this->getUserId(); | ||
151 | + $page = $this->request->param('page',1,'intval'); | ||
152 | + $pageNum = $this->request->param('pageNum',10,'intval'); | ||
153 | + $list = Db::name('detail') | ||
154 | + ->where('user_id',$user_id) | ||
155 | + ->field('id,user_id,type,total,create_time') | ||
156 | + ->page($page,$pageNum) | ||
157 | + ->select(); | ||
158 | + foreach ($list as &$v){ | ||
159 | + $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']); | ||
160 | + } | ||
161 | + $this->success('SUCCESS',$list); | ||
162 | + } | ||
163 | + | ||
164 | + | ||
110 | } | 165 | } |
@@ -95,15 +95,17 @@ class PayController extends HomeBaseController | @@ -95,15 +95,17 @@ class PayController extends HomeBaseController | ||
95 | $list = Db::name('integral') | 95 | $list = Db::name('integral') |
96 | ->where('user_id',$order['user_id']) | 96 | ->where('user_id',$order['user_id']) |
97 | ->find(); | 97 | ->find(); |
98 | - $res['now'] = $list['now']; | ||
99 | - $res['before_wallet'] = $list['before_wallet']; | 98 | + $res['before_wallet'] = $list['now_integral']; |
100 | $res['total'] = $arr['integral']; | 99 | $res['total'] = $arr['integral']; |
101 | $res['after_wallet'] = $arr['before_wallet'] + $arr['integral']; | 100 | $res['after_wallet'] = $arr['before_wallet'] + $arr['integral']; |
102 | - $res['add_total'] = $res['add_total'] + $arr['integral']; | ||
103 | $res['type'] = 1; | 101 | $res['type'] = 1; |
104 | - Db::name('integral') | 102 | + Db::name('detail') |
105 | ->where('user_id',$order['user_id']) | 103 | ->where('user_id',$order['user_id']) |
106 | ->update($res); | 104 | ->update($res); |
105 | + $after_wallet = $res['after_wallet']; | ||
106 | + Db::name('integral') | ||
107 | + ->where('user_id',$order['user_id']) | ||
108 | + ->update(['now_integral'=>$after_wallet]); | ||
107 | } else { // 用户支付失败 | 109 | } else { // 用户支付失败 |
108 | $update['status']=1; | 110 | $update['status']=1; |
109 | } | 111 | } |
@@ -145,5 +147,32 @@ class PayController extends HomeBaseController | @@ -145,5 +147,32 @@ class PayController extends HomeBaseController | ||
145 | return $url; | 147 | return $url; |
146 | } | 148 | } |
147 | 149 | ||
150 | + /** | ||
151 | + * 微信提现 | ||
152 | + * @param $data | ||
153 | + * @return mixed | ||
154 | + */ | ||
155 | + public function tixian($data) | ||
156 | + { | ||
157 | + $merchantPayData = [ | ||
158 | + 'partner_trade_no' => $data['num'], //随机字符串作为订单号,跟红包和支付一个概念。 | ||
159 | + 'openid' => $data['openid'], //收款人的openid | ||
160 | + 'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK | ||
161 | + 're_user_name'=>'', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交 | ||
162 | + 'amount' => (1-0.006)*$data['total']*100, //单位为分 | ||
163 | + 'desc' => '提现', | ||
164 | + 'spbill_create_ip' => '192.168.0.1', //发起交易的IP地址 | ||
165 | + ]; | ||
166 | + $app = new Application($this->options); | ||
167 | + | ||
168 | + $merchantPay = $app->merchant_pay; | ||
169 | + $result = $merchantPay->send($merchantPayData); | ||
170 | + if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') { | ||
171 | + return $result->code_url; | ||
172 | + } else { | ||
173 | + $this->error('支付参数错误', '', $result); | ||
174 | + } | ||
175 | + } | ||
176 | + | ||
148 | 177 | ||
149 | } | 178 | } |
@@ -192,22 +192,4 @@ class UserController extends RestBaseController | @@ -192,22 +192,4 @@ class UserController extends RestBaseController | ||
192 | $this->success('SUCCESS',$data); | 192 | $this->success('SUCCESS',$data); |
193 | } | 193 | } |
194 | 194 | ||
195 | - /** | ||
196 | - * @title 提现 | ||
197 | - * @author Guosheng | ||
198 | - * @url /index/order/pay | ||
199 | - * @method GET | ||
200 | - * | ||
201 | - * @header name:XX-Token require:1 default: desc:token | ||
202 | - * | ||
203 | - * @param name:order_id type:int require:1 other: desc:订单id | ||
204 | - */ | ||
205 | - public function deposit() | ||
206 | - { | ||
207 | - $id = $this->getUserId(); | ||
208 | - | ||
209 | - } | ||
210 | - | ||
211 | - | ||
212 | - | ||
213 | } | 195 | } |
-
请 注册 或 登录 后发表评论