作者 chencheng

0601-6

... ... @@ -320,7 +320,7 @@ class Wechat extends Api
return $config;
}else{
Common::put_file_log('预下单是啊比',json_encode($result), 'prepare_order', __CLASS__ . __FUNCTION__ . __LINE__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($result),'time'=>time(),'action'=>'prepare_order']);
return $result;
}
... ... @@ -339,7 +339,7 @@ class Wechat extends Api
file_put_contents('1_notify.log',($xmljson),FILE_APPEND);
$message = json_decode($xmljson,true);
// 使用通知里的 "微信支付订单号" 或者 "商户订单号" 去自己的数据库找到订单
Common::put_file_log('支付成功-微信支付回调信息',json_encode($message), 'pay_notify', __CLASS__ . __FUNCTION__ . __LINE__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($message),'time'=>time(),'action'=>'pay_notify']);
$out_trade_no = $message['out_trade_no'];
if ($message['return_code'] === 'SUCCESS' && $message['result_code'] === 'SUCCESS') {
$o_w["order_no"] = $out_trade_no;
... ... @@ -390,7 +390,7 @@ class Wechat extends Api
try{
$this->getParent($myInfo['pid'],$order_info['verification_coupon_ids'],$order_info['id']);
}catch(\Exception $e){
Common::put_file_log('上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($e->getMessage()),'time'=>time(),'action'=>'sales_distribution']);
}
//上级的上级
try{
... ... @@ -400,7 +400,7 @@ class Wechat extends Api
$this->getParent($myInfoP['pid'],$order_info['verification_coupon_ids'],$order_info['id']);
}
}catch(\Exception $e){
Common::put_file_log('上级的上级-分销异常',json_encode($e->getMessage()), 'sales_distribution', __CLASS__ . __FUNCTION__ . __LINE__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($e->getMessage()),'time'=>time(),'action'=>'sales_distribution']);
}
}
}
... ... @@ -451,47 +451,7 @@ class Wechat extends Api
}
}
// 发放佣金 企业付款到零钱
public function grant_commission($pid=0,$order_id=0){
//测试 https://coupon.xp.yn.cn/api/v1/wechat/grant_commission
//$order_id = 14;
try{
$send_result = 0;
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
$verification_store = Db::name('verification_store')->where(['id'=>$verification_order['verification_store_id']])->find();
//测试发送红包 开始
$pid = 2;
$verification_store['commission'] = mt_rand(100,111)/100;
//测试结束
$user_info = Db::name('user')->where(['id'=>$pid])->find();
if(!empty($verification_store['commission'])){
$app = WehcatModule::getInstance()->initWechatPay();
$result = $app->transfer->toBalance([
'partner_trade_no' => $verification_order['order_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
'openid' => $user_info['openid'],
'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
're_user_name' => $user_info['nickname'], // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
'amount' =>$verification_store['commission']*100 , // 企业付款金额,单位为分
'desc' => '分销佣金', // 企业付款操作说明信息。必填
]);
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
//记录佣金表 后台没有配置
$send_result = 1;
}else{
Common::put_file_log('失败-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
}
}else{
}
$this->brokerage_record($verification_store,$user_info,$send_result,$verification_order);
}catch(\Exception $e){
Common::put_file_log('异常-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
}
}
// 发放红包 单位 分 最低100分,
... ... @@ -518,16 +478,16 @@ class Wechat extends Api
'act_name' => '佣金分享红包到账',
'remark' => '感谢您的参与',
]);
return json($result);
die;
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
//记录佣金表 verification_brokerage_record
$send_result = 1;
}
Common::put_file_log('红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($result),'time'=>time(),'action'=>'grant_red_packets']);
$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__);
Db::name('wechat_pay_recode')->insert(['json'=>json_encode($result),'time'=>time(),'action'=>'grant_red_packets']);
}
}
... ... @@ -553,7 +513,7 @@ class Wechat extends Api
$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__);
Db::name('wechat_pay_recode')->insert(['json'=>$e->getMessage(),'time'=>time()]);
}
}
... ...