InformAdminClass.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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' => 6, '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($params, $admin, $TMList)
  29. {
  30. $totalFee = 199;
  31. $orderSn = '2051229823132466';
  32. $orderName = '商品';
  33. $userName = '石头';
  34. $data['briefContent'] = "客户" . $userName . "付款" . $totalFee . '元';
  35. //收入提醒
  36. $openId = $admin['openId'];
  37. $shortTempId = 'OPENTM207422813';
  38. $tempId = isset($TMList[$shortTempId]) ? $TMList[$shortTempId] : '';
  39. $tMessage = ["touser" => $openId, "template_id" => $tempId, "url" => Yii::$app->params['adminUrl'] . '/order/detail?id=' . $orderSn, "data" => [
  40. "first" => ["value" => '您有宝贝售出哦!', "color" => "#173177"],
  41. "keyword1" => ["value" => (string)$orderSn, "color" => "#173177"],
  42. "keyword2" => ["value" => $orderName, "color" => "#173177"],
  43. "keyword3" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  44. "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  45. "keyword5" => ["value" => $userName, "color" => "#173177"],
  46. "remark" => ["value" => '点此查看详细、编辑收花人信息。', "color" => "#173177"]]];
  47. $data['tMessage'] = json_encode($tMessage);
  48. $msg = "客户" . $userName . "付款" . $totalFee . '元';
  49. $data['content'] = $msg;
  50. return $data;
  51. }
  52. //添加通知内容 shish 2020.1.8
  53. public static function addData($data)
  54. {
  55. self::add($data);
  56. }
  57. }