|
@@ -287,18 +287,22 @@ class Wechat extends Api |
|
@@ -287,18 +287,22 @@ class Wechat extends Api |
287
|
*/
|
287
|
*/
|
288
|
public function prepare_order($order_no = ''){
|
288
|
public function prepare_order($order_no = ''){
|
289
|
$user_id = $this->auth->id;
|
289
|
$user_id = $this->auth->id;
|
290
|
-
|
290
|
+
|
291
|
if(empty($user_id)){
|
291
|
if(empty($user_id)){
|
292
|
return $this->error('预下单的用户信息错误');
|
292
|
return $this->error('预下单的用户信息错误');
|
293
|
}
|
293
|
}
|
|
|
294
|
+
|
294
|
$userInfo = Db::name('user')->where(['id'=>$user_id])->find();
|
295
|
$userInfo = Db::name('user')->where(['id'=>$user_id])->find();
|
295
|
|
296
|
|
296
|
$out_trade_no = $order_no;
|
297
|
$out_trade_no = $order_no;
|
|
|
298
|
+ $o_w["order_no"] = $out_trade_no;
|
|
|
299
|
+ $order_info = Db::name('verification_order')->where($o_w)->find();
|
|
|
300
|
+ $total_fee = $order_info['price'] = 1;//测试支付1分钱
|
297
|
$app = WehcatModule::getInstance()->initWechatPay();
|
301
|
$app = WehcatModule::getInstance()->initWechatPay();
|
298
|
$result = $app->order->unify([
|
302
|
$result = $app->order->unify([
|
299
|
'body' => '优惠券购买',
|
303
|
'body' => '优惠券购买',
|
300
|
'out_trade_no' => $out_trade_no,
|
304
|
'out_trade_no' => $out_trade_no,
|
301
|
- 'total_fee' => 1,
|
305
|
+ 'total_fee' => $total_fee,
|
302
|
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
|
306
|
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
|
303
|
'openid' => $userInfo['openid'],
|
307
|
'openid' => $userInfo['openid'],
|
304
|
]);
|
308
|
]);
|
|
@@ -412,7 +416,6 @@ class Wechat extends Api |
|
@@ -412,7 +416,6 @@ class Wechat extends Api |
412
|
}
|
416
|
}
|
413
|
// 发放佣金
|
417
|
// 发放佣金
|
414
|
public function grant_commission($pid=0,$order_id=0){
|
418
|
public function grant_commission($pid=0,$order_id=0){
|
415
|
-
|
|
|
416
|
try{
|
419
|
try{
|
417
|
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
420
|
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
418
|
$app = WehcatModule::getInstance()->initWechatPay();
|
421
|
$app = WehcatModule::getInstance()->initWechatPay();
|
|
@@ -433,4 +436,32 @@ class Wechat extends Api |
|
@@ -433,4 +436,32 @@ class Wechat extends Api |
433
|
Common::put_file_log('异常-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
|
436
|
Common::put_file_log('异常-佣金发放',json_encode($result), 'grant_commission', __CLASS__ . __FUNCTION__ . __LINE__);
|
434
|
}
|
437
|
}
|
435
|
}
|
438
|
}
|
|
|
439
|
+
|
|
|
440
|
+
|
|
|
441
|
+ // 发放红包
|
|
|
442
|
+ public function grant_red_packets($pid=0,$order_id=0){
|
|
|
443
|
+ try{
|
|
|
444
|
+ $verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
|
|
|
445
|
+ $app = WehcatModule::getInstance()->initWechatPay();
|
|
|
446
|
+ $result = $app->redpack->sendNormal([
|
|
|
447
|
+
|
|
|
448
|
+ 'mch_billno' => '168532907259455',
|
|
|
449
|
+ 'send_name' => '测试红包',
|
|
|
450
|
+ 're_openid' => 'o5OQw6PPEGaHqIjAir7gqeDV5MzQ',
|
|
|
451
|
+ 'total_num' => 1, //固定为1,可不传
|
|
|
452
|
+ 'total_amount' => 100, //单位为分,不小于100
|
|
|
453
|
+ 'wishing' => '祝福语',
|
|
|
454
|
+
|
|
|
455
|
+ 'act_name' => '测试活动',
|
|
|
456
|
+ 'remark' => '测试备注',
|
|
|
457
|
+ ]);
|
|
|
458
|
+ if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
|
|
|
459
|
+ //记录佣金表
|
|
|
460
|
+ }else{
|
|
|
461
|
+ Common::put_file_log('失败-红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
462
|
+ }
|
|
|
463
|
+ }catch(\Exception $e){
|
|
|
464
|
+ Common::put_file_log('异常-红包发放',json_encode($result), 'grant_red_packets', __CLASS__ . __FUNCTION__ . __LINE__);
|
|
|
465
|
+ }
|
|
|
466
|
+ }
|
436
|
} |
467
|
} |