ShopExtClass.php 18 KB

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