nizongfeng пре 3 година
родитељ
комит
34ae95150b
3 измењених фајлова са 137 додато и 0 уклоњено
  1. +12
    -0
      application/admin/controller/ReceiptOrder.php
  2. +91
    -0
      application/admin/service/ReceiptOrderDao.php
  3. +34
    -0
      application/admin/service/ReceiptOrderService.php

+ 12
- 0
application/admin/controller/ReceiptOrder.php Прегледај датотеку

@@ -2,6 +2,7 @@

namespace app\admin\controller;

use app\admin\service\ReceiptOrderDao;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
@@ -184,4 +185,15 @@ class ReceiptOrder extends Backend
$this->view->assign("row", $row);
return $this->view->fetch();
}

/**
* 保存记录
* @return \think\response\Json
*/
public function save(){
$params=$this->request->post();
$service = new ReceiptOrderDao();
$result = $service->save($params);
return json($result);
}
}

+ 91
- 0
application/admin/service/ReceiptOrderDao.php Прегледај датотеку

@@ -0,0 +1,91 @@
<?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\ReceiptOrder;
use think\Exception;

class ReceiptOrderDao
{
/**
* 添加记录
* @param $param
* @return array
*/
public function save($param)
{
try {
$data = [
'name' => $param['name']
];
$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['name'] = $param['name'];
}
if ($param['status'] != 'all') {
$where["status"] = $param['status'];
}
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
$receiptOrder = new ReceiptOrder();
$list = $receiptOrder
->alias("a")
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left')
->field("a.*,count(1),sum(b.total_amount)")
->group("a.id")
->where($where);
$total = $list->count();
$list = $list->limit($offset, $param['pageSize'])->select();
$data = ["total" => $total, "list" => $list];
return Util::returnArrSu("", $data);
} catch (Exception $e) {
return Util::returnArrSu("", ["total" => 0, "list" => []]);
}
}
}

+ 34
- 0
application/admin/service/ReceiptOrderService.php Прегледај датотеку

@@ -0,0 +1,34 @@
<?php
/**
* Created by PhpStorm.
* User: nizongfeng
* Date: 2021/11/10
* Time: 11:06
*/

namespace app\admin\service;


class ReceiptOrderService
{

/**
* 保存详情
* @param $param
* @return array
*/
public function saveInfo($param){
$dao = new ReceiptOrderDao();
return $dao->save($param);
}

/**
* 获取列表
* @param $param
* @return array
*/
public function getList($param){
$dao = new ReceiptOrderDao();
return $dao->getList($param);
}
}

Loading…
Откажи
Сачувај