123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace App\Modules\OfficialAccount\Services;
- use App\Modules\OfficialAccount\Models\WechatKeywordMsgs;
- use Redis;
- class WechatKeywordMsgService
- {
- /**
- * 通过id获取关键字
- */
- static function wechatKeywordMsgById($wechatKeywordPrams)
- {
- return WechatKeywordMsgs::wechatKeywordMsgsById($wechatKeywordPrams['id']);
- }
- /**
- * 获取推送关键字消息列表
- */
- static function wechatKeywordMsgBydistributionChannelId($wechatKeywordPrams)
- {
- return WechatKeywordMsgs::wechatKeywordMsgsBydistributionChannelId($wechatKeywordPrams['distribution_channel_id']);
- }
-
- /**
- * 更新状态
- */
- static function updateWechatKeywordMsgStatus($wechatKeywordPrams)
- {
-
- return WechatKeywordMsgs::updateWechatKeywordMsgStatus($wechatKeywordPrams['id'],$wechatKeywordPrams['distribution_channel_id'],$wechatKeywordPrams['status']);
-
- }
- /**
- * 增加关键字
- */
- static function addWechatKeywordMsg($wechatKeywordMsgPrams)
- {
- try {
- \Log::info($wechatKeywordMsgPrams);
-
- $wechatKeywordMsg = WechatKeywordMsgs::wechatKeywordByDistributionChannelIdAndKeyword($wechatKeywordMsgPrams['distribution_channel_id'],$wechatKeywordMsgPrams['keyword'],1);
- if(empty($wechatKeywordMsg)) {
- \Log::info('addWechatKeywordMsg_create');
-
- WechatKeywordMsgs::firstOrCreate($wechatKeywordMsgPrams);
- return 1;
- }else{
- \Log::info('addWechatKeywordMsg_exist');
- return 2;
-
- }
- } catch (\Exception $e) {
- \Log::info("addWechatKeywordMsg_ept:".$e);
-
- return 0;
- }
- }
-
- /**
- * 修改关键字
- */
- static function updateWechatKeywordMsg($wechatKeywordMsgPrams)
- {
-
- try {
-
- $wechatKeywordMsg = WechatKeywordMsgs::wechatKeywordMsgsById($wechatKeywordMsgPrams['id']);
- \Log::info('updateWechatKeywordMsg_origin');\Log::info($wechatKeywordMsg);
- if(!empty($wechatKeywordMsg)) {
- $wechatKeywordMsg->appids = $wechatKeywordMsgPrams['appids'];
- $wechatKeywordMsg->bid = $wechatKeywordMsgPrams['bid'];
- $wechatKeywordMsg->cid = $wechatKeywordMsgPrams['cid'];
- $wechatKeywordMsg->book_name = $wechatKeywordMsgPrams['book_name'];
- $wechatKeywordMsg->chapter_name = $wechatKeywordMsgPrams['chapter_name'];
- $wechatKeywordMsg->send_title = $wechatKeywordMsgPrams['send_title'];
- $wechatKeywordMsg->send_cover = $wechatKeywordMsgPrams['send_cover'];
- $wechatKeywordMsg->keyword = $wechatKeywordMsgPrams['keyword'];
- $wechatKeywordMsg->link_type = $wechatKeywordMsgPrams['link_type'];
- $wechatKeywordMsg->link = $wechatKeywordMsgPrams['link'];
- $wechatKeywordMsg->desc = $wechatKeywordMsgPrams['desc'];
- $wechatKeywordMsg->mode = $wechatKeywordMsgPrams['mode'];
- $wechatKeywordMsg->content = $wechatKeywordMsgPrams['content'];
- \Log::info('after_update:');
- \Log::info($wechatKeywordMsg);
- $wechatKeywordMsg->save();
-
- return 1;
-
- }else{
- \Log::info('updateWechatKeywordMsg_not_exist');
- return 2;
-
- }
-
- } catch (\Exception $e) {
- \Log::info("updateWechatKeywordMsg_ept:".$e);
-
- return 0;
-
- }
-
- }
- }
|