NotifyClass.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. }
  47. //新增售后申请通过 ssh 20230814
  48. public static function addRefundApplyNotify($refund)
  49. {
  50. $mainId = $refund->mainId ?? 0;
  51. $shopId = $refund->shopId ?? 0;
  52. $title = '售后申请';
  53. $id = $refund->id;
  54. $refundPrice = $refund->refundPrice;
  55. $refundPrice = floatval($refundPrice);
  56. $customId = $refund->customId;
  57. $custom = CustomClass::getById($customId, true);
  58. $customName = $custom->name ?? '';
  59. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  60. if (!empty($staffList)) {
  61. foreach ($staffList as $staff) {
  62. $staffId = $staff->id;
  63. $data = [
  64. 'mainId' => $mainId,
  65. 'shopId' => $shopId,
  66. 'staffId' => $staffId,
  67. 'title' => $title,
  68. 'type' => 0,
  69. 'targetId' => $id,
  70. 'read' => 0,
  71. 'content' => $customName . '申请退款' . $refundPrice . '元',
  72. 'page' => '/pagesOrder/refundDetail?from=1&id=' . $id,
  73. ];
  74. self::add($data);
  75. $notifyNum = bcadd($staff->notifyNum, 1);
  76. $staff->notifyNum = $notifyNum;
  77. $staff->save();
  78. }
  79. }
  80. }
  81. }