Commit 75bee767 by 朱继来

Merge branch 'zjl_action_log_20190116' into development

parents bd6b8ce5 97fb1f12
......@@ -624,12 +624,16 @@ Class AddOrderController extends Controller
$type_val = '自营';
}
if (count($map) != count($excel[0])) return ['errcode' => 1, 'errmsg' => '导入模板错误,需导入'.$type_val.'模板'];
if (count($map) != count($excel[0])) {
errorLog(Error::E_IMPORT_TEMP_ERR, '导入模板错误,需导入'.$type_val.'模板');
return ['errcode' => 1, 'errmsg' => '导入模板错误,需导入'.$type_val.'模板'];
}
// 验证excel内容
$valid = $this->excelValid($excel);
if ($valid['errcode'] != 0) {
errorLog(Error::E_IMPORT_VALID_FAILED, $valid['errmsg']);
return $valid;
}
......
......@@ -14,6 +14,7 @@ use App\Http\Error;
use Excel;
use App\Model\OrderModel;
use App\Model\UserMainModel;
use App\Model\OrderActionLogModel;
// 获取订单优惠券金额
function getCoupon($order_id)
......@@ -525,14 +526,6 @@ Class OrderController extends Controller
{
if ($request->isMethod('post')) {
$order_id = $request->input('order_id');
// 操作记录
$log['order_id'] = $order_id;
$log['operator_id'] = $request->user->userId;
$log['operator_type'] = 2;
$log['event'] = '下载合同';
$log['ip'] = get_client_ip();
$log['create_time'] = time();
$actionLog = DB::connection('order')->table('lie_order_action_log')->insert($log);
if (!$actionLog){
errorLog(Error::E_ADD_FAILED, '添加操作记录失败');
......@@ -544,6 +537,10 @@ Class OrderController extends Controller
$k2 = md5(md5($k1).'fh6y5t4rr351d2c3bryi');
$downLoadUrl = $apiUrl.'contract/pdfinfo?id='.$order_id.'&k1='.$k1.'&k2='.$k2;
// 操作记录
$OrderActionLogModel = new OrderActionLogModel();
$actionLog = $OrderActionLogModel->addLog($order_id, $request->user->userId, 2, '下载合同');
return ['errcode'=>0, 'errmsg'=>'', 'data'=>$downLoadUrl];
}
}
......@@ -591,7 +588,7 @@ Class OrderController extends Controller
$info['extend'] = $extend ? $extend : '';
}
// 外部引用
// 外部引用---会员系统、CRM系统
public function detailsPage(Request $request, $id)
{
return $this->templateData($request, $id, 'page');
......@@ -630,8 +627,8 @@ Class OrderController extends Controller
$collert = $request->input();
$operator_id = $request->user->userId;
if(!$request->isMethod('post') OR !$collert['rec_id']){
return array('errcode'=>1,'errmsg'=>'错误操作');
if(!$request->isMethod('post') || !$collert['rec_id']){
return array('errcode'=>1, 'errmsg'=>'错误操作');
}
if(!$collert['reason']){
......@@ -730,13 +727,8 @@ Class OrderController extends Controller
}
// 操作记录
$log['order_id'] = $order_id;
$log['operator_id'] = $request->user->userId;
$log['operator_type'] = 2;
$log['event'] = '审核驳回';
$log['ip'] = get_client_ip();
$log['create_time'] = time();
DB::connection('order')->table('lie_order_action_log')->insert($log);
$OrderActionLogModel = new OrderActionLogModel();
$actionLog = $OrderActionLogModel->addLog($order_id, $request->user->userId, 2, '审核驳回');
return array('errcode'=>0,'errmsg'=>'驳回成功');
}
......@@ -802,6 +794,8 @@ Class OrderController extends Controller
// 去掉已离职人员
public function filterLeave(&$data)
{
$data = array();
if (!empty($data)) {
foreach ($data as $k => $v) {
if ($v->status == 4) {
......@@ -849,116 +843,37 @@ Class OrderController extends Controller
}
}
// 申请再次调价
public function applyAdjust(Request $request, $id)
{
$info = $this->orderDetail($request, $id);
if($info['order_info']['status'] == 3 || $info['order_info']['status'] == 4){
return redirect('/prompt')->with(['message'=>"客户已经支付了,无法进行调价了.",'url' =>'/check/'.$id, 'jumpTime'=>3,'status'=>false]);
}
if($info['order_info']['status'] != -1){
//总共允许2次调价(以点击审核按钮次数来统计)
if ($info['order_info']['status'] != 2 || $info['order_info']['adjust_count'] >= 2) {
return redirect('/prompt')->with(['message'=>"该订单无法再进行该操作",'url' =>'/check/'.$id, 'jumpTime'=>3,'status'=>false]);
} elseif ($info['order_info']['status'] == 2 && $info['order_info']['adjust_count'] <= 2 && !in_array($info['role'], array(1, 2))) {
return redirect('/prompt')->with(['message'=>"没有权限进行二次调价",'url' =>'/check/'.$id, 'jumpTime'=>3,'status'=>false]);
}
}
if ($request->isMethod('post')) {
$remark = $request->input('adjust_remark', '', 'trim');
$order_id = $info['order_info']['order_id'];
if (empty($remark)) {
return array('errcode' => -1, 'errmsg' => '调价原因不能为空');
}
$url = Config('website.api_domain').'order/applyAdjust';
$check['k1'] = time();
$check['k2'] = md5(md5($check['k1']).'fh6y5t4rr351d2c3bryi');
$resData = array("order_id"=>$order_id, "pf"=>1, "k1"=>$check['k1'], "k2"=>$check['k2']);
$temp = json_decode(curlApi($url, $resData, "POST"), true);
if ($temp['err_code'] == 0) {
return array('errcode'=>0,'errmsg'=>'申请成功');
} else {
return array('errcode'=>0,'errmsg'=>'申请失败');
}
}
return view('detail.adjust', $info);
}
// 审核不通过
// public function ajaxCheck(Request $request)
// {
// if($request->isMethod('post')){
// $order_id = $request->input('order_id', ''); //订单号
// $sale_id = $request->input('sale_id', null); //对应销售
// $operator_id = $request->user->userId;
// $cancel_reason = $request->input('cancel_reason', '');
// 审核
public function check(Request $request, $id)
{
$data = $this->orderDetail($request, $id);
// if (!isset($sale_id)) {
// return array('errcode'=>1, 'errmsg'=>'请选择订单业务员!');
// }
// 获取所有的业务员
$sale_list = $this->getSales('销售');
// if (!$order_id) {
// return array('errcode'=>1, 'errmsg'=>'订单参数有误!');
// }
$perm = new PermController;
// //用于后台订单审核
// $url = Config('website.api_domain').'order/cancel';
$manager = $perm->getRoleUsers($request, '经理');
$sale_list = $perm->getRoleUsers($request, '交易员');
// $check['k1'] = time();
// $check['k2'] = md5(md5($check['k1']).'fh6y5t4rr351d2c3bryi');
// $manager = array();
// $resData = array("cancel_reason"=>$cancel_reason, "order_id"=>$order_id, 'sale_id'=>$sale_id, "pf"=>1, "k1"=>$check['k1'], "k2"=>$check['k2'], 'operator_id'=>$operator_id, 'type' => 3);
// 过滤业务员,并新建经理数组
// if (!empty($managerId)) {
// foreach ($sale_list as $k=>$v) {
// foreach ($managerId as $id)
// if ($v->userId == $id) {
// $manager[$v->userId] = $v->name;
// $temp = json_decode(curlApi($url, $resData, "POST"), true);
// array_splice($sale_list, $k, 1);
// }
// return array('errcode'=>$temp['err_code'],'errmsg'=>$temp['err_msg']);
// }
// }
$data['sale_list'] = $sale_list;
$data['manager'] = $manager;
return view('detail', $data);
}
// 审核ajax
public function ajaxCheck(Request $request)
{
if($request->isMethod('post')){
$order_id = $request->input('order_id', ''); //订单号
$sale_id = $request->input('sale_id', null); //对应销售
$operator_id = $request->user->userId;
$cancel_reason = $request->input('cancel_reason', '');
if (!isset($sale_id)) {
return array('errcode'=>1, 'errmsg'=>'请选择订单业务员!');
}
if (!$order_id) {
return array('errcode'=>1, 'errmsg'=>'订单参数有误!');
}
//用于后台订单审核
$url = Config('website.api_domain').'order/cancel';
$check['k1'] = time();
$check['k2'] = md5(md5($check['k1']).'fh6y5t4rr351d2c3bryi');
$resData = array("cancel_reason"=>$cancel_reason, "order_id"=>$order_id, 'sale_id'=>$sale_id, "pf"=>1, "k1"=>$check['k1'], "k2"=>$check['k2'], 'operator_id'=>$operator_id, 'type' => 3);
$temp = json_decode(curlApi($url, $resData, "POST"), true);
return array('errcode'=>$temp['err_code'],'errmsg'=>$temp['err_msg']);
}
}
// 对账
public function checkPay(Request $request, $id)
{
......@@ -1402,7 +1317,7 @@ Class OrderController extends Controller
}
$info = $this->getPageInfo($request);
$info['title'] = '快递配置';
$info['title'] = '快递费用配置';
$redis = Redis::connection('read');
$express = $redis->get($key);
......@@ -1496,9 +1411,13 @@ Class OrderController extends Controller
if ($temp['err_code'] == 0) {
continue;
} else {
errorLog($temp['err_code'], $temp['err_msg'].',订单ID:'.$v->order_id); // 消息推送失败记录
}
}
}
}
}
......@@ -1530,18 +1449,13 @@ Class OrderController extends Controller
->update(['status' => -1, 'pay_time' => 0, 'cancel_time' => time()]);
if ($update) {
$log = array();
// 记录
$log['order_id'] = $v->order_id;
$log['operator_id'] = 0;
$log['operator_type'] = 3;
$log['event'] = '取消订单,取消原因:超时未付款';
$log['ip'] = 0;
$log['create_time'] = time();
DB::connection('order')->table('lie_order_action_log')->insert($log);
// 操作记录
$OrderActionLogModel = new OrderActionLogModel();
$actionLog = $OrderActionLogModel->addLog($v->order_id, 0, 3, '取消订单,取消原因:超时未付款'); // 系统取消
continue;
} else {
errorLog(E_UPDATE_FAILED, '自动取消订单失败, 订单ID:'.$v->order_id); // 自动取消订单失败记录
}
}
}
......@@ -1573,13 +1487,8 @@ Class OrderController extends Controller
}
// 操作记录
$log['order_id'] = $order_id;
$log['operator_id'] = $request->user->userId;
$log['operator_type'] = 2;
$log['event'] = '延长付款时间,截止到:'.date('Y-m-d H:i:s', $delay_time);
$log['ip'] = get_client_ip();
$log['create_time'] = time();
$actionLog = DB::connection('order')->table('lie_order_action_log')->insert($log);
$OrderActionLogModel = new OrderActionLogModel();
$actionLog = $OrderActionLogModel->addLog($order_id, $request->user->userId, 3, '延长付款时间,截止到:'.date('Y-m-d H:i:s', $delay_time));
return ['errcode'=>0, 'errmsg'=>'延长成功'];
}
......
......@@ -17,4 +17,6 @@ class Error
const E_ADD_FAILED = -10011; // 添加失败
const E_UPDATE_FAILED = -10012; // 更新失败
const E_IMPORT_TEMP_ERR = -10013; // 导入模板错误
const E_IMPORT_VALID_FAILED = -10014; // 导入验证失败
};
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderActionLogModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_action_log';
protected $primaryKey = 'log_id';
public $timestamps = false;
/**
* 操作记录
* @param [Integer] $order_id [订单ID]
* @param [Integer] $operator_id [操作人]
* @param [Integer] $operator_type [操作人类型:1.网站用户,2.CMS用户, 3-系统定时任务,4-ERP,5-WMS,6-中金]
* @param [string] $event [操作事件]
* @return [type] [description]
*/
public function addLog($order_id, $operator_id, $operator_type = 1, $event='')
{
$log['order_id'] = $order_id;
$log['operator_id'] = $operator_id;
$log['operator_type'] = $operator_type;
$log['event'] = $event;
$log['ip'] = get_client_ip(0, true);
$log['create_time'] = time();
$actionLog = $this->insert($log);
if (!$actionLog) return false;
return $actionLog;
}
}
\ No newline at end of file
......@@ -51,12 +51,6 @@ class OrderModel extends Model
/* 临时添加 所有人只能查看线上订单 */
$map['online_order'] = 1;
if ($map['order_goods_type'] == 1) {
$sale_name = '推送业务员';
} else {
$sale_name = '客服';
}
// 非竞调账号,则查看真实数据
if ($info['username'] != 'vpadmin@ichunt.com') {
$map['is_fake'] = 0;
......@@ -237,7 +231,7 @@ class OrderModel extends Model
})
->where('it.status', '<>', -1)
->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', 'it.order_source as items_source', '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')
->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_type', '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')
->orderBy('o.create_time', 'DESC')
->get()
......@@ -247,11 +241,17 @@ class OrderModel extends Model
// 订单数据处理
$cellData = $this->exportList($list);
if ($map['order_goods_type'] == 1) {
$sale_name = '推送业务员';
} else {
$sale_name = '客服';
}
// 标题
if ($map['order_goods_type'] == 1) {
$headerCell = ['订单ID', '订单编号', '会员账号', '是否为新订单', '收货人', '下单日期', '下单时间', '客户名称', '明细来源', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注'];
$headerCell = ['订单ID', '订单编号', '会员账号', '是否为新订单', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注'];
} else {
$headerCell = ['订单ID', '订单编号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '明细来源', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注'];
$headerCell = ['订单ID', '订单编号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', '商品型号', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', $sale_name, '商品总额', '运费', '附加费', '优惠券', '订单总额', '订单类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注'];
}
array_unshift($cellData, $headerCell);
......@@ -345,7 +345,7 @@ class OrderModel extends Model
$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]['com_name'] = !empty($order[$i]['tax_title']) ? $order[$i]['tax_title'] : $order[$i]['com_name'];
$tmp[$i]['items_source'] = $order[$i]['items_source'];
$tmp[$i]['items_source'] = $this->getOrderSource($order[$i]['order_id'], $order[$i]['order_type']);
// 自营商品名称换成商品型号
$tmp[$i]['goods_name'] = $order[$i]['order_goods_type'] == 1 ? $order[$i]['goods_name'] : $this->getGoodsName($order[$i]['goods_id']);
......@@ -425,4 +425,39 @@ class OrderModel extends Model
return $price ? $price->price : 0;
}
// 获取订单来源
public function getOrderSource($order_id, $order_type=1)
{
if ($order_type == 1) {
$order = DB::connection('order')->table('lie_order_extend')->where('order_id', $order_id)->select('order_type')->first();
if ($order) {
switch ($order->order_type) {
case 1:
case 2:
case 3:
return '后台';
}
}
$order_source = $this->where('order_id', $order_id)->select('order_source')->first();
if (preg_match('/pf=1/', $order_source->order_source)) {
$source = 'PC端';
} else if (preg_match('/pf=2/', $order_source->order_source)) {
$source = '移动端';
} else if (preg_match('/pf=6/', $order_source->order_source)) {
$source = '小程序';
} else {
$source = '未知';
}
return $source;
} else if ($order_type == 3) {
return '京东';
}
return false;
}
}
\ No newline at end of file
......@@ -8,15 +8,15 @@
$('.update_express').click(function(){
var content = '<div class="form-group">'+
'<label>深圳市内:</label>'+
'<input type="text" name="sz_inside" class="sz_inside" value="" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'<input type="text" name="sz_inside" class="sz_inside" value="'+express_fee.sz_inside+'" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'</div>'+
'<div class="form-group">'+
'<label>广东省内:</label>'+
'<input type="text" name="gd_inside" class="gd_inside" value="" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'<input type="text" name="gd_inside" class="gd_inside" value="'+express_fee.gd_inside+'" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'</div>'+
'<div class="form-group">'+
'<label>广东省外:</label>'+
'<input type="text" name="gd_outside" class="gd_outside" value="" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'<input type="text" name="gd_outside" class="gd_outside" value="'+express_fee.gd_outside+'" placeholder="输入快递费用,如20.00" style="width:70%;">'+
'</div>';
layer.open({
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | 首页</title>
<title>订单管理后台 | 账期申请列表</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
<link href="/js/layui/css/layui.css" rel="stylesheet">
@include('index.css')
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | 首页</title>
<title>订单管理后台 | PCB首页</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
<link href="/js/layui/css/layui.css" rel="stylesheet">
@include('index.css')
......
......@@ -15,7 +15,7 @@
</div>
<div class="layui-inline">
<label class="layui-form-label">是否包括测试:</label>
<div class="layui-input-inline">
<div class="layui-input-inline" style="top:9px">
<input type="checkbox" lay-ignore name="test_order" <?php if (@$_GET['test_order']) echo "checked='checked'" ?> >
</div>
</div>
......
......@@ -568,7 +568,7 @@
</div>
<?php $client_source = App\Http\Controllers\clientSource($order_info['user_id']); ?>
@if (!empty($client_source) || $order_info['status'] == -1)
@if (!empty($client_source))
<div class="tabs-box table-responsive">
<table class="table table-bordered table-hover">
@if (!empty($client_source))
......@@ -577,13 +577,6 @@
<td colspan="3">{{ $client_source }}</td>
</tr>
@endif
@if ($order_info['status'] == -1)
<tr>
<td width="10%">订单取消原因:</td>
<td colspan="3">{{ $order_info['cancel_reason'] }}</td>
</tr>
@endif
</table>
</div>
@endif
......
......@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | 订单统计</title>
<title>订单管理后台 | 快递费用配置</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
@include('express_set.css')
......
......@@ -34,5 +34,8 @@
</div>
<script>
var express_fee = '<?= json_encode($express_fee) ?>';
express_fee = eval('('+express_fee+')');
$.lie.express.index();
</script>
\ No newline at end of file
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