InformAdminService.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace biz\message\services;
  3. use biz\admin\classes\AdminClass;
  4. use biz\admin\classes\AdminShopClass;
  5. use biz\admin\services\AdminService;
  6. use biz\admin\services\AdminShopService;
  7. use biz\base\services\BaseService;
  8. use biz\merchant\services\MerchantService;
  9. use biz\message\classes\InformAdminClass;
  10. use common\components\sms;
  11. use common\components\wxUtil;
  12. use common\services\xhTMessageService;
  13. use Yii;
  14. class InformAdminService extends BaseService
  15. {
  16. public static $baseFile = '\biz\message\classes\InformAdminClass';
  17. //通知员工 shish 2020.1.1
  18. public static function addInform($merchantId, $shopId, $type, $params)
  19. {
  20. $adminShopList = AdminShopService::getNoticeAdminList($shopId);
  21. if (empty($adminShopList)) {
  22. return false;
  23. }
  24. //本地环境取消通知
  25. if (getenv('YII_ENV') == 'local') {
  26. return false;
  27. }
  28. $TMList = xhTMessageService::getList($merchantId);
  29. foreach ($adminShopList as $adminKey => $adminShop) {
  30. InformAdminClass::addInform($params, $adminShop, $type, $TMList);
  31. }
  32. }
  33. //消费通知内容 shish 2020.1.1
  34. //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','adminShopId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'']
  35. public static function consumeInformQueue($data)
  36. {
  37. $informWay = $data['informWay'];
  38. $adminShopId = $data['adminShopId'];
  39. $adminShop = AdminShopClass::getById($adminShopId);
  40. $merchantId = $adminShop['merchantId'];
  41. $mobile = $data['mobile'];
  42. $merchant = MerchantService::getMerchantById($merchantId);
  43. $hasSend = 0;
  44. $noticeWay = 0;
  45. if ($informWay == 'wx') {
  46. $tMessage = json_decode($data['tMessage'], true);
  47. $r = wxUtil::sendTaskInform($tMessage, $merchant);
  48. print_r($r);
  49. $hasSend = 1;
  50. $noticeWay = 0;
  51. } elseif ($informWay == 'sms') {
  52. $msg = $data['content'];
  53. sms::merchantSend($mobile, $msg, $merchant);
  54. $hasSend = 1;
  55. $noticeWay = 1;
  56. } elseif ($informWay == 'miniProgram') {
  57. $tMessage = json_decode($data['tMessage'], true);
  58. $r = wxUtil::sendTaskInform($tMessage, $merchant);
  59. print_r($r);
  60. $hasSend = 1;
  61. $noticeWay = 0;
  62. } else {
  63. }
  64. //存入数据库
  65. $informData = [
  66. 'userId' => $admin['userId'],
  67. 'adminId' => $id,
  68. 'merchantId' => $merchantId,
  69. 'noticeType' => 0,
  70. 'content' => $data['briefContent'],
  71. 'noticeWay' => $noticeWay,
  72. 'status' => $hasSend,
  73. 'sourceType' => 0,
  74. 'sourceId' => 0,
  75. 'addTime' => time(),
  76. 'createTime' => date("Y-m-d H:i:s"),
  77. ];
  78. InformAdminClass::addData($informData);
  79. return true;
  80. }
  81. }