save($param); if (!$addRe['flag']) { return $addRe; } return Util::returnArrSu(); } /** * 获取列表 * @param $param * @return array */ public function getList($param){ $dao = new ReceiptOrderDao(); return $dao->getList($param); } /** * 设置状态 * @param $id * @param $status * @return array */ public function setStatus($id,$status) { Db::startTrans(); //1.设置收购单状态 $dao = new ReceiptOrderDao(); $statusRe = $dao->setStatus($id,$status); if (!$statusRe['flag']) { Db::rollback(); return$statusRe; } //2.设置所有订单主表的状态 $orderDao = new OrderMainDao(); $orderRe = $orderDao->setReceiptOrderStatus($id,$status); if (!$orderRe['flag']) { Db::rollback(); return $orderRe; } //3.设置订单状态 $orderIds = $orderDao->getOrderMainIdsByReceipt($id); foreach ($orderIds as $orderId) { $setRe = $orderDao->setOrderAmount($orderId); if (!$setRe['flag']) { Db::rollback(); return $setRe; } } Db::commit(); return Util::returnArrSu(); } /** * 添加主订单到采购单 * @param $id * @param $order_id * @return array */ public function addOrderMain($id,$order_id){ $model = new ReceiptOrderDao(); $infoRe = $model->getInfoById($id); if (!$infoRe['flag']) { return $infoRe; } $orderIds = explode(",", $order_id); $orderMainDao = new OrderMainDao(); $addRe = $orderMainDao->addOrderMainInReceipt($infoRe['data'],$orderIds); if (!$addRe['flag']) { return $addRe; } return Util::returnArrSu(); } /** * 移除采购单 * @param $order_id * @return array */ public function removeOrderMain($order_id){ $orderIds = explode(",", $order_id); $orderMainDao = new OrderMainDao(); return $orderMainDao->removeOrderMainFormReceipt($orderIds); } /** * 获取主订单列表 * @param $param * @return array */ public function getOrderMainList($param){ $orderMainDao = new OrderMainDao(); $where = ["id"=>["neq",""],"group_id"=>$param['group_id']]; if (!empty($param['order_id'])) { $where["id"]=$param['order_id']; } if (!empty($param['channel_id'])) { $where['channel_id'] = $param['channel_id']; } if (!empty($param['channel_order_no'])) { $where['channel_order_no'] = $param['channel_order_no']; } if ($param['order_status'] !== '') { $where['order_status'] = $param['order_status']; } if (!empty($param['commissioner_id'])) { $where['commissioner_id'] = $param['commissioner_id']; } if (!empty($param['user_name'])) { $where['user_name'] = ["like","%".$param['user_name']."%"]; } if (!empty($param['user_phone'])) { $where['user_phone'] = $param['user_phone']; } if (!empty($param['create_id'])) { $where['create_id'] = $param['create_id']; } //金额区间查询 if (!empty($param['startMoney'])&& empty($param['endMoney'])) { $where['total_amount'] = [">=",$param['startMoney']]; } if (!empty($param['endMoney']) && empty($param['startMoney'])) { $where['total_amount'] = ["<=",$param['endMoney']]; } if (!empty($param['endMoney']) && !empty($param['startMoney'])) { $where['total_amount'] = ["between",[$param['startMoney'],$param['endMoney']]]; } //时间区间查询 if (!empty($param['startTime']) && empty($param['endTime'])) { $where['create_time'] = [">=",$param['startTime']." 00:00:00"]; } if (!empty($param['endTime'])&& empty($param['startTime'])) { $where['create_time'] = ["<=",$param['endTime']." 23:59:59"]; } if(!empty($param['endTime'])&& !empty($param['startTime'])){ $where['create_time'] = ["between",[$param['startTime']." 00:00:00",$param['endTime']." 23:59:59"]]; } switch ($param['inReceipt']) { case 1: $where["receipt_order_id"] = $param['receipt_order_id']; break; case 2: $where["receipt_order_id"] = ["neq",$param['receipt_order_id']]; break; case 3: $where["receipt_order_id"] = ""; } return $orderMainDao->getOrderListByWhere($where,$param); } /** * 删除采购单 * @param $id * @return array */ public function delAll($id){ Db::startTrans(); //1.删除采购单下的主订单 $orderMainDao = new OrderMainDao(); $delReceipt = $orderMainDao->delReceiptOrder($id); if (!$delReceipt['flag']) { Db::rollback(); return $delReceipt; } //2.删除采购单 $model = new ReceiptOrderDao(); $delRe = $model->del($id); if (!$delRe['flag']) { Db::rollback(); return $delRe; } Db::commit(); return Util::returnArrSu(); } }