id)?$batch_create_res->id:''; \Log::info('$batch_create_res:'.$batch_no); return 1; } catch (\Exception $e) { \Log::info('addBatchCustomSendMsgs_ept:'.$e->getMessage()); return 0; } } /** * 获取批次客服消息列表 */ static function autoSendTrusteeShipCustomerMsg($sex) { \Log::info('autoSendTrusteeShipCustomerMsg:'.$sex); // 每天晚上19点 $customMsgPrams['send_time'] = date('Y-m-d 19:00:00'); $customMsgPrams['name'] = '自动发送托管客服消息:'.$customMsgPrams['send_time']; $books = []; // 男生 if($sex == 'a'){ $books = BookConfigService::getTrusteeShipChannelBook('','男频', 4); } // 女生 else{ $books = BookConfigService::getTrusteeShipChannelBook('','女频', 4); } $books = CustomMsgService::get_book_full_infos($books,$sex); // 随机推送内容 $customMsgPrams['content'] = json_encode($books); $customMsgPrams['redirect_url'] = ''; $customMsgPrams['sex'] = $sex; $customMsgPrams['subscribe_time'] = 'g';// 关注1天前,有过交互的 $customMsgPrams['trusteeship'] = '1'; // 托管 $customMsgPrams['balance'] = 'z'; $customMsgPrams['order_type'] = 'z'; $customMsgPrams['category_id'] = 'z'; $customMsgPrams['status'] = '1'; $customMsgPrams['is_show_list'] = '0';// 分销界面不展示 \Log::info($customMsgPrams); $batch_no = ''; $batch_res = BatchCustomMsgService::addBatchCustomSendMsgs($customMsgPrams,$batch_no); \Log::info('batch_res:'.$batch_res.' batch_no:'.$batch_no); if($batch_res == 1){ $customMsgPrams['batch_no'] = $batch_no; $official_accounts = OfficialAccountService::getTrusteeshipOfficialAccounts(); \Log::info('getTrusteeshipOfficialAccounts'); \Log::info($official_accounts); // return true; foreach($official_accounts as $official_account){ $customMsgPrams['appid'] = $official_account->appid; $customMsgPrams['distribution_channel_id'] = $official_account->distribution_channel_id; \Log::info('getTrusteeshipOfficialAccounts:appid:'.$official_account->appid.' distribution_channel_id:'.$official_account->distribution_channel_id); //先判断在发送时间段1小时以内,有没有发起过相同的模板消息,如果有发送过,就提示用户已经创建过相同模板消息,不创建新的模板消息 $isSendCustomer = CustomMsgService::isSendCustomerAtSameTimeAndSex($customMsgPrams); if (!empty($isSendCustomer)) { \Log::info('isSendCustomerAtSameTime already_send:appid:'.$customMsgPrams['appid'].' distribution_channel_id:'.$customMsgPrams['distribution_channel_id']); continue; } $customMsgService = CustomMsgService::addCustomSendMsgs($customMsgPrams); } } } }