20240604
This commit is contained in:
@@ -209,7 +209,8 @@ class Cusorder extends Wxapp
|
||||
if (!$row || !$status) throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
$res = $this->orders_model->update(['status' => $status], ['id' => $id]);
|
||||
if ($res) {
|
||||
//提交汽车之家
|
||||
//数据提交汽车之家
|
||||
$this->orders_entity->post_auto($id);
|
||||
throw new Exception('修改成功', API_CODE_SUCCESS);
|
||||
} else {
|
||||
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
||||
|
||||
@@ -22,15 +22,17 @@ class CarHome
|
||||
431100, 431200, 431300, 433100
|
||||
];
|
||||
protected $other_city = 439900;//439900 其它城市
|
||||
private $ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->client = new Client();
|
||||
if (!is_product()) { //测试环境
|
||||
$this->base_url = 'https://ahohcrm-test.autohome.com.cn/api/community/';
|
||||
$this->storeId = 50;
|
||||
}
|
||||
|
||||
$this->ci->load->model('auto/auto_api_log_model');
|
||||
}
|
||||
//autohomeOrderId Long 否 之家订单id 更新时必传
|
||||
//outSystemCode int 是 外部系统编号 1001 爱能
|
||||
@@ -75,25 +77,35 @@ class CarHome
|
||||
* @return array|void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function saveOrder($data)
|
||||
public function saveOrder($data, $oid)
|
||||
{
|
||||
try {
|
||||
$post_url = $this->base_url . self::SAVE_ORDER;
|
||||
$data['outSystemCode'] = $this->outSystemCode;
|
||||
$data['specId'] = $this->storeId;
|
||||
$data['storeId'] = $this->storeId;
|
||||
//城市转换
|
||||
$data['registerCityId'] = $this->city_lists[$data['registerCityId']] ? $this->city_lists[$data['registerCityId']] : $this->other_city;
|
||||
debug_log("post_data:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
$req = $this->send($post_url, $data, self::METHOD_POST);
|
||||
list($req, $header, $httpStatus) = $this->send($post_url, $data, self::METHOD_POST);
|
||||
debug_log("result:" . $req);
|
||||
$reqArr = json_decode($req, true);
|
||||
$log_data = [
|
||||
'order_id' => $oid,
|
||||
'url' => $post_url,
|
||||
'header' => json_encode($header, JSON_UNESCAPED_UNICODE),
|
||||
'post_data' => json_encode($data, JSON_UNESCAPED_UNICODE),
|
||||
'res_http_status' => $httpStatus,
|
||||
'c_time' => time()
|
||||
];
|
||||
$req && $log_data['res'] = $req;
|
||||
$this->ci->auto_api_log_model->add($log_data);
|
||||
if (isset($reqArr['returncode']) && intval($reqArr['returncode']) == 0) {
|
||||
return ['code' => 1, 'message' => '操作成功', 'data' => $reqArr['result']];
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $reqArr['result']];
|
||||
} else {
|
||||
return ['code' => 0, 'message' => $reqArr['message']];
|
||||
return ['code' => 0, 'msg' => $reqArr['message']];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return ['code' => 0, 'message' => $e->getMessage()];
|
||||
return ['code' => 0, 'msg' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +132,7 @@ class CarHome
|
||||
$options['json'] = $data;
|
||||
}
|
||||
$response = $this->client->request($type, $url, $options);
|
||||
return $response->getBody()->getContents();
|
||||
return [$response->getBody()->getContents(), $options, $response->getStatusCode()];
|
||||
} catch (GuzzleException $e) {
|
||||
debug_log($e->getMessage() . ' URL: ' . $url . ' Data: ' . json_encode($data));
|
||||
throw $e;
|
||||
|
||||
@@ -13,6 +13,7 @@ class Orders_entity
|
||||
$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');
|
||||
}
|
||||
@@ -24,12 +25,14 @@ class Orders_entity
|
||||
*/
|
||||
public function post_auto($oid)
|
||||
{
|
||||
$order_row = $this->ci->orders_model->get($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'],
|
||||
@@ -40,33 +43,47 @@ class Orders_entity
|
||||
'outOrderCreateTime' => date('Y-m-d H:i:s', $order_row['c_time']),
|
||||
'registerCityId' => $customer_row['city_id'],
|
||||
];
|
||||
// $data['autohomeOrderId'] = 20;
|
||||
// $data['invoiceAmount'] = 7000;
|
||||
// $data['isRegisterInStore'] = 1;
|
||||
// $data['registerAmount'] = 700;
|
||||
// $data['isInsured'] = 1;
|
||||
// $data['isLoan'] = 1;
|
||||
// $data['loanAmount'] = 500000;
|
||||
// $data['loanPeriods'] = 36;
|
||||
// $data['monthlyPayment'] = 3000;
|
||||
$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';
|
||||
// $data['contractImg'] = $img;
|
||||
// $data['invoiceImg'] = $img;
|
||||
// $data['payImg'] = $img;
|
||||
// $data['outColor'] = '黑色';
|
||||
// $data['inColor'] = '蓝色';
|
||||
// $data['deliveryDate'] = '2024-06-15';
|
||||
// $data['downpaymentType'] = 1;
|
||||
// $data['confirmAmount'] = 4000;
|
||||
// $data['discountAmount'] = 0;
|
||||
$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;
|
||||
// $data['idCardNo'] = '350522198910148675';
|
||||
// $data['carDocumentImg'] = $img;
|
||||
// $data['insuranceImg'] = $img;
|
||||
// $data['deliveryPhoto'] = $img;
|
||||
// $data['priceRightsConfirmDoc'] = $img;
|
||||
$req = $this->ci->carhome->saveOrder($post_data);
|
||||
$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']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user