ShopExtClass.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 linslin\yii2\curl;
  8. use biz\base\classes\BaseClass;
  9. class ShopExtClass extends BaseClass
  10. {
  11. public static $baseFile = '\biz\shop\models\ShopExt';
  12. public static function orderCancelRemind($shopExt, $order)
  13. {
  14. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  15. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  16. $sendNum = $order->sendNum ?? 0;
  17. $sound = $sendNum . '号单已被取消';
  18. if ($order->fromType == 4) {
  19. $mtSn = $order->thirdSn ?? 0;
  20. $sound = '美团' . $mtSn . '号单已被取消';
  21. }
  22. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  23. $curl = new curl\Curl();
  24. $curl->get($url);
  25. }
  26. //新的制作单提示
  27. public static function newWorkRemind($shopExt, $order)
  28. {
  29. $id = $order->id ?? 0;
  30. $list = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
  31. if (empty($list)) {
  32. //提示有订单,但没有生成制作单
  33. if (isset($order->shopAdminId) == false || empty($order->shopAdminId)) {
  34. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  35. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  36. $sound = "您有新订单,没有生成制作单";
  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. } else {
  42. //散花
  43. $sh = 0;
  44. //花束
  45. $hs = 0;
  46. foreach ($list as $work) {
  47. if ($work->sh == 1) {
  48. $sh = 1;
  49. } else {
  50. $hs = 1;
  51. }
  52. }
  53. if ($sh == 1) {
  54. $lbSn = $shopExt->lbSn??'';
  55. $lbVersion = $shopExt->lbVersion??'';
  56. if (!empty($lbSn)) {
  57. $sound = "您有新的散花订单";
  58. $reachDate = $order->reachDate ?? '';
  59. if ($order->sendType == 1) {
  60. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  61. $readPeriod = $order->reachPeriod ?? 0;
  62. $period = explode(':', $readPeriod);
  63. $periodName = implode($period, '点');
  64. if ($reachDate == date("Y-m-d")) {
  65. $sound .= ',今天' . $periodName . "分客户到店自取";
  66. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  67. $sound .= ',明天' . $periodName . "分客户到店自取";
  68. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  69. $sound .= ',后天' . $periodName . "分客户到店自取";
  70. } else {
  71. $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分客户到店自取";
  72. }
  73. } else {
  74. $sound .= ",客户到店自取";
  75. }
  76. } else {
  77. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  78. $readPeriod = $order->reachPeriod ?? 0;
  79. $period = explode(':', $readPeriod);
  80. $periodName = implode($period, '点');
  81. if ($reachDate == date("Y-m-d")) {
  82. $sound .= ',今天' . $periodName . "分前送达";
  83. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  84. $sound .= ',明天' . $periodName . "分前送达";
  85. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  86. $sound .= ',后天' . $periodName . "分前送达";
  87. } else {
  88. $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前送达";
  89. }
  90. }
  91. }
  92. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  93. $curl = new curl\Curl();
  94. $curl->get($url);
  95. }
  96. }
  97. if ($hs == 1) {
  98. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  99. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  100. if (!empty($lbSn)) {
  101. $sound = "您有新的制作单";
  102. $reachDate = $order->reachDate ?? '';
  103. if ($order->sendType == 1) {
  104. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  105. $readPeriod = $order->reachPeriod ?? 0;
  106. $period = explode(':', $readPeriod);
  107. $periodName = implode($period, '点');
  108. if ($reachDate == date("Y-m-d")) {
  109. $sound .= ',今天' . $periodName . "分客户到店自取";
  110. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  111. $sound .= ',明天' . $periodName . "分客户到店自取";
  112. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  113. $sound .= ',后天' . $periodName . "分客户到店自取";
  114. } else {
  115. $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分客户到店自取";
  116. }
  117. } else {
  118. $sound .= ",客户到店自取";
  119. }
  120. } else {
  121. if (!empty($reachDate) && $reachDate != '0000-00-00') {
  122. $readPeriod = $order->reachPeriod ?? 0;
  123. $period = explode(':', $readPeriod);
  124. $periodName = implode($period, '点');
  125. if ($reachDate == date("Y-m-d")) {
  126. $sound .= ',今天' . $periodName . "分前送达";
  127. } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
  128. $sound .= ',明天' . $periodName . "分前送达";
  129. } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
  130. $sound .= ',后天' . $periodName . "分前送达";
  131. } else {
  132. $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前送达";
  133. }
  134. }
  135. }
  136. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  137. $curl = new curl\Curl();
  138. $curl->get($url);
  139. }
  140. }
  141. }
  142. }
  143. //花店采购供货商端播放声音
  144. public static function hdCgGhsReport($orderSn)
  145. {
  146. $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  147. if (isset($cg->onlinePay) && $cg->onlinePay == dict::getDict('onlinePay', 'yes')) {
  148. $saleId = $cg->saleId ?? 0;
  149. $order = \bizGhs\order\classes\OrderClass::getById($saleId, true);
  150. if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'noNeed')) {
  151. $shopId = $order->shopId ?? 0;
  152. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  153. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  154. $actPrice = floatval($order->actPrice) ?? 0;
  155. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  156. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  157. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  158. $curl = new curl\Curl();
  159. $curl->get($url);
  160. }
  161. }
  162. //app新订单通知
  163. NoticeClass::ghsNewOrderNotice($order);
  164. }
  165. }
  166. public static function pleasePayReport($order)
  167. {
  168. $shopId = $order->shopId ?? 0;
  169. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  170. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  171. $mainPay = $order->mainPay ? floatval($order->mainPay) : 0;
  172. $sound = $mainPay . '元,请出示付款码';
  173. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  174. $curl = new curl\Curl();
  175. $curl->get($url);
  176. }
  177. }
  178. //零售花店收款声音播放 ssh 20220423
  179. public static function hdGatheringReport($order)
  180. {
  181. if ($order->fromType != dict::getDict("fromType", "shop")) {
  182. //非门店订单不播报语音
  183. return false;
  184. }
  185. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  186. //非在线支付的不播报
  187. return false;
  188. }
  189. if ($order->payStatus != 1) {
  190. //还没有付款订单不播报
  191. return false;
  192. }
  193. $shopId = $order->shopId ?? 0;
  194. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  195. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  196. $actPrice = $order->mainPay ? floatval($order->mainPay) : 0;
  197. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  198. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  199. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  200. $curl = new curl\Curl();
  201. $curl->get($url);
  202. }
  203. }
  204. //清除所有小菊
  205. public static function clearXjALl($shopId)
  206. {
  207. $where = [];
  208. $where['shopId'] = $shopId;
  209. return self::updateByCondition($where, ['xj' => '']);
  210. }
  211. }