feat(平台后台): 订单分配团队
parent
23976b7c3b
commit
cd0725c55e
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace app\admin\controller\order;
|
||||
|
||||
use app\admin\logic\user\BusinessTeamLogic;
|
||||
use app\common\basics\AdminBase;
|
||||
use app\common\model\order\order as OrderModel;
|
||||
use app\common\server\JsonServer;
|
||||
|
@ -68,6 +69,7 @@ class Order extends AdminBase
|
|||
'order_type' => $order_type,
|
||||
'order_source' => $order_source,
|
||||
'pay_way' => $pay_way,
|
||||
'team_list' => BusinessTeamLogic::getBusinessTeamList(),
|
||||
'delivery_type' => $delivery_type
|
||||
]);
|
||||
}
|
||||
|
@ -128,4 +130,21 @@ class Order extends AdminBase
|
|||
}
|
||||
return JsonServer::success('', $result);
|
||||
}
|
||||
|
||||
public function setTeam(){
|
||||
if($this->request->isAjax()){
|
||||
$post = $this->request->post();
|
||||
if (empty($post['order_ids']) || empty($post['team_id'])) {
|
||||
return JsonServer::error('参数错误');
|
||||
}
|
||||
$result = OrderLogic::setTeam($post);
|
||||
if($result === true) {
|
||||
return JsonServer::success('设置成功');
|
||||
}
|
||||
return JsonServer::error(OrderLogic::getError());
|
||||
}
|
||||
return view('', [
|
||||
'team_list' => json_encode(BusinessTeamLogic::getBusinessTeamList())
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -134,6 +134,11 @@ class OrderLogic extends Logic
|
|||
$where[] = ['o.pay_way', '=', $get['pay_way']];
|
||||
}
|
||||
|
||||
//业务团队
|
||||
if (isset($get['team_id']) && $get['team_id'] != '') {
|
||||
$where[] = ['o.team_id', '=', $get['team_id']];
|
||||
}
|
||||
|
||||
// 前置订单
|
||||
if (isset($get['is_frontend']) && $get['is_frontend'] != '') {
|
||||
$where[] = ['o.is_frontend', '=', $get['is_frontend']];
|
||||
|
@ -166,7 +171,7 @@ class OrderLogic extends Logic
|
|||
return self::export($where);
|
||||
}
|
||||
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text,delivery_type as delivery_type_text,s.name as shop_name,order_type as order_type_text,u.level';
|
||||
$field = 'o.*,order_status as order_status_text,pay_way as pay_way_text,delivery_type as delivery_type_text,s.name as shop_name,order_type as order_type_text,u.level,bt.name as team_name';
|
||||
|
||||
$count = $order
|
||||
->alias('o')
|
||||
|
@ -174,6 +179,7 @@ class OrderLogic extends Logic
|
|||
->join('shop s', 's.id = o.shop_id')
|
||||
->join('user u', 'u.id = o.user_id')
|
||||
->join('order_goods g', 'g.order_id = o.id')
|
||||
->leftJoin('business_team bt', 'bt.id = o.team_id')
|
||||
->with(['order_goods', 'user', 'shop'])
|
||||
->where($where)
|
||||
->group('o.id')
|
||||
|
@ -185,6 +191,7 @@ class OrderLogic extends Logic
|
|||
->join('shop s', 's.id = o.shop_id')
|
||||
->join('user u', 'u.id = o.user_id')
|
||||
->join('order_goods g', 'g.order_id = o.id')
|
||||
->leftJoin('business_team bt', 'bt.id = o.team_id')
|
||||
->with(['order_goods', 'user', 'shop'])
|
||||
->where($where)
|
||||
->append(['delivery_address', 'pay_status_text', 'order_source_text'])
|
||||
|
@ -203,6 +210,8 @@ class OrderLogic extends Logic
|
|||
$order_good['image'] = UrlServer::getFileUrl($order_good['image']);
|
||||
}
|
||||
|
||||
$list['team_name'] = $list['team_name'] ?: '无';
|
||||
|
||||
// 会员等级
|
||||
$list['user_level'] = '暂无等级';
|
||||
if(isset($user_level[$list['level']])) {
|
||||
|
@ -481,4 +490,19 @@ class OrderLogic extends Logic
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setTeam($post)
|
||||
{
|
||||
try{
|
||||
Order::where([
|
||||
['id', 'in', $post['order_ids']]
|
||||
])->update([
|
||||
'team_id' => $post['team_id']
|
||||
]);
|
||||
return true;
|
||||
}catch(\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -192,6 +192,9 @@
|
|||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div style="padding-bottom: 10px;">
|
||||
<button class="layui-btn layui-btn-sm layuiadmin-btn-user {$view_theme_color}" data-type="set_team">设置业务团队</button>
|
||||
</div>
|
||||
<table id="order-lists" lay-filter="order-lists"></table>
|
||||
|
||||
<script type="text/html" id="order-operation" >
|
||||
|
@ -234,6 +237,7 @@
|
|||
否
|
||||
{{# } }}
|
||||
</p>
|
||||
<p>业务团队:{{d.team_name}}</p>
|
||||
<p>下单时间:{{d.create_time}}</p>
|
||||
<p>支付时间:
|
||||
{{# if(d.pay_time == '0'){ }}
|
||||
|
@ -430,7 +434,8 @@
|
|||
elem: '#order-lists'
|
||||
, url: '{:url("order.order/lists")}?type=' + type
|
||||
, cols: [[
|
||||
{field:'id',title: 'id',width:60,align: 'center'}
|
||||
{checkbox:true}
|
||||
,{field:'id',title: 'id',width:60,align: 'center'}
|
||||
, {field: 'shop', title: '商家信息', align: 'center',templet:'#shop',width:230}
|
||||
, {field: 'order', title: '订单信息', align: 'center',templet:'#order',width:230}
|
||||
, {field: 'user', title: '会员信息', templet:'#user',width:300}
|
||||
|
@ -465,6 +470,64 @@
|
|||
});
|
||||
}
|
||||
|
||||
var active = {
|
||||
set_team:function() { //设置业务团队
|
||||
var check_status = table.checkStatus('order-lists')
|
||||
,user_list = check_status.data; //得到选中的数据
|
||||
|
||||
//是否已选数据
|
||||
if( user_list.length === 0){
|
||||
return layer.msg('请选择数据');
|
||||
}
|
||||
//获取所选id
|
||||
ids = [];
|
||||
for (var i in user_list){
|
||||
ids.push(user_list[i]['id']);
|
||||
}
|
||||
|
||||
layer.open({
|
||||
type: 2
|
||||
,title: '设置业务团队'
|
||||
,content: '{:url("order.order/setTeam")}'
|
||||
,area: ['60%', '60%']
|
||||
,btn: ['确定', '取消']
|
||||
,yes: function(index, layero){
|
||||
var iframeWindow = window['layui-layer-iframe'+ index]
|
||||
,submitID = 'set_tag-submit'
|
||||
,submit = layero.find('iframe').contents().find("#set_tag-submit");
|
||||
//监听提交
|
||||
iframeWindow.layui.form.on('submit(set_tag-submit)', function(data){
|
||||
$.ajax({
|
||||
url:'{:url("order.order/setTeam")}',
|
||||
data:{team_id:data.field.team_id,order_ids:ids},
|
||||
type:"post",
|
||||
success:function(res)
|
||||
{
|
||||
if(res.code == 1)
|
||||
{
|
||||
layui.layer.msg(res.msg, {
|
||||
offset: '15px'
|
||||
, icon: 1
|
||||
, time: 1000
|
||||
});
|
||||
layer.close(index); //关闭弹层
|
||||
table.reload('order-lists'); //数据刷新
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
submit.trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('.layui-btn.layuiadmin-btn-user').on('click', function(){
|
||||
var type = $(this).data('type');
|
||||
active[type] ? active[type].call(this) : '';
|
||||
});
|
||||
|
||||
//监听工具条
|
||||
table.on('tool(order-lists)', function (obj) {
|
||||
var id = obj.data.id;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{layout name="layout2" /}
|
||||
<div class="layui-form" lay-filter="layuiadmin-form-user" id="layuiadmin-form-user" style="padding: 20px 30px 0 0;">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label" style="width: 180px">选择业务团队:</label>
|
||||
<div class="layui-input-inline" style="width: 420px">
|
||||
<div id="teamList"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<input type="button" lay-submit lay-filter="set_tag-submit" id="set_tag-submit" value="确认">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
layui.config({
|
||||
version:"{$front_version}",
|
||||
base: '/static/lib/' //静态资源所在路径
|
||||
}).extend({
|
||||
xmSelect: 'xmSelect/xm-select'
|
||||
}).use(['xmSelect', 'form'], function(){
|
||||
var $ = layui.$,form = layui.form ;
|
||||
var xmSelect = layui.xmSelect;
|
||||
var tag_list = '{$team_list|raw}';
|
||||
|
||||
var xmIns = xmSelect.render({
|
||||
el: '#teamList',
|
||||
name: 'team_id',
|
||||
radio: true,
|
||||
language: 'zn',
|
||||
data: JSON.parse(tag_list),
|
||||
prop: {
|
||||
value: 'id'
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue