Merge branch 'master' of http://47.108.67.251:8099/coupon.xp.yn.cn/coupon_backend
正在显示
1 个修改的文件
包含
32 行增加
和
8 行删除
@@ -324,6 +324,9 @@ class Wechat extends Api | @@ -324,6 +324,9 @@ class Wechat extends Api | ||
324 | */ | 324 | */ |
325 | public function notify(){ | 325 | public function notify(){ |
326 | $app = WehcatModule::getInstance()->initWechatPay(); | 326 | $app = WehcatModule::getInstance()->initWechatPay(); |
327 | + $xml = file_get_contents("php://input"); | ||
328 | + $xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON | ||
329 | + Common::put_file_log('支付回调记录-微信支付回调信息',$xmljson, 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); | ||
327 | $response = $app->handlePaidNotify(function($message, $fail){ | 330 | $response = $app->handlePaidNotify(function($message, $fail){ |
328 | // 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单 | 331 | // 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单 |
329 | Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); | 332 | Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); |
@@ -331,7 +334,15 @@ class Wechat extends Api | @@ -331,7 +334,15 @@ class Wechat extends Api | ||
331 | if ($message['return_code'] === 'SUCCESS' && $message['result_code'] === 'SUCCESS') { | 334 | if ($message['return_code'] === 'SUCCESS' && $message['result_code'] === 'SUCCESS') { |
332 | $o_w["order_no"] = $out_trade_no; | 335 | $o_w["order_no"] = $out_trade_no; |
333 | $order_info = Db::name('verification_order')->where($o_w)->find(); | 336 | $order_info = Db::name('verification_order')->where($o_w)->find(); |
334 | - $this->sales_distribution($order_info); | 337 | + if($order_info['type'] != 2){ |
338 | + //1. 更改状态信息 | ||
339 | + $up['type'] = 2; | ||
340 | + $up['paytime'] = time(); | ||
341 | + $up['payMode'] = '0'; | ||
342 | + Db::name('verification_order')->where($o_w)->update($up); | ||
343 | + //2. 分销处理 | ||
344 | + $this->sales_distribution($order_info); | ||
345 | + } | ||
335 | } else { | 346 | } else { |
336 | Common::put_file_log('支付失败-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); | 347 | Common::put_file_log('支付失败-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__); |
337 | } | 348 | } |
@@ -363,11 +374,20 @@ class Wechat extends Api | @@ -363,11 +374,20 @@ class Wechat extends Api | ||
363 | //是否与上级 | 374 | //是否与上级 |
364 | if(!empty($myInfo['pid'])){ | 375 | if(!empty($myInfo['pid'])){ |
365 | //上级 | 376 | //上级 |
366 | - $this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']); | 377 | + try{ |
378 | + $this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']); | ||
379 | + }catch(\Exception $e){ | ||
380 | + Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); | ||
381 | + } | ||
367 | //上级的上级 | 382 | //上级的上级 |
368 | - $w1['id'] = $myInfo['pid']; | ||
369 | - $myInfoP = Db::name('user')->where($w1)->find(); | ||
370 | - $this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']); | 383 | + try{ |
384 | + $w1['id'] = $myInfo['pid']; | ||
385 | + $myInfoP = Db::name('user')->where($w1)->find(); | ||
386 | + $this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']); | ||
387 | + }catch(\Exception $e){ | ||
388 | + Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__); | ||
389 | + } | ||
390 | + | ||
371 | 391 | ||
372 | } | 392 | } |
373 | } | 393 | } |
@@ -376,12 +396,13 @@ class Wechat extends Api | @@ -376,12 +396,13 @@ class Wechat extends Api | ||
376 | private function getParent($pid,$verification_store_id,$order_id){ | 396 | private function getParent($pid,$verification_store_id,$order_id){ |
377 | //上级身份 | 397 | //上级身份 |
378 | $time = time(); | 398 | $time = time(); |
399 | + $w1 = []; | ||
379 | $w1['user_id'] = $pid; | 400 | $w1['user_id'] = $pid; |
380 | $w1['verification_store_id'] = $verification_store_id; | 401 | $w1['verification_store_id'] = $verification_store_id; |
381 | $role = Db::name('verification_staff')->where($w1)->find(); | 402 | $role = Db::name('verification_staff')->where($w1)->find(); |
382 | if(in_array($role['type'],['1','3'])){ | 403 | if(in_array($role['type'],['1','3'])){ |
383 | //属于代理 企业付款到佣金 | 404 | //属于代理 企业付款到佣金 |
384 | - $this->grant_commission($pid,$order_id); | 405 | + //$this->grant_commission($pid,$order_id); |
385 | }else{ | 406 | }else{ |
386 | //属于普通用户 发送代金券 | 407 | //属于普通用户 发送代金券 |
387 | $this->send_voucher($pid,$verification_store_id,$order_id,$time); | 408 | $this->send_voucher($pid,$verification_store_id,$order_id,$time); |
@@ -390,6 +411,7 @@ class Wechat extends Api | @@ -390,6 +411,7 @@ class Wechat extends Api | ||
390 | 411 | ||
391 | //发放代金券 | 412 | //发放代金券 |
392 | public function send_voucher($pid,$verification_store_id,$order_id,$time){ | 413 | public function send_voucher($pid,$verification_store_id,$order_id,$time){ |
414 | + $w1 = []; | ||
393 | $w1['verification_store_id'] = $verification_store_id; | 415 | $w1['verification_store_id'] = $verification_store_id; |
394 | $w1['closetime'] = ['<',$time]; | 416 | $w1['closetime'] = ['<',$time]; |
395 | $coupon = Db::name('verification_coupon')->where($w1)->select(); | 417 | $coupon = Db::name('verification_coupon')->where($w1)->select(); |
@@ -414,7 +436,8 @@ class Wechat extends Api | @@ -414,7 +436,8 @@ class Wechat extends Api | ||
414 | } | 436 | } |
415 | } | 437 | } |
416 | } | 438 | } |
417 | - // 发放佣金 | 439 | + |
440 | + // 发放佣金 企业付款到零钱 | ||
418 | public function grant_commission($pid=0,$order_id=0){ | 441 | public function grant_commission($pid=0,$order_id=0){ |
419 | try{ | 442 | try{ |
420 | $verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find(); | 443 | $verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find(); |
@@ -428,7 +451,8 @@ class Wechat extends Api | @@ -428,7 +451,8 @@ class Wechat extends Api | ||
428 | 'desc' => '理赔', // 企业付款操作说明信息。必填 | 451 | 'desc' => '理赔', // 企业付款操作说明信息。必填 |
429 | ]); | 452 | ]); |
430 | if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){ | 453 | if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){ |
431 | - //记录佣金表 | 454 | + //记录佣金表 后台没有配置 |
455 | + | ||
432 | }else{ | 456 | }else{ |
433 | Common::put_file_log('失败-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__); | 457 | Common::put_file_log('失败-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__); |
434 | } | 458 | } |
-
请 注册 或 登录 后发表评论