Commit 71c07223 by 朱继来

fix

parents 5dc2dbba a3c6eed7
......@@ -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
......@@ -10,8 +10,11 @@ use App\Model\Pcb\PcbOrderModel;
use App\Model\Pcb\PcbPublicModel;
use App\Model\Pcb\PcbPurchaseModel;
use App\Model\Pcb\PcbServerModel;
<<<<<<< HEAD
use App\Model\KefuModel;
use App\Model\CmsModel;
=======
>>>>>>> a3c6eed77aa83c025c32e53d0229d4c09a152309
class ApiController extends Controller
{
......
......@@ -16,6 +16,7 @@ use App\Model\OrderModel;
use App\Model\UserMainModel;
use App\Model\OrderActionLogModel;
use App\Model\OrderReturnModel;
use App\Model\OrderItemsTrackModel;
// 获取订单优惠券金额
function getCoupon($order_id)
......@@ -285,6 +286,17 @@ function getOrderExtend($order_id, $field="*", $where=array())
return $extend;
}
// 获取订单跟踪
function getLastTrack($rec_id)
{
$OrderItemsTrackModel = new OrderItemsTrackModel;
$track = $OrderItemsTrackModel->getLastItemTrack($rec_id);
if (!$track) return false;
return $track['track_content'].',数量:'.$track['track_num'];
}
Class OrderController extends Controller
{
// 首页
......@@ -1705,6 +1717,38 @@ 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 getOrderItemsTrack(Request $request)
{
if ($request->isMethod('post')) {
$rec_id = $request->input('rec_id');
$OrderItemsTrackModel = new OrderItemsTrackModel;
$data = $OrderItemsTrackModel->getOrderItemsTrack($rec_id);
return ['errcode'=>0, 'errmsg'=>'成功', 'data'=>$data];
}
}
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,10 @@ 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');
Route::post('/ajax/getOrderItemsTrack', 'OrderController@getOrderItemsTrack');
});
// 不需要登陆态
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderItemsTrackModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_items_track';
protected $primaryKey = 'track_items_id';
protected $guarded = ['amount_id'];
public $timestamps = true;
const CREATED_AT = 'create_time';
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取最新的明细跟踪
public function getLastItemTrack($rec_id)
{
return $this->where('rec_id', $rec_id)->select('track_items_id', 'order_id', 'track_content', 'track_num', 'create_name', 'create_time')->orderBy('create_time', 'desc')->first();
}
// 获取所有明细跟踪
public function getOrderItemsTrack($rec_id)
{
return $this->where('rec_id', $rec_id)->select('track_items_id', 'order_id', 'track_content', 'track_num', 'create_name', 'create_time')->orderBy('create_time', 'desc')->get();
}
}
\ No newline at end of file
......@@ -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']);
}
......
......@@ -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) {
......
......@@ -756,6 +756,46 @@
})
})
// 查看订单明细跟踪
$('.order-track').click(function () {
var rid = $(this).data('rid');
$.ajax({
url : '/ajax/getOrderItemsTrack',
type: 'post',
data: {rec_id : rid},
success: function(resp) {
if (resp.errcode == 0) {
var data = resp.data;
var content = '<table class="table">\
<tr>\
<th width="30%">时间</th>\
<th>说明</th>\
<th width="13%">负责人</th>\
</tr>';
for (var i = 0; i < data.length; i++) {
content += '<tr><td>'+data[i].create_time+'</td><td>'+data[i].track_content+',数量:'+data[i].track_num+'</td><td>'+data[i].create_name+'</td></tr>';
}
content += '</table>';
layer.open({
title: '订单明细跟踪',
area: ['600px', '400px'],
content: content,
btn: [],
})
} else {
layer.alert(resp.errmsg || '网络异常');
}
},
error: function(err) {
console.log(err);
}
})
})
// 点击物流展开
$('.click-down').click(function() {
$(this).parents('tbody').find('.other-infos').show();
......@@ -880,6 +920,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 }}";
......
......@@ -476,6 +476,10 @@
<th>供应商</th>
@endif
@if ($order_info['order_goods_type'] == 1)
<th>生产跟踪</th>
@endif
<?php
if ($action_name == 'changeOrder' && count($order_items_info) > 1 && in_array($order_info['status'], [1, 2])) {
echo '<th>操作</th>';
......@@ -516,6 +520,10 @@
<td>{{$v['supplier_name']}}</td>
@endif
@if ($order_info['order_goods_type'] == 1)
<th><a class="order-track" data-rid="{{$v['rec_id']}}">{{ App\Http\Controllers\getLastTrack($v['rec_id']) }}</a></th>
@endif
@if ($action_name == 'changeOrder' && count($order_items_info) > 1 && in_array($order_info['status'], [1, 2]))
<td><a class="btn btn-danger deletegoods" href="javascript:;" data-id="{{$v['rec_id']}}">删除</a></td>
@endif
......@@ -749,6 +757,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 +971,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