作者 chencheng

0601-5

... ... @@ -507,8 +507,9 @@ class Wechat extends Api
$user_info = Db::name('user')->where(['id'=>$pid])->find();
$total_amount = $verification_store['commission'] * 100;
$app = WehcatModule::getInstance()->initWechatPay();
$mch_billno=time().rand(10000,99999);
$result = $app->redpack->sendNormal([
'mch_billno' => $verification_order['order_no'],
'mch_billno' => $mch_billno,
'send_name' => '佣金红包',
're_openid' => $user_info['openid'],
'total_num' => 1, //固定为1,可不传
... ... @@ -524,14 +525,14 @@ class Wechat extends Api
$send_result = 1;
}
Common::put_file_log('红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
$this->brokerage_record($verification_store,$user_info,$send_result,$verification_order);
$this->brokerage_record($verification_store,$user_info,$send_result,$verification_order,$mch_billno);
}catch(\Exception $e){
Common::put_file_log('异常-红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
}
}
//佣金发放记录
private function brokerage_record($verification_store,$user_info,$send_result,$verification_order){
private function brokerage_record($verification_store,$user_info,$send_result,$verification_order,$mch_billno){
//关于该笔订单是否有发送给这个人
// $w_re = [];
// $w_re['order_id'] = $verification_order['id'];
... ... @@ -549,6 +550,7 @@ class Wechat extends Api
$record['send_result'] = $send_result;
$record['send_reason'] = 'ID:'.$user_info['id'].'分享给ID:'.$verification_order['user_id'].',并且成功支付ID:'.$verification_order['id'];
$record['order_id'] = $verification_order['id'];
$record['mch_billno'] = $mch_billno;
Db::name('verification_brokerage_record')->insert($record);
}catch(\Exception $e){
Common::put_file_log('佣金记录失败',$e->getMessage(), 'brokerage_record', __CLASS__ . __FUNCTION__ . __LINE__);
... ...