作者 王晓刚
1 个管道 的构建 通过 耗费 7 秒

代理人注册

... ... @@ -52,7 +52,11 @@ class AllGuaranteeController extends WeChatBaseController
$insurer = $collocationModel->insurerData(array('user_id'=>$user_id),"insurer");//获取全部保险人
$collocation = $orderInfoModel->selectData(array('c.user_id'=>$user_id));//获取到在托管中状态的保单
//获取第一个被保人的默认信息
$collocation_data = $orderInfoModel->selectData1(array('c.user_id'=>$user_id,'c.insurer'=>$insurer[0]['insurer']));
if(!empty($insurer)){
$collocation_data = $orderInfoModel->selectData1(array('c.user_id'=>$user_id,'c.insurer'=>$insurer[0]['insurer']));
}else{
$collocation_data = [];
}
$pageHtmlModel = new PageHtmlModel();
$page_html = $pageHtmlModel->findData(array('id'=>4));
... ...
... ... @@ -415,6 +415,21 @@ class FormController extends WeChatBaseController
Db::name('order')->where('id',$result1)->update($update);
}
$orderModel->commit();
//推送模板消息
if($data1['status'] == 1 || $data1['status'] == 3){
$templateId = 'rQSM5XqM4cJEua6nsJC4IGuLfIOYvkNOVKVABILc8Ro';
$data1 = array(
'first'=>"尊敬的用户,您的保单即将生效",
'keyword1'=>$collocation['insurance_num'],
'keyword2'=>$collocation['product_name'],
'keyword3'=>$collocation['insurer'],
'keyword4'=>"$collocation[take_time]至$collocation[expire_time]",
'remark'=>"立即查看保单详情",
);
$url = cmf_url('');
$user1 = Db::name('third_party_user')->where('user_id',$vo['user_id'])->find();
$this->template($templateId,$data1,$url,$user1['openid']);
}
$arr['code'] = 20000;
$arr['msg'] = '操作成功!';
$arr['data'] = $result1;//返回主订单id
... ... @@ -460,6 +475,19 @@ class FormController extends WeChatBaseController
$arr['msg'] = '创建续费订单失败!';
return json_encode($arr);
}
//推送模板消息
// $templateId = 'HVcMt58ic_QhO4yHm4IONQE466ijqQxF0l7rPDcQK1o';
// $data1 = array(
// 'first'=>"尊敬的用户,您有一份保单即将到期需要续费,请在保障截止日期前完成续保,否则保单将失效",
// 'keyword1'=>$vo['insurer'],
// 'keyword2'=>$vo['product_name'],
// 'keyword3'=>$vo['insurance_num'],
// 'keyword4'=>date('Y-m-d',$s['time']+30*24*60*60),
// 'remark'=>"请在保障期间内续费",
// );
// $url = '';
// $user1 = Db::name('third_party_user')->where('user_id',$vo['user_id'])->find();
// $this->template($templateId,$data1,$url,$user1['openid']);
$arr['code'] = 20000;
$arr['msg'] = '创建续费订单成功';
$arr['data'] = $result;
... ...
... ... @@ -105,10 +105,20 @@ class PayController extends HomeBaseController
}
Db::name('send')->insertAll($data4);
$update['pay_time']=time();
// 不是已经支付状态则修改为已经支付状态
//支付状态则修改为已经支付状态
$update['status'] = 3;
$update['order_expire_time']=$collocation['expire_time'];
$update['order_about_time']=$data4[count($data4)-1]['time'];
//推送模板消息
$templateId = 'iZwqjrOt7NCILnI0zkayK59y4jUXmnmfmROERWq-NEw';
$data1 = array(
'first'=>"您好,您已购买成功。",
'keyword1'=>date('Y-m-d',$update['order_about_time']),
'remark'=>"您好,您已购买成功。",
);
$url = '';
$user1 = Db::name('third_party_user')->where('user_id',$order['user_id'])->find();
$this->template($templateId,$data1,$url,$user1['openid']);
} else { // 用户支付失败
$update['status']=2;
}
... ... @@ -247,5 +257,30 @@ class PayController extends HomeBaseController
return $url;
}
public function template($templateId,$data,$url=null,$openid){
$options=config('wechat_config');
$app = new Application($options);
$notice = $app->notice;
if(empty($url)){
$notice->uses($templateId)->andData($data)->andReceiver($openid)->send();
}else{
$notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($openid)->send();
}
}
public function note($content,$mobile){
$data = array(
'content' => $content,//短信内容
'mobile' => $mobile,//手机号码
'productid' => '887361',//产品id
'xh' => ''//小号
);
$result = send_sms($data);
if(substr($result,0,strpos($result,',')) == "1"){
echo '发送成功!';
}else{
echo '接口出错!';
}
}
}
\ No newline at end of file
... ...
... ... @@ -294,6 +294,33 @@ class WeChatBaseController extends BaseController
return $user;
}
/**
* 模板消息
*/
public function template($templateId,$data,$url=null,$openid){
$options=config('wechat_config');
$app = new Application($options);
$notice = $app->notice;
if(empty($url)){
$notice->uses($templateId)->andData($data)->andReceiver($openid)->send();
}else{
$notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($openid)->send();
}
}
public function note($content,$mobile){
$data = array(
'content' => $content,//短信内容
'mobile' => $mobile,//手机号码
'productid' => '887361',//产品id
'xh' => ''//小号
);
$result = send_sms($data);
if(substr($result,0,strpos($result,',')) == "1"){
echo '发送成功!';
}else{
echo '接口出错!';
}
}
/**
* 处理数据
*/
public function regroup($data, $insurance_type_id = null, $question = null, $user = null){
... ...