147 lines
4.8 KiB
PHP
147 lines
4.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 订单
|
|
*/
|
|
class Orders_entity{
|
|
|
|
private $ci;
|
|
|
|
public function __construct(){
|
|
$this->ci = & get_instance();
|
|
}
|
|
|
|
/*
|
|
* 获取合同h5地址
|
|
* @param $id int 订单id
|
|
* @param $type int 合同类型(0整车合同 1代理协议 2确定信息 3交接信息)
|
|
*/
|
|
public function get_contract_h5($id,$type,$wxapp=''){
|
|
$url = http_host_com('api');
|
|
$res = $path = '';
|
|
switch($type){
|
|
case 0;
|
|
$path = '/wxapp/licheb/protocol/car';
|
|
$title = '车辆整车合同';
|
|
break;
|
|
case 1:
|
|
$path = '/wxapp/licheb/protocol/agent';
|
|
$title = '委托代理服务协议';
|
|
break;
|
|
case 2:
|
|
$path = '/wxapp/licheb/protocol/car_ck';
|
|
$title = '车辆信息确认单';
|
|
break;
|
|
case 3:
|
|
$path = '/wxapp/licheb/protocol/car_fh';
|
|
$title = '车辆交接信息';
|
|
break;
|
|
default:
|
|
}
|
|
if($path){
|
|
$res = $url.$path.'?id='.$id.'&wxapp='.$wxapp;
|
|
}
|
|
return [$res,$title];
|
|
}
|
|
|
|
/**
|
|
* 创建定金消费订单
|
|
* @param $oid int 订单id
|
|
* return boolean
|
|
*/
|
|
public function c_order($oid,$app_id,$userinfo){
|
|
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->ci->load->model('apporder/order_purchase_model');
|
|
$this->ci->load->model('auto/auto_series_model');
|
|
$this->ci->load->model('auto/auto_brand_model');
|
|
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
|
if(!$row){
|
|
return false;
|
|
}
|
|
$brand = $this->ci->auto_brand_model->get(['id'=>$row['brand_id']],'name');
|
|
$series = $this->ci->auto_series_model->get(['id'=>$row['s_id']],'name');
|
|
$car_json = json_decode($row['car_json'],true);
|
|
$color = isset($car_json['color']) ? $car_json['color'] : '';
|
|
|
|
$sid = create_order_no(350200,'liche',1,2);
|
|
$jsondata['car'] = $car_json;
|
|
if($color['jsondata']['img']){
|
|
$jsondata['cover'] = $color['jsondata']['img'];
|
|
}
|
|
$add_data = [
|
|
'app_id' => $app_id,
|
|
'app_uid' => $userinfo['uid'],
|
|
'sid' => $sid,
|
|
'item_id' => $row['id'],
|
|
'item_title' => $brand['name'].$series['name'],
|
|
'item_num' => 1,
|
|
'type' => 4,
|
|
'item_price' => $row['deposit'],
|
|
'total_price' => $row['deposit'],
|
|
'uname' => $userinfo['nickname'],
|
|
'mobile' => $userinfo['mobile'],
|
|
'payway' => 1,
|
|
'status' => 1,
|
|
'status_detail' => 11,
|
|
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
|
|
'c_time' => time(),
|
|
'cf_id' => $oid
|
|
];
|
|
$result = $this->ci->order_purchase_model->add($add_data);
|
|
return $result;
|
|
}
|
|
/*
|
|
* 获取签名图片
|
|
* @param $oid int 订单id
|
|
* @param $type array 类型
|
|
*/
|
|
public function get_sign_imgs($oid,$type){
|
|
$this->ci->load->model('receiver/order/receiver_order_contracts_model');
|
|
$where = [
|
|
'o_id' => $oid,
|
|
'status' => 1
|
|
];
|
|
$types = implode(',',$type);
|
|
if($types){
|
|
$where["type in ($types)"] = null;
|
|
}
|
|
$contracts = $this->ci->receiver_order_contracts_model->select($where,'type asc','','','imgs');
|
|
$data = [];
|
|
if($contracts){
|
|
foreach($contracts as $key => $val){
|
|
$imgs = json_decode($val['imgs'],true);
|
|
foreach($imgs as $item){
|
|
$data[] = build_qiniu_image_url($item);
|
|
}
|
|
}
|
|
}
|
|
return $data;
|
|
}
|
|
/**
|
|
* 更新订单用户信息
|
|
* @param $oid int 订单id
|
|
* @param $info array() 腾讯云识别返回参数
|
|
*/
|
|
public function up_info($oid,$info){
|
|
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$row = $this->ci->orders_model->get(['id'=>$oid]);
|
|
if(!$row){
|
|
return false;
|
|
}
|
|
$info_json = json_decode($row['info_json'],true);
|
|
$info['Name'] && $info_json['name'] = $info['Name'];
|
|
$info['Sex'] && $info_json['sex'] = $info['Sex'];
|
|
$info['Nation'] && $info_json['nation'] = $info['Nation'];
|
|
$info['Birth'] && $info_json['birth'] = date('Y-m-d',strtotime($info['Birth']));
|
|
$info['Address'] && $info_json['address'] = $info['Address'];
|
|
$info['IdNum'] && $info_json['cardid'] = $info['IdNum'];
|
|
$update = [
|
|
'info_json' => json_encode($info_json,JSON_UNESCAPED_UNICODE)
|
|
];
|
|
$result = $this->ci->orders_model->update($update,['id'=>$row['id']]);
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
?>
|