sendNum ?? 0; $sound = '请注意,' . $sendNum . '号单有修改'; if ($order->fromType == 4) { $mtSn = $order->thirdSn ?? 0; $sound = '请注意,美团' . $mtSn . '号单有修改'; } $hasSh = 0; $hasHs = 0; $workList = WorkClass::getAllByCondition(['orderId' => $order->id], null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { if ($work->status == 0) { $sh = $work->sh ?? 0; if ($sh == 0) { $hasHs = 1; } else { $hasSh = 1; } } } } if ($hasHs == 1) { $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn; $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion; $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } if ($hasSh == 1) { $lbSn = $shopExt->lbSn ?? ''; $lbVersion = $shopExt->lbVersion; $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } public static function orderCancelRemind($shopExt, $order) { $sendNum = $order->sendNum ?? 0; $hasSh = 0; $hasHs = 0; $workList = WorkClass::getAllByCondition(['orderId' => $order->id], null, '*', null, true); if (!empty($workList)) { foreach ($workList as $work) { if ($work->status == 2) { $sh = $work->sh ?? 0; if ($sh == 0) { $hasHs = 1; } else { $hasSh = 1; } $sound = '请注意,' . $sendNum . '号单已被取消'; if ($order->fromType == 4) { $mtSn = $order->thirdSn ?? 0; $sound = '请注意,美团' . $mtSn . '号单已被取消'; } } if ($work->preNum > $work->num && $work->status == 0) { $sh = $work->sh ?? 0; if ($sh == 0) { $hasHs = 1; } else { $hasSh = 1; } $sound = '请注意,' . $sendNum . '号单有修改'; if ($order->fromType == 4) { $mtSn = $order->thirdSn ?? 0; $sound = '请注意,美团' . $mtSn . '号单有修改'; } } } } if ($hasHs == 1) { $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn; $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion; $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } if ($hasSh == 1) { $lbSn = $shopExt->lbSn ?? ''; $lbVersion = $shopExt->lbVersion; $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } //新制作单提示 public static function newWorkRemind($shopExt, $order) { $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn; $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion; if (empty($lbSn)) { return false; } $sound = "您有新的制作单"; $reachDate = $order->reachDate ?? ''; if ($order->sendType == 1) { if (!empty($reachDate) && $reachDate != '0000-00-00') { $readPeriod = $order->reachPeriod ?? 0; $period = explode(':', $readPeriod); $periodName = implode($period, '点'); if ($reachDate == date("Y-m-d")) { $sound .= ',今天' . $periodName . "分到店自取"; } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) { $sound .= ',明天' . $periodName . "分到店自取"; } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) { $sound .= ',后天' . $periodName . "分到店自取"; } else { $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取"; } } else { $sound .= ",客户到店自取"; } } else { if (!empty($reachDate) && $reachDate != '0000-00-00') { $readPeriod = $order->reachPeriod ?? 0; $period = explode(':', $readPeriod); $periodName = implode($period, '点'); if ($reachDate == date("Y-m-d")) { $sound .= ',今天' . $periodName . "分前配送"; } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) { $sound .= ',明天' . $periodName . "分前配送"; } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) { $sound .= ',后天' . $periodName . "分前配送"; } else { $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送"; } } } $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); $curl->get($url); return true; } //花店采购供货商端播放声音 public static function hdCgGhsReport($orderSn) { $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true); if (isset($cg->onlinePay) && $cg->onlinePay == dict::getDict('onlinePay', 'yes')) { $saleId = $cg->saleId ?? 0; $order = \bizGhs\order\classes\OrderClass::getById($saleId, true); if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'noNeed')) { $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) { $actPrice = floatval($order->actPrice) ?? 0; $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay'); $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } //app新订单通知 //NoticeClass::ghsNewOrderNotice($order); } } public static function pleasePayReport($order) { $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) { $mainPay = $order->mainPay ? floatval($order->mainPay) : 0; $sound = $mainPay . '元,请出示付款码'; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } //供货商收银台 ssh 20230421 public static function ghsPleasePayReport($order) { $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) { $mainPay = $order->actPrice ? floatval($order->actPrice) : 0; $sound = $mainPay . '元,请出示付款码'; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); // 复杂分支/关键逻辑:设置 cURL 连接和执行超时,并强制使用 IPv4,防止因外部音箱接口卡顿或 DNS 解析慢拖垮收银结账主进程 $curl->setOption(CURLOPT_CONNECTTIMEOUT, 1); // 连接超时限制为 1 秒,避免网络握手长时间卡死 $curl->setOption(CURLOPT_TIMEOUT, 1); // 总执行时间限制为 1 秒,避免请求挂起时间过长 $curl->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // 强制 IPv4 解析,防止 IPv6 解析超时重试 $curl->get($url); } } /** * 零售花店收款声音播放 * 职责:向外部音箱接口发送语音播报请求,提示商户收款成功(零售端) * 入参:ActiveRecord $order (订单模型实例) * 返回:bool (是否成功触发播报) * 副作用:发送外部 HTTP 网络请求 * 关键边界: * 1. 仅限门店订单、在线支付且已付款的订单播报 * 2. 优化:设置极短的 cURL 连接超时与执行超时限制,并强制使用 IPv4 解析,防止因外部音箱接口延迟拖垮收银支付主流程 */ public static function hdGatheringReport($order) { if ($order->fromType != dict::getDict("fromType", "shop")) { //非门店订单不播报语音 return false; } if ($order->onlinePay == dict::getDict('onlinePay', 'not')) { //非在线支付的不播报 return false; } if ($order->payStatus != 1) { //还没有付款订单不播报 return false; } $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) { $actPrice = $order->mainPay ? floatval($order->mainPay) : 0; $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay'); $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); // 复杂分支/关键逻辑:设置 cURL 连接和执行超时,并强制使用 IPv4,防止因外部音箱接口卡顿或 DNS 解析慢拖垮收银结账主进程 $curl->setOption(CURLOPT_CONNECTTIMEOUT, 1); // 连接超时限制为 1 秒,避免网络握手长时间卡死 $curl->setOption(CURLOPT_TIMEOUT, 1); // 总执行时间限制为 1 秒,避免请求挂起时间过长 $curl->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // 强制 IPv4 解析,防止 IPv6 解析超时重试 $curl->get($url); } } public static function skRechargeReport($recharge) { if (empty($recharge)) { return false; } if ($recharge->payStatus != 1) { //还没有付款订单不播报 return false; } $shopId = $recharge->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (!empty($shopExt->lbSn)) { $actPrice = $recharge->amount ?? 0; $payWay = $recharge->payWay ?? 0; $sound = $payWay == 0 ? "微信充值{$actPrice}元," : "支付宝充值{$actPrice}元"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } public static function hdScanPayReport($order) { if (empty($order)) { return false; } if ($order->payStatus != 1) { //还没有付款订单不播报 return false; } $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (!empty($shopExt->lbSn)) { $actPrice = $order->actPrice ?? 0; $payWay = $order->payWay ?? 0; $sound = $payWay == 0 ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } /** * 供货商收款声音播放 * 职责:向外部音箱接口发送语音播报请求,提示商户收款成功 * 入参:ActiveRecord $order (订单模型实例) * 返回:bool (是否成功触发播报) * 副作用:发送外部 HTTP 网络请求 * 关键边界: * 1. 仅限门店订单、在线支付且已付款的订单播报 * 2. 优化:设置极短的 cURL 连接超时与执行超时限制,并强制使用 IPv4 解析,防止因外部音箱接口延迟拖垮收银支付主流程 */ public static function ghsGatheringReport($order) { if ($order->fromType != dict::getDict("fromType", "shop")) { //非门店订单不播报语音 return false; } if ($order->onlinePay == dict::getDict('onlinePay', 'not')) { //非在线支付的不播报 return false; } if ($order->payStatus != 1) { //还没有付款订单不播报 return false; } $shopId = $order->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) { $actPrice = $order->actPrice ? floatval($order->actPrice) : 0; $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay'); $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); // 复杂分支/关键逻辑:设置 cURL 连接和执行超时,并强制使用 IPv4,防止因外部音箱接口卡顿或 DNS 解析慢拖垮收银结账主进程 $curl->setOption(CURLOPT_CONNECTTIMEOUT, 1); // 连接超时限制为 1 秒,避免网络握手长时间卡死 $curl->setOption(CURLOPT_TIMEOUT, 1); // 总执行时间限制为 1 秒,避免请求挂起时间过长 $curl->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // 强制 IPv4 解析,防止 IPv6 解析超时重试 $curl->get($url); } } //订单取消,钱原路退回,提醒客户 public static function orderCancelBackMoneyReport($shopId) { $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (!empty($shopExt->lbSn)) { $sound = "订单已取消,付款已原路退回,请稍等几秒重新付款"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } //提醒输入密码 ssh 20250501 public static function remindInputPassword($shopId) { $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); if (!empty($shopExt->lbSn)) { $sound = "请输入密码"; $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound; $curl = new curl\Curl(); $curl->get($url); } } //清除所有小菊 public static function clearXjALl($shopId) { $where = []; $where['shopId'] = $shopId; return self::updateByCondition($where, ['xj' => '']); } }