@@ -267,6 +267,17 @@ class OrderMain extends Backend | |||
return json($result); | |||
} | |||
/** | |||
* 获取订单详情 | |||
* @return \think\response\Json | |||
*/ | |||
public function getShowInfo(){ | |||
$params=$this->request->post(); | |||
$orderMainService = new OrderMainService(); | |||
$result = $orderMainService->getOrderInfo($params['id']); | |||
return json($result); | |||
} | |||
public function newAdd(){ | |||
$params=$this->request->post(); | |||
$hotelMain = $params["orderMain"]; | |||
@@ -199,4 +199,22 @@ class OrderHotelDao | |||
$model = new OrderHotel(); | |||
$model->save(["del_flag"=>1],["id"=>$id]); | |||
} | |||
/** | |||
* 获取酒店子订单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId){ | |||
$subOrderModel = new OrderHotel(); | |||
try { | |||
$subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $subOrderList) { | |||
return Util::returnArrEr([]); | |||
} | |||
return Util::returnArrSu($subOrderList); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取酒店订单列表异常".$e->getMessage()); | |||
} | |||
} | |||
} |
@@ -153,4 +153,23 @@ class OrderItemDao | |||
$model->save(["del_flag"=>1],["id"=>$id]); | |||
} | |||
/** | |||
* 获取附加项目子订单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId){ | |||
$subOrderModel = new OrderItem(); | |||
try { | |||
$subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $subOrderList) { | |||
return Util::returnArrEr([]); | |||
} | |||
return Util::returnArrSu($subOrderList); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取附加项目订单列表异常".$e->getMessage()); | |||
} | |||
} | |||
} |
@@ -77,4 +77,52 @@ class OrderMainDao | |||
return Util::returnArrEr("更新主表订单金额失败".$orderId); | |||
} | |||
} | |||
/** | |||
* 根据ID获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$orderMainModel = new OrderMain(); | |||
$orderMain = $orderMainModel->where(["id" => $id])->find(); | |||
if (null == $orderMain) { | |||
return Util::returnArrEr("订单查询失败".$id); | |||
} | |||
return Util::returnArrSu($orderMain); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("订单查询失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 子订单展示 | |||
* @param $purchaseShow | |||
* @param $orderHotel | |||
* @param $orderItem | |||
* @return array | |||
*/ | |||
public function setSubOrderShow($purchaseShow,$orderHotel,$orderItem){ | |||
$result = []; | |||
foreach ($orderItem as $item) { | |||
$item['prod_type'] = 'item'; | |||
foreach ($purchaseShow as $key=> $purchase) { | |||
if ($item['id'] == $key) { | |||
array_merge($item,$purchase); | |||
} | |||
} | |||
$result[] = $item; | |||
} | |||
foreach ($orderHotel as $hotel) { | |||
$hotel['prod_type'] = 'hotel'; | |||
foreach ($purchaseShow as $key=> $purchase) { | |||
if ($hotel['id'] == $key) { | |||
array_merge($hotel,$purchase); | |||
} | |||
} | |||
$result[] = $hotel; | |||
} | |||
return Util::returnArrSu($result); | |||
} | |||
} |
@@ -207,4 +207,53 @@ class OrderMainService | |||
return Util::returnArrEr("删除子订单失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 获取订单详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getOrderInfo($id){ | |||
$orderMainDao = new OrderMainDao(); | |||
$orderMainRe = $orderMainDao->getInfoById($id); | |||
if (!$orderMainRe['flag']) { | |||
return $orderMainRe; | |||
} | |||
$orderMain = $orderMainRe['data']; | |||
//获取采购单金额列表 | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$purchasePriceRe = $purchasePriceDao->getPurchasePriceListByOrderId($id); | |||
if (!$purchasePriceRe['flag']) { | |||
return $purchasePriceRe; | |||
} | |||
//获取采购单列表 | |||
$purchaseDao = new PurchaseDao(); | |||
$purchaseRe = $purchaseDao->getListByOrderId($id); | |||
if (!$purchaseRe['flag']) { | |||
return $purchaseRe; | |||
} | |||
//设置采购单展示数据 | |||
$purchaseShow = $purchaseDao->setPurchaseShow($purchaseRe['data'],$purchasePriceRe['data']); | |||
if (!$purchaseShow['flag']) { | |||
return $purchaseShow; | |||
} | |||
//获取子订单列表 | |||
$orderHotelDao = new OrderHotelDao(); | |||
$orderHotelRe = $orderHotelDao->getListByOrderId($id); | |||
if (!$orderHotelRe['flag']) { | |||
return $orderHotelRe; | |||
} | |||
$orderItemDao = new OrderItemDao(); | |||
$orderItemRe = $orderItemDao->getListByOrderId($id); | |||
if (!$orderItemRe['flag']) { | |||
return $orderItemRe; | |||
} | |||
//设置子订单列表 | |||
$subOrderList = $orderMainDao->setSubOrderShow($purchaseShow['data'],$orderHotelRe['data'],$orderItemRe['data']); | |||
if (!$subOrderList['flag']) { | |||
return $subOrderList; | |||
} | |||
$orderMain["subOrderList"]=$subOrderList['data']; | |||
return Util::returnArrSu($orderMain); | |||
} | |||
} |
@@ -132,4 +132,59 @@ class PurchaseDao | |||
$model = new Purchase(); | |||
$model->save(["del_flag"=>1],["order_detail_id"=>$subOrderId]); | |||
} | |||
/** | |||
* 获取采购单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId) { | |||
$model = new Purchase(); | |||
try { | |||
$list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $list) { | |||
return Util::returnArrSu([]); | |||
} | |||
return Util::returnArrSu($list); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取订单的采购单列表失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 设置 | |||
* @param $purchaseList | |||
* @param $purchasePriceList | |||
* @return array | |||
*/ | |||
public function setPurchaseShow($purchaseList,$purchasePriceList){ | |||
$result = []; | |||
foreach ($purchaseList as $purchase) { | |||
$purchaseShow=[ | |||
"purchase_id"=>$purchase['id'], | |||
"purchase_user_id"=>$purchase['purchase_user_id'], | |||
"purchase_user"=>$purchase['purchase_user'], | |||
"supplier_id"=>$purchase['supplier_id'], | |||
"supplier_name" =>$purchase['supplier_name'], | |||
"purchasePriceList"=>[] | |||
]; | |||
foreach ($purchasePriceList as $price) { | |||
if ($price['purchase_id'] == $purchase['id']) { | |||
$priceShow = [ | |||
"id"=>$price['id'], | |||
"run_date"=>$price['run_date'], | |||
"count"=>$price['count'], | |||
"price"=>$price['price'], | |||
"cost"=>$price['cost'] | |||
]; | |||
$purchaseShow["purchasePriceList"][]=$priceShow; | |||
} | |||
} | |||
if (null == $result[$purchase['order_detail_id']]) { | |||
$result[$purchase['order_detail_id']] = []; | |||
} | |||
$result[$purchase['order_detail_id']][]= $purchaseShow; | |||
} | |||
return Util::returnArrSu($result); | |||
} | |||
} |
@@ -74,4 +74,22 @@ class PurchasePriceDao | |||
$model = new PurchasePrice(); | |||
$model->save(["del_flag" => 1], ["order_detail_id" => $subOrderId]); | |||
} | |||
/** | |||
* 获取采购单金额 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getPurchasePriceListByOrderId($orderId) { | |||
$model = new PurchasePrice(); | |||
try { | |||
$list = $model->where(["order_id" => $orderId, "del_flag" => $orderId])->select(); | |||
if (null == $list) { | |||
return Util::returnArrSu([]); | |||
} | |||
return Util::returnArrSu($list); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取采购单金额异常".$e->getMessage()); | |||
} | |||
} | |||
} |