Browse Source

接口收款单

dev
nizongfeng 3 years ago
parent
commit
8a2271e82a
5 changed files with 178 additions and 7 deletions
  1. +30
    -3
      application/admin/controller/ReceiptOrder.php
  2. +2
    -2
      application/admin/service/AdminDao.php
  3. +58
    -0
      application/admin/service/OrderMainDao.php
  4. +24
    -1
      application/admin/service/ReceiptOrderDao.php
  5. +64
    -1
      application/admin/service/ReceiptOrderService.php

+ 30
- 3
application/admin/controller/ReceiptOrder.php View File

@@ -3,6 +3,7 @@
namespace app\admin\controller;

use app\admin\service\ReceiptOrderDao;
use app\admin\service\ReceiptOrderService;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
@@ -192,7 +193,9 @@ class ReceiptOrder extends Backend
*/
public function save(){
$params=$this->request->post();
$service = new ReceiptOrderDao();
$params['create_id']=$this->auth->id;
$params['group_id']=$this->auth->getGroupId();
$service = new ReceiptOrderService();
$result = $service->save($params);
return json($result);
}
@@ -203,7 +206,7 @@ class ReceiptOrder extends Backend
*/
public function getList(){
$params=$this->request->post();
$service = new ReceiptOrderDao();
$service = new ReceiptOrderService();
$result = $service->getList($params);
return json($result);
}
@@ -214,9 +217,33 @@ class ReceiptOrder extends Backend
*/
public function setStatus(){
$params=$this->request->post();
$service = new ReceiptOrderDao();
$service = new ReceiptOrderService();
$result = $service->setStatus($params['id'],$params['status']);
return json($result);
}

/**
* 添加到收款单
* @return \think\response\Json
*/
public function addOrderMain(){
$params=$this->request->post();
$service = new ReceiptOrderService();
$result = $service->addOrderMain($params['id'],$params['order_id']);
return json($result);
}

/**
* 移除收购单
* @return \think\response\Json
*/
public function removeOrderMain(){
$params=$this->request->post();
$service = new ReceiptOrderService();
$result = $service->removeOrderMain($params['order_id']);
return json($result);
}



}

+ 2
- 2
application/admin/service/AdminDao.php View File

@@ -23,11 +23,11 @@ class AdminDao
public function getInfoById(int $id) {
try{
$model = new Admin();
$info = $model->where(["id"=>$id])->find()->toArray();
$info = $model->where(["id"=>$id])->find();
if ($info == null) {
return Util::returnArrEr("获取管理员信息失败:".$id);
}
return Util::returnArrSu("",$info);
return Util::returnArrSu("",$info->toArray());
}catch (Exception $e){
return Util::returnArrEr("获取管理员信息失败:".$e->getMessage());
}


+ 58
- 0
application/admin/service/OrderMainDao.php View File

@@ -141,4 +141,62 @@ class OrderMainDao
}
return Util::returnArrSu("",$result);
}

/**
* 更新采购单下的订单信息
* @param $receiptOrderId
* @param $status
* @return array
*/
public function setReceiptOrderStatus($receiptOrderId, $status){
try{
$model = new OrderMain();
$model->save(['receipt_order_status'=>$status],['receipt_order_id'=>$receiptOrderId]);
return Util::returnArrSu();
}catch (Exception $e){
return Util::returnArrEr("更新收款单子啊的主订单状态失败".$e->getMessage());
}
}

/**
* 添加主订单到采购单下
* @param $receiptOrder
* @param $orderIds
* @return array
*/
public function addOrderMainInReceipt($receiptOrder,$orderIds){
try{
$data = [
"receipt_order_id"=>$receiptOrder['id'],
"receipt_order_status"=>$receiptOrder['status'],
"receipt_order_name"=>$receiptOrder['name']
];
$model = new OrderMain();
$model->save($data,["id"=>$orderIds]);
return Util::returnArrSu();
}catch (Exception $e){
return Util::returnArrEr("添加主订单到采购单下失败".$e->getMessage());
}
}

/**
* 将主订单从采购单下移除
* @param $orderIds
* @return array
*/
public function removeOrderMainFormReceipt($orderIds){
try{
$data = [
"receipt_order_id"=>0,
"receipt_order_status"=>0,
"receipt_order_name"=>""
];
$model = new OrderMain();
$model->save($data,["id"=>$orderIds]);
return Util::returnArrSu();
}catch (Exception $e){
return Util::returnArrEr("将主订单从采购单下移除失败".$e->getMessage());
}
}

}

+ 24
- 1
application/admin/service/ReceiptOrderDao.php View File

@@ -10,11 +10,31 @@ namespace app\admin\service;


use app\admin\command\Util;
use app\admin\model\OrderMain;
use app\admin\model\ReceiptOrder;
use think\Exception;

class ReceiptOrderDao
{

/**
* 获取详情
* @param $id
* @return array
*/
public function getInfoById($id){
try{
$model = new OrderMain();
$info = $model->where(["id"=>$id])->find();
if ($info == null) {
return Util::returnArrEr("获取管理员信息失败:".$id);
}
return Util::returnArrSu("",$info->toArray());
}catch (Exception $e){
return Util::returnArrEr("获取管理员信息失败:".$e->getMessage());
}
}

/**
* 添加记录
* @param $param
@@ -24,7 +44,9 @@ class ReceiptOrderDao
{
try {
$data = [
'name' => $param['name']
'name' => $param['name'],
"create_id"=>$param['create_id'],
"group_id"=>$param['group_id']
];
$receiptOrder = new ReceiptOrder();
if (empty($param['id'])) {
@@ -48,6 +70,7 @@ class ReceiptOrderDao
public function setStatus($id, $status)
{
try {
//设置收购单状态
$receiptOrder = new ReceiptOrder();
$receiptOrder->save(['status' => $status], ['id' => $id]);
return Util::returnArrSu();


+ 64
- 1
application/admin/service/ReceiptOrderService.php View File

@@ -9,6 +9,10 @@
namespace app\admin\service;


use app\admin\command\Util;
use think\Db;
use think\Exception;

class ReceiptOrderService
{

@@ -17,7 +21,7 @@ class ReceiptOrderService
* @param $param
* @return array
*/
public function saveInfo($param){
public function save($param){
$dao = new ReceiptOrderDao();
return $dao->save($param);
}
@@ -31,4 +35,63 @@ class ReceiptOrderService
$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;
}
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);
}
}

Loading…
Cancel
Save