109 lines
2.9 KiB
PHP
109 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic;
|
|
use think\Db;
|
|
use app\common\server\ConfigServer;
|
|
|
|
class OrderchanelLogic{
|
|
public static function ordertypelist(){
|
|
$lists = Db::name('orderchannel')
|
|
->where('deletetime','NULL')
|
|
->order('sort','desc')
|
|
->select();
|
|
|
|
$pids = Db::name('orderchannel')
|
|
->column('pid');
|
|
foreach ($lists as &$item){
|
|
$item['createtime']=date("Y-m-d H:i:s",$item['createtime']);
|
|
$item['updatetime']=date("Y-m-d H:i:s",$item['updatetime']);
|
|
}
|
|
return linear_to_tree($lists);
|
|
}
|
|
|
|
|
|
/**
|
|
* order: 哆啦猫订单渠道
|
|
* Desc: 显示增加渠道的分类
|
|
*/
|
|
public static function Menu($id =1){
|
|
$lists = Db::name('orderchannel')
|
|
->where('deletetime','NULL')
|
|
->select();
|
|
if ($id) {
|
|
$remove_ids = self::getChildIds($lists, $id);
|
|
$remove_ids[] = $id;
|
|
foreach ($lists as $key => $row) {
|
|
if (in_array($row['id'], $remove_ids)) {
|
|
unset($lists[$key]);
|
|
}
|
|
}
|
|
$lists = array_values($lists);
|
|
}
|
|
return multilevel_linear_sort($lists, '|-');
|
|
|
|
}
|
|
|
|
private static function getChildIds($lists, $id)
|
|
{
|
|
$ids = [];
|
|
foreach ($lists as $key => $row) {
|
|
if ($row['pid'] == $id) {
|
|
$ids[] = $row['id'];
|
|
$child_ids = self::getChildIds($lists, $row['id']);
|
|
foreach ($child_ids as $child_id) {
|
|
$ids[] = $child_id;
|
|
}
|
|
}
|
|
}
|
|
return $ids;
|
|
}
|
|
|
|
/**
|
|
* order: 哆啦猫订单渠道
|
|
* Desc: 增加渠道的类别
|
|
*/
|
|
public static function ordertypeadd($post){
|
|
$now = time();
|
|
$data['createtime'] = $now;
|
|
$data['updatetime'] = $now;
|
|
$data['name']=$post['name'];
|
|
$data['sort']=$post['sort'];
|
|
$data['pid']=$post['pid'];
|
|
$datas = Db::name('orderchannel')->insertGetId($data);
|
|
return $datas;
|
|
}
|
|
/**
|
|
* order: 哆啦猫订单渠道
|
|
* Desc: 增加渠道的类别
|
|
*/
|
|
public static function ordertypeedit($post){
|
|
$now = time();
|
|
$data['createtime'] = $now;
|
|
$data['updatetime'] = $now;
|
|
$data['name']=$post['name'];
|
|
$data['sort']=$post['sort'];
|
|
$data['pid']=$post['pid'];
|
|
return Db::name('orderchannel')
|
|
->where('id',$post['id'])
|
|
->update($data);
|
|
}
|
|
/**
|
|
* order: 哆啦猫订单渠道
|
|
* Desc: 查询分类列表
|
|
*/
|
|
public static function info($id)
|
|
{
|
|
return Db::name('orderchannel')->where('id',$id)->find();
|
|
}
|
|
/**
|
|
* order: 哆啦猫订单渠道
|
|
* Desc: 订单的渠道列表查询
|
|
*/
|
|
public static function infolist(){
|
|
return Db::name('orderchannel')->where('deletetime','NULL')
|
|
->order('sort','desc')
|
|
->select();
|
|
}
|
|
|
|
|
|
} |