first commit
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ApiHook implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 2;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* 商品服务层.
|
||||
* @var \App\Service\PayService
|
||||
*/
|
||||
private $goodsService;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->goodsService = app('Service\GoodsService');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$goodInfo = $this->goodsService->detail($this->order->goods_id);
|
||||
// 判断是否有配置支付回调
|
||||
if(empty($goodInfo->api_hook)){
|
||||
return;
|
||||
}
|
||||
$postdata = [
|
||||
'title' => $this->order->title,
|
||||
'order_sn' => $this->order->order_sn,
|
||||
'email' => $this->order->email,
|
||||
'actual_price' => $this->order->actual_price,
|
||||
'order_info' => $this->order->info,
|
||||
'good_id' => $goodInfo->id,
|
||||
'gd_name' => $goodInfo->gd_name
|
||||
|
||||
];
|
||||
|
||||
|
||||
$opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/json',
|
||||
'content' => json_encode($postdata,JSON_UNESCAPED_UNICODE)
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($opts);
|
||||
file_get_contents($goodInfo->api_hook, false, $context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
|
||||
class BarkPush implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 2;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* 商品服务层.
|
||||
* @var \App\Service\PayService
|
||||
*/
|
||||
private $goodsService;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->goodsService = app('Service\GoodsService');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$goodInfo = $this->goodsService->detail($this->order->goods_id);
|
||||
$client = new Client();
|
||||
$apiUrl = dujiaoka_config_get('bark_server') .'/'. dujiaoka_config_get('bark_token');
|
||||
$params = [
|
||||
"title" => __('dujiaoka.prompt.new_order_push').'('.$this->order->actual_price.'元)',
|
||||
"body" => __('order.fields.order_id') .': '.$this->order->id."\n"
|
||||
. __('order.fields.order_sn') .': '.$this->order->order_sn."\n"
|
||||
. __('order.fields.pay_id') .': '.$this->order->pay->pay_name."\n"
|
||||
. __('order.fields.title') .': '.$this->order->title."\n"
|
||||
. __('order.fields.actual_price') .': '.$this->order->actual_price."\n"
|
||||
. __('order.fields.email') .': '.$this->order->email."\n"
|
||||
. __('goods.fields.gd_name') .': '.$goodInfo->gd_name."\n"
|
||||
. __('goods.fields.in_stock') .': '.$goodInfo->in_stock."\n"
|
||||
. __('order.fields.order_created') .': '.$this->order->created_at,
|
||||
"icon"=>url('assets/common/images/default.jpg'),
|
||||
"level"=>"timeSensitive",
|
||||
"group"=>dujiaoka_config_get('text_logo', '独角数卡')
|
||||
];
|
||||
if (dujiaoka_config_get('is_open_bark_push_url', 0) == BaseModel::STATUS_OPEN) {
|
||||
$params["url"] = url('detail-order-sn/'.$this->order->order_sn);
|
||||
}
|
||||
$client->post($apiUrl,['form_params' => $params, 'verify' => false]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CouponBack implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* 任务可以执行的最大秒数 (超时时间)。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 20;
|
||||
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// 如果订单有使用优惠码
|
||||
if ($this->order->coupon_id) {
|
||||
// 优惠码次数+1
|
||||
app('Service\CouponService')->retIncrByID($this->order->coupon_id);
|
||||
// 设置订单优惠码已回退
|
||||
app('Service\OrderService')->couponIsBack($this->order->order_sn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Mail\MailServiceProvider;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class MailSend implements ShouldQueue
|
||||
{
|
||||
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 2;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
private $to;
|
||||
|
||||
private $content;
|
||||
|
||||
private $title;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $to, string $title, string $content)
|
||||
{
|
||||
$this->to = $to;
|
||||
$this->title = $title;
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$body = $this->content;
|
||||
$title = $this->title;
|
||||
$sysConfig = cache('system-setting');
|
||||
$mailConfig = [
|
||||
'driver' => $sysConfig['driver'] ?? 'smtp',
|
||||
'host' => $sysConfig['host'] ?? '',
|
||||
'port' => $sysConfig['port'] ?? '465',
|
||||
'username' => $sysConfig['username'] ?? '',
|
||||
'from' => [
|
||||
'address' => $sysConfig['from_address'] ?? '',
|
||||
'name' => $sysConfig['from_name'] ?? '独角发卡'
|
||||
],
|
||||
'password' => $sysConfig['password'] ?? '',
|
||||
'encryption' => $sysConfig['encryption'] ?? ''
|
||||
];
|
||||
$to = $this->to;
|
||||
// 覆盖 mail 配置
|
||||
config([
|
||||
'mail' => array_merge(config('mail'), $mailConfig)
|
||||
]);
|
||||
// 重新注册驱动
|
||||
(new MailServiceProvider(app()))->register();
|
||||
Mail::send(['html' => 'email.mail'], ['body' => $body], function ($message) use ($to, $title){
|
||||
$message->to($to)->subject($title);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OrderExpired implements ShouldQueue
|
||||
{
|
||||
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* 任务可以执行的最大秒数 (超时时间)。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 20;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
* @var string
|
||||
*/
|
||||
private $orderSN;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $orderSN)
|
||||
{
|
||||
$this->orderSN = $orderSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// 如果x分钟后还没支付就算过期
|
||||
$order = app('Service\OrderService')->detailOrderSN($this->orderSN);
|
||||
if ($order && $order->status == Order::STATUS_WAIT_PAY) {
|
||||
app('Service\OrderService')->expiredOrderSN($this->orderSN);
|
||||
// 回退优惠券
|
||||
CouponBack::dispatch($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ServerJiang implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 2;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$postdata = http_build_query([
|
||||
'text' => __('dujiaoka.prompt.new_order_push') . ":{$this->order['ord_title']}",
|
||||
'desp' => "
|
||||
- ". __('order.fields.title') .":{$this->order->title}
|
||||
- ". __('order.fields.order_sn') .":{$this->order->order_sn}
|
||||
- ". __('order.fields.email') .":{$this->order->email}
|
||||
- ". __('order.fields.actual_price') .":{$this->order->actual_price}
|
||||
"
|
||||
]);
|
||||
$opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $postdata
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($opts);
|
||||
$apiToken = dujiaoka_config_get('server_jiang_token');
|
||||
file_get_contents('https://sctapi.ftqq.com/' . $apiToken . '.send', false, $context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
class TelegramPush implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 2;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* 商品服务层.
|
||||
* @var \App\Service\PayService
|
||||
*/
|
||||
private $goodsService;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->goodsService = app('Service\GoodsService');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$goodInfo = $this->goodsService->detail($this->order->goods_id);
|
||||
$formatText = '*'. __('dujiaoka.prompt.new_order_push').'('.$this->order->actual_price.'元)*%0A'
|
||||
. __('order.fields.order_id') .': `'.$this->order->id.'`%0A'
|
||||
. __('order.fields.order_sn') .': `'.$this->order->order_sn.'`%0A'
|
||||
. __('order.fields.pay_id') .': `'.$this->order->pay->pay_name.'`%0A'
|
||||
. __('order.fields.title') .': '.$this->order->title.'%0A'
|
||||
. __('order.fields.actual_price') .': '.$this->order->actual_price.'%0A'
|
||||
. __('order.fields.email') .': `'.$this->order->email.'`%0A'
|
||||
. __('goods.fields.gd_name') .': `'.$goodInfo->gd_name.'`%0A'
|
||||
. __('goods.fields.in_stock') .': `'.$goodInfo->in_stock.'`%0A'
|
||||
. __('order.fields.order_created') .': '.$this->order->created_at;
|
||||
$client = new Client([
|
||||
'timeout' => 30,
|
||||
'proxy'=> ''
|
||||
]);
|
||||
$apiUrl = 'https://api.telegram.org/bot' . dujiaoka_config_get('telegram_bot_token') .
|
||||
'/sendMessage?chat_id=' . dujiaoka_config_get('telegram_userid') . '&parse_mode=Markdown&text='.$formatText;
|
||||
$client->post($apiUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Order;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
class WorkWeiXinPush implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* 任务最大尝试次数。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 1;
|
||||
|
||||
/**
|
||||
* 任务运行的超时时间。
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* 商品服务层.
|
||||
* @var \App\Service\PayService
|
||||
*/
|
||||
private $goodsService;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->goodsService = app('Service\GoodsService');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$goodInfo = $this->goodsService->detail($this->order->goods_id);
|
||||
$client = new Client();
|
||||
$apiUrl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='. dujiaoka_config_get('qywxbot_key');
|
||||
$params = [
|
||||
"msgtype"=>"markdown",
|
||||
"markdown"=>[
|
||||
"content"=>__('dujiaoka.prompt.new_order_push').'(<font color="warning">'.$this->order->actual_price."</font>元)\n"
|
||||
.'>'.__('order.fields.order_id') .': <font color="comment">'.$this->order->id."</font>\n"
|
||||
.'>'.__('order.fields.order_sn') .': <font color="comment">'.$this->order->order_sn."</font>\n"
|
||||
.'>'.__('order.fields.pay_id') .': <font color="comment">'.$this->order->pay->pay_name."</font>\n"
|
||||
.'>'.__('order.fields.title') .': <font color="comment">'.$this->order->title."</font>\n"
|
||||
.'>'.__('order.fields.actual_price') .': <font color="comment">'.$this->order->actual_price."</font>\n"
|
||||
.'>'.__('order.fields.email') .': <font color="comment">'.$this->order->email."</font>\n"
|
||||
.'>'.__('goods.fields.gd_name') .': <font color="comment">'.$goodInfo->gd_name."</font>\n"
|
||||
.'>'.__('goods.fields.in_stock') .': <font color="comment">'.$goodInfo->in_stock."</font>\n"
|
||||
.'>'.__('order.fields.order_created') .': <font color="comment">'.$this->order->created_at."</font>"
|
||||
]
|
||||
];
|
||||
$client->post($apiUrl,['json' => $params, 'verify' => false]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user