Commit 93f68f1e by 朱继来

Merge branch 'zjl_adjust_20181026'

parents 31e1731d c239fb1a
...@@ -363,6 +363,7 @@ Class OrderController extends Controller ...@@ -363,6 +363,7 @@ Class OrderController extends Controller
$map['order_payment_mode'] = $request->input('order_payment_mode', ''); $map['order_payment_mode'] = $request->input('order_payment_mode', '');
$map['order_invoice_status']= $request->input('order_invoice_status', ''); $map['order_invoice_status']= $request->input('order_invoice_status', '');
$map['is_new'] = $request->input('is_new', ''); $map['is_new'] = $request->input('is_new', '');
$map['is_new_order'] = $request->input('is_new_order', '');
} }
// 订单查看权限---交易员、客服、测试 // 订单查看权限---交易员、客服、测试
...@@ -1691,4 +1692,43 @@ Class OrderController extends Controller ...@@ -1691,4 +1692,43 @@ Class OrderController extends Controller
echo '一年增票订单数:'.$yearAddInvoice.'<br>'; echo '一年增票订单数:'.$yearAddInvoice.'<br>';
} }
// 检查历史订单数据
public function checkHistroyOrder(Request $request)
{
// 查找用户订单数,并更新用户表和订单扩展表
$subQuery = OrderModel::where('is_type', '=', 0)->orderBy('order_id');
OrderModel::from(DB::raw("({$subQuery->toSql()}) as sub"))
->mergeBindings($subQuery->getQuery())
->select(DB::raw('sub.user_id, sub.order_id, count(*) as order_count'))
->groupBy('sub.user_id')
->chunk(100, function($orderCount) {
foreach ($orderCount as $k=>$v) {
$new_user = $new_order = [];
if ($v->order_count == 1) {
$new_user['is_new'] = 1; // 新用户
$new_order['is_new'] = 1; // 新订单
} else {
$new_user['is_new'] = 2; // 老用户
$new_order['is_new'] = 1; // 多订单将第一个订单设置为新订单
}
// 更新用户
DB::connection('order')->table('lie_user_main')->where('user_id', $v->user_id)->update($new_user);
$extend = DB::connection('order')->table('lie_order_extend')->where('order_id', $v->order_id)->first();
if ($extend) {
// 更新订单
DB::connection('order')->table('lie_order_extend')->where('order_id', $v->order_id)->update($new_order);
} else {
// 创建
$new_order['order_id'] = $v->order_id;
DB::connection('order')->table('lie_order_extend')->insert($new_order);
}
}
});
}
} }
\ No newline at end of file
...@@ -86,6 +86,8 @@ ...@@ -86,6 +86,8 @@
return 7; return 7;
} else if ($department->name == '运营助理') { } else if ($department->name == '运营助理') {
return 8; return 8;
} else if ($department->name == '财务') {
return 9;
} else { } else {
return 0; return 0;
} }
......
...@@ -110,5 +110,6 @@ Route::group(['middleware' => 'web'], function () { ...@@ -110,5 +110,6 @@ Route::group(['middleware' => 'web'], function () {
Route::group(['middleware' => 'api'], function () { Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms'); Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms');
Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel'); Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel');
Route::get ('/api/check/histroyorder', 'OrderController@checkHistroyOrder');
}); });
...@@ -44,6 +44,8 @@ class OrderModel extends Model ...@@ -44,6 +44,8 @@ class OrderModel extends Model
$map['order_payment_mode'] = $request->input('order_payment_mode', ''); $map['order_payment_mode'] = $request->input('order_payment_mode', '');
$map['order_invoice_status'] = $request->input('order_invoice_status', ''); $map['order_invoice_status'] = $request->input('order_invoice_status', '');
$map['order_goods_type'] = $request->input('order_goods_type', ''); $map['order_goods_type'] = $request->input('order_goods_type', '');
$map['is_new'] = $request->input('is_new', '');
$map['is_new_order'] = $request->input('is_new_order', '');
} }
/* 临时添加 所有人只能查看线上订单 */ /* 临时添加 所有人只能查看线上订单 */
...@@ -187,9 +189,21 @@ class OrderModel extends Model ...@@ -187,9 +189,21 @@ class OrderModel extends Model
$query->where('i.inv_type', '=', $map['order_invoice_status']); $query->where('i.inv_type', '=', $map['order_invoice_status']);
} }
}) })
->where(function ($query) use ($map) {
// 是否为新用户
if ($map['is_new'] != '') {
$query->where('u.is_new', '=', $map['is_new']);
}
})
->where(function ($query) use ($map) {
// 是否新订单
if ($map['is_new_order'] != '') {
$query->where('oe.is_new', '=', $map['is_new_order']);
}
})
->where('it.status', '<>', -1) ->where('it.status', '<>', -1)
->where('o.order_goods_type', '=', $map['order_goods_type']) ->where('o.order_goods_type', '=', $map['order_goods_type'])
->select('it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'o.order_id', 'o.order_sn', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'a.consignee', 'a.address', 's.status as shipping_status', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'c.com_name', 'oe.send_remark') ->select('it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'o.order_id', 'o.order_sn', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'a.consignee', 'a.address', 's.status as shipping_status', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'c.com_name', 'oe.send_remark', 'oe.is_new as is_new_order')
->groupBy('it.rec_id') ->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC') ->orderBy('o.create_time', 'DESC')
->get() ->get()
...@@ -200,7 +214,7 @@ class OrderModel extends Model ...@@ -200,7 +214,7 @@ class OrderModel extends Model
$cellData = $this->exportList($list); $cellData = $this->exportList($list);
// 标题 // 标题
$headerCell = ['订单ID', '订单编号', '会员账号', '是否为新用户', '收货人', '下单日期', '下单时间', '客户名称', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注']; $headerCell = ['订单ID', '订单编号', '会员账号', '是否为新订单', '收货人', '下单日期', '下单时间', '客户名称', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注'];
array_unshift($cellData, $headerCell); array_unshift($cellData, $headerCell);
...@@ -283,7 +297,8 @@ class OrderModel extends Model ...@@ -283,7 +297,8 @@ class OrderModel extends Model
$tmp[$i]['order_id'] = $order[$i]['order_id']; $tmp[$i]['order_id'] = $order[$i]['order_id'];
$tmp[$i]['order_sn'] = "\t".$order[$i]['order_sn']."\t"; $tmp[$i]['order_sn'] = "\t".$order[$i]['order_sn']."\t";
$tmp[$i]['user_account'] = $order[$i]['mobile'] ? $order[$i]['mobile'] : $order[$i]['email']; $tmp[$i]['user_account'] = $order[$i]['mobile'] ? $order[$i]['mobile'] : $order[$i]['email'];
$tmp[$i]['is_new'] = $order[$i]['is_new'] == 1 ? '是' : '否'; // 是否为新用户 // $tmp[$i]['is_new'] = $order[$i]['is_new'] == 1 ? '是' : '否'; // 是否为新用户
$tmp[$i]['is_new_order'] = $order[$i]['is_new_order'] == 1 ? '是' : '否'; // 是否为新订单
$tmp[$i]['consignee'] = isset($order[$i]['consignee']) ? $order[$i]['consignee'] : ''; $tmp[$i]['consignee'] = isset($order[$i]['consignee']) ? $order[$i]['consignee'] : '';
$tmp[$i]['create_time_date'] = date('Y-m-d', $order[$i]['create_time']); $tmp[$i]['create_time_date'] = date('Y-m-d', $order[$i]['create_time']);
$tmp[$i]['create_time_sec'] = date('H:i:s', $order[$i]['create_time']); $tmp[$i]['create_time_sec'] = date('H:i:s', $order[$i]['create_time']);
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
test_order = $('input[name=test_order]'), test_order = $('input[name=test_order]'),
erp_order_id = $('#erp_order_id').data('default'), erp_order_id = $('#erp_order_id').data('default'),
is_new = $('#is_new').val(), is_new = $('#is_new').val(),
is_new_order = $('#is_new_order').data('default'),
listUrl = '/list'; listUrl = '/list';
listUrl += '?order_type=' + order_type; listUrl += '?order_type=' + order_type;
...@@ -142,11 +143,15 @@ ...@@ -142,11 +143,15 @@
listUrl += '&is_new=' + is_new; listUrl += '&is_new=' + is_new;
} }
if (is_new_order) {
listUrl += '&is_new_order=' + is_new_order;
}
if (test_order.is(':checked')) { if (test_order.is(':checked')) {
listUrl += '&test_order=' + 1; listUrl += '&test_order=' + 1;
} }
if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && !order_source_ptag && !erp_order_id && (is_new === '') && !test_order.is(':checked')) { if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && !order_source_ptag && !erp_order_id && (is_new === '') && !is_new_order && !test_order.is(':checked')) {
listUrl = '/list'; listUrl = '/list';
} }
...@@ -170,14 +175,15 @@ ...@@ -170,14 +175,15 @@
erp_order_id = $('#erp_order_id').data('default'), erp_order_id = $('#erp_order_id').data('default'),
test_order = $('input[name=test_order]'), test_order = $('input[name=test_order]'),
is_new = $('#is_new').val() ? $('#is_new').val() : ''; is_new = $('#is_new').val() ? $('#is_new').val() : '';
is_new_order = $('#is_new_order').data('default');
if (test_order.length) { if (test_order.length) {
if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && ! order_source_ptag && !erp_order_id && !test_order.is(':checked')) { if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && ! order_source_ptag && !erp_order_id && !is_new && !is_new_order && !test_order.is(':checked')) {
layer.msg('请选择筛选条件,再导出!'); layer.msg('请选择筛选条件,再导出!');
return false; return false;
} }
} else { } else {
if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && !order_source_ptag && !erp_order_id) { if (!order_contain && !time_start && !time_end && !order_pay_type && !order_status && !shipping_name && !order_send && !order_source_pf && !order_source_adtag && !order_source_ptag && !erp_order_id && !is_new && !is_new_order) {
layer.msg('请选择筛选条件,再导出!'); layer.msg('请选择筛选条件,再导出!');
return false; return false;
} }
...@@ -201,7 +207,7 @@ ...@@ -201,7 +207,7 @@
test_order = ''; test_order = '';
} }
location.href = '/export?order_type='+order_type+'&order_contain='+order_contain+'&time_start='+time_start+'&time_end='+time_end+'&order_pay_type='+order_pay_type+'&order_status='+order_status+'&shipping_name='+shipping_name+'&order_send='+order_send+'&order_source_pf='+order_source_pf+'&order_source_adtag='+order_source_adtag+'&order_source_ptag='+order_source_ptag+'&erp_order_id='+erp_order_id+'&test_order='+test_order+'&is_new='+is_new+'&order_goods_type='+1; location.href = '/export?order_type='+order_type+'&order_contain='+order_contain+'&time_start='+time_start+'&time_end='+time_end+'&order_pay_type='+order_pay_type+'&order_status='+order_status+'&shipping_name='+shipping_name+'&order_send='+order_send+'&order_source_pf='+order_source_pf+'&order_source_adtag='+order_source_adtag+'&order_source_ptag='+order_source_ptag+'&erp_order_id='+erp_order_id+'&test_order='+test_order+'&is_new='+is_new+'&is_new_order='+is_new_order+'&order_goods_type='+1;
}) })
// 选择查看测试订单 // 选择查看测试订单
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
order_source_ptag = $('input[name="order_source_ptag"]').val(), order_source_ptag = $('input[name="order_source_ptag"]').val(),
test_order = $('input[name=test_order]'), test_order = $('input[name=test_order]'),
is_new = $('#is_new').data('default'), is_new = $('#is_new').data('default'),
is_new_order = $('#is_new_order').data('default'),
listUrl = '/self_order'; listUrl = '/self_order';
listUrl += '?order_type=' + order_type; listUrl += '?order_type=' + order_type;
...@@ -77,11 +78,15 @@ ...@@ -77,11 +78,15 @@
listUrl += '&is_new=' + is_new; listUrl += '&is_new=' + is_new;
} }
if (is_new_order !== '') {
listUrl += '&is_new_order=' + is_new_order;
}
if (test_order.is(':checked')) { if (test_order.is(':checked')) {
listUrl += '&test_order=' + 1; listUrl += '&test_order=' + 1;
} }
if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag && (is_new === '') && !test_order.is(':checked')) { if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag && (is_new === '') && !is_new_order && !test_order.is(':checked')) {
listUrl = '/self_order'; listUrl = '/self_order';
} }
...@@ -102,15 +107,17 @@ ...@@ -102,15 +107,17 @@
order_invoice_status = $('#order_invoice_status').data('default'), order_invoice_status = $('#order_invoice_status').data('default'),
order_source_adtag = $('input[name="order_source_adtag"]').val(), order_source_adtag = $('input[name="order_source_adtag"]').val(),
order_source_ptag = $('input[name="order_source_ptag"]').val(), order_source_ptag = $('input[name="order_source_ptag"]').val(),
is_new = $('#is_new').data('default'),
is_new_order = $('#is_new_order').data('default'),
test_order = $('input[name=test_order]'); test_order = $('input[name=test_order]');
if (test_order.length) { if (test_order.length) {
if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag && !test_order.is(':checked')) { if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag && !is_new && !is_new_order && !test_order.is(':checked')) {
layer.msg('请选择筛选条件,再导出!'); layer.msg('请选择筛选条件,再导出!');
return false; return false;
} }
} else { } else {
if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag) { if (!order_contain && !time_start && !time_end && !order_payment_mode && !order_status && !sale_type && !order_invoice_status && !order_source_pf && !order_source_adtag && !order_source_ptag && !is_new && !is_new_order) {
layer.msg('请选择筛选条件,再导出!'); layer.msg('请选择筛选条件,再导出!');
return false; return false;
} }
...@@ -130,7 +137,7 @@ ...@@ -130,7 +137,7 @@
test_order = ''; test_order = '';
} }
location.href = '/export?order_type='+order_type+'&order_contain='+order_contain+'&time_start='+time_start+'&time_end='+time_end+'&order_payment_mode='+order_payment_mode+'&order_status='+order_status+'&sale_type='+sale_type+'&order_invoice_status='+order_invoice_status+'&order_source_pf='+order_source_pf+'&order_source_adtag='+order_source_adtag+'&order_source_ptag='+order_source_ptag+'&test_order='+test_order+'&order_goods_type='+2; location.href = '/export?order_type='+order_type+'&order_contain='+order_contain+'&time_start='+time_start+'&time_end='+time_end+'&order_payment_mode='+order_payment_mode+'&order_status='+order_status+'&sale_type='+sale_type+'&order_invoice_status='+order_invoice_status+'&order_source_pf='+order_source_pf+'&order_source_adtag='+order_source_adtag+'&order_source_ptag='+order_source_ptag+'&test_order='+test_order+'&is_new='+is_new+'&is_new_order='+is_new_order+'&order_goods_type='+2;
}) })
// 选择查看测试订单 // 选择查看测试订单
......
...@@ -217,11 +217,11 @@ ...@@ -217,11 +217,11 @@
@if (!$isPage) @if (!$isPage)
<!-- 发票状态小于2(已发货)且更改权限存在 显示按钮 --> <!-- 发票状态小于2(已发货)且更改权限存在 显示按钮 -->
@if (!isset($_REQUEST['tags'])) @if (!isset($_REQUEST['tags']))
@if($order_info['status'] < 10 && $order_invoice_info['invoice_status'] < 2 && in_array('update_invoice', $userPerms)) @if(in_array($order_info['status'], [1, 2, 3, 4]) && $order_invoice_info['invoice_status'] < 2 && in_array('update_invoice', $userPerms))
<a href="/changeInvoice/{{$order_info['order_id']}}" class="btn btn-success btn-sm changeBtn">更改发票</a> <a href="/changeInvoice/{{$order_info['order_id']}}" class="btn btn-success btn-sm changeBtn">更改发票</a>
@endif @endif
@elseif (isset($_REQUEST['tags']) && $_REQUEST['tags'] == 'self' && !$extend) @elseif (isset($_REQUEST['tags']) && $_REQUEST['tags'] == 'self' && !$extend)
@if($order_info['status'] < 10 && $order_invoice_info['invoice_status'] < 2 && in_array('self_order_update_invoice', $userPerms)) @if(in_array($order_info['status'], [1, 2, 3, 4]) && $order_invoice_info['invoice_status'] < 2 && in_array('self_order_update_invoice', $userPerms))
<a href="/changeInvoice/{{$order_info['order_id']}}?tags={{$_REQUEST['tags']}}" class="btn btn-success btn-sm changeBtn">更改发票</a> <a href="/changeInvoice/{{$order_info['order_id']}}?tags={{$_REQUEST['tags']}}" class="btn btn-success btn-sm changeBtn">更改发票</a>
@endif @endif
@elseif (isset($_REQUEST['tags']) && $_REQUEST['tags'] == 'erp') @elseif (isset($_REQUEST['tags']) && $_REQUEST['tags'] == 'erp')
......
...@@ -170,6 +170,18 @@ ...@@ -170,6 +170,18 @@
</div> --> </div> -->
</dd> </dd>
</dl> </dl>
<dl>
<dt>新订单:</dt>
<dd style="width: 115px;">
<div class="droplist" data-default="{{$condition['is_new_order']}}" id="is_new_order" name="is_new_order">
<ul class="dropdown-menu">
<li data-val="" class="active">全部</li>
<li data-val="1"></li>
<li data-val="0"></li>
</ul>
</div>
</dd>
</dl>
@if (in_array('check_test_order', $userPerms)) @if (in_array('check_test_order', $userPerms))
<dl> <dl>
......
...@@ -147,6 +147,18 @@ ...@@ -147,6 +147,18 @@
</div> </div>
</dd> </dd>
</dl> </dl>
<dl>
<dt>新订单:</dt>
<dd style="width: 115px;">
<div class="droplist" data-default="{{$condition['is_new_order']}}" id="is_new_order" name="is_new_order">
<ul class="dropdown-menu">
<li data-val="" class="active">全部</li>
<li data-val="1"></li>
<li data-val="0"></li>
</ul>
</div>
</dd>
</dl>
@if (in_array('self_check_test_order', $userPerms)) @if (in_array('self_check_test_order', $userPerms))
<dl> <dl>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment