Browse Source

状态变更

dev
nizongfeng 3 years ago
parent
commit
d7b94f90b6
3 changed files with 41 additions and 7 deletions
  1. +28
    -3
      application/admin/service/OrderMainDao.php
  2. +5
    -1
      application/admin/service/PaymentOrderService.php
  3. +8
    -3
      application/admin/service/ReceiptOrderService.php

+ 28
- 3
application/admin/service/OrderMainDao.php View File

@@ -101,8 +101,11 @@ class OrderMainDao
$statusList['isPayment']++;
}
}
$orderInfo = $this->getInfoById($orderId);
$orderStatus = $this->getStatus($cnt,$statusList,$orderInfo);
$orderInfoRe = $this->getInfoById($orderId);
if (!$orderInfoRe['flag']) {
return $orderInfoRe;
}
$orderStatus = $this->getStatus($cnt,$statusList,$orderInfoRe['data']);
//更新金额
$orderMain = new OrderMain();
$orderMain->save(["total_amount" => $amount, "cost_amount" => $cost,"profit_amount"=>$amount-$cost,"order_status"=>$orderStatus],["id" => $orderId]);
@@ -122,7 +125,6 @@ class OrderMainDao
public function getStatus($cnt,$statusList,$orderInfo){
//资源单状态 1、未发单/ 2已发单、3已确认、4已取消
//订单状态0待处理 1已确认 2部分取消 3处理中 10已完成 11已取消

//已完成:订单已完成付款、已完成收款(无视子订单状态)
if ($orderInfo['receipt_order_status'] ==2 && $statusList['isPayment'] == $cnt) {
return 10;
@@ -293,4 +295,27 @@ class OrderMainDao
return Util::returnArrEr("将主订单从收款单下移除失败".$e->getMessage());
}
}

/**
* 获取收款单下所有主订单的订单ID
* @param $receipt_order_id
* @return array
*/
public function getOrderMainIdsByReceipt($receipt_order_id){
$orderModel = new OrderMain();
try {
$subOrderList = $orderModel->where(["receipt_order_id" => $receipt_order_id, "del_flag" => 0])->select()->toArray();
if (null == $subOrderList) {
return [];
}

$id = [];
foreach ($subOrderList as $val){
$id[] = $val['id'];
}
return array_unique($id);
}catch (Exception $e) {
return [];
}
}
}

+ 5
- 1
application/admin/service/PaymentOrderService.php View File

@@ -74,7 +74,11 @@ class PaymentOrderService
$orderMainIds = array_unique(array_merge($hotelIds,$itemIds));
$orderMainDao = new OrderMainDao();
foreach ($orderMainIds as $orderId) {
$orderMainDao->setOrderAmount($orderId);
$setRe = $orderMainDao->setOrderAmount($orderId);
if (!$setRe['flag']) {
Db::rollback();
return $setRe;
}
}
Db::commit();
return Util::returnArrSu();


+ 8
- 3
application/admin/service/ReceiptOrderService.php View File

@@ -64,10 +64,15 @@ class ReceiptOrderService
Db::rollback();
return $orderRe;
}

//3.设置订单状态
$setRe = $orderDao->setOrderAmount($id);
if (!$setRe['flag']) {
return $setRe;
$orderIds = $orderDao->getOrderMainIdsByReceipt($id);
foreach ($orderIds as $orderId) {
$setRe = $orderDao->setOrderAmount($orderId);
if (!$setRe['flag']) {
Db::rollback();
return $setRe;
}
}
Db::commit();
return Util::returnArrSu();


Loading…
Cancel
Save