Commit d427ee91 by 朱继来

Merge branch 'zjl_iteration_20190802'

parents 69d71efb bf2563fb
......@@ -10,6 +10,8 @@ use Cookie;
use App\Http\Page;
use App\Http\Controllers\PermController;
use App\Http\Error;
use App\Model\UserMainModel;
use App\Model\OrderModel;
use Excel;
Class AddOrderController extends Controller
......@@ -87,22 +89,32 @@ Class AddOrderController extends Controller
public function getUserInfo(Request $request)
{
if ($request->isMethod('post')) {
$mobile = $request->input('mobile');
$mobile = $request->input('mobile');
$goods_type = $request->input('goods_type'); // 类型,1-联营,2-自营
$operator_id = $request->user->userId;
$UserMainModel = new UserMainModel;
if (preg_match('/@/', $mobile)) {
$user = DB::connection('order')->table('lie_user_main')->where('email', $mobile)->select('user_id', 'email', 'is_test')->first();
$user = $UserMainModel->where('email', $mobile)->select('user_id', 'email', 'is_test')->first();
} else {
$user = DB::connection('order')->table('lie_user_main')->where('mobile', $mobile)->select('user_id', 'mobile', 'is_test')->first();
}
$user = $UserMainModel->where('mobile', $mobile)->select('user_id', 'mobile', 'is_test')->first();
}
if (!empty($user)) {
$perm = new PermController;
$role = $perm->getUserRole($request); // 用户角色
if (!empty($user)) {
// 收货地址
$address = DB::connection('order')->table('lie_user_address')->where('user_id', $user->user_id)->get();
if ($goods_type == 1 || ($goods_type == 2 && !in_array($role, [1, 10, 11]))) { // 自营管理员、主管、主管助理可以帮客服下单
$last_sale_id = $this->findLastSaleId($user->user_id);
// 发票信息
$invoice = DB::connection('order')->table('lie_taxinfo')->where('user_id', $user->user_id)->get();
if ($last_sale_id && $operator_id != $last_sale_id) return ['errcode' => -1, 'errmsg' => '暂不能跟进该客户,请联系主管重新指派'];
}
$address = DB::connection('order')->table('lie_user_address')->where('user_id', $user->user_id)->get(); // 收货地址
$invoice = DB::connection('order')->table('lie_taxinfo')->where('user_id', $user->user_id)->get(); // 发票信息
$info['user'] = $user;
$info['user'] = $user;
$info['address'] = $address;
$info['invoice'] = $invoice;
}
......@@ -115,6 +127,20 @@ Class AddOrderController extends Controller
}
}
// 获取用户最近的订单跟进业务员
public function findLastSaleId($user_id)
{
$OrderModel = new OrderModel;
$map['user_id'] = $user_id;
$map['is_type'] = 0; // 过滤尽调数据
$map[] = ['sale_id', '>', 0];
$order = $OrderModel->where($map)->select('sale_id')->orderBy('order_id', 'desc')->first();
return $order ? $order['sale_id'] : 0;
}
// 选择收货地址
public function selectAddr(Request $request)
{
......@@ -743,4 +769,22 @@ Class AddOrderController extends Controller
return $goods_info;
}
// 添加商品到订单
public function addGoods(Request $request)
{
if ($request->isMethod('post')) {
$data['order_id'] = $request->input('order_id');
$data['goods_id'] = $request->input('goods_id');
$data['goods_num'] = $request->input('goods_num');
$data['operator_id'] = $request->user->userId;
$url = Config('website.order_api_domain').'/order/addgoods';
$response = json_decode(curlApi($url, $data, 'post'), true);
return ['errcode' => $response['errcode'], 'errmsg' => $response['errmsg']];
}
}
}
\ No newline at end of file
......@@ -1705,6 +1705,25 @@ Class OrderController extends Controller
}
}
// 回传合同
public function uploadContract(Request $request)
{
if ($request->isMethod('post')) {
$order_id = $request->input('order_id');
$data['upload_contract_url'] = $request->input('url');
DB::connection('order')->transaction(function() use ($request, $order_id, $data) {
DB::connection('order')->table('lie_order')->where('order_id', $order_id)->update(['erp_syn'=>1]); // 标记ERP同步
DB::connection('order')->table('lie_order_extend')->where('order_id', $order_id)->update($data);
$OrderActionLogModel = new OrderActionLogModel();
$OrderActionLogModel->addLog($order_id, $request->user->userId, 2, '回传合同'); // 操作记录
});
return ['errcode'=>0, 'errmsg'=>'回传合同成功'];
}
}
public function tempCount(Request $request)
{
$current = strtotime(date('Y-m-d', time())); // 当天0点
......
......@@ -394,4 +394,16 @@ function utf8_strlen($string = null) {
preg_match_all("/./us", $string, $match);
// 返回单元个数
return count($match[0]);
}
//上传文件接口签名
function Autograph(){
$url=Config('website.api_domain');
$data['k1']=time();
$data['k2']=MD5(MD5($data['k1']).Config('website.upload_key'));
echo '<script>
k1="'.$data['k1'].'";
k2="'.$data['k2'].'";
UploadImgUrl="'.$url.'"
</script>';
}
\ No newline at end of file
......@@ -132,6 +132,9 @@ Route::group(['middleware' => 'web'], function () {
Route::get('/self_return_export', 'ReturnController@selfReturnExport');
Route::match(['get', 'post'], '/return_edit/{id}', 'OrderController@orderReturnEdit');
Route::post('/ajax/addGoods', 'AddOrderController@addGoods');
Route::post('/ajax/uploadContract', 'OrderController@uploadContract');
});
// 不需要登陆态
......
......@@ -17,8 +17,8 @@ class OrderModel extends Model
// 订单导出
public function orderExport($request, $info)
{
set_time_limit(300);
ini_set('memory_limit', '512M');
set_time_limit(0);
ini_set('memory_limit', '2048M');
$map = array();
......@@ -90,6 +90,8 @@ class OrderModel extends Model
$query->where('it.goods_name', '=', $map['order_contain']);
} else if ($map['order_type'] == 3) { // 发票抬头
$query->where('i.tax_title', '=', $map['order_contain']);
} else if($map['order_type'] == 4) {
$query->where('o.user_id', '=', $map['order_contain']);
} else { // 订单编号
$query->where('o.order_sn', '=', $map['order_contain']);
}
......
......@@ -61,9 +61,9 @@
'self_map' => [
0 => 'id',
1 => 'goods_name',
2 => 'brand_name',
3 => 'num',
1 => 'num',
2 => 'goods_name',
3 => 'brand_name',
],
// 特殊业务类型
......
......@@ -16,6 +16,7 @@ return [
'order_url' => 'http://order.liexin.net',
// API项目
'api_domain' => 'http://api.liexin.com/',
'upload_key' => 'fh6y5t4rr351d2c3bryi', // 上传文件key
// 权限系统
'perm_url' => 'http://perm.liexin.net',
// 获取用户权限接口
......@@ -76,4 +77,7 @@ return [
// 支付地址
'pay_url' => 'https://www.liexin.com/v3/pay/online?id=',
// 订单微服务
'order_api_domain' => 'http://orderapi.liexin.com',
];
......@@ -46,7 +46,7 @@
$.ajax({
url: '/ajax/getUserInfo',
type: 'post',
data: {mobile : mobile.trim()},
data: {mobile : mobile.trim(), goods_type: goods_type},
dataType: 'json',
success: function (resp) {
if (resp.errcode == 0) {
......
+(function($){
$.lie = $.lie || {version: "v1.0.0"};
$.extend($.lie, {
goods:{
add:function(){
$('.order-change-main').on('click', '.add_goods', function() {
layer.open({
area: ['1000px', '400px'],
type: 1,
title: '新增商品',
content: $('#addGoods'),
btn: ['新增', '取消'],
btn1: function() {
var goods_min_num = $('.sku-info').find('.moq').text(); // 最小起订量
var goods_id = $('.sku-info').find('.goods_id').val();
var type = $('.sku-info').find('.goods_type').val(); // 商品类型
var order_id = $('#order_id').val();
var delivery_place = 1 // 1.大陆,2.香港 自营默认是大陆
var goods_min_price = $('.sku-info').find('.goods-min-price').text(); // 人民币单价
var goods_min_price_us = $('.sku-info').find('.goods-min-price-us').text(); // 美元单价
if (goods_type == 1) { // 联营需要选择交货地
if (type == 3 || type == 4) {
layer.msg('自营商品不能添加到联营订单');
return false;
}
if (delivery_place == 1) {
if (!goods_min_price) {
layer.msg('缺少RMB价格,商品添加失败');
return false;
}
} else if (delivery_place == 2) {
if (!goods_min_price_us) {
layer.msg('缺少美金价格,商品添加失败');
return false;
}
}
} else {
if (type == 1 || type == 2) { // 1.联营 2.专卖
layer.msg('联营商品不能添加到自营订单');
return false;
}
if (!goods_min_price) {
layer.msg('缺少RMB价格,商品添加失败');
return false;
}
}
var datax = {
order_id: order_id,
goods_id: goods_id,
goods_num: goods_min_num,
};
$.ajax({
type: "POST",
url: '/ajax/addGoods',
data: datax,
dataType: "json",
success: function(resp){
if(resp.errcode == 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
return false;
} else {
layer.alert(resp.errmsg || '网络异常');
}
},
})
},
btn2: function(index) {
layer.close(index)
}
})
})
// 获取SKU信息
$('.get-sku').click(function() {
var sku_id = $(this).siblings('.search-sku').val();
if (!sku_id) {
layer.msg('请输入SKU_ID');
return false;
}
if (!/\d/.test(sku_id)) {
layer.msg('参数错误,请输入正确的SKU_ID');
return false;
}
$.ajax({
url: '/ajax/getSku',
type: 'post',
data: {sku_id : sku_id.trim()},
dataType: 'json',
success: function (resp) { console.log(resp)
if (resp.errcode != 0) {
layer.msg(resp.errmsg);
return false;
}
$('.sku-info').show();
var data = resp.data;
var status_val = '';
$('.goods_name').text(data.goods_name);
$('.brand_name').text(data.brand_name);
$('.supplier_name').text(data.supplier_name);
$('.stock').text(data.goods_number);
$('.moq').text(data.min_buy);
$('.mpq').text(data.min_mpq);
// if (goods_type == 1) {
// var status = data.goods_status;
// } else {
// var status = data.status;
// }
// switch (status) {
// case 0: status_val = '待入库'; break;
// case 1: status_val = '审核通过(上架)'; break;
// case 3: status_val = '下架'; break;
// case 4: status_val = '删除'; break;
// }
status_val = data.is_buy ? '是' : '否';
$('.status').text(status_val);
$('.goods_id').val(data.goods_id);
$('.goods_type').val(data.goods_type);
//阶梯价格
if (data.tiered != null) {
var len = data.tiered.length;
if (len > 0) {
var html = '';
html += '<tr><th>阶梯</th><th>RMB价格</th>';
if (data.ac_type) {
switch (data.ac_type) {
case 1: html += '<th>限时限量</th>'; break;
case 2: html += '<th>活动价</th>'; break;
case 3: html += '<th>会员价</th>'; break;
default: html += ''; break;
}
}
if (goods_type == 1 && data.tiered[0]['price_us']) {
html += '<th>USD价格</th>';
}
html += '</tr>';
for (var i = 0; i < len; i++) {
html += '<tr>';
if (i == 0) {
if (data.ac_type) {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price price-line">'+data.tiered[i]['price_cn']+'</span><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span class="goods-min-num">'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="goods-min-price">'+data.tiered[i]['price_cn']+'</span></td>';
}
if (goods_type == 1 && data.tiered[0]['price_us']) {
html += '<td>$<span class="goods-min-price-us">'+data.tiered[i]['price_us']+'</span></td>';
}
} else {
if (data.ac_type) {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span class="price-line">'+data.tiered[i]['price_cn']+'</span></td><td>¥<span>'+data.tiered[i]['price_ac']+'</span></td>';
} else {
html += '<td><span>'+data.tiered[i]['purchases']+'</span></td><td>¥<span>'+data.tiered[i]['price_cn']+'</span></td>';
}
if (goods_type == 1 && data.tiered[0]['price_us']) {
html += '<td>$<span>'+data.tiered[i]['price_us']+'</span></td>';
}
}
html += '</tr>';
}
// $('.ladder_price_table tr:gt(0)').remove();
$('.ladder_price_table').empty().append(html);
}
}
}
})
})
},
}
});
})(jQuery)
......@@ -880,6 +880,70 @@
})
})
//上传图片按扭事件
$(document).on('click', '#upload-contract', function(){
var order_id = $(this).data('id');
var form = $('<form id="formUpload" enctype="multipart/form-data">\
<input type="file" name="upload" accept="application/pdf">\
</form>');
form.appendTo('body');
form.find('input').change(function(){
// 预览图片
var file = this;
var formData = new FormData();
formData.append('upload', this.files[0]);
formData.append('source', 1);
formData.append('k1', k1);
formData.append('k2', k2);
$.ajax({
url : UploadImgUrl+'oss/upload',
type : 'post',
data : formData,
dataType : 'json',
cache : false,
processData: false,
contentType: false,
xhrFields: {withCredentials: true},
success : function(res){
if(res.code == 200){
layer.msg(res.message);
var data = res.data;
$.ajax({
url: '/ajax/uploadContract',
type: 'post',
data: {order_id: order_id, url: data[0]},
dataType: 'json',
success: function(res) {
if (res.errcode == 0) {
location.reload();
return false;
}
layer.msg(res.errmsg);
},
error : function(err){
console.log(err);
}
})
return false;
}
layer.msg(res.message);
},
error : function(err){
console.log(err);
}
})
});
form.find('input[type="file"]').trigger('click');
})
},
//物流信息
......
......@@ -93,7 +93,7 @@
<div class="batch-btn">
<a class="btn btn-success goods_import" data-type="2">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
</div>
</div>
</div>
......
......@@ -228,7 +228,7 @@
<div class="batch-btn">
<a class="btn btn-success goods_import" data-type="2">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
</div>
</div>
</div>
......
......@@ -228,7 +228,7 @@
<div class="batch-btn">
<a class="btn btn-success goods_import" data-type="2">批量导入物料</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E8%AE%A2%E5%8D%95%E6%89%B9%E9%87%8F%E6%B7%BB%E5%8A%A0%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
<a class="btn btn-info" href="http://img.ichunt.com/doc/excel/template/%E8%87%AA%E8%90%A5%E6%89%B9%E9%87%8F%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.csv">自营物料模板下载</a>
</div>
</div>
</div>
......
......@@ -5,7 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | 订单详情</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
{{ Autograph() }}
@include('orderlist.css')
@include('orderlist.js')
</head>
......
<style>
#addGoods{ display: none; }
.search-sku{width: 240px !important;}
.label-prompt{padding: 6px 6px;}
.get-sku{padding: 3px 6px; margin-right: 20px;}
</style>
<div id="addGoods">
<div class="ibox-content">
<div class="row">
<div class="col-sm-12">
<input type="text" class="search-sku" name="sku_id" value="" placeholder="请输入SKUID">
<a class="btn btn-info get-sku">获取SKU信息</a>
<span>快捷入口:<a href="{{ $order_info['order_goods_type'] == 1 ? Config('website.search-sku-url-1') : Config('website.search-sku-url-2')}}" target="_blank">查询SKU</a></span>
</div>
</div>
<!-- SKU信息 -->
<div class="sku-info">
<h4>型号信息</h4>
<div class="sku-info-left">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<span>SKU型号:</span>
<span class="goods_name"></span>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span>制造商:</span>
<span class="brand_name"></span>
</div>
</div>
</div>
<div class="row">
<!-- <div class="col-sm-6">
<div class="form-group">
<span>供应商:</span>
<span class="supplier_name"></span>
</div>
</div> -->
<div class="col-sm-6">
<div class="form-group">
<span>库存数量:</span>
<span class="stock"></span>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span>起订量:</span>
<span class="moq"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<span>标准包装量:</span>
<span class="mpq"></span>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span>状态:</span>
<span class="status"></span>
</div>
</div>
</div>
</div>
<div class="sku-info-right table-responsive">
<table class="table table-hover ladder_price_table">
<tr>
<th>阶梯</th>
<th>RMB价格</th>
</tr>
</table>
</div>
<input type="hidden" name="goods_id" class="goods_id" value="">
<input type="hidden" name="goods_type" class="goods_type" value="">
</div>
</div>
</div>
<script>
var goods_type = "{{ $order_info['order_goods_type'] }}";
var delivery_place = "{{ $order_info['delivery_place'] }}";
</script>
......@@ -88,7 +88,11 @@
@endif
<!-- 调价 -->
<p>调价</p>
<div>
<p style="float: left;">调价</p>
<a class="btn btn-info add_goods" style="float: right; margin-bottom: 5px;">新增商品</a>
</div>
<table class="table table-bordered table-hover order-change-table">
<thead>
<th width="20%">供应商</th>
......@@ -491,6 +495,8 @@
</div>
@endif
@include('detail.addGoods')
<script>
var is_manager = "{{ $role == 1 || $role == 2 || $role == 10 ? true : false }}";
......
......@@ -749,6 +749,11 @@
<a href="javascript:;" data-id="{{$order_info['order_id']}}" data-sn="{{$order_info['order_sn']}}" class="btn btn-success offline-paid">线下转账</a>
@endif
<!-- 回传合同 -->
@if ($order_info['status'] == 2)
<a class="btn btn-warning" id="upload-contract" data-id="{{$order_info['order_id']}}">回传合同</a>
@endif
@if (in_array($order_info['status'], array(4, 7, 8, 10)) && in_array('order_send', $userPerms))
<!-- <a href="{{URL('send', ['order_id'=>$order_info['order_id']])}}" class="btn btn-default">订单发货</a> -->
@endif
......@@ -958,4 +963,5 @@
}
$.lie.order.details();
$.lie.goods.add();
</script>
\ No newline at end of file
......@@ -19,7 +19,8 @@
<div class="droplist" data-default="{{$condition['order_type']}}" id="order_type" name="order_type">
<ul class="dropdown-menu">
<li class="order_type_tab active" data-val="">订单编号</li>
<li class="order_type_tab" data-val="1">会员账号</li>
<li class="order_type_tab" data-val="1">会员账号</li>
<li class="order_type_tab" data-val="4">会员ID</li>
<li class="order_type_tab" data-val="2">型号名称</li>
</ul>
</div>
......@@ -309,14 +310,18 @@
<a class="btn btn-info" href="{{URL('sendSales', ['order_id'=>$v['order_id']])}}" target="_blank">推送</a>
@endif
<?php
?>
@if ($v['status'] > 1 && in_array('download_contract', $userPerms))
<a class="btn btn-default download-contract" data-id="{{$v['order_id']}}" href="javascript:;">下载合同</a>
@endif
<?php
$extend = App\Http\Controllers\getOrderExtend($v['order_id'], 'upload_contract_url');
if (!empty($extend->upload_contract_url)) {
echo '<a class="btn btn-warning" href="'.$extend->upload_contract_url.'" target="_blank">客户合同下载</a>';
}
?>
@if ($v['status'] == -1 && !$v['cancel_reason'])
<a class="btn btn-danger input-cancel-reason" href="javascript:;" data-oid="{{$v['order_id']}}" data-type="4">填写取消原因</a>
@endif
......
......@@ -13,4 +13,5 @@
<script src="/js/orderamount.js"></script>
<script src="/js/plugins/DatePicker/WdatePicker.js"></script>
<script src="/js/refund.js?v=<?= time() ?>"></script>
<script src="/js/goods.js?v=<?= time() ?>"></script>
......@@ -20,6 +20,7 @@
<ul class="dropdown-menu">
<li class="order_type_tab active" data-val="">订单编号</li>
<li class="order_type_tab" data-val="1">会员账号</li>
<li class="order_type_tab" data-val="4">会员ID</li>
<li class="order_type_tab" data-val="2">型号名称</li>
<li class="order_type_tab" data-val="3">发票抬头</li>
</ul>
......
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