InformAdminClass.php 5.1 KB

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