validate()) return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; 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_PT); 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 = []; $md_info = []; $flag_id = 0; $store = Store::findOne(get_store_id()); $province_name = District::findOne($store->province_id)->name; $city_name = District::findOne($store->city_id)->name; $district_name = District::findOne($store->district_id)->name; $lat = ''; $long = ''; $coordinate = explode(',', $store->coordinate); if ($coordinate) { $lat = $coordinate[0]; $long = $coordinate[1]; } $md_info = [ 'is_md' => 0, '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; // } foreach ($storeList[0]['goods_list'] as &$arr) { $goods = Goods::findOne($arr['goods_id']); //TODO 新的 //计算返利 $send_price += floatval($goods->goods_send_profit * $arr['price'] * 0.01 * $arr['num']); $take_price += floatval($goods->goods_take_price * $arr['price'] * 0.01 * $arr['num']); } $user = User::findOne(get_user_id()); $user_league_price = 0; $saas_user = SaasUser::findOne(['mobile' => $user->binding]); if($saas_user){ $user_league_price = $saas_user->league_price; } if($take_price > $user_league_price){ $take_price = $user_league_price; } $total_price = 0; foreach ($storeList as $store_item) { $total_price += $store_item['total_price']; } if ($total_price < $take_price) { $take_price = 0; $send_price = 0; } $template_id = NoticeAction::getSendTamplateId(['order_pay', 'order_submit', 'order_send']); return [ 'code' => 0, 'msg' => 'OOKK', 'data' => [ 'order_no' => $order_no, 'flag_id' => intval($flag_id), 'store_info' => $store_info, 'food_pay' => $food_pay_type, 'pay_type_list' => $this->getPayTypeList(), 'take_price' => $take_price, 'send_price' => $send_price, 'user_league_price' => $user_league_price, 'address' => $this->address, 'level' => [], 'store_list' => $storeList, 'integral'=>$this->integral, 'goods_card_list' => [], 'template_id' => $template_id ], ]; } }