ShopExtClass.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 orderUpdateRemind($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 == 0) {
  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. public static function orderCancelRemind($shopExt, $order)
  51. {
  52. $sendNum = $order->sendNum ?? 0;
  53. $hasSh = 0;
  54. $hasHs = 0;
  55. $workList = WorkClass::getAllByCondition(['orderId' => $order->id], null, '*', null, true);
  56. if (!empty($workList)) {
  57. foreach ($workList as $work) {
  58. if ($work->status == 2) {
  59. $sh = $work->sh ?? 0;
  60. if ($sh == 0) {
  61. $hasHs = 1;
  62. } else {
  63. $hasSh = 1;
  64. }
  65. $sound = $sendNum . '号单已被取消,请注意';
  66. if ($order->fromType == 4) {
  67. $mtSn = $order->thirdSn ?? 0;
  68. $sound = '美团' . $mtSn . '号单已被取消,请注意';
  69. }
  70. }
  71. if ($work->preNum > $work->num && $work->status == 0) {
  72. $sh = $work->sh ?? 0;
  73. if ($sh == 0) {
  74. $hasHs = 1;
  75. } else {
  76. $hasSh = 1;
  77. }
  78. $sound = $sendNum . '号单有修改,请注意';
  79. if ($order->fromType == 4) {
  80. $mtSn = $order->thirdSn ?? 0;
  81. $sound = '美团' . $mtSn . '号单有修改,请注意';
  82. }
  83. }
  84. }
  85. }
  86. if ($hasHs == 1) {
  87. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  88. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  89. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  90. $curl = new curl\Curl();
  91. $curl->get($url);
  92. }
  93. if ($hasSh == 1) {
  94. $lbSn = $shopExt->lbSn ?? '';
  95. $lbVersion = $shopExt->lbVersion;
  96. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  97. $curl = new curl\Curl();
  98. $curl->get($url);
  99. }
  100. }
  101. //新的制作单提示
  102. public static function newWorkRemind($shopExt, $order)
  103. {
  104. $id = $order->id ?? 0;
  105. $list = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
  106. if (empty($list)) {
  107. //提示有订单,但没有生成制作单
  108. if (isset($order->shopAdminId) == false || empty($order->shopAdminId)) {
  109. $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
  110. $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
  111. if (!empty($lbSn)) {
  112. $sound = "您有新订单,没有生成制作单";
  113. $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
  114. $curl = new curl\Curl();
  115. $curl->get($url);
  116. }
  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. }
  217. }
  218. }
  219. }
  220. //花店采购供货商端播放声音
  221. public static function hdCgGhsReport($orderSn)
  222. {
  223. $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  224. if (isset($cg->onlinePay) && $cg->onlinePay == dict::getDict('onlinePay', 'yes')) {
  225. $saleId = $cg->saleId ?? 0;
  226. $order = \bizGhs\order\classes\OrderClass::getById($saleId, true);
  227. if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'noNeed')) {
  228. $shopId = $order->shopId ?? 0;
  229. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  230. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  231. $actPrice = floatval($order->actPrice) ?? 0;
  232. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  233. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  234. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  235. $curl = new curl\Curl();
  236. $curl->get($url);
  237. }
  238. }
  239. //app新订单通知
  240. NoticeClass::ghsNewOrderNotice($order);
  241. }
  242. }
  243. public static function pleasePayReport($order)
  244. {
  245. $shopId = $order->shopId ?? 0;
  246. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  247. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  248. $mainPay = $order->mainPay ? floatval($order->mainPay) : 0;
  249. $sound = $mainPay . '元,请出示付款码';
  250. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  251. $curl = new curl\Curl();
  252. $curl->get($url);
  253. }
  254. }
  255. //零售花店收款声音播放 ssh 20220423
  256. public static function hdGatheringReport($order)
  257. {
  258. if ($order->fromType != dict::getDict("fromType", "shop")) {
  259. //非门店订单不播报语音
  260. return false;
  261. }
  262. if ($order->onlinePay == dict::getDict('onlinePay', 'not')) {
  263. //非在线支付的不播报
  264. return false;
  265. }
  266. if ($order->payStatus != 1) {
  267. //还没有付款订单不播报
  268. return false;
  269. }
  270. $shopId = $order->shopId ?? 0;
  271. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  272. if (isset($shopExt->lbSn) && !empty($shopExt->lbSn)) {
  273. $actPrice = $order->mainPay ? floatval($order->mainPay) : 0;
  274. $payWay = $order->payWay ?? dict::getDict('payWay', 'wxPay');
  275. $sound = $payWay == dict::getDict('payWay', 'wxPay') ? "微信收款{$actPrice}元" : "支付宝收款{$actPrice}元";
  276. $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
  277. $curl = new curl\Curl();
  278. $curl->get($url);
  279. }
  280. }
  281. //清除所有小菊
  282. public static function clearXjALl($shopId)
  283. {
  284. $where = [];
  285. $where['shopId'] = $shopId;
  286. return self::updateByCondition($where, ['xj' => '']);
  287. }
  288. }