51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\queue\redis;
|
|
|
|
use app\admin\logic\operation\OpurchaseclassLogic;
|
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
|
use app\common\model\opurchase\Opurchaseinfo;
|
|
use app\common\service\JgPushService;
|
|
use Webman\RedisQueue\Consumer;
|
|
use support\Log;
|
|
use think\facade\Db;
|
|
|
|
/**
|
|
* 推送给供应商报价
|
|
*/
|
|
class PushSupplierProductsSend implements Consumer
|
|
{
|
|
// 要消费的队列名
|
|
public $queue = 'push-supplier-products';
|
|
|
|
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
|
public $connection = 'default';
|
|
|
|
// 消费
|
|
public function consume($data)
|
|
{
|
|
$order_id=$data['order_id'];
|
|
$select=Opurchaseinfo::where('pid',$order_id)->where('is_push',0)->select();
|
|
foreach ($select as $key => $arr) {
|
|
OpurchaseclassLogic::createSupplierGoods($arr);
|
|
}
|
|
$supplier_id_arr=OpurchaseGoodsOffer::where('order',$order_id)->whereDay('create_time')->column('supplier_id');
|
|
if($supplier_id_arr){
|
|
$supplier_id_arr=array_unique($supplier_id_arr);
|
|
foreach($supplier_id_arr as $key => $supplier_id){
|
|
$jg_register_id=Db::name('user_auth_shop')-> where('pid',$supplier_id)->where('type',2)->value('jg_register_id');
|
|
if($jg_register_id){
|
|
(new JgPushService())->sendMsg($jg_register_id, '您有一笔新的报价清单,请及时处理', '/pages/quote/list',3);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
public function onConsumeFailure(\Throwable $e, $package)
|
|
{
|
|
$package['max_attempts']=0;
|
|
Log::error('添加推送给供应商报价失败order_id'.$package['data']['order_id']);
|
|
return $package;
|
|
}
|
|
} |