feat: 兼容is_api=1用户直接地址下单

master
yin5th 2023-10-13 14:10:18 +08:00
parent 8377e97ead
commit d9806a96cb
1 changed files with 23 additions and 5 deletions

View File

@ -110,11 +110,27 @@ class OrderLogic extends Logic
if (false === $check_goods) {
throw new Exception(self::$error);
}
$address = UserAddress::where('id', $post['address_id'])
->field('contact,telephone,province_id,city_id,district_id,address')
->find();
if (empty($address)) {
throw new Exception('请选择地址');
$address = [];
// is_api接口
if (!empty($post['is_api']) && $post['is_api'] == 1) {
if (empty($post['contact']) || empty($post['province_id']) || empty($post['city_id'])
|| empty($post['district_id']) || empty($post['address']) || empty($post['telephone'])) {
throw new Exception('请填写收货信息');
}
$address['contact'] = $post['contact'];
$address['province_id'] = $post['province_id'];
$address['city_id'] = $post['city_id'];
$address['district_id'] = $post['district_id'];
$address['address'] = $post['address'];
$address['telephone'] = $post['telephone'];
} else {
$address = UserAddress::where('id', $post['address_id'])
->field('contact,telephone,province_id,city_id,district_id,address')
->find();
if (empty($address)) {
throw new Exception('请选择地址');
}
}
// 校验发票信息 返回以店铺id为键,原发票参数为值的数组
@ -919,12 +935,14 @@ class OrderLogic extends Logic
$order_data['pay_way'] = $post['pay_way'];
$order_data['delivery_type'] = $post['delivery_type'] ?? 0;
$order_data['aftersale_status'] = OrderEnum::AFTERSALE_STATUS_NO_SALE;
$order_data['consignee'] = $address['contact'];
$order_data['province'] = $address['province_id'];
$order_data['city'] = $address['city_id'];
$order_data['district'] = $address['district_id'];
$order_data['address'] = $address['address'];
$order_data['mobile'] = $address['telephone'];
$order_data['goods_price'] = $goods_price;
$order_data['shipping_price'] = $shipping_price;
$order_data['order_amount'] = $order_amount;