|
|
@@ -9,6 +9,7 @@ use biz\admin\services\ShopAdminService;
|
|
|
use biz\base\services\BaseService;
|
|
|
use biz\merchant\services\MerchantService;
|
|
|
use biz\message\classes\InformAdminClass;
|
|
|
+use biz\wx\classes\WxOpenClass;
|
|
|
use biz\wx\services\WxOpenService;
|
|
|
use common\components\sms;
|
|
|
use common\components\util;
|
|
|
@@ -18,79 +19,31 @@ 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 {
|
|
|
+ public static $baseFile = '\biz\message\classes\InformAdminClass';
|
|
|
|
|
|
- }
|
|
|
- //存入数据库
|
|
|
- $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;
|
|
|
- }
|
|
|
+ //通知管理员 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)
|
|
|
+ {
|
|
|
+ return InformAdminClass::consumeInformQueue($data);
|
|
|
+ }
|
|
|
|
|
|
}
|