This commit is contained in:
mkm 2024-05-14 17:56:33 +08:00
parent 5396290624
commit 7d858959df
3 changed files with 13 additions and 7 deletions
app
api/controller
common

@ -19,9 +19,8 @@ class IndexController extends BaseApiController
public function index() public function index()
{ {
$app=new WeChatMnpService();
$a= $app->delivery('PF171564998868869065'); d(config('payment.wechat.default.mch_id'));
d($a);
$queue = 'send-mail'; $queue = 'send-mail';
// 数据,可以直接传数组,无需序列化 // 数据,可以直接传数组,无需序列化
$data = ['to' => 'tom@gmail.com', 'content' => 'hello']; $data = ['to' => 'tom@gmail.com', 'content' => 'hello'];

@ -9,6 +9,7 @@ use app\common\model\recharge\RechargeOrder;
use app\common\model\retail\Cashierclass; use app\common\model\retail\Cashierclass;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\service\PushService; use app\common\service\PushService;
use app\common\service\wechat\WeChatMnpService;
use support\Log; use support\Log;
use think\facade\Db; use think\facade\Db;
@ -72,6 +73,9 @@ class PayNotifyLogic extends BaseLogic
} }
} }
PushService::push('cash_register_'.$order['user_id'], $order['user_id'], '您有一笔订单已支付'); PushService::push('cash_register_'.$order['user_id'], $order['user_id'], '您有一笔订单已支付');
if(isset($orderSn,$extra['payer']['openid'])){
(new WeChatMnpService)->delivery($orderSn,$extra['payer']['openid']);
}
return true; return true;
} }

@ -100,7 +100,7 @@ class WeChatMnpService
/** /**
* @notes 发货 * @notes 发货
*/ */
public function delivery($order_id) public function delivery($order_id,$openid)
{ {
$token=Cache::get('mmp_access_token'); $token=Cache::get('mmp_access_token');
if(!$token){ if(!$token){
@ -108,10 +108,11 @@ class WeChatMnpService
} }
$dateTime = new DateTime(date('Y-m-d H:i:s')); $dateTime = new DateTime(date('Y-m-d H:i:s'));
$formattedDateTime = $dateTime->format('Y-m-d\TH:i:s.uP'); $formattedDateTime = $dateTime->format('Y-m-d\TH:i:s.uP');
return $this->app->getClient()->post("wxa/sec/order/upload_shipping_info?access_token=$token", [ return $this->app->getClient()->postJson("wxa/sec/order/upload_shipping_info?access_token=$token", [
'order_key' =>[ 'order_key' =>[
'order_number_type'=>1, 'order_number_type'=>1,
'out_trade_no'=>$order_id 'out_trade_no'=>$order_id,
'mchid'=>config('payment.wechat.default.mch_id')
], ],
'logistics_type'=>4, 'logistics_type'=>4,
'delivery_mode'=>'UNIFIED_DELIVERY', 'delivery_mode'=>'UNIFIED_DELIVERY',
@ -120,7 +121,7 @@ class WeChatMnpService
], ],
'upload_time'=>$formattedDateTime, 'upload_time'=>$formattedDateTime,
'payer'=>[ 'payer'=>[
'openid'=>'onoIP7VVWhCZSWX8zazdNS4KazPE' 'openid'=>$openid
] ]
])->toArray(); ])->toArray();
} }
@ -134,6 +135,8 @@ class WeChatMnpService
if($token){ if($token){
Cache::set('mmp_access_token',$token,7200); Cache::set('mmp_access_token',$token,7200);
return $token; return $token;
}else{
throw new Exception('获取access_token失败');
} }
} }
} }