6
0
Fork 0
panliang 2022-08-04 10:16:24 +08:00
parent ded43e4ed7
commit 28bbdc5fcd
3 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,6 @@
namespace App\Console\Commands;
use App\Enums\PayWay;
use App\Exceptions\BizException;
use App\Models\Order;
use App\Services\DistributeService;
use Illuminate\Console\Command;
@ -62,8 +61,8 @@ class OrderProfitCommand extends Command
->where('completed_at', '<', now()->subDays($saleDays))
// 未支付提成
->whereNull('profit_paid')
->limit(200);
->limit(200)
->get();
foreach ($orders as $order) {
foreach($order->profits as $profit) {
@ -79,8 +78,9 @@ class OrderProfitCommand extends Command
$service->wechatTransfer($profit);
}
DB::commit();
} catch (BizException $e) {
} catch (\Exception $e) {
DB::rollBack();
// $this->error($e->getMessage());
}
}
// 没有待付款的提成记录

View File

@ -157,6 +157,8 @@ class DistributeService
/**
* 使用微信企业付款, 支付返利金额
* 调用之前, 需要提前生成商户订单号
*
* @throws WeChatPayException
*/
public function wechatTransfer(OrderProfit $profit)
{

View File

@ -29,7 +29,7 @@ class UserSeeder extends Seeder
DB::table('wallet_to_bank_logs')->truncate();
DB::table('sales_value_logs')->truncate();
DB::table('balances')->truncate();
DB::table('users')->truncate();
$this->faker = $this->withFaker();