正在显示
7 个修改的文件
包含
195 行增加
和
82 行删除
@@ -14,7 +14,6 @@ return array( | @@ -14,7 +14,6 @@ return array( | ||
14 | 'mch_id' => '1515355581', //支付商户ID | 14 | 'mch_id' => '1515355581', //支付商户ID |
15 | 'key' => 'cccccccccccccccccccccccccccccc00', | 15 | 'key' => 'cccccccccccccccccccccccccccccc00', |
16 | // 'notify_url' => '/addons/epay/api/notify/type/wechat', //请勿修改此配置 | 16 | // 'notify_url' => '/addons/epay/api/notify/type/wechat', //请勿修改此配置 |
17 | -// 'notify_url' => 'http://feipin.w.brotop.cn/api/Wxpay/notify', //请勿修改此配置 | ||
18 | 'cert_client' => '/epay/certs/apiclient_cert.pem', // 可选, 退款,红包等情况时需要用到 | 17 | 'cert_client' => '/epay/certs/apiclient_cert.pem', // 可选, 退款,红包等情况时需要用到 |
19 | 'cert_key' => '/epay/certs/apiclient_key.pem',// 可选, 退款,红包等情况时需要用到 | 18 | 'cert_key' => '/epay/certs/apiclient_key.pem',// 可选, 退款,红包等情况时需要用到 |
20 | 'log' => 1, | 19 | 'log' => 1, |
@@ -105,9 +105,6 @@ class Api extends Controller | @@ -105,9 +105,6 @@ class Api extends Controller | ||
105 | echo '签名错误'; | 105 | echo '签名错误'; |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | - //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 | ||
109 | -// $porderModel = new Porder(); | ||
110 | -// $porderModel->where(['pay_order_sn' => $pay->out_trade_no, 'uid' => $this->user_id])->update(['status'=>$this->order_status[1]]); | ||
111 | //下面这句必须要执行,且在此之前不能有任何输出 | 108 | //下面这句必须要执行,且在此之前不能有任何输出 |
112 | echo $pay->success(); | 109 | echo $pay->success(); |
113 | return; | 110 | return; |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\api\controller; | 3 | namespace app\api\controller; |
4 | 4 | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | +use app\admin\model\Bank; | ||
6 | use think\Db; | 7 | use think\Db; |
7 | use think\Validate; | 8 | use think\Validate; |
8 | /** | 9 | /** |
@@ -42,6 +43,7 @@ class Person extends Api | @@ -42,6 +43,7 @@ class Person extends Api | ||
42 | "company_name": "",//公司名字 | 43 | "company_name": "",//公司名字 |
43 | "license_num": "",//公司编码 | 44 | "license_num": "",//公司编码 |
44 | "license_img": ""//公司营业执照 | 45 | "license_img": ""//公司营业执照 |
46 | + "money":100//账户余额 | ||
45 | } | 47 | } |
46 | }) | 48 | }) |
47 | */ | 49 | */ |
@@ -49,7 +51,7 @@ class Person extends Api | @@ -49,7 +51,7 @@ class Person extends Api | ||
49 | if($this->request->isGet()){ | 51 | if($this->request->isGet()){ |
50 | $data = Db::table('gc_user') | 52 | $data = Db::table('gc_user') |
51 | ->where(['id'=>$this->user_id]) | 53 | ->where(['id'=>$this->user_id]) |
52 | - ->field('id,username,mobile,type,address,id_num,id_img,company_name,license_num,license_img') | 54 | + ->field('id,username,mobile,type,address,id_num,id_img,company_name,license_num,license_img,money') |
53 | ->find(); | 55 | ->find(); |
54 | $this->success('成功', $data); | 56 | $this->success('成功', $data); |
55 | }else{ | 57 | }else{ |
@@ -158,4 +160,84 @@ class Person extends Api | @@ -158,4 +160,84 @@ class Person extends Api | ||
158 | } | 160 | } |
159 | $this->success('上传成功',rtrim($images,',')); | 161 | $this->success('上传成功',rtrim($images,',')); |
160 | } | 162 | } |
163 | + | ||
164 | + /** | ||
165 | + * @ApiTitle (账单明细) | ||
166 | + * @ApiSummary (账单明细) | ||
167 | + * @ApiMethod (POST) | ||
168 | + * @ApiRoute (/api/person/accountDetail) | ||
169 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
170 | + * @ApiParams (name="page", type="integer", required=true, description="分页页码") | ||
171 | + * @ApiReturn ({ | ||
172 | + "code": 1, | ||
173 | + "msg": "成功", | ||
174 | + "time": "1554270371", | ||
175 | + "data": [ | ||
176 | + { | ||
177 | + "id": 1, | ||
178 | + "type": 0,//类型 0:充值 1:提现 | ||
179 | + "money": 0.01,//充值或提现金额 | ||
180 | + "createtime": "2019-04-03 13:03:57"//时间 | ||
181 | + } | ||
182 | + ] | ||
183 | + }) | ||
184 | + */ | ||
185 | + public function accountDetail(){ | ||
186 | + if($this->request->isGet()){ | ||
187 | + $page = $this->request->get('page');//分页页码 | ||
188 | + $limit = config('site.page_limit');//分页限制数量 | ||
189 | + $rule = config('site.gift_pages'); | ||
190 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
191 | + if (!$validate->check(['page'=>$page])) { | ||
192 | + $this->error($validate->getError()); | ||
193 | + } | ||
194 | + $data = Db::table('gc_account') | ||
195 | + ->where(['uid'=>$this->user_id]) | ||
196 | + ->page($page,$limit) | ||
197 | + ->field('id,type,money,createtime') | ||
198 | + ->select(); | ||
199 | + foreach($data as &$value){ | ||
200 | + $value['createtime'] = date('Y-m-d H:i:s',$value['createtime']); | ||
201 | + } | ||
202 | + $this->success('成功', $data); | ||
203 | + }else{ | ||
204 | + $this->error('请求方式错误'); | ||
205 | + } | ||
206 | + } | ||
207 | + | ||
208 | + /** | ||
209 | + * @ApiTitle (绑定银行卡) | ||
210 | + * @ApiSummary (绑定银行卡) | ||
211 | + * @ApiMethod (POST) | ||
212 | + * @ApiRoute (/api/person/bindBank) | ||
213 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
214 | + * @ApiParams (name="bank_num", type="integer", required=true, description="银行卡号") | ||
215 | + * @ApiParams (name="open_bank", type="string", required=true, description="开会行") | ||
216 | + * @ApiReturn ({ | ||
217 | + "code": 1, | ||
218 | + "msg": "保存成功", | ||
219 | + "time": "1554270371", | ||
220 | + "data": null | ||
221 | + }) | ||
222 | + */ | ||
223 | + public function bindBank(){ | ||
224 | + if($this->request->isPost()) { | ||
225 | + $bank_num = $this->request->post('bank_num');//银行卡号 | ||
226 | + $open_bank = $this->request->post('open_bank');//开户行 | ||
227 | + $rule = config('site.bank'); | ||
228 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
229 | + if (!$validate->check(['bank_num'=>$bank_num,'open_bank'=>$open_bank])) { | ||
230 | + $this->error($validate->getError()); | ||
231 | + } | ||
232 | + $bank = new Bank(); | ||
233 | + $data = $bank::create(['uid'=>$this->user_id,'bank_num'=>$bank_num,'open_bank'=>$open_bank]); | ||
234 | + if($data){ | ||
235 | + $this->success('保存成功'); | ||
236 | + }else{ | ||
237 | + $this->error('保存失败'); | ||
238 | + } | ||
239 | + }else{ | ||
240 | + $this->error('请求方式错误'); | ||
241 | + } | ||
242 | + } | ||
161 | } | 243 | } |
@@ -4,7 +4,7 @@ namespace app\api\controller; | @@ -4,7 +4,7 @@ namespace app\api\controller; | ||
4 | 4 | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | use app\admin\model\User; | 6 | use app\admin\model\User; |
7 | -use app\admin\model\OffLine; | 7 | +use app\admin\model\off\Line; |
8 | use think\Validate; | 8 | use think\Validate; |
9 | /** | 9 | /** |
10 | * 卖废品接口** | 10 | * 卖废品接口** |
@@ -54,7 +54,7 @@ class Sell extends Api | @@ -54,7 +54,7 @@ class Sell extends Api | ||
54 | $score = config('site.share_sell'); | 54 | $score = config('site.share_sell'); |
55 | $user = new User(); | 55 | $user = new User(); |
56 | $user->where(['id'=>$sell_data['share_uid'],'status'=>'normal'])->setInc('score', $score); | 56 | $user->where(['id'=>$sell_data['share_uid'],'status'=>'normal'])->setInc('score', $score); |
57 | - $offlineModel = new OffLine(); | 57 | + $offlineModel = new Line(); |
58 | $offlineModel->create(['uid'=>$sell_data['share_uid'],'s_score'=>$score,'off_uid'=>$this->user_id]); | 58 | $offlineModel->create(['uid'=>$sell_data['share_uid'],'s_score'=>$score,'off_uid'=>$this->user_id]); |
59 | } | 59 | } |
60 | $sell = new \app\admin\model\Sell(); | 60 | $sell = new \app\admin\model\Sell(); |
@@ -8,7 +8,7 @@ use think\Validate; | @@ -8,7 +8,7 @@ use think\Validate; | ||
8 | /** | 8 | /** |
9 | * 系统消息接口 | 9 | * 系统消息接口 |
10 | */ | 10 | */ |
11 | -class Messages extends Api | 11 | +class Smessages extends Api |
12 | { | 12 | { |
13 | protected $noNeedLogin = []; | 13 | protected $noNeedLogin = []; |
14 | protected $noNeedRight = '*'; | 14 | protected $noNeedRight = '*'; |
@@ -24,7 +24,7 @@ class Messages extends Api | @@ -24,7 +24,7 @@ class Messages extends Api | ||
24 | * @ApiTitle (系统消息列表) | 24 | * @ApiTitle (系统消息列表) |
25 | * @ApiSummary (系统消息列表) | 25 | * @ApiSummary (系统消息列表) |
26 | * @ApiMethod (GET) | 26 | * @ApiMethod (GET) |
27 | - * @ApiRoute (/api/messages/getMessageList) | 27 | + * @ApiRoute (/api/smessages/getMessageList) |
28 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | 28 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") |
29 | * @ApiParams (name="page", type="integer", required=true, description="分页页码") | 29 | * @ApiParams (name="page", type="integer", required=true, description="分页页码") |
30 | * @ApiReturn ({ | 30 | * @ApiReturn ({ |
@@ -32,15 +32,17 @@ class Messages extends Api | @@ -32,15 +32,17 @@ class Messages extends Api | ||
32 | "msg": "成功", | 32 | "msg": "成功", |
33 | "time": "1553777266", | 33 | "time": "1553777266", |
34 | "data":{ | 34 | "data":{ |
35 | - "id": 1, | ||
36 | - "title": "系统消息",//系统消息标题 | ||
37 | - "is_read": 0 //系统消息是否已读 0:未读,1:已读 | 35 | + "id": 1, |
36 | + "title": "您有一个系统消息提示,请及时查看。",//提现系统消息标题 | ||
37 | + "type": 1,//类型 0:充值,1:提现 | ||
38 | + "is_read": 0 //系统消息是否已读 0:未读,1:已读 | ||
38 | }, | 39 | }, |
39 | { | 40 | { |
40 | - "id": 5, | ||
41 | - "title": "重大好消息1", | ||
42 | - "is_read": 0 | ||
43 | - } | 41 | + "id": 2, |
42 | + "title": "您有一个系统消息提示,请及时查看。",//提现系统消息标题 | ||
43 | + "type": 1,//类型 0:充值,1:提现 | ||
44 | + "is_read": 0 //系统消息是否已读 0:未读,1:已读 | ||
45 | + }, | ||
44 | }) | 46 | }) |
45 | */ | 47 | */ |
46 | public function getMessageList(){ | 48 | public function getMessageList(){ |
@@ -52,12 +54,13 @@ class Messages extends Api | @@ -52,12 +54,13 @@ class Messages extends Api | ||
52 | if (!$validate->check(['page'=>$page])) { | 54 | if (!$validate->check(['page'=>$page])) { |
53 | $this->error($validate->getError()); | 55 | $this->error($validate->getError()); |
54 | } | 56 | } |
57 | + $withdrawal = config('site.withdrawal'); | ||
55 | $data = Db::table('gc_message') | 58 | $data = Db::table('gc_message') |
56 | - ->alias('l') | ||
57 | - ->join('gc_message m','l.message_id = m.id','LEFT') | ||
58 | - ->where(['l.user_id'=>$this->user_id]) | 59 | + ->alias('m') |
60 | + ->join('gc_account a','m.account_id = a.id','LEFT') | ||
61 | + ->where(['a.uid'=>$this->user_id,'a.type'=>$withdrawal]) | ||
59 | ->page($page,$limit) | 62 | ->page($page,$limit) |
60 | - ->field('m.id,m.title,l.is_read') | 63 | + ->field('m.id,m.title,m.type,m.is_read') |
61 | ->select(); | 64 | ->select(); |
62 | $this->success('成功',$data); | 65 | $this->success('成功',$data); |
63 | }else{ | 66 | }else{ |
@@ -69,19 +72,22 @@ class Messages extends Api | @@ -69,19 +72,22 @@ class Messages extends Api | ||
69 | * @ApiTitle (系统消息详情) | 72 | * @ApiTitle (系统消息详情) |
70 | * @ApiSummary (系统消息详情) | 73 | * @ApiSummary (系统消息详情) |
71 | * @ApiMethod (GET) | 74 | * @ApiMethod (GET) |
72 | - * @ApiRoute (/api/messages/messageDetail) | 75 | + * @ApiRoute (/api/smessages/messageDetail) |
73 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | 76 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") |
74 | * @ApiParams (name="page", type="integer", required=true, description="分页页码") | 77 | * @ApiParams (name="page", type="integer", required=true, description="分页页码") |
75 | * @ApiReturn ({ | 78 | * @ApiReturn ({ |
76 | "code": 1, | 79 | "code": 1, |
77 | "msg": "成功", | 80 | "msg": "成功", |
78 | - "time": "1553777266", | ||
79 | - "data":{ | ||
80 | - "id": 5, | ||
81 | - "title": "重大好消息1",//系统消息标题 | ||
82 | - "description": "系统消息系统消息详情“, | ||
83 | - "createtime": "2019-03-20 16:24:48" | 81 | + "time": "1554262435", |
82 | + "data": [ | ||
83 | + { | ||
84 | + "id": 1, | ||
85 | + "title": "您有一个系统消息提示,请及时查看。", | ||
86 | + "type": 1,//类型 0:充值,1:提现 | ||
87 | + "money": 0.01,//充值或提现金额 | ||
88 | + "createtime": "2019-04-03 11:00:29"//时间 | ||
84 | } | 89 | } |
90 | + ] | ||
85 | }) | 91 | }) |
86 | */ | 92 | */ |
87 | public function messageDetail(){ | 93 | public function messageDetail(){ |
@@ -92,17 +98,18 @@ class Messages extends Api | @@ -92,17 +98,18 @@ class Messages extends Api | ||
92 | if (!$validate->check(['id'=>$message_id])) { | 98 | if (!$validate->check(['id'=>$message_id])) { |
93 | $this->error($validate->getError()); | 99 | $this->error($validate->getError()); |
94 | } | 100 | } |
95 | - $data = Db::table('gc_message_log') | ||
96 | - ->alias('l') | ||
97 | - ->join('gc_message m','l.message_id = m.id','LEFT') | ||
98 | - ->where(['l.user_id'=>$this->user_id,'m.id'=>$message_id]) | ||
99 | - ->field('m.id,m.title,m.description,l.createtime') | 101 | + $withdrawal = config('site.withdrawal'); |
102 | + $data = Db::table('gc_message') | ||
103 | + ->alias('m') | ||
104 | + ->join('gc_account a','m.account_id = a.id','LEFT') | ||
105 | + ->where(['m.id'=>$message_id,'a.uid'=>$this->user_id,'a.type'=>$withdrawal]) | ||
106 | + ->field('m.id,m.title,m.type,a.money,m.createtime') | ||
100 | ->select(); | 107 | ->select(); |
101 | foreach($data as &$value){ | 108 | foreach($data as &$value){ |
102 | $value['createtime'] = date('Y-m-d H:i:s',$value['createtime']); | 109 | $value['createtime'] = date('Y-m-d H:i:s',$value['createtime']); |
103 | } | 110 | } |
104 | - Db::table('gc_message_log') | ||
105 | - ->where(['message_id'=>$message_id,'user_id'=>$this->user_id]) | 111 | + Db::table('gc_message') |
112 | + ->where(['id'=>$message_id]) | ||
106 | ->update(['is_read'=>$this->read,'readtime'=>time()]); | 113 | ->update(['is_read'=>$this->read,'readtime'=>time()]); |
107 | $this->success('成功',$data); | 114 | $this->success('成功',$data); |
108 | }else{ | 115 | }else{ |
@@ -9,6 +9,8 @@ use think\Db; | @@ -9,6 +9,8 @@ use think\Db; | ||
9 | use Yansongda\Pay\Pay; | 9 | use Yansongda\Pay\Pay; |
10 | use app\admin\model\Account; | 10 | use app\admin\model\Account; |
11 | use app\admin\model\User; | 11 | use app\admin\model\User; |
12 | +use app\admin\model\Message; | ||
13 | +use app\admin\model\off\Line; | ||
12 | use think\Log; | 14 | use think\Log; |
13 | use fast\Http; | 15 | use fast\Http; |
14 | use think\Validate; | 16 | use think\Validate; |
@@ -18,8 +20,8 @@ use Exception; | @@ -18,8 +20,8 @@ use Exception; | ||
18 | */ | 20 | */ |
19 | class Wxpay extends Api | 21 | class Wxpay extends Api |
20 | { | 22 | { |
21 | - protected $noNeedLogin = ['notify','wechatReturn','notifyCharge']; | ||
22 | - protected $noNeedRight = ['notify','wechatReturn','notifyCharge']; | 23 | + protected $noNeedLogin = ['notify','notifyCharge']; |
24 | + protected $noNeedRight = ['notify','notifyCharge']; | ||
23 | protected $user_id = '';//token存贮user_id | 25 | protected $user_id = '';//token存贮user_id |
24 | protected $order_status = [];//订单状态 | 26 | protected $order_status = [];//订单状态 |
25 | public function _initialize() | 27 | public function _initialize() |
@@ -37,6 +39,7 @@ class Wxpay extends Api | @@ -37,6 +39,7 @@ class Wxpay extends Api | ||
37 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | 39 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") |
38 | * @ApiParams (name="openid", type="string", required=true, description="小程序openid") | 40 | * @ApiParams (name="openid", type="string", required=true, description="小程序openid") |
39 | * @ApiParams (name="pay_order_sn", type="string", required=true, description="支付订单号") | 41 | * @ApiParams (name="pay_order_sn", type="string", required=true, description="支付订单号") |
42 | + * @ApiParams (name="share_uid", type="integer", required=false, description="分享用户id") | ||
40 | * @ApiReturn ({code: 0, msg: "无效的订单", time: "1554176100", data: null}) | 43 | * @ApiReturn ({code: 0, msg: "无效的订单", time: "1554176100", data: null}) |
41 | */ | 44 | */ |
42 | public function pay(){ | 45 | public function pay(){ |
@@ -45,7 +48,7 @@ class Wxpay extends Api | @@ -45,7 +48,7 @@ class Wxpay extends Api | ||
45 | $pay = Pay::wechat(Service::getConfig('wechat')); | 48 | $pay = Pay::wechat(Service::getConfig('wechat')); |
46 | $openid = $this->request->post('openid');//小程序传递openid | 49 | $openid = $this->request->post('openid');//小程序传递openid |
47 | $pay_order_sn = $this->request->post('pay_order_sn');//支付订单号 | 50 | $pay_order_sn = $this->request->post('pay_order_sn');//支付订单号 |
48 | - | 51 | + $share_uid = $this->request->post('share_uid');//分享用户uid |
49 | if(empty($openid) && empty($pay_order_sn)){ | 52 | if(empty($openid) && empty($pay_order_sn)){ |
50 | $this->error('无效的参数'); | 53 | $this->error('无效的参数'); |
51 | } | 54 | } |
@@ -76,9 +79,12 @@ class Wxpay extends Api | @@ -76,9 +79,12 @@ class Wxpay extends Api | ||
76 | // 'total_fee' => 1, | 79 | // 'total_fee' => 1, |
77 | 'total_fee' => floatval($total_price)*100,//单位:分 | 80 | 'total_fee' => floatval($total_price)*100,//单位:分 |
78 | 'openid' => $openid, | 81 | 'openid' => $openid, |
79 | - 'notify_url' => url('api/Wxpay/notify','','',true), | ||
80 | - 'return_url' => url('api/Wxpay/wechatReturn','','',true), | ||
81 | ]; | 82 | ]; |
83 | + if(!empty($share_uid)){ | ||
84 | + $order['notify_url'] = url('api/Wxpay/notify/share_uid/'.$share_uid,'','',true); | ||
85 | + }else{ | ||
86 | + $order['notify_url'] = url('api/Wxpay/notify','','',true); | ||
87 | + } | ||
82 | //跳转或输出 | 88 | //跳转或输出 |
83 | $this->success('成功',$pay->miniapp($order)); | 89 | $this->success('成功',$pay->miniapp($order)); |
84 | 90 | ||
@@ -125,36 +131,35 @@ class Wxpay extends Api | @@ -125,36 +131,35 @@ class Wxpay extends Api | ||
125 | } | 131 | } |
126 | 132 | ||
127 | /** | 133 | /** |
128 | - * 支付成功回调 | 134 | + * 微信异步通知 |
129 | */ | 135 | */ |
130 | public function notify(){ | 136 | public function notify(){ |
131 | - $pay = Service::checkNotify('wechat'); | ||
132 | - if (!$pay) { | ||
133 | - $this->error('签名错误'); | ||
134 | - } | ||
135 | - //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 | ||
136 | - $data = $pay->verify(); | ||
137 | - if($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') { | ||
138 | - $porderModel = new Porder(); | ||
139 | - $porderModel->where(['pay_order_sn'=>$data['out_trade_no']])->update(['status'=>$this->order_status[1]]); | ||
140 | - //下面这句必须要执行,且在此之前不能有任何输出 | ||
141 | - $this->success('成功',$pay->success()); | ||
142 | - } | ||
143 | - $this->success(); | ||
144 | - } | 137 | + $pay = Pay::wechat(Service::getConfig('wechat')); |
138 | + $share_uid = $this->request->param('share_uid'); | ||
139 | + try { | ||
140 | + $data = $pay->verify(); | ||
141 | + if($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS'){ | ||
142 | + $porderModel = new Porder(); | ||
143 | + $porderModel->where(['pay_order_sn'=>$data['out_trade_no']])->update(['status'=>$this->order_status[1]]); | ||
145 | 144 | ||
146 | - /** | ||
147 | - * 微信异步通知 | ||
148 | - */ | ||
149 | - public function wechatReturn(){ | ||
150 | - $pay = Service::checkReturn('wechat'); | ||
151 | - if (!$pay) { | ||
152 | - $this->error('签名错误'); | 145 | + //如果携带分享uid,则按照积分增加 |
146 | + if(!empty($share_uid)){ | ||
147 | + $score = config('site.share_purchase'); | ||
148 | + //给分享用户增加积分 | ||
149 | + $user = new User(); | ||
150 | + $user->where(['id'=>$share_uid,'status'=>'normal'])->setInc('score', $score); | ||
151 | + //成为分享用户的下线 | ||
152 | + $offlineModel = new Line(); | ||
153 | + $offlineModel->create(['uid'=>$share_uid,'s_score'=>$score,'off_uid'=>$this->user_id]); | ||
154 | + } | ||
155 | + } | ||
156 | + } catch (Exception $e) { | ||
157 | + echo "验签失败"; | ||
158 | + return; | ||
153 | } | 159 | } |
154 | - //你可以在这里定义你的提示信息,但切记不可在此编写逻辑 | ||
155 | - $this->success("恭喜你!支付成功!"); | ||
156 | - return; | 160 | + return $pay->success()->send(); |
157 | } | 161 | } |
162 | + | ||
158 | /** | 163 | /** |
159 | * @ApiTitle (充值) | 164 | * @ApiTitle (充值) |
160 | * @ApiSummary (充值) | 165 | * @ApiSummary (充值) |
@@ -188,7 +193,6 @@ class Wxpay extends Api | @@ -188,7 +193,6 @@ class Wxpay extends Api | ||
188 | 'total_fee' => floatval($amount)*100,//单位:分 | 193 | 'total_fee' => floatval($amount)*100,//单位:分 |
189 | 'openid' => $openid, | 194 | 'openid' => $openid, |
190 | 'notify_url' => url('api/Wxpay/notifyCharge','','',true), | 195 | 'notify_url' => url('api/Wxpay/notifyCharge','','',true), |
191 | - 'return_url' => url('api/Wxpay/wechatReturn','','',true), | ||
192 | ]; | 196 | ]; |
193 | //跳转或输出 | 197 | //跳转或输出 |
194 | $this->success('成功',$pay->miniapp($order)); | 198 | $this->success('成功',$pay->miniapp($order)); |
@@ -198,25 +202,35 @@ class Wxpay extends Api | @@ -198,25 +202,35 @@ class Wxpay extends Api | ||
198 | } | 202 | } |
199 | 203 | ||
200 | /** | 204 | /** |
201 | - * 充值成功回调 | 205 | + * 微信异步通知 |
202 | */ | 206 | */ |
203 | public function notifyCharge(){ | 207 | public function notifyCharge(){ |
204 | - $pay = Service::checkNotify('wechat'); | ||
205 | - if (!$pay) { | ||
206 | - $this->error('签名错误'); | ||
207 | - } | ||
208 | - //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 | ||
209 | - $data = $pay->verify(); | ||
210 | - if($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') { | ||
211 | - $userModel = new User(); | ||
212 | - $user = $userModel->where(['openid'=>$data['openid']])->find(); | ||
213 | - $accountModel = new Account(); | ||
214 | - $money = $data['total_fee']/100; | ||
215 | - $accountModel::create(['uid'=>$user['id'],'type'=>config('site.pay_charge'),'money'=>$money]); | ||
216 | - //下面这句必须要执行,且在此之前不能有任何输出 | ||
217 | - $this->success('成功',$pay->success()); | 208 | + $pay = Pay::wechat(Service::getConfig('wechat')); |
209 | + try { | ||
210 | + $data = $pay->verify(); | ||
211 | + //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 | ||
212 | + if($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS'){ | ||
213 | + $money = $data['total_fee'] / 100; | ||
214 | + $userModel = new User(); | ||
215 | + $user = $userModel->where(['openid' => $data['openid']])->find(); | ||
216 | + //给用户增加充值金额 | ||
217 | + $userModel->where(['openid' => $data['openid']])->setInc('money',$money); | ||
218 | + | ||
219 | + //充值记录 | ||
220 | + $accountModel = new Account(); | ||
221 | + $account = $accountModel::create(['uid' => $user['id'], 'money' => $money]); | ||
222 | + | ||
223 | + //系统充值消息 | ||
224 | + $messageModel = new Message(); | ||
225 | + $messageModel::create(['account_id' => $account->id, 'title' => config('site.message')]); | ||
226 | + Log::info('执行一次'); | ||
227 | + } | ||
228 | + } catch (Exception $e) { | ||
229 | + echo "验签失败"; | ||
230 | + return; | ||
218 | } | 231 | } |
219 | - $this->success(); | 232 | + //下面这句必须要执行,且在此之前不能有任何输出 |
233 | + return $pay->success()->send(); | ||
220 | } | 234 | } |
221 | 235 | ||
222 | } | 236 | } |
@@ -54,7 +54,9 @@ return array ( | @@ -54,7 +54,9 @@ return array ( | ||
54 | //消息已读 | 54 | //消息已读 |
55 | 'is_read' => 1, | 55 | 'is_read' => 1, |
56 | //充值 | 56 | //充值 |
57 | - 'pay_charge' => 1, | 57 | + 'pay_charge' => 0, |
58 | + //提现 | ||
59 | + 'withdrawal' => 1, | ||
58 | //系统消息提示 | 60 | //系统消息提示 |
59 | 'message'=>'您有一个系统消息提示,请及时查看。', | 61 | 'message'=>'您有一个系统消息提示,请及时查看。', |
60 | //设置积分规则(分享购买,分享卖废品) | 62 | //设置积分规则(分享购买,分享卖废品) |
@@ -280,4 +282,16 @@ return array ( | @@ -280,4 +282,16 @@ return array ( | ||
280 | 'o_id.number' => '订单id必须是数字', | 282 | 'o_id.number' => '订单id必须是数字', |
281 | ] | 283 | ] |
282 | ], | 284 | ], |
285 | + 'bank' => [ | ||
286 | + 'rule' => [ | ||
287 | + 'bank_num' => ['require','regex'=>'/^(\d{16}|\d{19})$/'], | ||
288 | + 'open_bank' => 'require|max:10', | ||
289 | + ], | ||
290 | + 'msg' => [ | ||
291 | + 'bank_num.require' => '银行卡号不能为空', | ||
292 | + 'bank_num' => '银行卡号格式不正确', | ||
293 | + 'open_bank.require' => '开户行不能为空', | ||
294 | + 'open_bank' => '开户行最多不超过10个字符', | ||
295 | + ] | ||
296 | + ], | ||
283 | ); | 297 | ); |
-
请 注册 或 登录 后发表评论