InformAdminClass.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace biz\message\classes;
  3. use Yii;
  4. use biz\base\classes\BaseClass;
  5. class InformAdminClass extends BaseClass
  6. {
  7. public static $baseFile = '\biz\message\models\InformAdmin';
  8. //增加通知员工 shish
  9. public static function addInform($params, $admin, $type, $TMList)
  10. {
  11. switch ($type) {
  12. case 'goodsSold':
  13. //宝贝售出
  14. $respond = self::goodsSoldInform($params, $admin, $TMList);
  15. break;
  16. case 'income':
  17. //收入提醒
  18. $respond = self::incomeInform($params, $admin, $TMList);
  19. break;
  20. default:
  21. }
  22. $data = ['messageType' => 'inform', 'informWay' => 'wx', 'userType' => 'admin', 'id' => 1, 'mobile' => '15280215347'];
  23. $data = array_merge($data, $respond);
  24. $producer = Yii::$app->rabbitmq->getProducer('producerInform');
  25. $msg = serialize($data);
  26. $producer->publish($msg, 'exInform', 'routeInform');
  27. }
  28. public static function incomeInform()
  29. {
  30. return [];
  31. }
  32. //宝贝售出通知 shish 2019.12.24
  33. public static function goodsSoldInform($params, $admin, $TMList)
  34. {
  35. $totalFee = 199;
  36. $orderSn = '2051229823132466';
  37. $orderName = '商品';
  38. $userName = '石头';
  39. $data['briefContent'] = "客户" . $userName . "付款" . $totalFee . '元';
  40. //收入提醒
  41. $openId = $admin['openId'];
  42. $shortTempId = 'OPENTM207422813';
  43. $tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
  44. $tMessage = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderSn, "data" => [
  45. "first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
  46. "keyword1" => ["value" => (string)$orderSn, "color" => "#173177"],
  47. "keyword2" => ["value" => $orderName, "color" => "#173177"],
  48. "keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  49. "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  50. "keyword5" => ["value" => $userName, "color" => "#173177"],
  51. "remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
  52. $data['tMessage'] = json_encode($tMessage);
  53. $msg = "客户" . $userName . "付款" . $totalFee . '元';
  54. $data['content'] = $msg;
  55. return $data;
  56. }
  57. //门店收入提醒 shish 2019.12.24
  58. public static function shopIncomeInformAdmin2($data, $merchantId = 0)
  59. {
  60. $TMList = xhTMessageService::getList($merchantId);
  61. $adminList = AdminClass::getAllNoticeAdmin($merchantId);
  62. $merchant = MerchantService::getById($merchantId);
  63. $shortTempId = 'OPENTM207422813';//收入提醒
  64. if (isset($TMList[$shortTempId]) == false) {
  65. util::fail('没有找到公众号的消息模样:' . $shortTempId);
  66. }
  67. $tempId = $TMList[$shortTempId];
  68. foreach ($adminList as $adminKey => $admin) {
  69. $openId = $admin['openId'];
  70. if (!empty($openId) && $admin['subscribe'] == 1) {
  71. $data = ["touser" => $openId, "template_id" => $tempId,
  72. "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderSn, "data" => [
  73. "first" => ["value" => $userName . $payWay . '付款', "color" => "#173177"],
  74. "keyword1" => ["value" => $totalFee . '元', "color" => "#173177"],
  75. "keyword2" => ["value" => '客户付款', "color" => "#173177"],
  76. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  77. "remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
  78. $respond = wxUtil::sendTaskInform($data, $merchant);
  79. Yii::info('tm:' . json_encode($respond));
  80. } else {
  81. $mobile = $admin['mobile'];
  82. $msg = "客户" . $userName . "付款" . $totalFee . '元';
  83. sms::merchantSend($mobile, $msg, $merchant);
  84. }
  85. }
  86. }
  87. //宝贝售出通知 shish 2019.12.24
  88. public static function goodsSoldInform2($merchantId)
  89. {
  90. $TMList = xhTMessageService::getList($merchantId);
  91. $merchant = MerchantService::getById($merchantId);
  92. $shortTempId = 'OPENTM207422813';//收入提醒
  93. $tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
  94. foreach ($adminList as $adminKey => $admin) {
  95. $openId = $admin['openId'];
  96. if (!empty($openId) && $admin['subscribe'] == 1) {
  97. $sendData = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderSn, "data" => [
  98. "first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
  99. "keyword1" => ["value" => (string)$orderSn, "color" => "#173177"],
  100. "keyword2" => ["value" => $orderName, "color" => "#173177"],
  101. "keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  102. "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  103. "keyword5" => ["value" => $userName, "color" => "#173177"],
  104. "remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
  105. $respond = wxUtil::sendTaskInform($sendData, $merchant);
  106. Yii::info('tm:' . json_encode($respond));
  107. } else {
  108. $mobile = $admin['mobile'];
  109. $msg = "客户" . $userName . "付款" . $totalFee . '元';
  110. sms::merchantSend($mobile, $msg, $merchant);
  111. }
  112. }
  113. }
  114. //添加通知内容 shish 2020.1.8
  115. public static function addData($data)
  116. {
  117. self::add($data);
  118. }
  119. }