91 lines
4.6 KiB
PHP
91 lines
4.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 订单
|
|
*/
|
|
class Orders_entity
|
|
{
|
|
private $ci;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->ci = &get_instance();
|
|
$this->ci->load->model('receiver/receiver_customers_model', 'customers_model');
|
|
|
|
$this->ci->load->model('receiver/order/receiver_orders_model', 'orders_model');
|
|
$this->ci->load->model('receiver/order/receiver_order_datas_model');
|
|
$this->ci->load->model('auto/auto_cars_model');
|
|
$this->ci->load->library('carHome');
|
|
}
|
|
|
|
/**
|
|
* 订单数据提交汽车之家
|
|
* @param $oid
|
|
* @return array|void
|
|
*/
|
|
public function post_auto($oid)
|
|
{
|
|
$order_row = $this->ci->orders_model->get(['id' => $oid]);
|
|
$customer_row = $this->ci->customers_model->get(['id' => $order_row['customer_id']]);
|
|
$car_row = $this->ci->auto_cars_model->get(['id' => $order_row['car_id']]);
|
|
$order_data = $this->ci->receiver_order_datas_model->get(['o_id' => $order_row['id']]);
|
|
if (!$order_row) {
|
|
return ['code' => 0, 'msg' => '订单不存在'];
|
|
}
|
|
$money_json = json_decode($order_row['money_json'], true);
|
|
$post_data = [
|
|
'buyerType' => $order_row['main_type'] ? 2 : 1,
|
|
'buyerName' => $order_row['name'],
|
|
'buyerPhone' => $order_row['mobile'],
|
|
'specId' => $car_row['third_car_id'],
|
|
'outOrderId' => $order_row['sid'],
|
|
'outLeadId' => $customer_row['cid'],
|
|
'outOrderCreateTime' => date('Y-m-d H:i:s', $order_row['c_time']),
|
|
'registerCityId' => $customer_row['city_id'],
|
|
];
|
|
$order_row['auto_order_id'] && $post_data['autohomeOrderId'] = $order_row['auto_order_id'];
|
|
$money_json['invoice_amount'] && $post_data['invoiceAmount'] = $money_json['invoice_amount'];
|
|
if ($order_row['if_num']) { //是否上牌
|
|
$post_data['isRegisterInStore'] = 1;
|
|
$money_json['register_amount'] && $post_data['registerAmount'] = $money_json['register_amount'];
|
|
}
|
|
$post_data['isInsured'] = $order_row['if_insure'] ? 1 : 0;
|
|
if (!$order_row['payway']) { //贷款
|
|
$post_data['isLoan'] = 1;
|
|
$money_json['loan_amount'] && $post_data['loanAmount'] = $money_json['loan_amount'];
|
|
$money_json['loan_periods'] && $post_data['loanPeriods'] = $money_json['loan_periods'];
|
|
$money_json['monthly_payment'] && $post_data['monthlyPayment'] = $money_json['monthly_payment'];
|
|
}
|
|
// $data['carryCarDate'] = '2024-06-02';
|
|
// $data['payDate'] = '2024-05-27';
|
|
$order_data['contract_img'] && $post_data['contractImg'] = build_qiniu_image_url($order_data['contract_img']);
|
|
$order_data['bill_img'] && $post_data['invoiceImg'] = build_qiniu_image_url($order_data['bill_img']);
|
|
$order_data['pay_img'] && $post_data['payImg'] = build_qiniu_image_url($order_data['pay_img']);
|
|
$order_row['color'] && $post_data['outColor'] = $order_row['color'];
|
|
$order_row['in_color'] && $post_data['inColor'] = $order_row['in_color'];
|
|
$post_data['deliveryDate'] = date('Y-m-d', strtotime($order_row['delry_time']));
|
|
$post_data['downpaymentType'] = $order_row['downpayment_type'];
|
|
$money_json['confirm_amount'] && $post_data['confirmAmount'] = $money_json['confirm_amount'];
|
|
$money_json['discount_amount'] && $post_data['discountAmount'] = $money_json['discount_amount'];
|
|
// $data['isLocalInvoice'] = 0;
|
|
$post_data['idCardNo'] = $order_row['card_id'];
|
|
$order_data['car_img'] && $data['carDocumentImg'] = build_qiniu_image_url($order_data['car_img']);
|
|
$insuranceImg = []; //保险图片
|
|
$order_data['insurance_img'] && $insuranceImg[] = build_qiniu_image_url($order_data['insurance_img']);
|
|
$order_data['business_img'] && $insuranceImg[] = build_qiniu_image_url($order_data['business_img']);
|
|
$insuranceImg && $post_data['insuranceImg'] = implode(',', $insuranceImg);
|
|
$order_data['delivery_ck_img'] && $post_data['deliveryPhoto'] = build_qiniu_image_url($order_data['delivery_ck_img']);
|
|
$order_data['equity_ck_img'] && $post_data['priceRightsConfirmDoc'] = build_qiniu_image_url($order_data['equity_ck_img']);
|
|
$req = $this->ci->carhome->saveOrder($post_data, $order_row['id']);
|
|
if ($req['code']) {
|
|
$auto_order_id = $req['data']['autohomeOrderId'];
|
|
$auto_order_id && $this->ci->orders_model->update(['auto_order_id' => $auto_order_id], ['id' => $order_row['id']]);
|
|
return ['code' => 1, 'msg' => '提交成功'];
|
|
} else {
|
|
return ['code' => 0, 'msg' => $req['msg']];
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|