save($param); if (!$addRe['flag']) { return $addRe; } return Util::returnArrSu(); } /** * 获取列表 * @param $param * @return array */ public function getList($param){ $dao = new PaymentOrderDao(); return $dao->getList($param); } /** * 设置状态 * @param $id * @param $status * @return array */ public function setStatus($id,$status) { Db::startTrans(); //1.设置收购单状态 $dao = new PaymentOrderDao(); $statusRe = $dao->setStatus($id,$status); if (!$statusRe['flag']) { Db::rollback(); return$statusRe; } //2.设置所有订单表的状态 $hotelDao = new OrderHotelDao(); $hotelRe = $hotelDao->setPaymentOrderStatus($id,$status); if (!$hotelRe['flag']) { Db::rollback(); return $hotelRe; } $itemDao = new OrderItemDao(); $itemRe = $itemDao->setPaymentOrderStatus($id,$status); if (!$itemRe['flag']) { Db::rollback(); return $itemRe; } //3.获取所有子订单对应的主订单ID $hotelIds = $hotelDao->getOrderMainIdByPayment($id); $itemIds = $itemDao->getOrderMainIdByPayment($id); $orderMainIds = array_unique(array_merge($hotelIds,$itemIds)); $orderMainDao = new OrderMainDao(); foreach ($orderMainIds as $orderId) { $setRe = $orderMainDao->setOrderAmount($orderId); if (!$setRe['flag']) { Db::rollback(); return $setRe; } } Db::commit(); return Util::returnArrSu(); } /** * 添加子订单到付款单 * @param $param * @return array */ public function addSubOrder($param){ $model = new PaymentOrderDao(); $infoRe = $model->getInfoById($param['id']); if (!$infoRe['flag']) { return $infoRe; } if (isset($param['hotel_id']) && count($param['hotel_id'])>0) { $orderMainDao = new OrderHotelDao(); $addRe = $orderMainDao->addSubOrderInPayment($infoRe['data'],$param['hotel_id']); if (!$addRe['flag']) { return $addRe; } } if (isset($param['item_id']) && count($param['item_id'])>0) { $orderMainDao = new OrderItemDao(); $addRe = $orderMainDao->addSubOrderInPayment($infoRe['data'],$param['item_id']); if (!$addRe['flag']) { return $addRe; } } return Util::returnArrSu(); } /** * 移除子订单 * @param $param * @return array */ public function removeSubOrder($param){ if (isset($param['hotel_id']) && count($param['hotel_id'])>0) { $orderMainDao = new OrderHotelDao(); $addRe = $orderMainDao->removeSubOrderFormPayment($param['hotel_id']); if (!$addRe['flag']) { return $addRe; } } if (isset($param['item_id']) && count($param['item_id'])>0) { $orderMainDao = new OrderItemDao(); $addRe = $orderMainDao->removeSubOrderFormPayment($param['item_id']); if (!$addRe['flag']) { return $addRe; } } return Util::returnArrSu(""); } /** * 获取子订单列表 * @param $param * @return array */ public function getSubOrderList($param){ $dao = new PaymentOrderDao(); $item_where_arr = ["d.del_flag=0","a.del_flag=0"]; $hotel_where_arr = ["c.del_flag=0","b.del_flag=0"]; $where_arr = []; if ($param['prod_type']=='hotel'){ $item_where_arr[] = " a.id = 0 "; }else{ $hotel_where_arr[]=" b.id = 0 "; } if (!empty($param['sub_order_id'])) { $item_where_arr[] = " a.id = {$param["sub_order_id"]} "; $hotel_where_arr[]=" b.id = {$param['sub_order_id']} "; } if (!empty($param['order_id'])) { $item_where_arr[] = " a.order_id = {$param["order_id"]} "; $hotel_where_arr[]=" b.order_id = {$param['order_id']} "; } if (!empty($param['supplier_id'])) { $item_where_arr[] = " d.supplier_id = {$param["supplier_id"]} "; $hotel_where_arr[]=" c.supplier_id = {$param['supplier_id']} "; } if (!empty($param['confirm_status'])) { $item_where_arr[] = " a.confirm_status = {$param["confirm_status"]} "; $hotel_where_arr[]=" b.confirm_status = {$param['confirm_status']} "; } if (!empty($param['customer_name'])) { $item_where_arr[] = " a.customer_name like '%{$param["customer_name"]}%' "; $hotel_where_arr[]=" b.customer_name like '%{$param['customer_name']}%' "; } if (!empty($param['item_id'])) { $item_where_arr[] = " a.item_id = {$param["item_id"]} "; } if (!empty($param['hotel_id'])) { $item_where_arr[] = " a.hotel_id = {$param["hotel_id"]} "; } switch ($param['inPayment']) { case 1: $item_where_arr[] = " a.payment_order_id = {$param["payment_order_id"]} "; $hotel_where_arr[]=" b.payment_order_id = {$param['payment_order_id']} "; break; case 2: $item_where_arr[] = " a.payment_order_id != {$param["payment_order_id"]} "; $hotel_where_arr[]=" b.payment_order_id != {$param['payment_order_id']} "; break; case 3: $item_where_arr[] = " a.payment_order_id = '' "; $hotel_where_arr[]=" b.payment_order_id = '' "; } //金额区间查询 if (!empty($param['startMoney'])) { $item_where_arr[] = " a.total_cost >= {$param["startMoney"]} "; $hotel_where_arr[]=" b.total_cost >= {$param['startMoney']} "; } if (!empty($param['endMoney'])) { $item_where_arr[] = " a.total_cost <= {$param["endMoney"]} "; $hotel_where_arr[]=" b.total_cost <= {$param['endMoney']} "; } //时间区间查询 if (!empty($param['startTime']) ) { $item_where_arr[] = " a.create_time >= {$param["startTime"]} 00:00:00 "; $hotel_where_arr[]=" b.create_time >= {$param['startTime']} 00:00:00 "; } if (!empty($param['endTime'])) { $item_where_arr[] = " a.create_time <= {$param["endTime"]} 23:59:59 "; $hotel_where_arr[]=" b.create_time <= {$param['endTime']} 23:59:59 "; } return $dao->getSubOrderListByWhere(join(" and ",$hotel_where_arr),join(" and ",$item_where_arr),join(" and ",$where_arr),$param); } /** * 删除付款单 * @param $id * @return array */ public function delAll($id){ Db::startTrans(); //1.删除付款单下的附加项目订单 $itemDao = new OrderItemDao(); $itemRe = $itemDao->delPaymentOrder($id); if (!$itemRe['flag']) { Db::rollback(); return $itemRe; } //1.删除付款单下的酒店订单 $hotelDao = new OrderHotelDao(); $hotelRe = $hotelDao->delPaymentOrder($id); if (!$hotelRe['flag']) { Db::rollback(); return $hotelRe; } //2.删除付款单 $model = new PaymentOrderDao(); $delRe = $model->del($id); if (!$delRe['flag']) { Db::rollback(); return $delRe; } Db::commit(); return Util::returnArrSu(); } }