getStoreInfo($store_condition)['data'] ?? []; $store_is_express = $store_info['is_express']; $store_is_o2o = $store_info['is_o2o']; $store_is_pickup = $store_info['is_pickup']; $store_config_model = new \addon\store\model\Config(); $store_config = $store_config_model->getStoreBusinessConfig($site_id)['data']['value'] ?? []; $order_model = new OrderCommon(); switch ($type) { case 'trade': $shop_goods_list = $calculate_data['shop_goods_list']; //必须是连锁模式 还需要判断某一个插件是否存在 if ($store_id > 0 && $store_config['store_business'] == 'store') { foreach ($shop_goods_list['deliver_sort'] as $type) { // 物流 if ($type == 'express') { $store_is_express = $store_is_express ?? 0; if ($store_is_express == 1) { $title = $shop_goods_list['express_config']['value']['express_name']; if ($title == '') { $title = Express::express_type['express']['title']; } $express_type[] = ['title' => $title, 'name' => 'express']; } } // 自提 if ($type == 'store') { $store_is_pickup = $store_is_pickup ?? 0; if ($store_is_pickup == 1) { //根据坐标查询门店 $store_model = new Store(); $store_condition = array( ['site_id', '=', $site_id], ['is_pickup', '=', 1], ['status', '=', 1], ['is_frozen', '=', 0], ); $store_condition[] = ['store_id', '=', $store_id]; $latlng = array( 'lat' => $calculate_data['latitude'], 'lng' => $calculate_data['longitude'], ); $store_list_result = $store_model->getLocationStoreList($store_condition, '*', $latlng); $store_list = $store_list_result['data']; $title = $shop_goods_list['store_config']['value']['store_name']; if ($title == '') { $title = Express::express_type['store']['title']; } $express_type[] = ['title' => $title, 'name' => 'store', 'store_list' => $store_list]; } } // 外卖 if ($type == 'local') { $store_is_o2o = $store_is_o2o ?? 0; if ($store_is_o2o == 1) { //查询本店的通讯地址 $title = $shop_goods_list['local_config']['value']['local_name']; if ($title == '') { $title = '外卖配送'; } $store_model = new Store(); $store_condition = array( ['site_id', '=', $site_id], ); $store_condition[] = ['is_o2o', '=', 1]; $store_condition[] = ['status', '=', 1]; $store_condition[] = ['is_frozen', '=', 0]; $store_condition[] = ['store_id', '=', $store_id]; $latlng = array( 'lat' => $calculate_data['latitude'], 'lng' => $calculate_data['longitude'], ); $store_list_result = $store_model->getLocationStoreList($store_condition, '*', $latlng); $store_list = $store_list_result['data']; $express_type[] = ['title' => $title, 'name' => 'local', 'store_list' => $store_list]; } } } return $order_model->success($express_type ?? []); } break; case 'trade_calc': if ($store_id > 0 && $store_config['store_business'] == 'store') { $shop_goods = $params['shop_goods']; //如果本地配送开启, 则查询出本地配送的配置 $local_model = new Local(); $local_info_result = $local_model->getLocalInfo([['site_id', '=', $site_id], ['store_id', '=', $store_id]]); $local_info = $local_info_result['data'] ?? []; $shop_goods['local_config']['info'] = $local_info; $delivery_array = $calculate_data['delivery'] ?? []; $delivery_type = $delivery_array['delivery_type'] ?? 'express'; if ($delivery_type == 'store') { //门店自提 $delivery_money = 0; $shop_goods['delivery']['delivery_type'] = 'store'; if ($store_is_pickup == 0) { $error = ['error_msg' => '门店自提方式未开启!']; } $shop_goods['delivery']['store_id'] = $calculate_data['delivery']['store_id']; $shop_goods['buyer_ask_delivery_time'] = $calculate_data['buyer_ask_delivery_time']; $shop_goods = $this->storeOrderData($shop_goods, $calculate_data); } else { if (empty($calculate_data['member_address'])) { $delivery_money = 0; $shop_goods['delivery']['delivery_type'] = 'express'; $error = ['error_msg' => '未配置默认收货地址!']; } else { if ($delivery_type == 'express') { if ($store_is_express == 1) { //物流配送 $express = new Express(); $express_fee_result = $express->calculate($shop_goods, $calculate_data); if ($express_fee_result['code'] < 0) { $error = ['error_msg' => $express_fee_result['message']]; $delivery_fee = 0; } else { $delivery_fee = $express_fee_result['data']['delivery_fee']; } } else { $error = ['error_msg' => '物流配送方式未开启!']; $delivery_fee = 0; } $delivery_money = $delivery_fee; $shop_goods['delivery']['delivery_type'] = 'express'; } else if ($delivery_type == 'local') { //外卖配送 $delivery_money = 0; $shop_goods['delivery']['delivery_type'] = 'local'; if ($store_is_o2o == 0) { $error = ['error_msg' => '外卖配送方式未开启!']; } else { if (empty($calculate_data['delivery']['store_id'])) { $error = ['error_msg' => '门店未选择!']; } $local_delivery_time = 0; if (!empty($calculate_data['buyer_ask_delivery_time'])) { $local_delivery_time = $calculate_data['buyer_ask_delivery_time']; } $shop_goods['buyer_ask_delivery_time'] = $local_delivery_time; $local_model = new Local(); $local_result = $local_model->calculate($shop_goods, $calculate_data); $shop_goods['delivery']['start_money'] = 0; if ($local_result['code'] < 0) { $shop_goods['delivery']['start_money'] = $local_result['data']['start_money_array'][0] ?? 0; $error = ['error_msg' => $local_result['message'], 'priority' => 1, 'error' => $local_result['data']['code']]; } else { $delivery_money = $local_result['data']['delivery_money']; if (!empty($local_result['data']['error_code'])) { $error = ['error_msg' => $local_result['data']['error'], 'priority' => 1, 'error' => $local_result['data']['error']]; } } $shop_goods['delivery']['error'] = $error['error'] ?? 0; $shop_goods['delivery']['error_msg'] = $error['error_msg'] ?? ''; } } } } return $order_model->success(['shop_goods' => $shop_goods, 'delivery_money' => $delivery_money, 'error' => $error ?? []]); } break; } } }