商户列表展示
This commit is contained in:
parent
9d486fc375
commit
2b4068e277
@ -53,14 +53,14 @@ class Merchant extends BaseController{
|
||||
/**
|
||||
* 商户列表数据
|
||||
*/
|
||||
public function lst()
|
||||
public function list()
|
||||
{
|
||||
$page = empty($params['page'])?1:$params['page'];
|
||||
$limit = empty($params['limit'])?10:$params['limit'];
|
||||
|
||||
$where = get_params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id']);
|
||||
|
||||
$data = $this->model->lst($where, $page, $limit);
|
||||
$data = $this->model->getList($where, $page, $limit);
|
||||
|
||||
return to_assign(0, '', $data);
|
||||
}
|
||||
|
@ -1,7 +1,22 @@
|
||||
{extend name="common/base"/}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<style>
|
||||
.layui-table-cell {
|
||||
line-height: 20px !important;
|
||||
vertical-align: middle;
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
text-overflow: inherit;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
|
||||
{block name="body"}
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<span class="layui-btn layui-btn-normal side-alert" lay-event="add" data-title="添加商户">+ 添加商户</span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<div class="p-3">
|
||||
|
||||
@ -158,6 +173,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="switchBest">
|
||||
<input type="checkbox" name="is_best" value="{{d.is_best}}" lay-skin="switch" lay-text="是|否" lay-filter="isBest" {{ d.is_best == 1 ? 'checked' : '' }}>
|
||||
</script>
|
||||
<script type="text/html" id="switchStatus">
|
||||
<input type="checkbox" name="status" value="{{d.status}}" lay-skin="switch" lay-text="正常|关闭" lay-filter="status" {{ d.is_best == 1 ? 'checked' : '' }}>
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
<!-- test end -->
|
||||
@ -203,6 +225,10 @@
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="reduct">修改管理员密码</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="record">设置第三方平台商品复制次数</a>
|
||||
</div>
|
||||
<div class="layui-btn-group">
|
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="mark">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="record">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 退回操作 -->
|
||||
@ -228,10 +254,18 @@
|
||||
elem: '#pay_list',
|
||||
title: '正常开启的商户',
|
||||
toolbar: '#toolbarDemo',
|
||||
url: '/admin/margin/lst',
|
||||
url: '/admin/system/merchant/lst',
|
||||
page: true,
|
||||
limit: 20,
|
||||
cellMinWidth: 300,
|
||||
parseData:(res)=>{
|
||||
return {
|
||||
"code": res.code, //解析接口状态
|
||||
"msg": res.msg, //解析提示文本
|
||||
"count": res.data.count, //解析数据长度
|
||||
"data": res.data.list //解析数据列表
|
||||
};
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{
|
||||
@ -246,50 +280,44 @@
|
||||
title: '商户名称',
|
||||
align: 'center',
|
||||
width: 200,
|
||||
templet: '<div>{{d.merchant.mer_name}}</div>'
|
||||
}, {
|
||||
field: 'type_id',
|
||||
title: '店铺类型',
|
||||
align: 'center',
|
||||
width: 220,
|
||||
templet: '<div>{{d.merchant.merchantType.type_name}}</div>'
|
||||
}, {
|
||||
field: 'real_name',
|
||||
title: '商户姓名',
|
||||
align: 'center',
|
||||
width: 220,
|
||||
templet: '<div>{{d.merchant.real_name}}</div>'
|
||||
}, {
|
||||
field: 'margin',
|
||||
title: '保证金额度',
|
||||
field: 'mark',
|
||||
title: '备注',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
templet: '<div>{{d.merchant.margin}}</div>'
|
||||
width: 220,
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
field: 'is_best',
|
||||
title: '推荐',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
templet: function(d){
|
||||
switch (d.merchant.is_margin) {
|
||||
case 0:
|
||||
return '<div>无</div>'
|
||||
case 1:
|
||||
return '<div>有未支付</div>'
|
||||
case 10:
|
||||
return '<div>已支付</div>'
|
||||
case -1:
|
||||
return '<div>申请退款</div>'
|
||||
case -10:
|
||||
return '<div>拒绝退款</div>'
|
||||
|
||||
}
|
||||
}
|
||||
templet: '#switchBest', unresize: true
|
||||
}, {
|
||||
field: 'pay_time',
|
||||
title: '支付时间',
|
||||
field: 'create_time',
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
width: 150
|
||||
}, {
|
||||
field: 'margin',
|
||||
title: '保证金',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
}, {
|
||||
field: 'sort',
|
||||
title: '排序',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '开启/关闭',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
templet:'#switchStatus',
|
||||
unresize:true,
|
||||
},
|
||||
{
|
||||
fixed: 'right',
|
||||
@ -297,122 +325,18 @@
|
||||
title: '操作',
|
||||
toolbar: '#barDemo',
|
||||
width: 200,
|
||||
align: 'center'
|
||||
align: 'center',
|
||||
done: function(res, curr, count){
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
$($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
],
|
||||
});
|
||||
|
||||
function refundList(data){
|
||||
|
||||
layui.refundTable = table.render({
|
||||
elem: '#refund_list',
|
||||
title: '退回保证金列表',
|
||||
toolbar: '#refundToolbar',
|
||||
url: '/admin/margin/refund/lst',
|
||||
parseData:(res)=>{
|
||||
return {
|
||||
"code": res.code, //解析接口状态
|
||||
"msg": res.msg, //解析提示文本
|
||||
"count": res.data.count, //解析数据长度
|
||||
"data": res.data.list //解析数据列表
|
||||
};
|
||||
},
|
||||
where: {
|
||||
...data
|
||||
},
|
||||
page: true,
|
||||
limit: 20,
|
||||
cellMinWidth: 300,
|
||||
cols: [
|
||||
[
|
||||
{
|
||||
fixed: 'ID',
|
||||
field: 'mer_id',
|
||||
title: 'ID',
|
||||
align: 'center',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
field: 'mer_name',
|
||||
title: '商户名称1',
|
||||
align: 'center',
|
||||
width: 200,
|
||||
templet: '<div>{{d.merchant.mer_name}}</div>'
|
||||
}, {
|
||||
field: 'type_id',
|
||||
title: '店铺类型',
|
||||
align: 'center',
|
||||
width: 220,
|
||||
templet: '<div>{{d.merchant.merchantType.type_name}}</div>'
|
||||
}, {
|
||||
field: 'real_name',
|
||||
title: '商户姓名',
|
||||
align: 'center',
|
||||
width: 220,
|
||||
templet: '<div>{{d.merchant.real_name}}</div>'
|
||||
}, {
|
||||
field: 'margin',
|
||||
title: '保证金额度',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
templet: '<div>{{d.merchant.margin}}</div>'
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '保证金申请状态',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
templet:(d)=>{
|
||||
switch(d.status) {
|
||||
case 0:
|
||||
return '待审核';
|
||||
case 1:
|
||||
return '通过';
|
||||
case -1:
|
||||
return '未通过';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '申请时间',
|
||||
align: 'center',
|
||||
width: 150
|
||||
},{
|
||||
field: 'extract_money',
|
||||
title: '结余保证金',
|
||||
align: 'center',
|
||||
width: 150
|
||||
},{
|
||||
field: 'financial_status',
|
||||
title: '退回状态',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
templet:(d)=>{
|
||||
switch(d.status) {
|
||||
case 0:
|
||||
return '未退';
|
||||
// case 1:
|
||||
// return '通过';
|
||||
// case -1:
|
||||
// return '未通过';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fixed: 'right',
|
||||
field: 'right',
|
||||
title: '操作',
|
||||
toolbar: '#refundBar',
|
||||
width: 190,
|
||||
align: 'center'
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 获取表单所有参数
|
||||
function getformdata() {
|
||||
|
@ -71,6 +71,8 @@ class Merchant extends Model
|
||||
->order('is_good DESC,sort DESC');
|
||||
}
|
||||
|
||||
/** -------------------- depend end -------------- */
|
||||
|
||||
/**
|
||||
* TODO 增加商户余额
|
||||
* @param int $merId
|
||||
@ -89,6 +91,34 @@ class Merchant extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商户列表
|
||||
*
|
||||
* @param array $where
|
||||
* @param $page
|
||||
* @param $limit
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getList(array $where, $page, $limit)
|
||||
{
|
||||
$query = $this->search($where);
|
||||
$count = $query->count($this->getPk());
|
||||
$list = $query->page($page, $limit)->setOption('field', [])
|
||||
->with([
|
||||
'admin' => function ($query) {
|
||||
$query->field('mer_id,account');
|
||||
},
|
||||
'merchantCategory',
|
||||
'merchantType'
|
||||
])
|
||||
->field('sort, mer_id, mer_name, real_name, mer_phone, mer_address, mark, status, create_time,is_best,is_trader,type_id,category_id,copy_product_num,export_dump_num,is_margin,margin,mer_avatar')->select();
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO 商户列表下的推荐
|
||||
* @return \think\Collection
|
||||
@ -253,8 +283,7 @@ class Merchant extends Model
|
||||
|
||||
/** ----------------------- controller 调用入口------------ */
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function createMerchant(array $data)
|
||||
@ -424,4 +453,86 @@ class Merchant extends Model
|
||||
return $query->where('is_del', 0)->count() > 0;
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------ protected func --------- */
|
||||
|
||||
/** 组合sql拼接
|
||||
*
|
||||
* @param array $where
|
||||
* @return BaseQuery
|
||||
*/
|
||||
protected function search(array $where, $is_del = 0)
|
||||
{
|
||||
$query = Merchant::when($is_del !== null,
|
||||
function ($query) use ($is_del) {
|
||||
$query->where('is_del', $is_del);
|
||||
}
|
||||
)
|
||||
->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) {
|
||||
$query->where('is_trader', $where['is_trader']);
|
||||
})
|
||||
->when(isset($where['is_best']) && $where['is_best'] !== '', function ($query) use ($where) {
|
||||
$query->where('is_best', $where['is_best']);
|
||||
})
|
||||
->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
|
||||
getModelTime($query, $where['date']);
|
||||
})
|
||||
->when(isset($where['mer_state']) && $where['mer_state'] !== '', function ($query) use ($where) {
|
||||
$query->where('mer_state', $where['mer_state']);
|
||||
})
|
||||
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
|
||||
$query->where('mer_id', $where['mer_id']);
|
||||
})
|
||||
->when(isset($where['category_id']) && $where['category_id'] !== '', function ($query) use ($where) {
|
||||
$query->whereIn('category_id', is_array($where['category_id']) ? $where['category_id'] : explode(',', $where['category_id']));
|
||||
})
|
||||
->when(isset($where['type_id']) && $where['type_id'] !== '', function ($query) use ($where) {
|
||||
$query->whereIn('type_id', is_array($where['type_id']) ? $where['type_id'] : explode(',', $where['type_id']));
|
||||
})
|
||||
->when(isset($where['delivery_way']) && $where['delivery_way'] !== '', function ($query) use ($where) {
|
||||
$query->whereLike('delivery_way', "%{$where['delivery_way']}%");
|
||||
});
|
||||
|
||||
if (isset($where['keyword']) && $where['keyword']) {
|
||||
if (is_numeric($where['keyword'])) {
|
||||
$query->whereLike('mer_name|mer_keyword|mer_phone', "%{$where['keyword']}%");
|
||||
} else {
|
||||
// 这里使用了搜索引擎
|
||||
// $word = app()->make(VicWordService::class)->getWord($where['keyword']);
|
||||
// $query->where(function ($query) use ($word, $where) {
|
||||
// foreach ($word as $item) {
|
||||
// if(mb_strlen($item) > 1) {
|
||||
// $query->whereOr('mer_name', 'LIKE', "%$item%");
|
||||
// }
|
||||
// }
|
||||
$query->whereOr('mer_name|mer_keyword', 'LIKE', "%{$where['keyword']}%");
|
||||
// });
|
||||
}
|
||||
}
|
||||
if (isset($where['status']) && $where['status'] !== '')
|
||||
$query->where('status', $where['status']);
|
||||
$order = $where['order'] ?? '';
|
||||
$query->when($order, function ($query) use ($where, $order) {
|
||||
if ($order == 'rate') {
|
||||
$query->order('is_best DESC, product_score DESC,service_score DESC,postage_score DESC');
|
||||
} else if ($order == 'sales'){
|
||||
$query->order('sales DESC,is_best DESC,sort DESC');
|
||||
}else if ($order == 'location' && isset($where['location']['long'], $where['location']['lat'])) {
|
||||
$lng = (float)$where['location']['long'];
|
||||
$lat = (float)$where['location']['lat'];
|
||||
$query->whereNotNull('lat')->whereNotNull('long')
|
||||
->order(Db::raw("(2 * 6378.137 * ASIN(
|
||||
SQRT(
|
||||
POW( SIN( PI( ) * ( $lng- `long` ) / 360 ), 2 ) + COS( PI( ) * $lat / 180 ) * COS( `lat` * PI( ) / 180 ) * POW( SIN( PI( ) * ( $lat- `lat` ) / 360 ), 2 )
|
||||
)
|
||||
)
|
||||
) ASC "));
|
||||
} else {
|
||||
$query->order('is_best DESC, sales DESC,sort DESC');
|
||||
}
|
||||
}, function ($query) use ($order) {
|
||||
$query->order('is_best DESC, sort DESC,sales DESC');
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user