@@ -133,7 +133,7 @@ class OrderHotelDao | |||
* @param int $subOrderId | |||
* @return array | |||
*/ | |||
public static function setSubOrderAmount( int $subOrderId) { | |||
public function setSubOrderAmount( int $subOrderId) { | |||
try{ | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select(); | |||
@@ -152,4 +152,22 @@ class OrderHotelDao | |||
} | |||
} | |||
/** | |||
* 获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$model = new OrderHotel(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
} | |||
} |
@@ -16,7 +16,7 @@ use app\admin\model\OrderItem; | |||
use app\admin\model\Purchase; | |||
use think\Exception; | |||
class OrderHotelDao | |||
class OrderItemDao | |||
{ | |||
/** | |||
* 添加失败 | |||
@@ -82,7 +82,7 @@ class OrderHotelDao | |||
* @param int $subOrderId | |||
* @return array | |||
*/ | |||
public static function setSubOrderAmount( int $subOrderId) { | |||
public function setSubOrderAmount( int $subOrderId) { | |||
try{ | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select(); | |||
@@ -104,4 +104,22 @@ class OrderHotelDao | |||
} | |||
/** | |||
* 获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$model = new OrderItem(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
} | |||
} |
@@ -77,7 +77,7 @@ class OrderMainDao | |||
* @param int $orderId | |||
* @return array | |||
*/ | |||
public static function setOrderAmount(int $orderId){ | |||
public function setOrderAmount(int $orderId){ | |||
try { | |||
$itemModel = new OrderItem(); | |||
$hotelModel = new OrderHotel(); | |||
@@ -8,6 +8,7 @@ use app\admin\model\OrderMain; | |||
use app\admin\model\Purchase; | |||
use app\admin\model\PurchasePrice; | |||
use think\Exception; | |||
use think\Url; | |||
/** | |||
* Created by PhpStorm. | |||
@@ -21,32 +22,77 @@ class OrderMainService | |||
public function createOrder($param) { | |||
/** | |||
* todo 1.添加主订单 | |||
* 1.添加主订单 | |||
*/ | |||
/** | |||
* todo 2.添加子订单 | |||
*/ | |||
$orderMainDao = new OrderMainDao(); | |||
$addOrderMain = $orderMainDao->addMain($param); | |||
if (!$addOrderMain["flag"]) { | |||
return $addOrderMain; | |||
} | |||
$orderId = $addOrderMain['data']; | |||
foreach ($param['subOrderList'] as $subOrderParam) { | |||
/** | |||
* todo 2.1添加子订单下的采购单 | |||
* 2.添加子订单 | |||
*/ | |||
if ($subOrderParam['prodType'] == 'hotel') { | |||
$subOrderDao = new OrderHotelDao(); | |||
}else { | |||
$subOrderDao = new OrderItemDao(); | |||
} | |||
$addSubOrder = $subOrderDao->addInfo($subOrderParam,$orderId); | |||
if (!$addSubOrder['flag']) { | |||
return $addSubOrder; | |||
} | |||
$subOrderId =$addSubOrder['data']; | |||
$subOrderInfo = $subOrderDao->getInfoById($subOrderId); | |||
/** | |||
* todo 2.1.1添加采购单的每日价格 | |||
*/ | |||
/** | |||
* 2.1添加子订单下的采购单 | |||
*/ | |||
$purchaseDao = new PurchaseDao(); | |||
if ($subOrderParam['prod_type'] == 'hotel') { | |||
$addPurchase = $purchaseDao->addHotelPurchase($subOrderParam,$subOrderInfo); | |||
} else { | |||
$addPurchase = $purchaseDao->addItemPurchase($subOrderParam,$subOrderInfo); | |||
} | |||
if (!$addPurchase['flag']) { | |||
return $addPurchase; | |||
} | |||
$purchaseId = $addPurchase['id']; | |||
/** | |||
* todo 2.1.2 计算更新 采购单总金额、成本、产品数量 | |||
*/ | |||
/** | |||
* 2.1.1添加采购单的每日价格 | |||
*/ | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$addPurchasePrice = $purchasePriceDao->addList($subOrderParam['purchasePriceList'],$orderId,$subOrderParam['prod_type'],$subOrderId,$purchaseId); | |||
if (!$addPurchasePrice['flag']) { | |||
return $addPurchasePrice; | |||
} | |||
/** | |||
* todo 2.2 计算更新 子订单成本、金额、产品数量 | |||
* 2.1.2 计算更新 采购单总金额、成本、产品数量 | |||
*/ | |||
$setPurchaseRe = $purchaseDao->setPurchaseAmount($purchaseId); | |||
if (!$setPurchaseRe['flag']) { | |||
return $setPurchaseRe; | |||
} | |||
/** | |||
* 2.2 计算更新 子订单成本、金额、产品数量 | |||
*/ | |||
$setSubOrderRe = $subOrderDao->setSubOrderAmount($subOrderId); | |||
if (!$setSubOrderRe['flag']) { | |||
return $setSubOrderRe; | |||
} | |||
} | |||
/** | |||
* todo 3 计算更新 主订单成本、金额、产品数量 | |||
* 3 计算更新 主订单成本、金额、产品数量 | |||
*/ | |||
$setOrderMainRe = $orderMainDao->setOrderAmount($orderId); | |||
if (!$setOrderMainRe['flag']) { | |||
return $setOrderMainRe; | |||
} | |||
return Util::returnArrSu($orderId); | |||
} | |||
} |
@@ -52,7 +52,7 @@ class PurchaseDao | |||
* @param $itemOrder | |||
* @return array | |||
*/ | |||
public function addItemInfo($param, $itemOrder):array { | |||
public function addItemPurchase($param, $itemOrder):array { | |||
try { | |||
$data = [ | |||
"order_id" => $itemOrder['order_id'], | |||
@@ -82,7 +82,7 @@ class PurchaseDao | |||
* @param $purchaseId | |||
* @return array | |||
*/ | |||
public function setPurchase(int $purchaseId){ | |||
public function setPurchaseAmount(int $purchaseId){ | |||
try{ | |||
$purchasePrice = new PurchasePrice(); | |||
$purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchaseId,"del_flag"=>0])->select()->toArray(); | |||