NotifyClass.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace bizGhs\notify\classes;
  3. use bizGhs\base\classes\BaseClass;
  4. use bizGhs\custom\classes\CustomClass;
  5. use bizGhs\shop\classes\ShopAdminClass;
  6. use Yii;
  7. class NotifyClass extends BaseClass
  8. {
  9. public static $baseFile = '\bizGhs\notify\models\Notify';
  10. public static function getNotifyList($where)
  11. {
  12. $data = self::getList('*', $where, 'addTime DESC');
  13. return $data;
  14. }
  15. //减少预订造成花材需要下架
  16. public static function bookReduceOutItem($bookItemCustomRes, $num, $shop)
  17. {
  18. $mainId = $shop->mainId ?? 0;
  19. $shopId = $shop->id ?? 0;
  20. $id = $bookItemCustomRes->id ?? 0;
  21. $customName = $bookItemCustomRes->customName ?? '';
  22. $seatSn = $bookItemCustomRes->seatSn ?? 0;
  23. $itemName = $bookItemCustomRes->name ?? '';
  24. $itemId = $bookItemCustomRes->itemId ?? 0;
  25. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  26. if (!empty($staffList)) {
  27. foreach ($staffList as $staff) {
  28. $staffId = $staff->id;
  29. $data = [
  30. 'mainId' => $mainId,
  31. 'shopId' => $shopId,
  32. 'staffId' => $staffId,
  33. 'title' => '下架花材',
  34. 'type' => 2,
  35. 'targetId' => $id,
  36. 'read' => 0,
  37. 'content' => '预订减少,请下架' . $customName . '(' . $seatSn . ')' . $itemName . $num . '份',
  38. 'page' => '/admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName,
  39. ];
  40. self::add($data);
  41. $notifyNum = bcadd($staff->notifyNum, 1);
  42. $staff->notifyNum = $notifyNum;
  43. $staff->save();
  44. }
  45. }
  46. $noticeText = json_encode(['id' => $id, 'num' => $num, 'shopId' => $shopId]);
  47. $noticeKey = "bookChangeOffItem";
  48. Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
  49. }
  50. //新增售后申请通过 ssh 20230814
  51. public static function addRefundApplyNotify($refund)
  52. {
  53. $mainId = $refund->mainId ?? 0;
  54. $shopId = $refund->shopId ?? 0;
  55. $title = '售后申请';
  56. $id = $refund->id;
  57. $refundPrice = $refund->refundPrice;
  58. $refundPrice = floatval($refundPrice);
  59. $customId = $refund->customId;
  60. $custom = CustomClass::getById($customId, true);
  61. $customName = $custom->name ?? '';
  62. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  63. if (!empty($staffList)) {
  64. foreach ($staffList as $staff) {
  65. $staffId = $staff->id;
  66. $data = [
  67. 'mainId' => $mainId,
  68. 'shopId' => $shopId,
  69. 'staffId' => $staffId,
  70. 'title' => $title,
  71. 'type' => 0,
  72. 'targetId' => $id,
  73. 'read' => 0,
  74. 'content' => $customName . '申请退款' . $refundPrice . '元',
  75. 'page' => '/pagesOrder/refundDetail?from=1&id=' . $id,
  76. ];
  77. self::add($data);
  78. $notifyNum = bcadd($staff->notifyNum, 1);
  79. $staff->notifyNum = $notifyNum;
  80. $staff->save();
  81. }
  82. }
  83. }
  84. }