ShopExtClass.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?php
  2. namespace biz\shop\classes;
  3. use bizHd\purchase\classes\PurchaseClass;
  4. use bizHd\work\classes\WorkClass;
  5. use common\components\dict;
  6. use linslin\yii2\curl;
  7. use biz\base\classes\BaseClass;
  8. class ShopExtClass extends BaseClass
  9. {
  10. public static $baseFile = '\biz\shop\models\ShopExt';
  11. public static function orderUpdateRemind($shopExt, $order)
  12. {
  13. $sendNum = $order->sendNum ?? 0;
  14. $sound = '请注意,' . $sendNum . '号单有修改';
  15. if ($order->fromType == 4) {
  16. $mtSn = $order->thirdSn ?? 0;
  17. $sound = '请注意,美团' . $mtSn . '号单有修改';
  18. }
  19. $hasSh = 0;
  20. $hasHs = 0;
  21. $workList = WorkClass::getAllByCondition(['orderId' => $order->id], null, '*', null, true);
  22. if (!empty($workList)) {
  23. foreach ($workList as $work) {
  24. if ($work->status == 0) {
  25. $sh = $work->sh ?? 0;
  26. if ($sh == 0) {
  27. $hasHs = 1;
  28. } else {
  29. $hasSh = 1;
  30. }
  31. }
  32. }
  33. }
  34. if ($hasHs == 1) {
  35. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  36. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  37. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  38. $curl = new curl\Curl();
  39. $curl->get($url);
  40. }
  41. if ($hasSh == 1) {
  42. $lbSn = $shopExt->lbSn ?? '';
  43. $lbVersion = $shopExt->lbVersion;
  44. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  45. $curl = new curl\Curl();
  46. $curl->get($url);
  47. }
  48. }
  49. public static function orderCancelRemind($shopExt, $order)
  50. {
  51. $sendNum = $order->sendNum ?? 0;
  52. $hasSh = 0;
  53. $hasHs = 0;
  54. $workList = WorkClass::getAllByCondition(['orderId' => $order->id], null, '*', null, true);
  55. if (!empty($workList)) {
  56. foreach ($workList as $work) {
  57. if ($work->status == 2) {
  58. $sh = $work->sh ?? 0;
  59. if ($sh == 0) {
  60. $hasHs = 1;
  61. } else {
  62. $hasSh = 1;
  63. }
  64. $sound = '请注意,' . $sendNum . '号单已被取消';
  65. if ($order->fromType == 4) {
  66. $mtSn = $order->thirdSn ?? 0;
  67. $sound = '请注意,美团' . $mtSn . '号单已被取消';
  68. }
  69. }
  70. if ($work->preNum > $work->num && $work->status == 0) {
  71. $sh = $work->sh ?? 0;
  72. if ($sh == 0) {
  73. $hasHs = 1;
  74. } else {
  75. $hasSh = 1;
  76. }
  77. $sound = '请注意,' . $sendNum . '号单有修改';
  78. if ($order->fromType == 4) {
  79. $mtSn = $order->thirdSn ?? 0;
  80. $sound = '请注意,美团' . $mtSn . '号单有修改';
  81. }
  82. }
  83. }
  84. }
  85. if ($hasHs == 1) {
  86. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  87. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  88. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  89. $curl = new curl\Curl();
  90. $curl->get($url);
  91. }
  92. if ($hasSh == 1) {
  93. $lbSn = $shopExt->lbSn ?? '';
  94. $lbVersion = $shopExt->lbVersion;
  95. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  96. $curl = new curl\Curl();
  97. $curl->get($url);
  98. }
  99. }
  100. //新的制作单提示
  101. public static function newWorkRemind($shopExt, $order)
  102. {
  103. $id = $order->id ?? 0;
  104. $list = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
  105. if (empty($list)) {
  106. //提示有订单,但没有生成制作单
  107. if (isset($order->shopAdminId) == false || empty($order->shopAdminId)) {
  108. //$lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  109. //$lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  110. if (!empty($lbSn)) {
  111. //$sound = "您有新订单,编号{$order->sendNum},因还有库存,没有生成制作单";
  112. //$url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  113. //$curl = new curl\Curl();
  114. //$curl->get($url);
  115. }
  116. //noticeUtil::push("订单id:{$id} 因还有库存,没有生成制作单,请跟进", '15280215347');
  117. }
  118. } else {
  119. //散花
  120. $sh = 0;
  121. //花束
  122. $hs = 0;
  123. foreach ($list as $work) {
  124. if ($work->sh == 1) {
  125. $sh = 1;
  126. } else {
  127. $hs = 1;
  128. }
  129. }
  130. if ($sh == 1) {
  131. $lbSn = $shopExt->lbSn ?? '';
  132. $lbVersion = $shopExt->lbVersion ?? '';
  133. if (!empty($lbSn)) {
  134. $sound = "您有新的散花订单";
  135. $reachDate = $order->reachDate ?? '';
  136. if ($order->sendType == 1) {
  137. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  138. $readPeriod = $order->reachPeriod ?? 0;
  139. $period = explode(':', $readPeriod);
  140. $periodName = implode($period, '点');
  141. if ($reachDate == date("Y-m-d")) {
  142. $sound .= ',今天' . $periodName . "分到店自取";
  143. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  144. $sound .= ',明天' . $periodName . "分到店自取";
  145. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  146. $sound .= ',后天' . $periodName . "分到店自取";
  147. } else {
  148. $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
  149. }
  150. } else {
  151. $sound .= ",客户到店自取";
  152. }
  153. } else {
  154. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  155. $readPeriod = $order->reachPeriod ?? 0;
  156. $period = explode(':', $readPeriod);
  157. $periodName = implode($period, '点');
  158. if ($reachDate == date("Y-m-d")) {
  159. $sound .= ',今天' . $periodName . "分前配送";
  160. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  161. $sound .= ',明天' . $periodName . "分前配送";
  162. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  163. $sound .= ',后天' . $periodName . "分前配送";
  164. } else {
  165. $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
  166. }
  167. }
  168. }
  169. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  170. $curl = new curl\Curl();
  171. $curl->get($url);
  172. }
  173. }
  174. if ($hs == 1) {
  175. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  176. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  177. if (!empty($lbSn)) {
  178. $sound = "您有新的制作单";
  179. $reachDate = $order->reachDate ?? '';
  180. if ($order->sendType == 1) {
  181. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  182. $readPeriod = $order->reachPeriod ?? 0;
  183. $period = explode(':', $readPeriod);
  184. $periodName = implode($period, '点');
  185. if ($reachDate == date("Y-m-d")) {
  186. $sound .= ',今天' . $periodName . "分到店自取";
  187. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  188. $sound .= ',明天' . $periodName . "分到店自取";
  189. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  190. $sound .= ',后天' . $periodName . "分到店自取";
  191. } else {
  192. $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
  193. }
  194. } else {
  195. $sound .= ",客户到店自取";
  196. }
  197. } else {
  198. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  199. $readPeriod = $order->reachPeriod ?? 0;
  200. $period = explode(':', $readPeriod);
  201. $periodName = implode($period, '点');
  202. if ($reachDate == date("Y-m-d")) {
  203. $sound .= ',今天' . $periodName . "分前配送";
  204. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  205. $sound .= ',明天' . $periodName . "分前配送";
  206. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  207. $sound .= ',后天' . $periodName . "分前配送";
  208. } else {
  209. $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
  210. }
  211. }
  212. }
  213. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  214. $curl = new curl\Curl();
  215. $curl->get($url);
  216. $curl->get($url);
  217. }
  218. }
  219. }
  220. }
  221. //花店采购供货商端播放声音
  222. public static function hdCgGhsReport($orderSn)
  223. {
  224. $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  225. if (isset($cg->onlinePay) && $cg->onlinePay == dict::getDict('onlinePay', 'yes')) {
  226. $saleId = $cg->saleId ?? 0;
  227. $order = \bizGhs\order\classes\OrderClass::getById($saleId, true);
  228. if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'noNeed')) {
  229. $shopId = $order->shopId ?? 0;
  230. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  231. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  232. $actPrice = floatval($order->actPrice) ?? 0;
  233. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  234. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  235. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  236. $curl = new curl\Curl();
  237. $curl->get($url);
  238. }
  239. }
  240. //app新订单通知
  241. //NoticeClass::ghsNewOrderNotice($order);
  242. }
  243. }
  244. public static function pleasePayReport($order)
  245. {
  246. $shopId = $order->shopId ?? 0;
  247. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  248. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  249. $mainPay = $order->mainPay ? floatval($order->mainPay) : 0;
  250. $sound = $mainPay . '元,请出示付款码';
  251. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  252. $curl = new curl\Curl();
  253. $curl->get($url);
  254. }
  255. }
  256. //供货商收银台 ssh 20230421
  257. public static function ghsPleasePayReport($order)
  258. {
  259. $shopId = $order->shopId ?? 0;
  260. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  261. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  262. $mainPay = $order->actPrice ? floatval($order->actPrice) : 0;
  263. $sound = $mainPay . '元,请出示付款码';
  264. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  265. $curl = new curl\Curl();
  266. $curl->get($url);
  267. }
  268. }
  269. //零售花店收款声音播放 ssh 20220423
  270. public static function hdGatheringReport($order)
  271. {
  272. if ($order->fromType != dict::getDict("fromType", "shop")) {
  273. //非门店订单不播报语音
  274. return false;
  275. }
  276. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  277. //非在线支付的不播报
  278. return false;
  279. }
  280. if ($order->payStatus != 1) {
  281. //还没有付款订单不播报
  282. return false;
  283. }
  284. $shopId = $order->shopId ?? 0;
  285. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  286. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  287. $actPrice = $order->mainPay ? floatval($order->mainPay) : 0;
  288. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  289. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  290. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  291. $curl = new curl\Curl();
  292. $curl->get($url);
  293. }
  294. }
  295. public static function skRechargeReport($recharge)
  296. {
  297. if (empty($recharge)) {
  298. return false;
  299. }
  300. if ($recharge->payStatus != 1) {
  301. //还没有付款订单不播报
  302. return false;
  303. }
  304. $shopId = $recharge->shopId ?? 0;
  305. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  306. if (!empty($shopExt->lbSn)) {
  307. $actPrice = $recharge->amount ?? 0;
  308. $payWay = $recharge->payWay ?? 0;
  309. $sound = $payWay == 0 ? "微信充值{$actPrice}元," : "支付宝充值{$actPrice}元";
  310. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  311. $curl = new curl\Curl();
  312. $curl->get($url);
  313. }
  314. }
  315. public static function hdScanPayReport($order)
  316. {
  317. if (empty($order)) {
  318. return false;
  319. }
  320. if ($order->payStatus != 1) {
  321. //还没有付款订单不播报
  322. return false;
  323. }
  324. $shopId = $order->shopId ?? 0;
  325. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  326. if (!empty($shopExt->lbSn)) {
  327. $actPrice = $order->actPrice ?? 0;
  328. $payWay = $order->payWay ?? 0;
  329. $sound = $payWay == 0 ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  330. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  331. $curl = new curl\Curl();
  332. $curl->get($url);
  333. }
  334. }
  335. //供货商收款声音播放 ssh 20230421
  336. public static function ghsGatheringReport($order)
  337. {
  338. if ($order->fromType != dict::getDict("fromType", "shop")) {
  339. //非门店订单不播报语音
  340. return false;
  341. }
  342. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  343. //非在线支付的不播报
  344. return false;
  345. }
  346. if ($order->payStatus != 1) {
  347. //还没有付款订单不播报
  348. return false;
  349. }
  350. $shopId = $order->shopId ?? 0;
  351. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  352. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  353. $actPrice = $order->actPrice ? floatval($order->actPrice) : 0;
  354. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  355. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  356. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  357. $curl = new curl\Curl();
  358. $curl->get($url);
  359. }
  360. }
  361. //订单取消,钱原路退回,提醒客户
  362. public static function orderCancelBackMoneyReport($shopId)
  363. {
  364. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  365. if (!empty($shopExt->lbSn)) {
  366. $sound = "订单已取消,付款已原路退回,请稍等几秒重新付款";
  367. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  368. $curl = new curl\Curl();
  369. $curl->get($url);
  370. }
  371. }
  372. //提醒输入密码 ssh 20250501
  373. public static function remindInputPassword($shopId)
  374. {
  375. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  376. if (!empty($shopExt->lbSn)) {
  377. $sound = "请输入密码";
  378. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  379. $curl = new curl\Curl();
  380. $curl->get($url);
  381. }
  382. }
  383. //清除所有小菊
  384. public static function clearXjALl($shopId)
  385. {
  386. $where = [];
  387. $where['shopId'] = $shopId;
  388. return self::updateByCondition($where, ['xj' => '']);
  389. }
  390. }