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

托管成功短信提示

... ... @@ -17,36 +17,50 @@ use think\Db;
class LoadController extends HomeBaseController
{
public function index(){
$type = $this->request->param('type');
if(!$type){
$arr['code'] = 40001;
$arr['msg'] = '缺点参数!';
return json_encode($arr);
}
//查询所有在托管中的保单
$orderInfoModel = new OrderInfoModel();
$time = time();
$where['o.status'] = ['eq',3];
$where['o.order_about_time'] = array(array('<',$time),array('>',$time-30*24*60*60));//array(array('gt',1),array('lt',10))
$whereor = "o.status = 1 and o.order_about_time < $time and o.order_about_time > ".($time-30*24*60*60);
$data = $orderInfoModel->selectData1($where,$whereor);
foreach($data as $key1 => $vo){
//判断是否已经发送
$send_vice = Db::name('send_vice')->where(array('order_id'=>$vo['o_id'],'collocation_id'=>$vo['id'],'time'=>$vo['order_about_time']))->find();
if(empty($send_vice)){
//模板消息
$templateId = '83NoWJ74UmI-DY_FwrDrTBx1iysu9__6fosB-eMFm78';
$data1 = array(
'first'=>"尊敬的用户,您有一份保单即将到期需要续费,请在保障截止日期前完成续保,否则保单将失效",
'keyword1'=>$vo['insurer'],
'keyword2'=>$vo['product_name'],
'keyword3'=>$vo['insurance_num'],
'keyword4'=>date('Y-m-d',$vo['order_about_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']);
//短信
$user2 = Db::name('user')->where('id',$vo['user_id'])->find();
$content = "【橙象保单】尊敬的用户,您有一份保单即将到期需要续费,请在保障截止日期前完成续保,否则保单将失效,保险单号$vo[insurance_num],请在".date('Y月m日d',$vo['order_about_time']+30*24*60*60)."之前续费。";
$this->note($content,$user2['mobile']);
Db::name('send_vice')->insert(array('order_id'=>$vo['o_id'],'collocation_id'=>$vo['id'],'time'=>$vo['order_about_time'],'user_id'=>$vo['user_id'],'create_time'=>time()));
if($type == 1){
$where['o.status'] = ['eq',3];
$where['o.order_about_time'] = array(array('<',$time),array('>',$time-30*24*60*60));//array(array('gt',1),array('lt',10))
$whereor = "o.status = 1 and o.order_about_time < $time and o.order_about_time > ".($time-30*24*60*60);
$data = $orderInfoModel->selectData1($where,$whereor);
foreach($data as $key1 => $vo){
//判断是否已经发送
$send_vice = Db::name('send_vice')->where(array('order_id'=>$vo['o_id'],'collocation_id'=>$vo['id'],'time'=>$vo['order_about_time']))->find();
if(empty($send_vice)){
//模板消息
$templateId = '83NoWJ74UmI-DY_FwrDrTBx1iysu9__6fosB-eMFm78';
$data1 = array(
'first'=>"尊敬的用户,您有一份保单即将到期需要续费,请在保障截止日期前完成续保,否则保单将失效",
'keyword1'=>$vo['insurer'],
'keyword2'=>$vo['product_name'],
'keyword3'=>$vo['insurance_num'],
'keyword4'=>date('Y-m-d',$vo['order_about_time']+30*24*60*60),
'remark'=>"请在保障期间内续费",
);
$url = url('/index/all_guarantee/guarantee_info',array('id'=>$vo['o_id']),'',true);
$user1 = Db::name('third_party_user')->where('user_id',$vo['user_id'])->find();
$this->template($templateId,$data1,$url,$user1['openid']);
//短信
$user2 = Db::name('user')->where('id',$vo['user_id'])->find();
$content = "【橙象保单】尊敬的用户,您有一份保单即将到期需要续费,请在保障截止日期前完成续保,否则保单将失效,保险单号$vo[insurance_num],请在".date('Y月m日d',$vo['order_about_time']+30*24*60*60)."之前续费。";
$this->note($content,$user2['mobile']);
Db::name('send_vice')->insert(array('order_id'=>$vo['o_id'],'collocation_id'=>$vo['id'],'time'=>$vo['order_about_time'],'user_id'=>$vo['user_id'],'create_time'=>time()));
}
}
}else if($type == 2){
//$data['status'] eq 2 || $data['order_expire_time'] lt time() || ($data['order_about_time']+24*30*60*60) lt time()
$where = [];
$whereor = "o.status = 2 or o.order_expire_time < $time or o.order_about_time < ".$time - 24*30*60*60;
$data = $orderInfoModel->selectData1($where,$whereor);
dump($data);
}
}
public function template($templateId,$data,$url=null,$openid){
... ...