Commit cfe21d14 by 李洋

手动发消息接口联调

parent 294256d2
......@@ -194,10 +194,39 @@ class MessageApiController extends Controller
}
$this->Export(0, empty($tpl_model['tpl_id']) ? '新增成功' : '修改成功');
}
//编辑手动消息
//发送手动消息
private function sendManualMessage($request)
{
// Csrf($request);
$data = $request->input();
$url = 'http://api.liexin.com/msg/sendMessageByHandle';
$params = [];
$params['channels'] = $data['channels'];
$params['msg_type'] = $data['msg_type'];
// $params['creater'] = $data['creater'];
$params['description'] = $data['description'];
$params['title_1'] = $data['title_1'];
$params['title_3'] = $data['title_3'];
$params['content_1'] = $data['content_1'];
$params['content_2'] = $data['content_2'];
$params['content_3'] = $data['content_3'];
$params['op_type'] = $data['op_type'];
$params['url'] = $data['url'];
$params['obj_user'] = $data['obj_user'];
$params['wechat_tpl_id'] = $data['wechat_tpl_id'];
$params['expect_send_time'] = $data['expect_send_time'];
//csrf
$check['k1'] = time();
$check['k2'] = pwdhash($check['k1'],'fh6y5t4rr351d2c3bryi');
$params['pf'] = 1;
$params['k1'] = $check['k1'];
$params['k2'] = $check['k2'];
$response = json_decode(curl($url,$params,1),true);
$this->Export($response['err_code'], $response['err_msg']);
}
}
\ No newline at end of file
......@@ -506,7 +506,7 @@ class MessageController extends Controller
$info = (object)null;
$info->tpl_id = $rq_tpl_id;
$info->obj_user = '';
$info->expect_send_time = 0;
$info->expect_send_time = '';
}
//通过tpl_id找到模板的渠道们 和 描述
......
......@@ -322,7 +322,7 @@ function curl($url, $params = false, $ispost = 0, $https = 0)
$response = curl_exec($ch);
if ($response === FALSE) {
//echo "cURL Error: " . curl_error($ch);
// echo "cURL Error: " . curl_error($ch);
return false;
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
......@@ -331,6 +331,16 @@ function curl($url, $params = false, $ispost = 0, $https = 0)
return $response;
}
/**
* 统一密码加密
* @param [type] $pwd [description]
* @return [type] [description]
*/
function pwdhash($pwd, $salt)
{
return md5(md5($pwd).$salt);
}
//Csrf接口验证
function Csrf($request){
// $Redis =RedisDB::connection('api');
......
......@@ -107,32 +107,37 @@ $('#msg_tpl_submit').click(function()
}
// addTemplate();
sendManualMessage();
})
function addTemplate()
function sendManualMessage()
{
var ue_inner = UE.getEditor('inner-tpl-content');
var ue_email = UE.getEditor('email-tpl-content');
$.ajax({
type: 'post',
url: '/msgapi/addTemplate',
url: '/msgapi/sendManualMessage',
timeout : 10000, //超时时间设置,单位毫秒
data: {
spu_id:$('#spu_id').val(),
class_id1:$('#class_id1').val(),
class_id2:$('#class_id2').val(),
class_id3:$('#class_id3').val(),
brand_id:$('#brand_id').val(),
spu_name:$('#spu_name').val(),
status:$("input[name='status']:checked").val(),
images_l:$('#images_l').val(),
images_s:$('#images_s').val(),
encap:$('#encap').val(),
pdf:$('#pdf').val(),
spu_brief:$('#spu_brief').val(),
has_rohs:$("input[name='has_rohs']:checked").val(),
attrs:$('#spu_attrs').val(),
spu_detail:ue.getContent(),
bussiness_area:checkBoxes,
channels:getChosenMsgChannels()?getChosenMsgChannels():'',
msg_type:$('#inner-tpl-type option:selected').val()?$('#inner-tpl-type option:selected').val():'',
// creater:$('#creater').val()?$('#creater').val():'',
description:$('#msg-tpl-desc').val()?$('#msg-tpl-desc').val():'',
title_1:$('#inner-tpl-title').val()?$('#inner-tpl-title').val():'',
content_1:ue_inner.getContent()?ue_inner.getContent():'',
op_type:$("input[name='inner-tpl-op']:checked").val()?$("input[name='inner-tpl-op']:checked").val():'',
url:$('#inner-tpl-op-url-text').val()?$('#inner-tpl-op-url-text').val():'',
content_2:$('#sms-tpl-content').val()?$('#sms-tpl-content').val():'',
title_3:$('#email-tpl-title').val()?$('#email-tpl-title').val():'',
content_3:ue_email.getContent()?ue_email.getContent():'',
wechat_tpl_id:$('#wechat-notify_tpl_title').val()?$('#wechat-notify_tpl_title').val():'',//存放的是微信模板的id
obj_user:$('#msg-specified-users-text').val()?$('#msg-specified-users-text').val():'is_to_all',
expect_send_time:$('#Choice_start').val()?$('#Choice_start').val():'',
},
dataType: 'json',
success: function(resp){
......
......@@ -205,7 +205,7 @@
<div class="col-sm-5">
<input type="radio" id="inner-tpl-op-open" name="inner-tpl-op" value="1" @if(!empty($info->channel_tpls['1']) && 1==$info->channel_tpls['1']->op_type) checked @endif/><label for="inner-tpl-op-open">打开消息</label>
<input type="radio" id="inner-tpl-op-url" name="inner-tpl-op" value="2" @if(!empty($info->channel_tpls['1']) && 2==$info->channel_tpls['1']->op_type) checked @endif/><label for="inner-tpl-op-url">打开URL</label>
<input type="text" id="inner-tpl-op-url-text" name="inner-tpl-url-text" placeholder="请输入URL" value=@if(!empty($info->channel_tpls['1']) && 2==$info->channel_tpls['1']->op_type) "{{ $info->channel_tpls['1']->url }}" @endif>
<input class="form-control" type="text" id="inner-tpl-op-url-text" name="inner-tpl-url-text" placeholder="请输入URL" value=@if(!empty($info->channel_tpls['1']) && 2==$info->channel_tpls['1']->op_type) "{{ $info->channel_tpls['1']->url }}" @endif>
</div>
</div>
......@@ -259,7 +259,7 @@
<div class="col-sm-5">
<input type="radio" name="user-range" id="user-range-all" class="form-control" value="1" @if(empty($info->obj_user)) checked @endif/><label for="user-range-all">所有用户</label>
<input type="radio" name="user-range" id="user-range-specified" class="form-control" value="3" @if(!empty($info->obj_user)) checked @endif/><label for="user-range-specified">指定用户</label>
<input type="text" id="msg-specified-users-text" name="msg-specified-users-text" placeholder="请输入指定用户" style="width: 200px" value="{{ $info->obj_user }}"/>
<input type="text" class="form-control" id="msg-specified-users-text" name="msg-specified-users-text" placeholder="请输入指定用户" style="width: 200px" value="{{ $info->obj_user }}"/>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment