61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs;
|
||
|
|
|
||
|
|
use Illuminate\Bus\Queueable;
|
||
|
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
|
use App\Models\RedPacketOrder;
|
||
|
|
class SendRedPacket implements ShouldQueue
|
||
|
|
{
|
||
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
|
|
||
|
|
protected $user_id;
|
||
|
|
protected $type;
|
||
|
|
protected $trade_no;
|
||
|
|
protected $amount;
|
||
|
|
protected $send_name;
|
||
|
|
protected $packet_type;
|
||
|
|
protected $openid;
|
||
|
|
/**
|
||
|
|
* Create a new job instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct($data)
|
||
|
|
{
|
||
|
|
$this->user_id = $data['user_id'];
|
||
|
|
$this->type = $data['type'];
|
||
|
|
$this->trade_no = $data['trade_no'];
|
||
|
|
$this->amount = $data['amount'];
|
||
|
|
$this->send_name = $data['send_name'];
|
||
|
|
$this->packet_type = $data['packet_type'];
|
||
|
|
$this->openid = $data['openid'];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
// RedPacketOrder::create([
|
||
|
|
// 'user_id'=>$this->user_id,
|
||
|
|
// 'type'=>$this->type,
|
||
|
|
// 'trade_no'=>$this->trade_no,
|
||
|
|
// 'amount'=>$this->amount,
|
||
|
|
// ]);
|
||
|
|
|
||
|
|
$total_amount = $this->amount * 100;
|
||
|
|
// $wish = '福恋一家,有你,有我、有祂!';
|
||
|
|
if ($this->packet_type == 'normal') {
|
||
|
|
// $result = \WechatService::sendNormalRedPack($this->trade_no, $this->send_name, $total_amount, $this->openid, $wish, $this->send_name);
|
||
|
|
// $result = \WechatService::userTransfer($this->trade_no, $this->openid, $total_amount, $this->send_name);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|