1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\jobs\system;
- use crmeb\basic\BaseJobs;
- use crmeb\traits\QueueTrait;
- use app\webscoket\SocketPush;
- class SocketPushJob extends BaseJobs
- {
- use QueueTrait;
-
- public static function queueName()
- {
- return 'CRMEB_PRO_SOCKET';
- }
-
- public function doJob($to, $type, $data, $userType = 'admin')
- {
- if (!$to || !$type) {
- return true;
- }
-
- try {
- SocketPush::instance()->to($to)->setUserType($userType)->type($type)->data($data)->push();
- } catch (\Throwable $e) {
- }
- return true;
- }
-
- public function sendApplyRefund($order)
- {
- if (!$order) {
- return true;
- }
- if ($order['store_id']) {
-
- try {
- SocketPush::store()->to($order['store_id'])->data(['order_id' => $order['order_id']])->type('NEW_REFUND_ORDER')->push();
- } catch (\Exception $e) {
- }
- } elseif ($order['supplier_id']) {
-
- try {
- SocketPush::instance()->setUserType('supplier')->to($order['supplier_id'])->data(['order_id' => $order['order_id']])->type('NEW_REFUND_ORDER')->push();
- } catch (\Exception $e) {
- }
- } else {
-
- try {
- SocketPush::admin()->data(['order_id' => $order['order_id']])->type('NEW_REFUND_ORDER')->push();
- } catch (\Exception $e) {
- }
- }
- return true;
- }
- }
|