| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace biz\message\services;
- use biz\admin\classes\AdminClass;
- use biz\admin\classes\AdminShopClass;
- use biz\admin\services\AdminService;
- use biz\admin\services\AdminShopService;
- use biz\base\services\BaseService;
- use biz\merchant\services\MerchantService;
- use biz\message\classes\InformAdminClass;
- use common\components\sms;
- 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($merchantId, $shopId, $type, $params)
- {
- $adminShopList = AdminShopService::getNoticeAdminList($shopId);
- if (empty($adminShopList)) {
- return false;
- }
- //本地环境取消通知
- if (getenv('YII_ENV') == 'local') {
- return false;
- }
- $TMList = xhTMessageService::getList($merchantId);
- foreach ($adminShopList as $adminKey => $adminShop) {
- InformAdminClass::addInform($params, $adminShop, $type, $TMList);
- }
- }
-
- //消费通知内容 shish 2020.1.1
- //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','adminShopId'=>913,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'']
- public static function consumeInformQueue($data)
- {
- $informWay = $data['informWay'];
- $adminShopId = $data['adminShopId'];
- $adminShop = AdminShopClass::getById($adminShopId);
- $merchantId = $adminShop['merchantId'];
- $mobile = $data['mobile'];
- $merchant = MerchantService::getMerchantById($merchantId);
- $hasSend = 0;
- $noticeWay = 0;
- if ($informWay == 'wx') {
- $tMessage = json_decode($data['tMessage'], true);
- $r = wxUtil::sendTaskInform($tMessage, $merchant);
- 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 = [
- 'userId' => $admin['userId'],
- 'adminId' => $id,
- '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;
- }
-
- }
|