From 0715308127cf25b943560cf2ab36a01ad548f3c2 Mon Sep 17 00:00:00 2001 From: chenrx Date: Fri, 31 May 2024 16:54:45 +0800 Subject: [PATCH] 20240531 --- api/controllers/wxapp/licheb/Cusorder.php | 139 ++++--- api/controllers/wxapp/licheb/Cusorderdata.php | 346 ++++++++++++++++++ api/controllers/wxapp/licheb/Sign.php | 4 +- .../order/Receiver_order_datas_model.php | 41 +++ .../receiver/order/Receiver_orders_model.php | 9 + 5 files changed, 487 insertions(+), 52 deletions(-) create mode 100644 api/controllers/wxapp/licheb/Cusorderdata.php create mode 100644 common/models/receiver/order/Receiver_order_datas_model.php diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index a3e3c11e..d7fb8555 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -94,13 +94,13 @@ class Cusorder extends Wxapp $if_num && $data['if_num'] = 1; $if_insure && $data['if_insure'] = 1; $money_json = []; + $money_json['confirm_amount'] = $confirm_amount ? $confirm_amount : 0; + $money_json['discount_amount'] = $discount_amount ? $discount_amount : 0; if (!$payway) { //贷款 $data['downpayment_type'] = $downpayment_type; $money_json['loan_amount'] = $loan_amount ? $loan_amount : 0; $money_json['loan_periods'] = $loan_periods ? $loan_periods : 0; $money_json['monthly_payment'] = $monthly_payment ? $monthly_payment : 0; - $money_json['confirm_amount'] = $confirm_amount ? $confirm_amount : 0; - $money_json['discount_amount'] = $discount_amount ? $discount_amount : 0; } if ($if_num) { $money_json['register_amount'] = $register_amount ? $register_amount : 0; @@ -117,6 +117,85 @@ class Cusorder extends Wxapp } } + protected function put() + { + $id = $this->input_param('id'); + $car_id = $this->input_param('car_id'); + $color = $this->input_param('color'); + $in_color = $this->input_param('in_color'); + $payway = $this->input_param('payway'); + $delry_time = $this->input_param('delry_time'); + $if_num = $this->input_param('if_num'); + $if_insure = $this->input_param('if_insure'); + $register_amount = $this->input_param('register_amount'); //上牌费 + //贷款相关参数 + $downpayment_type = $this->input_param('downpayment_type'); + $loan_amount = $this->input_param('loan_amount'); + $loan_periods = $this->input_param('loan_periods'); + $monthly_payment = $this->input_param('monthly_payment'); + $confirm_amount = $this->input_param('confirm_amount'); + $discount_amount = $this->input_param('discount_amount'); + + $row = $this->orders_model->get(['id' => $id]); + $car_row = $this->auto_cars_model->get(['id' => $car_id]); + if (!$row || !$car_row || !$delry_time) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + $data = [ + 'brand_id' => $car_row['brand_id'], + 'series_id' => $car_row['series_id'], + 'car_id' => $car_id, + 'payway' => $payway ? 1 : 0 + ]; + $delry_time && $data['delry_time'] = $delry_time; + $color && $data['color'] = $color; + $in_color && $data['in_color'] = $in_color; + $data['if_num'] = $if_num ? 1 : 0; + $data['if_insure'] = $if_insure ? 1 : 0; + $money_json = json_decode($row['money_json'], true); + $money_json['confirm_amount'] = $confirm_amount ? $confirm_amount : 0; + $money_json['discount_amount'] = $discount_amount ? $discount_amount : 0; + if (!$payway) { //贷款 + $data['downpayment_type'] = $downpayment_type; + $money_json['loan_amount'] = $loan_amount ? $loan_amount : 0; + $money_json['loan_periods'] = $loan_periods ? $loan_periods : 0; + $money_json['monthly_payment'] = $monthly_payment ? $monthly_payment : 0; + } + if ($if_num) { + $money_json['register_amount'] = $register_amount ? $register_amount : 0; + } + $data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE); + $result = $this->orders_model->update($data, ['id' => $row['id']]); + if ($result) { + throw new Exception('修改成功', API_CODE_SUCCESS); + } else { + throw new Exception('修改失败', ERR_PARAMS_ERROR); + } + } + + //修改用户基本信息 + protected function put_info() + { + $id = $this->input_param('id'); + + $row = $this->orders_model->get(['id' => $id]); + if (!$row) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + + $name = trim($this->input_param('name')); + $cardid = trim($this->input_param('cardid')); + $data['name'] = $name; + $data['card_id'] = $cardid; + + $result = $this->orders_model->update($data, ['id' => $row['id']]); + if ($result) { + throw new Exception('修改成功', API_CODE_SUCCESS); + } else { + throw new Exception('修改失败', ERR_PARAMS_ERROR); + } + } + //获取客户订单 protected function get_customer() { @@ -340,8 +419,6 @@ class Cusorder extends Wxapp $series = $this->auto_series_model->get(['id' => $row['series_id']], 'name'); $car = $this->auto_cars_model->get(['id' => $row['car_id']], 'name'); $payway = $row['payway']; - $deposit = $money_json['price_book']; - $if_zero_firstpay = $payway == 0 && !$deposit ? 1 : 0; $car_data = []; $car_data['车辆品牌'] = $brand['name'] . $series['name']; @@ -351,6 +428,7 @@ class Cusorder extends Wxapp $car_data['付款方式'] = $payway ? '全款' : '分期'; $car_data['期望交付时间'] = date('Y-m-d', strtotime($row['delry_time'])); if (!$payway) { // 分期 + $car_data['首付款方式'] = $this->orders_model->downpayment_type($row['downpayment_type']); $car_data['贷款额度'] = $money_json['loan_amount']; $car_data['贷款期数'] = $money_json['loan_periods']; $car_data['月供'] = $money_json['monthly_payment']; @@ -360,12 +438,8 @@ class Cusorder extends Wxapp if ($row['if_num']) { $car_data['上牌费'] = $money_json['register_amount'] ? $money_json['register_amount'] : 0; } - $money_json['confirm_amount'] && $money_json['定金'] = $money_json['confirm_amount']; - $money_json['discount_amount'] && $money_json['车身优惠'] = $money_json['discount_amount']; -// $car_data['委托代办']['value'] = 0.01; -// $car_data['委托代办']['list']['dd'] = 0.22; -// $car_data['委托代办']['list']['cc'] = 0.33; -// $car_data['需开具本地发票'] = $row['if_local_bill'] ? '需要' : '不需要'; + $money_json['confirm_amount'] && $car_data['定金'] = $money_json['confirm_amount']; + $money_json['discount_amount'] && $car_data['车身优惠'] = $money_json['discount_amount']; $data = [ 'id' => $id, @@ -383,48 +457,15 @@ class Cusorder extends Wxapp 'car_data' => $car_data, 'if_num' => $row['if_num'], 'if_insure' => $row['if_insure'], - 'delry_time' => date('Y-m-d',strtotime($row['delry_time'])), + 'delry_time' => date('Y-m-d', strtotime($row['delry_time'])), 'money_json' => json_decode($row['money_json'], true), + 'downpayment_type' => $row['downpayment_type'], + 'cardid' => $row['card_id'], + 'edit_info_status' => $row['status'] > 0 ? false : true, + 'edit_order_status' => $row['status'] > 1 ? false : true, ]; + //图片信息 - $data['if_zero_firstpay'] = $if_zero_firstpay; - $data['cardid'] = $row['card_id']; - - $data['bill_img'] = ''; - //选择随车物品 - $ckcar_status = 0; - $ckcar_data = [ - - ]; - $data['ckcar_status'] = $ckcar_status; - $data['ckcar_data'] = $ckcar_data; - $data['price_book_status'] = true; - $data['price_loan0_status'] = true; - $data['price_loan_status'] = true; - $data['price_srv_status'] = true; - $data['price_last_status'] = true; - $data['edit_status'] = 1; - $data['loan_status'] = true; - - $notify_file_list = []; - $data['notify_file'] = $notify_file_list; - $data['lend_file'] = [ - 'src' => '', - 'value' => '' - ]; - $data['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : 0.00; - $data['loan_rebate'] = $money_json['loan_rebate'] ? $money_json['loan_rebate'] : 0; # 0612 按揭返点系数 - $data['num'] = 0; - $data['is_tiexi'] = 111; - $data['admin_name'] = ''; - if ($row['admin_id']) { - $admin_row = $this->app_user_model->get(['id' => $row['admin_id']], 'uname'); - $data['admin_name'] = $admin_row['uname']; - } - - $data['sa'] = ''; - $data['refund_status'] = $row['status'] == 2 ? true : false; - $data['option_ids'] = $row['option_ids'] ? json_decode($row['option_ids'], true) : []; return $data; } diff --git a/api/controllers/wxapp/licheb/Cusorderdata.php b/api/controllers/wxapp/licheb/Cusorderdata.php new file mode 100644 index 00000000..df9db35a --- /dev/null +++ b/api/controllers/wxapp/licheb/Cusorderdata.php @@ -0,0 +1,346 @@ +login_white = array();//登录白名单 + $this->check_status = array();//用户状态校验 + $this->check_mobile = array();//需要手机号 + $this->check_headimg = array();//授权微信信息 + + $this->load->model('receiver/order/receiver_orders_model', 'orders_model'); + $this->load->model('receiver/order/receiver_order_datas_model'); + +// $this->load->library('receiver/order_datas_entity'); + $this->load->library('TcOrc'); + } + + protected function get() + { + $id = $this->input_param('id'); + $row = $this->orders_model->get(['id' => $id]); + $data = []; + $data['img_status'] = 1; + $row_data = $this->receiver_order_datas_model->get(['o_id' => $id]); + $cardidb = $cardida = $business_licence = $register_img = $car_img = []; + if ($row_data['car_img']) { + $car_img = [ + 'value' => $row_data['car_img'], + 'img' => build_qiniu_image_url($row_data['car_img']) + ]; + } + $bill_img = $car_auth_img = $equity_ck_img = $pay_img = $contract_img = $accident_img = $destory_img = $mut_wx_img = $wx_img = $delivery_ck_img = $bill_ck_img = $business_img = $insurance_img = []; + if ($row_data['insurance_img']) { + $insurance_img = [ + 'value' => $row_data['insurance_img'], + 'img' => build_qiniu_image_url($row_data['insurance_img']), + ]; + } + if ($row_data['business_img']) { + $business_img = [ + 'value' => $row_data['business_img'], + 'img' => build_qiniu_image_url($row_data['business_img']), + ]; + } + if ($row_data['delivery_ck_img']) { + $delivery_ck_img = [ + 'value' => $row_data['delivery_ck_img'], + 'img' => build_qiniu_image_url($row_data['delivery_ck_img']) + ]; + } + if ($row_data['contract_img']) { + $contract_img = [ + 'value' => $row_data['contract_img'], + 'img' => build_qiniu_image_url($row_data['contract_img']) + ]; + } + if ($row_data['pay_img']) { + $pay_img = [ + 'value' => $row_data['pay_img'], + 'img' => build_qiniu_image_url($row_data['pay_img']) + ]; + } + if ($row_data['equity_ck_img']) { + $equity_ck_img = [ + 'value' => $row_data['equity_ck_img'], + 'img' => build_qiniu_image_url($row_data['equity_ck_img']) + ]; + } + if ($row_data['car_auth_img']) { + $car_auth_img = [ + 'value' => $row_data['car_auth_img'], + 'img' => build_qiniu_image_url($row_data['car_auth_img']) + ]; + } + if ($row_data['bill_img']) { + $bill_img = [ + 'value' => $row_data['bill_img'], + 'img' => build_qiniu_image_url($row_data['bill_img']) + ]; + } + $imgs = [ + 'cardida' => [], + 'cardidb' => [], + 'business_licence' => [], + 'car_img' => $car_img, + 'ins_img' => [], + 'other_img' => [], + 'insurance_img' => $insurance_img, + 'business_img' => $business_img, + 'accident_img' => $accident_img, + 'bill_ck_img' => $bill_ck_img, + 'wx_img' => $wx_img, + 'mut_wx_img' => $mut_wx_img, + 'destory_img' => $destory_img, + 'pay_img' => $pay_img, + 'contract_img' => $contract_img, + 'equity_ck_img' => $equity_ck_img, + 'bill_img' => $bill_img, + 'car_auth_img' => $car_auth_img, + 'delivery_ck_img' => $delivery_ck_img + ]; + $data['imgs'] = $imgs; + + if ($row['main_type']) { + if ($row_data['business_licence']) { + $business_licence = [ + 'value' => $row_data['business_licence'], + 'img' => build_qiniu_image_url($row_data['business_licence']) + ]; + } + $data['imgs']['business_licence'] = $business_licence; + } else { + if ($row_data['cardida']) { + $cardida = [ + 'value' => $row_data['cardida'], + 'img' => build_qiniu_image_url($row_data['cardida']) + ]; + } + if ($row_data['cardidb']) { + $cardidb = [ + 'value' => $row_data['cardidb'], + 'img' => build_qiniu_image_url($row_data['cardidb']) + ]; + } + $data['imgs']['cardida'] = $cardida; + $data['imgs']['cardidb'] = $cardidb; + } + if ($row_data['ins_img']) { + $ins_img = json_decode($row_data['ins_img'], true); + $imgs = []; + foreach ($ins_img as $item) { + $imgs[] = [ + 'value' => $item, + 'img' => build_qiniu_image_url($item) + ]; + } + $data['imgs']['ins_img'] = $imgs; + } + return $data; + } + + protected function put() + { + $id = $this->input_param('id'); + $row = $this->orders_model->get(['id' => $id]); + if (!$row) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + $data_row = $this->receiver_order_datas_model->get(['o_id' => $id]); + $jsondata = json_decode($data_row['jsondata'], true); + if (!$data_row) { + $this->receiver_order_datas_model->add(['o_id' => $id]); + } + $cardida = $this->input_param('cardida'); + $cardidb = $this->input_param('cardidb'); + $car_img = $this->input_param('car_img'); + + $business_licence = $this->input_param('business_licence'); + $ins_imgs = $this->input_param('ins_imgs'); + $other_imgs = $this->input_param('other_imgs'); + $insurance_img = $this->input_param('insurance_img'); + $business_img = $this->input_param('business_img'); + $accident_img = $this->input_param('accident_img'); + $delivery_ck_img = $this->input_param('delivery_ck_img'); + $wx_img = $this->input_param('wx_img'); + $mut_wx_img = $this->input_param('mut_wx_img'); + $destory_img = $this->input_param('destory_img'); + $contract_img = $this->input_param('contract_img'); + $pay_img = $this->input_param('pay_img'); + $equity_ck_img = $this->input_param('equity_ck_img'); + $car_auth_img = $this->input_param('car_auth_img'); + $bill_img = $this->input_param('bill_img'); + $update = []; + if ($cardida) { + $full_cardida = build_qiniu_image_url($cardida); + $result = $this->tcorc->IdentityCard($full_cardida); + if (!$result['code']) { + $res_data['code'] = API_CODE_ORC_FAIL; + $res_data['data'] = [ + ['caridA' => false, 'errmsg' => $result['msg']], + ['caridB' => true, 'errmsg' => ''], + ]; + return $res_data; + } + $userinfo = $result['data']; + //校验订单客户和身份证姓名 + if ($userinfo['Name'] != $row['name']) { + $res_data['code'] = API_CODE_ORC_FAIL; + $res_data['data'] = [ + ['caridA' => false, 'errmsg' => '身份证姓名与客户不一致'], + ['caridB' => true, 'errmsg' => ''], + ]; + return $res_data; + } + //个人核对身份证 + if ($userinfo['IdNum'] != $row['card_id']) { + $res_data['code'] = API_CODE_ORC_FAIL; + $res_data['data'] = [ + ['caridA' => false, 'errmsg' => '身份证号码与客户不一致'], + ['caridB' => true, 'errmsg' => ''], + ]; + return $res_data; + } + $update['cardida'] = $cardida; + } elseif ($business_licence) { + $full_business_licence = build_qiniu_image_url($business_licence); + $result = $this->tcorc->BizLicense($full_business_licence); + if (!$result['code']) { + $res_data['code'] = API_CODE_ORC_FAIL; + $res_data['data'] = [ + ['business_licence' => false, 'errmsg' => $result['msg']], + ]; + return $res_data; + } + $update['business_licence'] = $business_licence; + } elseif (is_array($ins_imgs)) { + $update['ins_img'] = json_encode($ins_imgs, JSON_UNESCAPED_UNICODE); + } elseif ($insurance_img) { + $update['insurance_img'] = $insurance_img; + } elseif ($business_img) { + $update['business_img'] = $business_img; + } elseif ($accident_img) { + $update['accident_img'] = json_encode(['img' => $accident_img], JSON_UNESCAPED_UNICODE); + } elseif (is_array($other_imgs)) { + $update['other_img'] = json_encode($other_imgs, JSON_UNESCAPED_UNICODE); + } else { + if ($cardidb) { + $key = 'cardidb'; + $img = $cardidb; + } + if ($car_img) { //图片识别行驶证 + $key = 'car_img'; + $img = $car_img; + $result = $this->tcorc->VehicleLicense(build_qiniu_image_url($car_img)); + if (!$result['code']) { + throw new Exception('行驶证识别失败,请重新上传', ERR_PARAMS_ERROR); + } + $jsondata['car_info'] = $result['data']['FrontInfo']; + $update['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + } + if ($delivery_ck_img) { + $key = 'delivery_ck_img'; + $img = $delivery_ck_img; + } + if ($wx_img) { + $key = 'wx_img'; + $img = $wx_img; + } + if ($mut_wx_img) { + $key = 'mut_wx_img'; + $img = $mut_wx_img; + } + if ($destory_img) { + $key = 'destory_img'; + $img = $destory_img; + } + if ($contract_img) { + $key = 'contract_img'; + $img = $contract_img; + } + + if ($pay_img) { + $key = 'pay_img'; + $img = $pay_img; + } + if ($equity_ck_img) { + $key = 'equity_ck_img'; + $img = $equity_ck_img; + } + if ($car_auth_img) { + $key = 'car_auth_img'; + $img = $car_auth_img; + } + if ($bill_img) { + $key = 'bill_img'; + $img = $bill_img; + } + $key && $update[$key] = $img; + } + $res = $this->receiver_order_datas_model->update($update, ['o_id' => $id]); + if ($res) { +// if ($insurance_img || $business_img || $accident_img) { //保单识别图片保存数据 +// $res = $this->order_datas_entity->orc_ins_img_2($id); +// if (!$res && !$accident_img) {//意外险不需要识别成功 +// throw new Exception('图片识别失败,请重新上传', ERR_PARAMS_ERROR); +// } +// } + throw new Exception('修改成功', API_CODE_SUCCESS); + } else { + throw new Exception('修改失败', ERR_PARAMS_ERROR); + } + } + + public function put_info() + { + $id = $this->input_param('id'); + $type = $this->input_param('type'); + $product = $this->input_param('product'); + $price = $this->input_param('price'); + $date = $this->input_param('date'); + $rebate = $this->input_param('rebate');//保险返点 + $data_row = $this->receiver_order_datas_model->get(['o_id' => $id]); + if (!$data_row) { + throw new Exception('数据不存在', ERR_PARAMS_ERROR); + } + !$rebate && $rebate = 0; + if ($type == 1) { //交强险图片 + $jsondata = json_decode($data_row['insurance_img'], true); + $jsondata['product'] = $product; + $jsondata['price'] = $price; + $jsondata['rebate'] = $rebate; + $jsondata['date'] = $date; + $update['insurance_img'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + } elseif ($type == 2) { //意外险图片 + $jsondata = json_decode($data_row['accident_img'], true); + $jsondata['product'] = $product; + $jsondata['price'] = $price; + $jsondata['rebate'] = $rebate; + $jsondata['date'] = $date; + $update['accident_img'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + } else { //商业险图片 + if ($price < 1000) { + throw new Exception('金额有误,请重新填写', ERR_PARAMS_ERROR); + } + $jsondata = json_decode($data_row['business_img'], true); + $jsondata['product'] = $product; + $jsondata['price'] = $price; + $jsondata['rebate'] = $rebate; + $jsondata['date'] = $date; + $update['business_img'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + } + $this->receiver_order_datas_model->update($update, ['id' => $data_row['id']]); + throw new Exception('修改成功', API_CODE_SUCCESS); + } +} diff --git a/api/controllers/wxapp/licheb/Sign.php b/api/controllers/wxapp/licheb/Sign.php index c98cecbb..f67117ac 100644 --- a/api/controllers/wxapp/licheb/Sign.php +++ b/api/controllers/wxapp/licheb/Sign.php @@ -33,7 +33,7 @@ class Sign extends Wxapp "province_id={$area['province_id']} or province_id=0" => null ]; $item_row = $this->item_model->get($where); - $time_out = 600000; + $time_out = 30; $item = []; if ($item_row) { $item['title'] = $item_row['title']; @@ -46,8 +46,6 @@ class Sign extends Wxapp 'biz_id' => $this->get_biz_id(), ]; $this->app_redis->save($key, $biz_info, $time_out); - echo $key; - exit; //获取小程序二维码 $wxconfig = $this->app_model->appConfig()[2]['wx']; $this->load->library("hd_wechat", $wxconfig); diff --git a/common/models/receiver/order/Receiver_order_datas_model.php b/common/models/receiver/order/Receiver_order_datas_model.php new file mode 100644 index 00000000..c6f949df --- /dev/null +++ b/common/models/receiver/order/Receiver_order_datas_model.php @@ -0,0 +1,41 @@ + '未上传', 1 => '已上传', 2 => '已审核', -1 => '审核不通过']; + + public function __construct() + { + parent::__construct($this->table_name, 'default'); + } + + public function get_ifcheck_cn() + { + return $this->ifcheck; + } + + /** + * Notes:根据id获取数据 + * Created on: 2021/7/15 17:27 + * @param $ids + * @param string $fileds + * @return array + */ + public function get_map_by_oids($oids, $fileds = '') + { + $rows = []; + $oids = array_filter($oids); + if ($oids) { + $cf_ids = implode(',', $oids); + $where = [ + "o_id in ($cf_ids)" => null + ]; + $rows = $this->map('o_id', '', $where, '', '', '', $fileds); + } + return $rows; + } + +} diff --git a/common/models/receiver/order/Receiver_orders_model.php b/common/models/receiver/order/Receiver_orders_model.php index 4535bef7..c69fc7e3 100644 --- a/common/models/receiver/order/Receiver_orders_model.php +++ b/common/models/receiver/order/Receiver_orders_model.php @@ -21,4 +21,13 @@ class Receiver_orders_model extends HD_Model return $this->status_arr; } + public function downpayment_type($type = 0) + { + $array = [1 => '现金', 2 => '0首付', 3 => '按揭']; + if ($type) { + return $array[$type] ? $array[$type] : ''; + } else { + return $array; + } + } }