...
|
...
|
@@ -324,6 +324,9 @@ class Wechat extends Api |
|
|
*/
|
|
|
public function notify(){
|
|
|
$app = WehcatModule::getInstance()->initWechatPay();
|
|
|
$xml = file_get_contents("php://input");
|
|
|
$xmljson= json_encode(simplexml_load_string($xml, 'SimplexmlElement', LIBXML_NOCDATA ));//将对象转换个JSON
|
|
|
Common::put_file_log('支付回调记录-微信支付回调信息',$xmljson, 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
$response = $app->handlePaidNotify(function($message, $fail){
|
|
|
// 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
|
|
|
Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
|
...
|
...
|
@@ -331,7 +334,15 @@ class Wechat extends Api |
|
|
if ($message['return_code'] === 'SUCCESS' && $message['result_code'] === 'SUCCESS') {
|
|
|
$o_w["order_no"] = $out_trade_no;
|
|
|
$order_info = Db::name('verification_order')->where($o_w)->find();
|
|
|
$this->sales_distribution($order_info);
|
|
|
if($order_info['type'] != 2){
|
|
|
//1. 更改状态信息
|
|
|
$up['type'] = 2;
|
|
|
$up['paytime'] = time();
|
|
|
$up['payMode'] = '0';
|
|
|
Db::name('verification_order')->where($o_w)->update($up);
|
|
|
//2. 分销处理
|
|
|
$this->sales_distribution($order_info);
|
|
|
}
|
|
|
} else {
|
|
|
Common::put_file_log('支付失败-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
...
|
...
|
@@ -363,11 +374,20 @@ class Wechat extends Api |
|
|
//是否与上级
|
|
|
if(!empty($myInfo['pid'])){
|
|
|
//上级
|
|
|
$this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
try{
|
|
|
$this->getParent($myInfo['pid'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
}catch(\Exception $e){
|
|
|
Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
//上级的上级
|
|
|
$w1['id'] = $myInfo['pid'];
|
|
|
$myInfoP = Db::name('user')->where($w1)->find();
|
|
|
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
try{
|
|
|
$w1['id'] = $myInfo['pid'];
|
|
|
$myInfoP = Db::name('user')->where($w1)->find();
|
|
|
$this->getParent($myInfoP['id'],$order_info['verification_store_id'],$order_info['id']);
|
|
|
}catch(\Exception $e){
|
|
|
Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -376,12 +396,13 @@ class Wechat extends Api |
|
|
private function getParent($pid,$verification_store_id,$order_id){
|
|
|
//上级身份
|
|
|
$time = time();
|
|
|
$w1 = [];
|
|
|
$w1['user_id'] = $pid;
|
|
|
$w1['verification_store_id'] = $verification_store_id;
|
|
|
$role = Db::name('verification_staff')->where($w1)->find();
|
|
|
if(in_array($role['type'],['1','3'])){
|
|
|
//属于代理 企业付款到佣金
|
|
|
$this->grant_commission($pid,$order_id);
|
|
|
//$this->grant_commission($pid,$order_id);
|
|
|
}else{
|
|
|
//属于普通用户 发送代金券
|
|
|
$this->send_voucher($pid,$verification_store_id,$order_id,$time);
|
...
|
...
|
@@ -390,6 +411,7 @@ class Wechat extends Api |
|
|
|
|
|
//发放代金券
|
|
|
public function send_voucher($pid,$verification_store_id,$order_id,$time){
|
|
|
$w1 = [];
|
|
|
$w1['verification_store_id'] = $verification_store_id;
|
|
|
$w1['closetime'] = ['<',$time];
|
|
|
$coupon = Db::name('verification_coupon')->where($w1)->select();
|
...
|
...
|
@@ -414,7 +436,8 @@ class Wechat extends Api |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 发放佣金
|
|
|
|
|
|
// 发放佣金 企业付款到零钱
|
|
|
public function grant_commission($pid=0,$order_id=0){
|
|
|
try{
|
|
|
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
...
|
...
|
@@ -428,7 +451,8 @@ class Wechat extends Api |
|
|
'desc' => '理赔', // 企业付款操作说明信息。必填
|
|
|
]);
|
|
|
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
|
|
|
//记录佣金表
|
|
|
//记录佣金表 后台没有配置
|
|
|
|
|
|
}else{
|
|
|
Common::put_file_log('失败-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
...
|
...
|
|