validate()) return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; // HKG 新增判断商城打烊状态 开始 if(get_store_id() > 0 && Option::get(OptionSetting::MALL_STATUS,get_store_id(),'store',0)['value'] == 1) return [ 'code' => 1, 'msg' => '商城已打烊~' ]; // HKG 新增判断商城打烊状态 结束 try { // 预生成订单号 $order_no = OrderNo::getOrderNo(OrderNo::ORDER_ALLIANCE); cache()->set('delivery_order_no_' . get_saas_user_id(), $order_no); $storeList = $this->getStoreListData(); if(isset($storeList['code']) && $storeList['code'] == 1){ return $storeList; } } catch(\Exception $e) { return [ 'code' => 1, 'line' => $e->getLine(), 'msg' => $e->getMessage(), 'file' => $e->getFile(), ]; } $food_pay_type = $store_info = []; $flag_id = 0; $store = Store::findOne(get_store_id()); if (get_md_id() && (!empty(input_params('flag_id')) || !empty(input_params('table_num')))) { if (!empty(input_params('flag_id'))) { $flag_id = input_params('flag_id'); } else { $flag_id = FoodFlag::findOne(['store_id' => get_store_id(), 'status' => 0, 'table_num' => input_params('table_num')])->id; } $food_payment = $store->food_payment; $food_paytype = $store->food_pay_type; $food_pay_list = []; if (!empty($food_payment)) { $food_pay_type = Json::decode($food_payment); // $pay_type_list_json = Option::get(OptionSetting::STORE_PAYMENT, get_store_id(), 'store'); // $is_food_ok = false; // if (!empty($pay_type_list_json)) { // $pay_type_list = Json::decode($pay_type_list_json['value']); // foreach ($pay_type_list as $index => $pay_type) { // if ($index == 'friend' && $pay_type['value'] == 1) { // $is_food_ok = true; // break; // } // } // } foreach ($food_pay_type as &$value) { // if ($value['key'] == 'friend') { // if ($is_food_ok && $value['value'] == 1) { // $value['value'] = 1; // } else { // $value['value'] = 0; // } // } if ($value['key'] == 'friend') { $value['payment'] = 7; if(!$value['name']){ $value['name'] = "朋友代付"; } } if ($value['key'] == 'alipay') { $value['payment'] = 4; if(!$value['name']){ $value['name'] = "支付宝支付"; } } if ($value['key'] == 'wechat') { $value['payment'] = 1; if(!$value['name']){ $value['name'] = "微信支付"; } } if ($value['key'] == 'huodao') { $value['payment'] = 2; if(!$value['name']){ $value['name'] = "货到付款"; } } } $food_pay_list = $food_pay_type; } foreach ($food_pay_list as $k => $val) { if (($val['payment'] == 4 && is_wechat_platform()) || ($val['payment'] == 4 && intval($val['value']) === 0)) { unset($food_pay_list[$k]); } if (($val['payment'] == 1 && is_alipay_platform()) || ($val['payment'] == 1 && intval($val['value']) === 0)) { unset($food_pay_list[$k]); } if ($val['payment'] == 7 && intval($val['value']) === 0) { unset($food_pay_list[$k]); } } $food_pay_list = array_values($food_pay_list); // 点餐支付方式 $food_pay_type = [ 'food_pay_type' => $food_paytype, 'food_payment' => $food_pay_list ]; } $province_name = isset(District::findOne($store->province_id)->name) ? District::findOne($store->province_id)->name : ''; $city_name = isset(District::findOne($store->city_id)->name) ? District::findOne($store->city_id)->name : ''; $district_name = isset(District::findOne($store->district_id)->name) ? District::findOne($store->district_id)->name : ''; list($lat, $long) = explode(',', empty($store->coordinate) ? ',' : $store->coordinate); $store_info = [ 'name' => $store->name, 'detail_address' => $province_name . $city_name . $district_name . $store->address, 'distance' => Tools::getDistance($this->latitude, $this->longitude, $lat, $long), 'longitude' => $long, 'latitude' => $lat, 'logo' => $store->logo ]; //计算联盟券 $take_price = 0; $send_price = 0; $user_league_price = \get_saas_user()->league_price ?? 0; // $send_profit_model = Option::findOne(['name' => 'store_send_profit']);//平台让利比例 // $this_store_send_profit_model= Option::findOne(['name' => 'store_this_profit','store_id' => get_store_id()]); // if($this_store_send_profit_model->value > 0){ // $basic_send_profit = $this_store_send_profit_model->value; // }else{ // $basic_send_profit = $send_profit_model->value; // } foreach ($storeList[0]['goods_list'] as &$arr) { // $goods = Goods::findOne($arr['goods_id']); //TODO 新的 //计算返利 $send_price += $arr['send_price'] ?? 0; $take_price += $arr['take_price'] ?? 0; } $total_price = 0; foreach ($storeList as $store_item) { $total_price += $store_item['total_price']; } if (bcsub($total_price, $take_price, 2) <= 0) { $this->integral = 0; } return [ 'code' => 0, 'msg' => 'OOKK', 'data' => [ 'order_no' => $order_no, 'goods_send_profit' => 0, 'store_send_profit' => 0, 'flag_id' => intval($flag_id), 'store_info' => $store_info, 'food_pay' => $food_pay_type, 'pay_type_list' => $this->getPayTypeList(), 'address' => $this->address, 'take_price' => $take_price, 'send_price' => $send_price, 'user_league_price' => $user_league_price, //'level' => $this->getLevelData(), 'store_list' => $storeList, 'integral' => $this->integral, //'goods_card_list' => $this->goodsCardList(), 'template_id' => NoticeAction::getSendTamplateId(['order_pay', 'order_submit', 'order_send']) ], ]; } }