| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\queue\redis\slow;
- use app\extra\tools\LifeWeb;
- use app\model\saas\SaasOrder;
- use Webman\RedisQueue\Consumer;
- class SyncOrder implements Consumer
- {
- /**
- * 延迟30秒获取达人信息
- * 消费队列名
- * @var string
- */
- public string $queue = "sync-order-info";
- /**
- * 连接配置
- * @var string
- */
- public string $connection = "default";
- public function consume($data): bool
- {
- try {
- if(empty($data['order'])) return true;
- echo getDateFull()."==开始获取订单达人信息\n";
- $order = (new SaasOrder)->where("order_sn",$data['order'])->findOrEmpty();
- if ($order->isEmpty()) return true;
- [$state,$resp] = (new LifeWeb)->token()->getOrderData($order['order_sn']);
- if (!$state) {
- echo getDateFull()."=={$order['order_sn']}==获取数据失败了==\n";
- return true;
- }
- echo getDateFull()."=={$order['order_sn']}==更新订单数据成功\n";
- $order->douyin_uid = $resp['douyin_uid'];
- $order->life_fee = $resp['life_fee'];
- $order->star_fee = $resp['star_fee'];
- $order->save();
- } catch (\Throwable $throwable) {
- echo getDateFull()."====获取达人信息失败\n";
- echo $throwable->getMessage()."\n";
- echo $throwable->getLine()."\n";
- echo $throwable->getFile()."\n";
- }
- return true;
- }
- }
|