@@ -2,6 +2,8 @@ | |||
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; | |||
@@ -14,7 +16,7 @@ use think\exception\ValidateException; | |||
*/ | |||
class ReceiptOrder extends Backend | |||
{ | |||
protected $noNeedLogin = ['getOrderMainList',"getList"]; | |||
/** | |||
* ReceiptOrder模型对象 | |||
* @var \app\admin\model\ReceiptOrder | |||
@@ -184,4 +186,74 @@ class ReceiptOrder extends Backend | |||
$this->view->assign("row", $row); | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 保存记录 | |||
* @return \think\response\Json | |||
*/ | |||
public function save(){ | |||
$params=$this->request->post(); | |||
$params['create_id']=$this->auth->id; | |||
$params['group_id']=$this->auth->getGroupId(); | |||
$service = new ReceiptOrderService(); | |||
$result = $service->save($params); | |||
return json($result); | |||
} | |||
/** | |||
* 获取列表 | |||
* @return \think\response\Json | |||
*/ | |||
public function getList(){ | |||
$params=$this->request->post(); | |||
$service = new ReceiptOrderService(); | |||
$result = $service->getList($params); | |||
return json($result); | |||
} | |||
/** | |||
* 状态设置 | |||
* @return \think\response\Json | |||
*/ | |||
public function setStatus(){ | |||
$params=$this->request->post(); | |||
$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); | |||
} | |||
/** | |||
* 获取订单列表 | |||
* @return \think\response\Json | |||
*/ | |||
public function getOrderMainList(){ | |||
$params=$this->request->post(); | |||
$service = new ReceiptOrderService(); | |||
$result = $service->getOrderMainList($params); | |||
return json($result); | |||
} | |||
} |
@@ -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()); | |||
} | |||
@@ -11,7 +11,6 @@ namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\CfItem; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\OrderItem; | |||
use app\admin\model\Purchase; | |||
use think\Exception; | |||
@@ -55,12 +54,12 @@ class OrderItemDao | |||
"trade_order_number" => $param['trade_order_number'], | |||
"del_flag"=>0 | |||
]; | |||
$orderHotelModel = new OrderHotel(); | |||
$model = new OrderItem(); | |||
if (empty($param['id'])) { | |||
$id = $orderHotelModel->insertGetId($data); | |||
$id = $model->insertGetId($data); | |||
return Util::returnArrSu("",$id); | |||
}else { | |||
$orderHotelModel->save($data,["id"=>$param['id']]); | |||
$model->save($data,["id"=>$param['id']]); | |||
return Util::returnArrSu("",$param['id']); | |||
} | |||
}catch (Exception $e){ | |||
@@ -141,4 +141,79 @@ 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()); | |||
} | |||
} | |||
/** | |||
* 获取订单列表 | |||
* @param $where | |||
* @param $param | |||
* @return array | |||
*/ | |||
public function getOrderListByWhere($where,$param){ | |||
try { | |||
$offset = ($param['pageNum'] - 1) * $param['pageSize']; | |||
$model = new OrderMain(); | |||
$count = $model->where($where)->count(); | |||
$list = $model->where($where)->limit($offset,$param['pageSize'])->order("id","DESC")->select(); | |||
return Util::returnArrSu("", ["total" => $count, "list" => $list->toArray()]); | |||
}catch (Exception $e){ | |||
return Util::returnArrSu("", ["total" => 0, "list" => []]); | |||
} | |||
} | |||
} |
@@ -91,11 +91,9 @@ class PurchaseDao | |||
"prod_type" => 'hotel', | |||
"order_detail_id" => $itemOrder['id'], | |||
"group_id" => $param['group_id'], | |||
"pro_name" => $itemOrder['hotel_name'], | |||
"item_name" => $itemOrder['item_name'], | |||
"item_unit" => $itemOrder['item_unit'], | |||
"check_in_date" => $param['check_in_date'], | |||
"check_out_date" => $param['check_out_date'], | |||
"supplier_id" => $param['supplier_id'], | |||
"supplier_name" => $suplierRe['data']['supplier_name'], | |||
"purchase_user_id" => $param['purchase_user_id'], | |||
@@ -111,7 +109,7 @@ class PurchaseDao | |||
return Util::returnArrSu("", $param['purchase_id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("新增采购都失败:".$e->getMessage()); | |||
return Util::returnArrEr("新增采购单失败:".$e->getMessage()); | |||
} | |||
} | |||
@@ -0,0 +1,121 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/11/10 | |||
* Time: 10:20 | |||
*/ | |||
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 | |||
* @return array | |||
*/ | |||
public function save($param) | |||
{ | |||
try { | |||
$data = [ | |||
'name' => $param['name'], | |||
"create_id"=>$param['create_id'], | |||
"group_id"=>$param['group_id'] | |||
]; | |||
$receiptOrder = new ReceiptOrder(); | |||
if (empty($param['id'])) { | |||
$id = $receiptOrder->insertGetId($data); | |||
return Util::returnArrSu("", $id); | |||
} else { | |||
$receiptOrder->save($data, ['id' => $param['id']]); | |||
return Util::returnArrSu("", $param['id']); | |||
} | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("更新主订单失败:" . $e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 修改状态 | |||
* @param $id | |||
* @param $status | |||
* @return array | |||
*/ | |||
public function setStatus($id, $status) | |||
{ | |||
try { | |||
//设置收购单状态 | |||
$receiptOrder = new ReceiptOrder(); | |||
$receiptOrder->save(['status' => $status], ['id' => $id]); | |||
return Util::returnArrSu(); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("修改状态失败" . $e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 获取列表 | |||
* @param $param | |||
* @return array | |||
*/ | |||
public function getList($param) | |||
{ | |||
try { | |||
$where = []; | |||
if (!empty($param['name'])) { | |||
$where['a.name'] = ["like","%".$param['name']."%"]; | |||
} | |||
if ($param['status'] != 'all') { | |||
$where["a.status"] = $param['status']; | |||
} | |||
$offset = ($param['pageNum'] - 1) * $param['pageSize']; | |||
$receiptOrder = new ReceiptOrder(); | |||
$total = $receiptOrder | |||
->alias("a") | |||
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') | |||
->field("a.*,GROUP_CONCAT(b.id) order_ids,sum(b.total_amount) total_amount") | |||
->group("a.id") | |||
->where($where)->count(); | |||
$list = $receiptOrder | |||
->alias("a") | |||
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left') | |||
->field("a.*,GROUP_CONCAT(b.id) order_ids,sum(b.total_amount) total_amount") | |||
->group("a.id") | |||
->where($where) | |||
->limit($offset, $param['pageSize']) | |||
->order("id","DESC")->select(); | |||
$data = ["total" => $total, "list" => $list->toArray()]; | |||
return Util::returnArrSu("", $data); | |||
} catch (Exception $e) { | |||
return Util::returnArrSu("", ["total" => 0, "list" => []]); | |||
} | |||
} | |||
} |
@@ -0,0 +1,123 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/11/10 | |||
* Time: 11:06 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use think\Db; | |||
use think\Exception; | |||
class ReceiptOrderService | |||
{ | |||
/** | |||
* 保存详情 | |||
* @param $param | |||
* @return array | |||
*/ | |||
public function save($param){ | |||
$dao = new ReceiptOrderDao(); | |||
return $dao->save($param); | |||
} | |||
/** | |||
* 获取列表 | |||
* @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; | |||
} | |||
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",""]]; | |||
if (!empty($param['order_id'])) { | |||
$where["order"]=$param['order_id']; | |||
} | |||
switch ($param['inReceipt']) { | |||
case 0: | |||
break; | |||
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); | |||
} | |||
} |
@@ -1,4 +1 @@ | |||
<script> | |||
window.id = '' | |||
</script> | |||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.52c3c3e0899019dbfb974aeea1af846f.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.accdcfe0d08d2846f7d5.js></script><script type=text/javascript src=/static/js/app.6299b4f800bc6a957d3d.js></script></body></html> | |||
<script>window.id = ''</script><!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.5256ce95b1a4552204b93fb3f52032dc.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.accdcfe0d08d2846f7d5.js></script><script type=text/javascript src=/static/js/app.926d659ee6721ed3378c.js></script></body></html> |
@@ -1,7 +1 @@ | |||
<input id="c-id" type="hidden" value="{$row.id}"> | |||
<script> | |||
window.id = document.getElementById('c-id').value | |||
console.log(id) | |||
</script> | |||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.52c3c3e0899019dbfb974aeea1af846f.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.accdcfe0d08d2846f7d5.js></script><script type=text/javascript src=/static/js/app.6299b4f800bc6a957d3d.js></script></body></html> | |||
<input id="c-id" type="hidden" value="{$row.id}"><script>window.id = document.getElementById('c-id').value</script><!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.5256ce95b1a4552204b93fb3f52032dc.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.accdcfe0d08d2846f7d5.js></script><script type=text/javascript src=/static/js/app.926d659ee6721ed3378c.js></script></body></html> |
@@ -8,8 +8,8 @@ | |||
<div id="toolbar" class="toolbar"> | |||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | |||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order_main/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> | |||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order_main/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> | |||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order_main/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> | |||
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order_main/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>--> | |||
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order_main/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>--> | |||
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order_main/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> | |||
<div class="dropdown btn-group {:$auth->check('order_main/multi')?'':'hide'}"> | |||