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

续费

... ... @@ -368,9 +368,17 @@ class FormController extends WeChatBaseController
public function create_order_renew(){
$user_id = cmf_get_current_user_id();
$param = $this->request->param();
//查询当前订单号
$orderInfoModel = new OrderInfoModel();
$order = $orderInfoModel->findData(array('collocation_id'=>$param['id']));
if(empty($order)){
$arr['code'] = 40000;
$arr['msg'] = "未查询到订单";
return json_encode($arr);
}
//判断当前订单是否为当收费
$orderModel = new OrderModel();
$order = $orderModel->findData(array('id'=>$param['order_id'],'user_id'=>$user_id));
$order = $orderModel->findData(array('id'=>$order['order_id'],'user_id'=>$user_id));
if(empty($order)){
$arr['code'] = 40002;
$arr['msg'] = '我查询到当前订单!';
... ... @@ -397,6 +405,7 @@ class FormController extends WeChatBaseController
}
$arr['code'] = 20000;
$arr['msg'] = '创建续费订单成功';
$arr['data'] = $result;
return json_encode($arr);
}
//进入下单页面
... ...
... ... @@ -18,7 +18,7 @@ class OrderRenewModel extends Model
return $data;
}
public function insertData($data){
$result = $this->insert($data);
$result = $this->insertGetId($data);
return $result;
}
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@ class PayRenewController extends HomeBaseController
* 微信支付
*/
public function index(){
$order_renew_id = $this->request->param('order_renew_id');
$order_renew_id = $this->request->param('id');
$data = Db::name('order_renew')->where('id',$order_renew_id)->find();
if(empty($data)){
$this->error('未查询到该订单!','');
... ... @@ -39,7 +39,7 @@ class PayRenewController extends HomeBaseController
'trade_type' => 'JSAPI',
'body' => '橙象保单-续费',
'detail' => '以客户为中心 以奋斗者文本',
'out_trade_no' => cmf_get_order_sn(),
'out_trade_no' => $data['num'],
'total_fee' => $data['total'],//1, // 单位:分
'notify_url' => url('portal/pay_renew/notify','','',true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'openid' => cmf_get_current_user_openid(), // trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识,
... ...
... ... @@ -148,12 +148,31 @@
<div class="trust_name">代理人姓名:{$data.agent_name}</div>
<div class="trust_name">代理人联系方式</div>
<div class="trust_nimitel">{$data.agent_phone}</div>
<a class="trust_btn" href="pay.html">立即续约</a>
<a class="trust_btn">立即续约</a>
</div>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/jquery-2.1.0.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/swiper-3.4.2.jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/common.js"></script>
<script>
$(function(){
var id = {$data.id};
//订单续费
$('.trust_btn').click(function(){
$.ajax({
url:"{:url('index/form/create_order_renew')}",
type:'POST',
data:{'id':id},
success:function(data){
var result = eval("(" + data + ")");
if(result.code == 20000){
window.location.href="{:url('portal/pay_renew/index','','')}"+'/id/'+result.data;
}
}
})
})
})
</script>
</body>
</html>
\ No newline at end of file
... ...