From 6179e6e001b80f63e9267bc01ab74d66f433a0fc Mon Sep 17 00:00:00 2001 From: weigang Date: Mon, 17 Aug 2020 21:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E4=B8=AA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/LogLabel.php | 5 +++++ app/Service/DeviceServiceImp.php | 3 +-- app/Service/MqttSpeakerService.php | 2 +- app/Service/OrderService.php | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/Constants/LogLabel.php b/app/Constants/LogLabel.php index aafacd8..1c88863 100644 --- a/app/Constants/LogLabel.php +++ b/app/Constants/LogLabel.php @@ -26,4 +26,9 @@ class LogLabel extends AbstractConstants * @Message("Pay Notice Log Label") */ const PAY_NOTIFY_WXMINI = 'notify_wxmini'; + + /** + * @Message("Order Log Label") + */ + const ORDER_LOG = 'order_log'; } diff --git a/app/Service/DeviceServiceImp.php b/app/Service/DeviceServiceImp.php index 16c9110..76a09e0 100644 --- a/app/Service/DeviceServiceImp.php +++ b/app/Service/DeviceServiceImp.php @@ -112,8 +112,7 @@ class DeviceServiceImp implements DeviceServiceInterface ->where(['store_id' => $order['store_id'], 'is_bind' => SpeakerDevic::IS_BIND_YES]) ->get() ->toArray(); - - $msg = "{\"msg\":\"到账".$order['money']."元\"}"; + $msg = $order['type']==1 ? "{\"msg\":\"您有新的外卖订单\"}" : "{\"msg\":\"到账".$order['money']."元\"}"; foreach ($device_names as $key => $dev_name) { $this->IOTService->pub($dev_name['device_name'], $msg); } diff --git a/app/Service/MqttSpeakerService.php b/app/Service/MqttSpeakerService.php index d058ae7..337834a 100644 --- a/app/Service/MqttSpeakerService.php +++ b/app/Service/MqttSpeakerService.php @@ -30,7 +30,7 @@ class MqttSpeakerService implements MqttServiceInterface // 循环发送 foreach ($orders as $k => &$order) { - $order['template'] = "懒族支付到账".floatval($order['money'])."元"; + $order['template'] = $order['type']==1 ? "您有新的外卖订单" : "到账".floatval($order['money'])."元"; // 获取终端ID $order['to_client_id'] = Store::query()->where(['id' => $order['store_id']])->value('loudspeaker_imei'); // 发布订阅消息 diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index b637ac3..7511b79 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -2,6 +2,8 @@ namespace App\Service; +use App\Commons\Log; +use App\Constants\LogLabel; use App\Model\Coupon; use App\Model\CouponUserRec; use App\Model\CouponUserUse; @@ -19,6 +21,11 @@ use Hyperf\Di\Annotation\Inject; class OrderService implements OrderServiceInterface { + /** + * @Inject + * @var Log + */ + protected $log; /** * @Inject @@ -333,6 +340,11 @@ class OrderService implements OrderServiceInterface } catch (Exception $e) { + $this->log->event( + LogLabel::ORDER_LOG, + $e->getMessage() + ); + Db::rollBack(); return $e->getMessage(); @@ -444,6 +456,10 @@ class OrderService implements OrderServiceInterface Db::commit(); return $orderMainId; } catch (Exception $e) { + $this->log->event( + LogLabel::ORDER_LOG, + $e->getMessage() + ); Db::rollBack(); return '购买失败'; }