diff --git a/app/admin/controller/merchant/system/merchant/Merchant.php b/app/admin/controller/merchant/system/merchant/Merchant.php
index f13db3f..af7c5cb 100644
--- a/app/admin/controller/merchant/system/merchant/Merchant.php
+++ b/app/admin/controller/merchant/system/merchant/Merchant.php
@@ -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);
}
diff --git a/app/admin/view/merchant/system/merchant/merchant/lst.html b/app/admin/view/merchant/system/merchant/merchant/lst.html
index 8ff9c9a..2bfeb7f 100644
--- a/app/admin/view/merchant/system/merchant/merchant/lst.html
+++ b/app/admin/view/merchant/system/merchant/merchant/lst.html
@@ -1,7 +1,22 @@
{extend name="common/base"/}
-{block name="body"}
+
+{block name="body"}
+
@@ -158,6 +173,13 @@
+
+
+
@@ -203,6 +225,10 @@
修改管理员密码
设置第三方平台商品复制次数
+
@@ -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: '{{d.merchant.mer_name}}
'
- }, {
- field: 'type_id',
- title: '店铺类型',
- align: 'center',
- width: 220,
- templet: '{{d.merchant.merchantType.type_name}}
'
}, {
field: 'real_name',
title: '商户姓名',
align: 'center',
width: 220,
- templet: '{{d.merchant.real_name}}
'
}, {
- field: 'margin',
- title: '保证金额度',
+ field: 'mark',
+ title: '备注',
align: 'center',
- width: 100,
- templet: '{{d.merchant.margin}}
'
+ width: 220,
}, {
- field: 'status',
- title: '状态',
+ field: 'is_best',
+ title: '推荐',
align: 'center',
width: 150,
- templet: function(d){
- switch (d.merchant.is_margin) {
- case 0:
- return '无
'
- case 1:
- return '有未支付
'
- case 10:
- return '已支付
'
- case -1:
- return '申请退款
'
- case -10:
- return '拒绝退款
'
-
- }
- }
+ 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: '{{d.merchant.mer_name}}
'
- }, {
- field: 'type_id',
- title: '店铺类型',
- align: 'center',
- width: 220,
- templet: '{{d.merchant.merchantType.type_name}}
'
- }, {
- field: 'real_name',
- title: '商户姓名',
- align: 'center',
- width: 220,
- templet: '{{d.merchant.real_name}}
'
- }, {
- field: 'margin',
- title: '保证金额度',
- align: 'center',
- width: 100,
- templet: '{{d.merchant.margin}}
'
- }, {
- 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() {
diff --git a/app/common/model/merchant/system/merchant/Merchant.php b/app/common/model/merchant/system/merchant/Merchant.php
index f8948f3..f1489b7 100644
--- a/app/common/model/merchant/system/merchant/Merchant.php
+++ b/app/common/model/merchant/system/merchant/Merchant.php
@@ -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;
+ }
}