| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace biz\message\services;
- use biz\admin\classes\AdminClass;
- use biz\admin\classes\ShopAdminClass;
- use biz\admin\services\AdminService;
- use biz\admin\services\ShopAdminService;
- use biz\base\services\BaseService;
- use biz\merchant\services\MerchantService;
- use biz\message\classes\InformAdminClass;
- use biz\wx\services\WxOpenService;
- use common\components\sms;
- use common\components\util;
- use common\components\wxUtil;
- use common\services\xhTMessageService;
- use Yii;
- class InformAdminService extends BaseService
- {
-
- public static $baseFile = '\biz\message\classes\InformAdminClass';
-
- //通知管理员 shish 2020.1.1
- public static function addInform($shopId, $type, $params)
- {
- $shopAdminList = ShopAdminService::getNoticeAdminList($shopId);
- if (empty($shopAdminList)) {
- return false;
- }
- //本地环境取消通知
- if (getenv('YII_ENV') == 'local') {
- return false;
- }
- $TMList = TMessageService::getOpenList();
- foreach ($shopAdminList as $adminKey => $shopAdmin) {
- InformAdminClass::addInform($params, $shopAdmin, $type, $TMList);
- }
- }
- //消费通知内容 shish 2020.1.1
- //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','shopAdminId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'','isOpen'=>1]
- public static function consumeInformQueue($data)
- {
- $informWay = $data['informWay'];
- $shopAdminId = isset($data['shopAdminId']) ? $data['shopAdminId'] : 0;
- if (empty($shopAdminId)) {
- echo "\n 没有找到门店管理员 \n";
- util::end();
- }
- $shopAdmin = ShopAdminClass::getById($shopAdminId);
- $merchantId = $shopAdmin['merchantId'];
- $adminId = $shopAdmin['adminId'];
- $mobile = $data['mobile'];
- $isOpen = isset($data['isOpen']) ? $data['isOpen'] : 0;
- $merchant = WxOpenService::getWxInfo();
- $hasSend = 0;
- $noticeWay = 0;
- if ($informWay == 'wx') {
- $tMessage = json_decode($data['tMessage'], true);
- $r = wxUtil::sendTaskInform($tMessage, $merchant, $isOpen);
- print_r($r);
- $hasSend = 1;
- $noticeWay = 0;
- } elseif ($informWay == 'sms') {
- $msg = $data['content'];
- sms::merchantSend($mobile, $msg, $merchant);
- $hasSend = 1;
- $noticeWay = 1;
- } elseif ($informWay == 'miniProgram') {
- $tMessage = json_decode($data['tMessage'], true);
- $r = wxUtil::sendTaskInform($tMessage, $merchant);
- print_r($r);
- $hasSend = 1;
- $noticeWay = 0;
- } else {
- }
- //存入数据库
- $informData = [
- 'adminId' => $adminId,
- 'merchantId' => $merchantId,
- 'noticeType' => 0,
- 'content' => $data['briefContent'],
- 'noticeWay' => $noticeWay,
- 'status' => $hasSend,
- 'sourceType' => 0,
- 'sourceId' => 0,
- 'addTime' => time(),
- 'createTime' => date("Y-m-d H:i:s"),
- ];
- InformAdminClass::addData($informData);
- return true;
- }
- }
|