|
|
@@ -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" => []]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |