ShopExtClass.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  104. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  105. if (empty($lbSn)) {
  106. return false;
  107. }
  108. $sound = "您有新的制作单";
  109. $reachDate = $order->reachDate ?? '';
  110. if ($order->sendType == 1) {
  111. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  112. $readPeriod = $order->reachPeriod ?? 0;
  113. $period = explode(':', $readPeriod);
  114. $periodName = implode($period, '点');
  115. if ($reachDate == date("Y-m-d")) {
  116. $sound .= ',今天' . $periodName . "分到店自取";
  117. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  118. $sound .= ',明天' . $periodName . "分到店自取";
  119. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  120. $sound .= ',后天' . $periodName . "分到店自取";
  121. } else {
  122. $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
  123. }
  124. } else {
  125. $sound .= ",客户到店自取";
  126. }
  127. } else {
  128. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  129. $readPeriod = $order->reachPeriod ?? 0;
  130. $period = explode(':', $readPeriod);
  131. $periodName = implode($period, '点');
  132. if ($reachDate == date("Y-m-d")) {
  133. $sound .= ',今天' . $periodName . "分前配送";
  134. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  135. $sound .= ',明天' . $periodName . "分前配送";
  136. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  137. $sound .= ',后天' . $periodName . "分前配送";
  138. } else {
  139. $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
  140. }
  141. }
  142. }
  143. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  144. $curl = new curl\Curl();
  145. $curl->get($url);
  146. $curl->get($url);
  147. return true;
  148. }
  149. //花店采购供货商端播放声音
  150. public static function hdCgGhsReport($orderSn)
  151. {
  152. $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  153. if (isset($cg->onlinePay) && $cg->onlinePay == dict::getDict('onlinePay', 'yes')) {
  154. $saleId = $cg->saleId ?? 0;
  155. $order = \bizGhs\order\classes\OrderClass::getById($saleId, true);
  156. if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'noNeed')) {
  157. $shopId = $order->shopId ?? 0;
  158. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  159. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  160. $actPrice = floatval($order->actPrice) ?? 0;
  161. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  162. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  163. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  164. $curl = new curl\Curl();
  165. $curl->get($url);
  166. }
  167. }
  168. //app新订单通知
  169. //NoticeClass::ghsNewOrderNotice($order);
  170. }
  171. }
  172. public static function pleasePayReport($order)
  173. {
  174. $shopId = $order->shopId ?? 0;
  175. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  176. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  177. $mainPay = $order->mainPay ? floatval($order->mainPay) : 0;
  178. $sound = $mainPay . '元,请出示付款码';
  179. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  180. $curl = new curl\Curl();
  181. $curl->get($url);
  182. }
  183. }
  184. //供货商收银台 ssh 20230421
  185. public static function ghsPleasePayReport($order)
  186. {
  187. $shopId = $order->shopId ?? 0;
  188. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  189. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  190. $mainPay = $order->actPrice ? floatval($order->actPrice) : 0;
  191. $sound = $mainPay . '元,请出示付款码';
  192. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  193. $curl = new curl\Curl();
  194. $curl->get($url);
  195. }
  196. }
  197. //零售花店收款声音播放 ssh 20220423
  198. public static function hdGatheringReport($order)
  199. {
  200. if ($order->fromType != dict::getDict("fromType", "shop")) {
  201. //非门店订单不播报语音
  202. return false;
  203. }
  204. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  205. //非在线支付的不播报
  206. return false;
  207. }
  208. if ($order->payStatus != 1) {
  209. //还没有付款订单不播报
  210. return false;
  211. }
  212. $shopId = $order->shopId ?? 0;
  213. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  214. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  215. $actPrice = $order->mainPay ? floatval($order->mainPay) : 0;
  216. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  217. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  218. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  219. $curl = new curl\Curl();
  220. $curl->get($url);
  221. }
  222. }
  223. public static function skRechargeReport($recharge)
  224. {
  225. if (empty($recharge)) {
  226. return false;
  227. }
  228. if ($recharge->payStatus != 1) {
  229. //还没有付款订单不播报
  230. return false;
  231. }
  232. $shopId = $recharge->shopId ?? 0;
  233. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  234. if (!empty($shopExt->lbSn)) {
  235. $actPrice = $recharge->amount ?? 0;
  236. $payWay = $recharge->payWay ?? 0;
  237. $sound = $payWay == 0 ? "微信充值{$actPrice}元," : "支付宝充值{$actPrice}元";
  238. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  239. $curl = new curl\Curl();
  240. $curl->get($url);
  241. }
  242. }
  243. public static function hdScanPayReport($order)
  244. {
  245. if (empty($order)) {
  246. return false;
  247. }
  248. if ($order->payStatus != 1) {
  249. //还没有付款订单不播报
  250. return false;
  251. }
  252. $shopId = $order->shopId ?? 0;
  253. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  254. if (!empty($shopExt->lbSn)) {
  255. $actPrice = $order->actPrice ?? 0;
  256. $payWay = $order->payWay ?? 0;
  257. $sound = $payWay == 0 ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  258. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  259. $curl = new curl\Curl();
  260. $curl->get($url);
  261. }
  262. }
  263. //供货商收款声音播放 ssh 20230421
  264. public static function ghsGatheringReport($order)
  265. {
  266. if ($order->fromType != dict::getDict("fromType", "shop")) {
  267. //非门店订单不播报语音
  268. return false;
  269. }
  270. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  271. //非在线支付的不播报
  272. return false;
  273. }
  274. if ($order->payStatus != 1) {
  275. //还没有付款订单不播报
  276. return false;
  277. }
  278. $shopId = $order->shopId ?? 0;
  279. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  280. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  281. $actPrice = $order->actPrice ? floatval($order->actPrice) : 0;
  282. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  283. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
  284. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  285. $curl = new curl\Curl();
  286. $curl->get($url);
  287. }
  288. }
  289. //订单取消,钱原路退回,提醒客户
  290. public static function orderCancelBackMoneyReport($shopId)
  291. {
  292. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  293. if (!empty($shopExt->lbSn)) {
  294. $sound = "订单已取消,付款已原路退回,请稍等几秒重新付款";
  295. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  296. $curl = new curl\Curl();
  297. $curl->get($url);
  298. }
  299. }
  300. //提醒输入密码 ssh 20250501
  301. public static function remindInputPassword($shopId)
  302. {
  303. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  304. if (!empty($shopExt->lbSn)) {
  305. $sound = "请输入密码";
  306. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  307. $curl = new curl\Curl();
  308. $curl->get($url);
  309. }
  310. }
  311. //清除所有小菊
  312. public static function clearXjALl($shopId)
  313. {
  314. $where = [];
  315. $where['shopId'] = $shopId;
  316. return self::updateByCondition($where, ['xj' => '']);
  317. }
  318. }