ShopExtClass.php 12 KB

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