...
|
...
|
@@ -287,18 +287,22 @@ class Wechat extends Api |
|
|
*/
|
|
|
public function prepare_order($order_no = ''){
|
|
|
$user_id = $this->auth->id;
|
|
|
|
|
|
|
|
|
if(empty($user_id)){
|
|
|
return $this->error('预下单的用户信息错误');
|
|
|
}
|
|
|
|
|
|
$userInfo = Db::name('user')->where(['id'=>$user_id])->find();
|
|
|
|
|
|
$out_trade_no = $order_no;
|
|
|
$o_w["order_no"] = $out_trade_no;
|
|
|
$order_info = Db::name('verification_order')->where($o_w)->find();
|
|
|
$total_fee = $order_info['price'] = 1;//测试支付1分钱
|
|
|
$app = WehcatModule::getInstance()->initWechatPay();
|
|
|
$result = $app->order->unify([
|
|
|
'body' => '优惠券购买',
|
|
|
'out_trade_no' => $out_trade_no,
|
|
|
'total_fee' => 1,
|
|
|
'total_fee' => $total_fee,
|
|
|
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
|
|
|
'openid' => $userInfo['openid'],
|
|
|
]);
|
...
|
...
|
@@ -412,7 +416,6 @@ 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();
|
|
|
$app = WehcatModule::getInstance()->initWechatPay();
|
...
|
...
|
@@ -433,4 +436,32 @@ class Wechat extends Api |
|
|
Common::put_file_log('异常-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 发放红包
|
|
|
public function grant_red_packets($pid=0,$order_id=0){
|
|
|
try{
|
|
|
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
|
|
$app = WehcatModule::getInstance()->initWechatPay();
|
|
|
$result = $app->redpack->sendNormal([
|
|
|
|
|
|
'mch_billno' => '168532907259455',
|
|
|
'send_name' => '测试红包',
|
|
|
're_openid' => 'o5OQw6PPEGaHqIjAir7gqeDV5MzQ',
|
|
|
'total_num' => 1, //固定为1,可不传
|
|
|
'total_amount' => 100, //单位为分,不小于100
|
|
|
'wishing' => '祝福语',
|
|
|
|
|
|
'act_name' => '测试活动',
|
|
|
'remark' => '测试备注',
|
|
|
]);
|
|
|
if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
|
|
|
//记录佣金表
|
|
|
}else{
|
|
|
Common::put_file_log('失败-红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
}catch(\Exception $e){
|
|
|
Common::put_file_log('异常-红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|