edit-api-over_time

This commit is contained in:
lccsw
2022-06-01 10:27:30 +08:00
parent a5d8e735f1
commit a61e877c9b
3 changed files with 71 additions and 44 deletions
+14 -3
View File
@@ -13,6 +13,7 @@ class Order extends CI_Controller{
$this->load->model('receiver/order/receiver_orders_v2_model');
$this->load->model('receiver/order/receiver_order_status_model');
$this->load->model('receiver/order/receiver_order_datas_model');
$this->load->model('receiver/order/receiver_order_contracts_model');
$this->load->model('app/liche/app_liche_orders_model');
$this->load->library('receiver/order_datas_entity');
@@ -311,14 +312,24 @@ class Order extends CI_Controller{
$rows = $this->receiver_orders_v2_model->select($where,'id asc',$page,$size);
if($rows){
foreach($rows as $key => $val){
$car_json = json_decode($val['car_json'],true);
$info_json = json_decode($val['info_json'],true);
$business_id = $info_json['business_id'];
$over_time = '';
$over_time = '0000-00-00 00:00:00';
if($business_id){
$business_row = $this->auto_business_model->get(['id'=>$business_id]);
$business_row['delivery_day'] && $over_time = date('Y-m-d H:i:s',$val['c_time']+$business_row['delivery_day']*24*60*60); //交付截止时间
if($business_row['delivery_day']){
$contract = $this->receiver_order_contracts_model->get(['o_id' => $val['id'],'type in (0,1)' => null]);
$s_time = $contract ? $contract['c_time'] : $val['c_time'];
$over_time = date('Y-m-d H:i:s',$s_time+$business_row['delivery_day']*24*60*60); //交付截止时间
}
$car_json['delivery_day'] = $business_row['delivery_day'];
}
$update = [];
$update = [
'car_json' => json_encode($car_json,JSON_UNESCAPED_UNICODE)
];
$over_time && $update['over_time'] = $over_time;
if($val['main_type']==1){
$update['owner_name'] = $info_json['c_company'];
+7 -2
View File
@@ -215,7 +215,10 @@ class CusorderV2 extends Wxapp{
}
}
}
$data['car_json'] = $data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
$car_json = $money_json;
$car_json['delivery_day'] = $business_row['delivery_day'];
$data['money_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
$data['car_json'] = json_encode($car_json,JSON_UNESCAPED_UNICODE);
$this->ck_money($money_json,$srv_arr,$biz);
$o_id = $this->orders_model->add($data);
@@ -402,7 +405,9 @@ class CusorderV2 extends Wxapp{
$color_arr = json_decode($business_row['colors'],true);
//获取金额json数据
$money_json = json_decode($row['money_json'],true);
$data['car_json'] = json_encode($money_json,JSON_UNESCAPED_UNICODE);
$car_json = $money_json;
$car_json['delivery_day'] = $business_row['delivery_day'];
$data['car_json'] = json_encode($car_json,JSON_UNESCAPED_UNICODE);
$money_json['price_car'] = $business_row['price_car'];
$money_json['price_book'] = $deposit;
$money_json['price_insure'] = $car_row['price_insure'];
+50 -39
View File
@@ -517,47 +517,54 @@ class Orders_v2_entity{
if($this->ci->receiver_order_contracts_model->count(['o_id'=>$oid,'status'=>1])){
return ['code'=>1,'msg'=>'操作成功'];
}
$need_sign = true;
if($this->order_row['brand_id'] == 4){ //除宁德哪吒需要购车合同
$biz = $this->ci->biz_model->get(['id'=>$this->order_row['biz_id']],'city_id');
$need_sign = $biz['city_id'] == '350900' ? true : false;
}
$fill_info = $this->pdf_data($this->order_row);
$fill_data = [
'sid' => $this->order_row['sid'],
'give_time' => $fill_info['give_time'],
'date' => $fill_info['now_day'],
'company' => $fill_info['companys']['company']['title'],
'name' => $fill_info['name'],
'owner_name' => $fill_info['owner_name'],
'owner_mobile' => $fill_info['owner_mobile'],
'identify_type' => $fill_info['identify_type'],
'identify' => $fill_info['identify'],
'address' => $fill_info['address'],
'version' => $fill_info['version'],
'color' => $fill_info['color'],
'incolor' => $fill_info['incolor'],
'price_car' => $fill_info['price_car'],
'price_discount' => $fill_info['price_discount'],
'price_finance' => $fill_info['price_finance'],
'recevable_price' => $fill_info['recevable_price'],
'price_book' => $fill_info['price_book'],
'last_price' => $fill_info['last_price'],
];
$pdf_path = 'pdf/car_tpl.pdf';
if($fill_info['sa']){
$fill_data['sa'] = $fill_info['sa'];
$pdf_path = 'pdf/car_sa_tpl.pdf';
if($need_sign) {
$fill_data = [
'sid' => $this->order_row['sid'],
'give_time' => $fill_info['give_time'],
'date' => $fill_info['now_day'],
'company' => $fill_info['companys']['company']['title'],
'name' => $fill_info['name'],
'owner_name' => $fill_info['owner_name'],
'owner_mobile' => $fill_info['owner_mobile'],
'identify_type' => $fill_info['identify_type'],
'identify' => $fill_info['identify'],
'address' => $fill_info['address'],
'version' => $fill_info['version'],
'color' => $fill_info['color'],
'incolor' => $fill_info['incolor'],
'price_car' => $fill_info['price_car'],
'price_discount' => $fill_info['price_discount'],
'price_finance' => $fill_info['price_finance'],
'recevable_price' => $fill_info['recevable_price'],
'price_book' => $fill_info['price_book'],
'last_price' => $fill_info['last_price'],
];
$pdf_path = 'pdf/car_tpl.pdf';
if ($fill_info['sa']) {
$fill_data['sa'] = $fill_info['sa'];
$pdf_path = 'pdf/car_sa_tpl.pdf';
}
$save_path = "pdf/{$this->order_row['sid']}/car.pdf";
$this->ci->load->library('pdftk');
$req = $this->ci->pdftk->esign_fill_pdf($pdf_path, $save_path, $fill_data);
if (!$req['code']) {
return ['code' => 0, 'msg' => $req['msg']];
}
$add_data[] = [
'o_id' => $this->order_row['id'],
'cid' => 0,
'file' => $req['data']['file_path'] ? $req['data']['file_path'] : '',
'type' => 0,
'status' => 1,
'c_time' => time()
];
}
$save_path = "pdf/{$this->order_row['sid']}/car.pdf";
$this->ci->load->library('pdftk');
$req = $this->ci->pdftk->esign_fill_pdf($pdf_path,$save_path,$fill_data);
if(!$req['code']){
return ['code'=>0,'msg'=>$req['msg']];
}
$add_data[] = [
'o_id' => $this->order_row['id'],
'cid' => 0,
'file' => $req['data']['file_path'] ? $req['data']['file_path'] : '',
'type' => 0,
'status' => 1,
'c_time' => time()
];
if($this->order_row['srv_ids']){
$fill_data = [
'sid' => $this->order_row['sid'],
@@ -586,6 +593,10 @@ class Orders_v2_entity{
}
$res = $this->ci->receiver_order_contracts_model->add_batch($add_data);
if($res){
//更新交付时间
$car_json = json_decode($this->order_row['car_json'],true);
$over_time = date('Y-m-d H:i:s',time()+$car_json['delivery_day']*24*60*60); //交付截止时间
$this->ci->receiver_orders_v2_model->update(['over_time'=>$over_time],['id'=> $this->order_row['id']]);
return ['code'=>1,'msg'=>'操作成功'];
}else{
return ['code'=>0,'msg'=>'操作失败'];