| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace biz\message\services;
- use biz\admin\classes\AdminClass;
- 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)
- {
- $adminList = AdminShopService::getNoticeAdminList($shopId);
- if (empty($adminList)) {
- return false;
- }
- //本地环境取消通知
- if (getenv('YII_ENV') == 'local') {
- return false;
- }
- $TMList = xhTMessageService::getList($merchantId);
- foreach ($adminList as $adminKey => $admin) {
- InformAdminClass::addInform($params, $admin, $type, $TMList);
- }
- }
-
- //消费通知内容 shish 2020.1.1
- public static function consumeInformQueue($data)
- {
- //['messageType'=>'inform','informWay'=>'miniProgram','userType'=>'admin','id'=>1,'mobile'=>'15280215347','tMessage'=>'','content'=>'','briefContent'=>'']
- $informWay = $data['informWay'];
- $id = $data['id'];
- $admin = AdminService::getAdminById($id);
- $merchantId = $admin['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;
- }
-
- }
|