61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Order;
|
|
use App\Models\OrderProfit;
|
|
use App\Services\DistributeService;
|
|
use App\Services\Payment\WxpayService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class OrderProfitCheck extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'order-profit:check';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = '检查提成支付结果';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$service = new WxpayService();
|
|
$service1 = new DistributeService();
|
|
$list = OrderProfit::where('status', 1)->get()->groupBy('order_id');
|
|
foreach ($list as $order_id => $profits) {
|
|
$transaction_id = Order::where('id', $order_id)->value('out_trade_no');
|
|
$sn = data_get($profits->first(), 'pay_no');
|
|
if ($transaction_id) {
|
|
$result = $service->queryShare($transaction_id, $sn);
|
|
$status = data_get($result, 'status');
|
|
if ($status == 'FINISHED') {
|
|
$service1->success($profits, $result);
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|