Merge branch 'hcy_pcb_20181221-r' into development

parents 2e03f039 17995b8b
......@@ -3,6 +3,10 @@
namespace App\Http\Controllers;
use App\Model\PaymentDaysModel;
use App\Model\Pcb\PcbOrderModel;
use App\Model\Pcb\PcbPublicModel;
use App\Model\Pcb\PcbPurchaseModel;
use App\Model\Pcb\PcbServerModel;
use Illuminate\Http\Request;
use App\Http\Requests;
......@@ -46,4 +50,36 @@ class ApiController extends Controller
$Model=new PaymentDaysModel();
$this->Export($Model->ApiAuthPaymentDays($request->user->userId));
}
//pcb订单列表
private function ApiPcbOrderList($request){
$this->ExportLayui((new PcbOrderModel())->getList());
}
//pcb订单列表导出
private function ApiPcbOrderListExport($request){
((new PcbOrderModel())->export());
}
//pcb客服点击确定发货
private function ApiSendStock($request){
$this->Export((new PcbPublicModel())->orderShipping($request->user->userId,$request->all()));
}
//pcb客服点击转采购
private function ApiAddPurchase($request){
echo (new PcbServerModel())->AddPurchase($request->user->userId,$request->input("order_id"));
}
//pcb客服审核订单,反馈给前台
private function ApiAuditOrder($request){
$this->Export((new PcbPublicModel())->auditOrder($request->user->userId,$request->input("order_id"),$request->input("order_sn"),$request->input("content")));
}
//pcb订单列表
private function ApiPcbPurchaseList($request){
$this->ExportLayui((new PcbPurchaseModel())->getList());
}
//pcb订单列表导出
private function ApiPcbPurchaseListExport($request){
((new PcbPurchaseModel())->export());
}
//pcb后台点击采购确认
private function ApiConfirmOrder($request){
echo (new PcbServerModel())->confirmOrder($request->user->userId,$request->input("purchase_id"));
}
}
......@@ -37,4 +37,12 @@ class RegionController extends Controller
'towns'=> $towns
);
}
//获取省市县名称
public function getRegionName($region_id){
if (empty($region_id)){
return "";
}
$list = DB::connection('order')->table('lie_region')->select("region_name")->where("region_id",$region_id)->get();
return !$list ? "" : current(objectToArray($list))['region_name'];
}
}
\ No newline at end of file
......@@ -208,6 +208,7 @@
$ret .= '<li><a href="#">' . $menus[$actives[0]]->title . '</a></li>';
}
}
return $ret;
}
......@@ -270,4 +271,113 @@
if (!$ret)
$actives = [];
return createMenuReal($menus, $actives, 0);
}
\ No newline at end of file
}
//过滤数据
function TrimX($data='',$empty=true,$arr=false){
if(is_array($data)){
foreach ($data as $k=>$v){
if(!empty($v) && $v!=0 && !is_array($v)){
$data[$k]=trim($v);
}
if($empty==true){
if((empty($v) && $v!=0) || $v=='undefined' || $v==null){
unset($data[$k]);
}
}
if(is_array($arr) && count($arr)>0 && count($data)>0){
if(!in_array($k,$arr)){
unset($data[$k]);
}
}
}
}else{
$data=trim($data);
}
return $data;
}
/**
* 导出CSV文件
* @param array $data 数据
* @param array $header_data 首行数据
* @param string $file_name 文件名称
* @return string
*/
function export_csv($data = [], $header_data = [], $file_name = '')
{
set_time_limit(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename='.$file_name);
header('Cache-Control: max-age=0');
$fp = fopen('php://output', 'a');
if (!empty($header_data)) {
foreach ($header_data as $key => $value) {
$header_data[$key] = iconv('utf-8', 'gbk', $value);
}
fputcsv($fp, $header_data);
}
$num = 0;
$limit = 100000; //每隔$limit行,刷新一下输出buffer,不要太大,也不要太小
$count = count($data); //逐行取出数据,不浪费内存
if ($count > 0) {
for ($i = 0; $i < $count; $i++) {
$num++;
//刷新一下输出buffer,防止由于数据过多造成问题
if ($limit == $num) {
ob_flush();
flush();
$num = 0;
}
$row = $data[$i];
foreach ($row as $key => $value) {
$row[$key] = iconv('utf-8', 'gbk', $value);
}
fputcsv($fp, $row);
}
}
fclose($fp);exit;
}
/*
* 取二维数组某一列的值生成以逗号分隔的字符串,如:$data = ['0'=>['uid'=>'1313','name'=>121],'1'=>['uid'=>'1414','name'=>121]]
转换后变为:arrayTostr($data,'uid') =》1313,1414
* @param array $data 要取值的数组
* @param string $s 下标:如 uid
* @param string $type 类型,1为控制返回null,2 返回数字
* @return str
*/
function arrayToCommaStr($data,$col,$type=''){
switch ($type){
case 1: //如果计算后的值是空,返回空
return array_filter(array_column($data,$col));
break;
case 2:
$arr = array_unique(array_column($data,$col));
return $res = implode(',',$arr);
break;
case 3:
$arr = array_filter(array_column($data,$col));
$res = implode(',',array_map('changeToStr',$arr)); //回调本类中的changeToStr 函数
return $res == "" ? "NULL" : $res;
break;
default:
$arr = array_filter(array_column($data,$col));
$res = implode(',',array_map('changeToStr',$arr)); //回调本类中的changeToStr 函数
return $res;
break;
}
}
/**
* 对象转换数组
*
* @param $e StdClass对象实例
* @return array|void
*/
function objectToArray($e)
{
$e = (array)$e;
foreach ($e as $k => $v) {
if (gettype($v) == 'resource') return;
if (gettype($v) == 'object' || gettype($v) == 'array')
$e[$k] = (array)objectToArray($v);
}
return $e;
}
\ No newline at end of file
<?php
namespace App\map;
class PcbOrderInvoiceMap{
//发票类型 2普通发票 3增值税专用发票 4增值税普通发票',
public static $inv_type=[
"1"=>"不开票",
"2"=>"普通发票",
"3"=>"增值税专用发票",
"4"=>"增值税普通发票",
];
/*
* 开票状态 0待确认 1已开票 2已发货 3已签收
*/
public static $invoice_status = [
'0'=>'待确认',
'1'=>'已开票',
'2'=>'已发货',
'3'=>'已签收',
];
}
\ No newline at end of file
<?php
namespace App\map;
class PcbOrderMap{
//类型 :1付预付款单 2退预付款单 3收款 4付款
//订单状态
public static $status=[
"-1"=>"已取消",
"1"=>"已提交",
"2"=>"采购中",
"3"=>"采购完成待确认",
"4"=>"确认不通过",
"10"=>"待支付",
"11"=>"支付完成",
"12"=>"生产中",
"13"=>"生产完成",
"14"=>"已发货到猎芯",
"15"=>"已发货给客户",
"20"=>"交易完成",
];
/*
* 支付方式
*/
public static $order_pay_type =[
'0'=> "",
'1'=>'微信支付',
'2'=>'支付宝',
'3'=>'银联支付(B2B)',
'4'=>'银联支付(B2C)',
'5'=>'账期支付',
'6'=>'京东支付',
'7'=>'交通银行',
'8'=>'恒生银行',
];
/*
* 类型:1样板 2小批量
*/
public static $order_type = [
'1'=>'样版',
'2'=>'小批量',
];
}
\ No newline at end of file
<?php
namespace App\map;
class PcbOrderShippingMap{
//发货信息:-1 未配送 1 配送中 2 已签
public static $status=[
"-1"=>"未配送",
"1"=>"配送中",
"2"=>"已签",
];
}
\ No newline at end of file
<?php
namespace App\Model\Pcb;
use App\map\PcbOrderMap;
use Illuminate\Database\Eloquent\Model;
use Request;
use DB;
class PcbActionLogModel extends Model
{
protected $connection='pcb';
protected $table='action_log';
protected $primaryKey='id';
public $timestamps = false;
/*
* 插入操作日志
* @param `type` '1 订单 2 采购单 ',
* @param `action` '操作 增删改查',
* @param `content` '操作内容',
* @param `remark` '操作备注',
* @param `oid` 关联ID
* @param `uid` '操作用户id',
* @param `user_name` '操作用户名称',
* @return
*/
static function log($type,$action="",$content="",$remark="",$oid = 0,$uid = 0){
$data['type'] = $type ;
$data['action'] = $action ;
$data['content'] = is_array($content) ? json_encode($content,JSON_UNESCAPED_UNICODE) : $content;
$data['remark'] = $remark;
$data['uid'] = $uid;
$data['oid'] = $oid;
$data['user_name'] = (new PcbPublicModel())->getAdminName($uid);
$data['create_time'] = time();
return self::insert($data);
}
}
\ No newline at end of file
<?php
namespace App\Model\Pcb;
use App\map\PcbOrderMap;
use Illuminate\Database\Eloquent\Model;
use Request;
use DB;
class PcbOrderModel extends Model
{
protected $connection='pcb';
protected $table='order';
protected $primaryKey='id';
public $timestamps = false;
//列表
public function getList($type =1)
{
$arr = ['p', 'limit','self','start_time','end_time','status',"user_account","order_sn","purchase_sn","order_type","adtag","ptag"];
$input = Request::only($arr);
$input=TrimX($input,true,$arr);
// //查询数据\
$list = $this->where(function ($query) use ($input) {
$PcbPurchaseModel = new PcbPurchaseModel();
foreach ($input as $k => $v){
$v = trim($v);
switch ($k){
case "p":
case "limit":
case "_url":
continue;
break;
case "start_time":
$query->where('create_time', '>=', strtotime($v));
break;
case "end_time":
$query->where('create_time', '<=',strtotime($v));
break;
case "end_time":
$query->where('create_time', '<=',strtotime($v));
break;
case "purchase_sn":
$items = $PcbPurchaseModel->select("order_id")->where("purchase_sn","like","%".$v."%")->get();
if ($items->count()){
$orderIds = arrayToCommaStr($items->toArray(),'order_id',1);
$query->whereIn("order_id",$orderIds);
}else{
$query->where("order_id",0);
}
break;
default:
$query->whereIn($k, explode(',',trim($v,',')));
break;
}
}
})->orderBy('order_id','desc');
//getSql();
if ($type == 1){
$list = $list->paginate($input['limit'], ['*'], 'p', $input['p'])->toArray();
if (!$list) return [20001, '没有数据'];
$data = $this->clearData($list['data']);
return [0, '成功', $data, $list['total']];
}else{
return $this->clearData($list->get()->toArray());
}
}
//清洗列表数据
private function clearData($data){
if (!is_array($data) || count($data) == 0 || $data == ""){
return [];
}
$PcbPurchaseModel = new PcbPurchaseModel();
foreach ($data as $k=>&$v){
//查询采购
$puchase = $PcbPurchaseModel->where("order_id",$v['order_id'])->first();
$v['tiaojia']=$v['purchase_amount'] = $v['purchase_sn'] = "";
if ($puchase){
if ( $puchase['purchase_amount'] > 0 && $puchase['purchase_amount'] != $v['order_amount']){
$v['tiaojia'] = "是";
}else{
$v['tiaojia'] = "否";
}
$v['purchase_amount'] = $puchase['purchase_amount'] > 0 ? $puchase['purchase_amount'] : "";
$v['purchase_sn'] = $puchase['purchase_sn'];
}
$v['order_pay_type'] = PcbOrderMap::$order_pay_type[$v['order_pay_type']];
$v['order_type'] = PcbOrderMap::$order_type[$v['order_type']];
$v['status_name'] = PcbOrderMap::$status[$v['status']];
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
return $data;
}
//导出
public function export()
{
$data = $this->getList(2);
$column = array('ID','会员账号','交易订单编号','采购订单编号','是否调价','订单金额','调整后订单金额','订单状态','订单类型','支付方式','下单时间'); // 表头
$fileName = 'PCB交易订单列表导出'.date('YmdHis', time()).'.csv';
$temp = [];
foreach ($data as $k=>$v){
array_push($temp,[
'order_id'=>$v['order_id'],
'user_account' =>$v['user_account']."\n",
'order_sn' =>$v['order_sn']."\n",
'purchase_sn' =>@$v['purchase_sn']."\n",
'tiaojia' =>$v['tiaojia'],
'order_amount' =>$v['order_amount'],
'purchase_amount' =>$v['purchase_amount'],
'status_name' =>$v['status_name'],
'order_type' =>$v['order_type'],
'order_pay_type' =>$v['order_pay_type'],
'create_time' =>$v['create_time'],
]);
}
export_csv($temp, $column, $fileName);
}
}
\ No newline at end of file
<?php
namespace App\Model\Pcb;
use Request;
use DB;
class PcbPublicModel
{
/*
* 插入后台客服审核结果
*/
public function auditOrder($audit_uid,$order_id,$order_sn,$remark,$type = 1){
$con = DB::connection('pcb');
$data = [
'audit_uid'=>$audit_uid,
'order_id'=>$order_id,
'order_sn'=>$order_sn,
'type'=>$type,
'remark'=>$remark,
'create_time'=>time(),
];
$in = $con->table("order_audit_reason")->insert($data);
if ($in){
PcbActionLogModel::log(1,'order_admin_exmine',"后台审核确认订单","",$order_id,$audit_uid);
return [0,'成功'];
}else{
return [1001,'失败'];
}
}
/*
* 查询后台用户名称
*/
public function getAdminName($userId=''){
if(empty($userId)) return "";
$result=DB::table("user_info")->where('userId','=',$userId)->select('userId','name','email')->first();
if(!$result) return "";
$result=objectToArray($result);
empty($result['name']) && $result['name']=$result['email'];
return $result['name'];
}
/*
* 插入后台客服审核结果
*/
public function orderShipping($user_id,$data){
$con = DB::connection('pcb');
$datas = [
'shipping_type'=>1,
'relevance_id'=>$data['order_id'],
'relevance_sn'=>$data['order_sn'],
'shipping_no'=>$data['shipping_no'],
'shipping_name'=>$data['shipping_name'],
'shipping_id'=>$data['shipping_id'],
'status'=>1,
'update_time'=>time(),
];
$shippingCon = $con->table("shipping");
$checkHave =$shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->first();
if ($checkHave){
$in = $shippingCon->where(['relevance_id'=>$data['order_id'],'shipping_type'=>1])->update($datas);
}else{
$data['create_time'] = time();
$in = $shippingCon->insert($datas);
}
if ($in){
PcbActionLogModel::log(1,'admin_add_shipping',"后台填写发货信息","",$data['order_id'],$user_id);
return [0,'成功'];
}else{
return [1001,'失败'];
}
}
}
\ No newline at end of file
<?php
namespace App\Model\Pcb;
use App\map\PcbOrderMap;
use Illuminate\Database\Eloquent\Model;
use Request;
use DB;
class PcbPurchaseModel extends Model
{
protected $connection='pcb';
protected $table='purchase';
protected $primaryKey='id';
public $timestamps = false;
//列表
public function getList($type =1)
{
$arr = ['p', 'limit','self','start_time','end_time','status',"user_account","order_sn","purchase_sn","order_type","adtag","ptag"];
$input = Request::only($arr);
$input=TrimX($input,true,$arr);
// //查询数据\
$list = $this->where(function ($query) use ($input) {
foreach ($input as $k => $v){
$v = trim($v);
switch ($k){
case "p":
case "limit":
case "_url":
continue;
break;
case "start_time":
$query->where('create_time', '>=', strtotime($v));
break;
case "end_time":
$query->where('create_time', '<=',strtotime($v));
break;
default:
$query->whereIn($k, explode(',',trim($v,',')));
break;
}
}
})->orderBy('purchase_id','desc');
//getSql();
if ($type == 1){
$list = $list->paginate($input['limit'], ['*'], 'p', $input['p'])->toArray();
if (!$list) return [20001, '没有数据'];
$data = $this->clearData($list['data']);
return [0, '成功', $data, $list['total']];
}else{
return $this->clearData($list->get()->toArray());
}
}
//清洗列表数据
private function clearData($data){
if (!is_array($data) || count($data) == 0 || $data == ""){
return [];
}
foreach ($data as $k=>&$v){
//查询采购
if ($v['purchase_amount'] > 0){
$v['tiaojia'] = $v['purchase_amount'] != $v['order_amount'] ? "是" :"否"; //是否调价
}else{
$v['tiaojia'] = $v['purchase_amount'] = "";
}
$v['order_pay_type'] = PcbOrderMap::$order_pay_type[$v['order_pay_type']];
$v['order_type'] = PcbOrderMap::$order_type[$v['order_type']];
$v['status_name'] = PcbOrderMap::$status[$v['status']];
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
return $data;
}
//导出
public function export()
{
$data = $this->getList(2);
$column = array('ID','会员账号','交易订单编号','采购订单编号','是否调价','订单金额','调整后订单金额','订单状态','订单类型','支付方式','下单时间'); // 表头
$fileName = 'PCB采购列表导出'.date('YmdHis', time()).'.csv';
$temp = [];
foreach ($data as $k=>$v){
array_push($temp,[
'order_id'=>$v['order_id'],
'user_account' =>$v['user_account']."\n",
'order_sn' =>$v['order_sn']."\n",
'purchase_sn' =>@$v['purchase_sn']."\n",
'tiaojia' =>$v['tiaojia'],
'order_amount' =>$v['order_amount'],
'purchase_amount' =>$v['purchase_amount'],
'status_name' =>$v['status_name'],
'order_type' =>$v['order_type'],
'order_pay_type' =>$v['order_pay_type'],
'create_time' =>$v['create_time'],
]);
}
export_csv($temp, $column, $fileName);
}
}
\ No newline at end of file
<?php
namespace App\Model\Pcb;
use Request;
use DB;
class PcbServerModel
{
public $PcbUrl ;
public function __construct()
{
$this->PcbUrl = config("website.api_domain");
}
/*
* 转采购
* @param int $admin_id 管理员id
* @param int $order_id 订单id
*/
public function AddPurchase($admin_id,$order_id){
$param = [
'admin_id'=> $admin_id ,
'order_id'=>$order_id,
];
$res = curlApi($this->PcbUrl.'/pcb/adminapi/addPurchase',$param,'POST');
return $res;
}
/*
*
* @param int $admin_id 管理员id
* @param int $order_id 订单id
*/
public function confirmOrder($admin_id,$purchase_id){
$param = [
'purchase_id'=> $purchase_id ,
];
$res = curlApi($this->PcbUrl.'/pcb/adminapi/confirmOrder',$param,'POST');
$json = json_decode($res);
if ($json['err_code'] == 0){
PcbActionLogModel::log(1,'confirm_order',"采购确认","",$purchase_id,$admin_id);
}
return $res;
}
}
\ No newline at end of file
......@@ -83,7 +83,18 @@ return [
'prefix' => '',
'strict' => false,
],
'pcb' => [
'driver' => 'mysql',
'host' => env('DB_HOST_PCB', ''),
'database' => env('DB_DATABASE_PCB', ''),
'username' => env('DB_USERNAME_PCB', ''),
'password' => env('DB_PASSWORD_PCB', ''),
'port' => env('DB_PORT_PCB', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
......
<?php
return [
'liexin_info'=>[
'company_name'=>'猎芯科技', //收货人
'contact'=>'待定', //联系方式
'address_shipping'=>'广东深圳龙岗区万科星火online', //收货地址
'tax_type'=>'增值税专用发票', //发票类型
'tax_head'=>'深圳市猎芯科技', //发票抬头
'address_reg'=>'广东深圳龙岗区万科星火',//公司注册地址
'tax_no'=>'914403006748459155 ',//税务登记号
'phone'=>'0755-83005999',//公司电话
'bank_name'=>'中国工商银行深圳华联支行',//开户银行
'bank_account'=>'4000021609200128449',//银行卡号
],
'joint_addr' => '深圳市龙岗区坂田五和大道南2号万科星火online六栋三楼猎芯科技', // 联营自提地址
'self_addr' => '深圳市光明新区新湖街道楼村社区荔都路32号A栋三楼', // 自营自提地址
......
......@@ -10,7 +10,7 @@ return [
'search'=> 'http://' . env('LOGIN_DOMAIN', '') . '/api/search',
],
'domain' => 'liexin.net',
'domain' => 'liexin.com',
// 订单系统
'order_url' => 'http://order.liexin.net',
......
layui.use(['table','form','element','layer', 'laydate'], function() {
var table = layui.table;
var element = layui.element;
var form = layui.form;
var laydate = layui.laydate;
})
//客服添加审核意见
function AuditOrder() {
alert_confirm("确定填写此审核结果?",function () {
$.ajax({
url:'/api/ApiAuditOrder',
type:'post',
data:{"order_id":$("#order_id").val(),'order_sn':$("#order_sn").val(),'content':$("#content").val()},
async: false,
dataType:'json',
timeout:10000,
success:function (res) {
if(res.errcode == 0){
alert_succ(res.errmsg,function () {
window.location.reload()
})
}else{
alert_err(res.errmsg)
}
}
})
})
return false;
}
//转采购
function AddPurchase() {
alert_confirm("确定填写此订单转采购?",function () {
$.ajax({
url:'/api/ApiAddPurchase',
type:'post',
data:{"order_id":$("#order_id").val()},
async: false,
dataType:'json',
timeout:10000,
success:function (res) {
if(res.err_code == 0){
alert_succ(res.err_msg,function () {
window.location.href = "/web/PcbPurchaseList"
})
}else{
alert_err(res.errmsg)
}
}
})
})
return false;
}
layui.use(['table','form','element','layer', 'laydate'], function() {
var table = layui.table;
var element = layui.element;
var form = layui.form;
var laydate = layui.laydate;
setTimeout(function () {
table.render({
elem: '#list'
,url:'/api/ApiPcbOrderList'
,method:'post'
,cellMinWidth: 100 //全局定义常规单元格的最小宽度
,request: {
pageName: 'p' //页码的参数名称,默认:page
,limitName: 'limit' //每页数据量的参数名,默认:limit
}
,where: {start_time: $("input[name='start_time']").val(), end_time: $("input[name='end_time']").val()} //如果无需传递额外参数,可不加该参数
,loading:true
,first: true //不显示首页
,last: false //不显示尾页
,id:'Abnormal'
,cols: [[
{field:'order_id', title: 'ID',width:120,align:'center'}
,{field:'user_account', title: '会员账号',width:160,align:'center'}
,{field:'order_sn', title: '交易订单编号',width:160,align:'center'}
,{field:'purchase_sn', title: '采购订单编号',width:160,align:'center'}
,{field:'tiaojia', title: '是否调价',width:160,align:'center'}
,{field:'order_amount', title: '订单金额',width:160,align:'center'}
,{field:'purchase_amount', title: '调整后订单金额',width:160,align:'center'}
,{field:'status_name', title: '订单状态',width:160,align:'center'}
,{field:'order_type', title: '订单类型',width:160,align:'center'}
,{field:'order_pay_type', title: '支付方式',width:160,align:'center'}
,{field:'create_time', title: '下单时间',width:160,align:'center'}
,{field:'adtag', title: 'adtag',width:160,align:'center'}
,{field:'ptag', title: 'ptag',width:160,align:'center'}
,{field:'cahe', title: '操作',templet:'#cahe',width:150,align:'center', fixed: 'right'}
]]
,page:{ }
,done: function(res, curr, count) {
// 若无数据,则禁用导出按钮
if (!count) {
$('.export').addClass('layui-disabled');
} else {
$('.export').removeClass('layui-disabled');
}
}
});
},500)
form.on('submit(load)', function(data){
form.render();
var data=data.field;
//执行重载
table.reload('Abnormal', {
page: {
curr: 1
}
,where: data
});
return false;
});
form.on('checkbox(*)', function(data){
var order_type='';
var status='';
$('input:checkbox:checked').each(function(){
var obj=$(this).data('type');
if(obj=='order_type'){
order_type +=$(this).val()+',';
}
if(obj=='status'){
status +=$(this).val()+',';
}
})
$("input[name=order_type]").val(order_type);
$("input[name=status]").val(status);
});
element.on('collapse(where)', function(data){
if(data.show==true){
$(data.title).html('查询条件 (点击收起)<i class="layui-icon layui-colla-icon"></i>');
}else{
$(data.title).html('查询条件 (点击展开)<i class="layui-icon layui-colla-icon"></i>');
}
});
// 导出
$('.export').click(function(){
if ($(this).hasClass('layui-disabled')) {
return false;
}
layer.confirm('确定导出数据吗?', {
title: '导出数据'
,btn: ['确定', '取消']
}, function(){
var url = '/api/ApiPcbOrderListExport?';
var forms = $('#form1').serializeArray();
var data = {};
$.each(forms, function (i, v) {
url = url+"&"+v['name']+"="+ v['value'];
});
layer.closeAll('dialog'); // 确定时关闭弹框
window.location.href = url;
return false;
});
return false;
})
laydate.render({
elem: '#start_time',
type: 'datetime'
,format:'yyyy-MM-dd HH:mm:ss'
//,value: new Date(Date.parse(new Date()) - three_month_timestamp)
,isInitValue: false
});
laydate.render({
elem: '#end_time'
,type:'datetime'
,format:'yyyy-MM-dd HH:mm:ss'
// ,value: new Date()
,isInitValue: false
});
//发起采购
form.on('submit(SendPurchase)',(function (data) {
$("#sure_order_id").val($(this).attr("order_id"))
$("#sure_order_sn").val($(this).attr("order_sn"))
layer.open({
type: 1,
title:"请录入如下信息并确认发货给客户",
skin: 'layui-layer-rim', //加上边框
area: ['420px', '260px'], //宽高
content: $("#sendPurchase")
});
}))
//关闭订单
form.on('submit(ClosePurchase)',(function () {
var picking_id = $(this).attr('picking_id')
alert_confirm("确定关闭此采购单?",function () {
var res = ajax("/api/ApiClosePurchase",{"picking_id":picking_id,"type":1});
if(res.errcode == 5001){
alert_confirm(res.errmsg,function () {
var res1 = ajax("/api/ApiClosePurchase",{"picking_id":picking_id,"type":2});
res1.errcode > 0 ? alert_err(res1.errmsg) : alert_succ(res1.errmsg,function () {
window.location.reload();
});
})
}else if(res.errcode ==0){
alert_succ(res.errmsg)
}else{
alert_err(res.errmsg)
}
})
}))
})
//确定发货
function SendStock() {
$.ajax({
url:'/api/ApiSendStock',
type:'post',
data:{"order_id":$("#sure_order_id").val(),"order_sn":$("#sure_order_sn").val(),"shipping_no":$("#shipping_no").val(),"shipping_id":$("#shipping_id").val(),"shipping_name":$("#shipping_id").find("option:selected").text(),},
async: false,
dataType:'json',
timeout:10000,
success:function (res) {
if(res.errcode == 0){
alert_succ(res.errmsg,function () {
window.location.href='/web/PcbOrderList';
})
}else{
alert_err(res.errmsg)
}
}
})
}
//转采购
function AddPurchase(order_id) {
alert_confirm("确定填写此订单转采购?",function () {
$.ajax({
url:'/api/ApiAddPurchase',
type:'post',
data:{"order_id":order_id},
async: false,
dataType:'json',
timeout:10000,
success:function (res) {
if(res.err_code == 0){
alert_succ(res.err_msg,function () {
window.location.href = "/web/PcbPurchaseList"
})
}else{
alert_err(res.errmsg)
}
}
})
})
return false;
}
layui.use(['table','form','element','layer', 'laydate'], function() {
var table = layui.table;
var element = layui.element;
var form = layui.form;
var laydate = layui.laydate;
setTimeout(function () {
table.render({
elem: '#list'
,url:'/api/ApiPcbPurchaseList'
,method:'post'
,cellMinWidth: 100 //全局定义常规单元格的最小宽度
,request: {
pageName: 'p' //页码的参数名称,默认:page
,limitName: 'limit' //每页数据量的参数名,默认:limit
}
,where: {start_time: $("input[name='start_time']").val(), end_time: $("input[name='end_time']").val()} //如果无需传递额外参数,可不加该参数
,loading:true
,first: true //不显示首页
,last: false //不显示尾页
,id:'Abnormal'
,cols: [[
{field:'purchase_id', title: 'ID',width:120,align:'center'}
,{field:'user_account', title: '会员账号',width:160,align:'center'}
,{field:'order_sn', title: '交易订单编号',width:160,align:'center'}
,{field:'purchase_sn', title: '采购订单编号',width:160,align:'center'}
,{field:'tiaojia', title: '是否调价',width:160,align:'center'}
,{field:'order_amount', title: '订单金额',width:160,align:'center'}
,{field:'purchase_amount', title: '调整后订单金额',width:160,align:'center'}
,{field:'status_name', title: '订单状态',width:160,align:'center'}
,{field:'order_type', title: '订单类型',width:160,align:'center'}
,{field:'order_pay_type', title: '支付方式',width:160,align:'center'}
,{field:'create_time', title: '下单时间',width:160,align:'center'}
,{field:'cahe', title: '操作',templet:'#cahe',width:150,align:'center', fixed: 'right'}
]]
,page:{ }
,done: function(res, curr, count) {
// 若无数据,则禁用导出按钮
if (!count) {
$('.export').addClass('layui-disabled');
} else {
$('.export').removeClass('layui-disabled');
}
}
});
},500)
form.on('submit(load)', function(data){
form.render();
var data=data.field;
//执行重载
table.reload('Abnormal', {
page: {
curr: 1
}
,where: data
});
return false;
});
form.on('checkbox(*)', function(data){
var order_type='';
var status='';
$('input:checkbox:checked').each(function(){
var obj=$(this).data('type');
if(obj=='order_type'){
order_type +=$(this).val()+',';
}
if(obj=='status'){
status +=$(this).val()+',';
}
})
$("input[name=order_type]").val(order_type);
$("input[name=status]").val(status);
});
element.on('collapse(where)', function(data){
if(data.show==true){
$(data.title).html('查询条件 (点击收起)<i class="layui-icon layui-colla-icon"></i>');
}else{
$(data.title).html('查询条件 (点击展开)<i class="layui-icon layui-colla-icon"></i>');
}
});
// 导出
$('.export').click(function(){
if ($(this).hasClass('layui-disabled')) {
return false;
}
layer.confirm('确定导出数据吗?', {
title: '导出数据'
,btn: ['确定', '取消']
}, function(){
var url = '/api/ApiPcbPurchaseListExport?';
var forms = $('#form1').serializeArray();
var data = {};
$.each(forms, function (i, v) {
url = url+"&"+v['name']+"="+ v['value'];
});
layer.closeAll('dialog'); // 确定时关闭弹框
window.location.href = url;
return false;
});
return false;
})
laydate.render({
elem: '#start_time',
type: 'datetime'
,format:'yyyy-MM-dd HH:mm:ss'
//,value: new Date(Date.parse(new Date()) - three_month_timestamp)
,isInitValue: false
});
laydate.render({
elem: '#end_time'
,type:'datetime'
,format:'yyyy-MM-dd HH:mm:ss'
// ,value: new Date()
,isInitValue: false
});
})
//确定发货
function SurePurchase(purchase_id) {
alert_confirm("采购已完成,请确认是否通过审核?",function () {
$.ajax({
url:'/api/ApiConfirmOrder',
type:'post',
data:{"purchase_id":purchase_id},
async: false,
dataType:'json',
timeout:10000,
success:function (res) {
if(res.err_code == 0){
alert_succ(res.errmsg,function () {
window.location.href='/web/Abnormal';
})
}else{
alert_err(res.errmsg)
}
}
})
})
}
......@@ -123,4 +123,47 @@ function date(format, timestamp){
}
return ret;
});
}
//tips 提示
function alert_tip(msg,callback) {
layer.msg(msg,{icon:6});
}
//提示成功
function alert_succ(msg,callback) {
if (!callback || typeof callback == 'undefined' || callback == undefined){
layer.alert(msg,{icon:1,title:'提示信息'},function (index) {
layer.close(index);
})
}else{
layer.alert(msg,{icon:1,title:'提示信息'},function (index) {
layer.close(index);
callback();
})
}
}
//提示失败
function alert_err(msg,callback) {
if (!callback || typeof callback == 'undefined' || callback == undefined){
layer.alert(msg,{icon:2,title:'提示信息'},function (index) {
layer.close(index);
})
}else{
layer.alert(msg,{icon:2,title:'提示信息'},function (index) {
layer.close(index);
callback();
})
}
}
//确认弹框,点击确认回调函数
function alert_confirm(msg,callback){
if (!callback || typeof callback == 'undefined' || callback == undefined){
layer.confirm(msg,{icon:3,title:'提示信息'},function (index) {
layer.close(index);
})
}else{
layer.confirm(msg,{icon:3,title:'提示信息'},function (index) {
layer.close(index);
callback();
})
}
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | 首页</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
<link href="/js/layui/css/layui.css" rel="stylesheet">
@include('index.css')
<style>
label{
width: 100px !important;
}
.red{
color: red;
}
.float-r{
float: right;
}
</style>
</head>
<body class="">
<div id="wrapper">
@include('layouts.navigation')
<div id="page-wrapper" class="gray-bg">
<div class="row">
<div class="wrapper">
@include('layouts.header')
<div class="page-content">
<div class="row-fluid ibox-content">
@include("Pcb.$id")
</div>
</div>
</div>
</div>
</div>
</div>
@include('index.js')
<script src="/js/layui/layui.js"></script>
<script src="/js/common.min.js"></script>
@if(empty($into))
<script src="/js/{{$id}}.js?{{time()}}"></script>
@endif
</body>
<form class="layui-form" id="form1">
<div class="layui-collapse layui-box" lay-filter="where">
<div class="layui-colla-item">
<h2 class="layui-colla-title" style="margin: 0">查询条件 (点击收起)</h2>
<div class="layui-colla-content layui-show">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">下单时间:</label>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="start_time" id="start_time" placeholder="开始时间" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="end_time" id="end_time" placeholder="结束时间" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">会员账号:</label>
<div class="layui-input-inline">
<input type="text" name="user_account" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">交易订单编号:</label>
<div class="layui-input-inline">
<input type="text" name="order_sn" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">采购订单编号:</label>
<div class="layui-input-inline">
<input type="text" name="purchase_sn" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">订单状态:</label>
<div class="layui-input-inline">
<div class="layui-input-inline payment-status" style="width: 800px !important;">
<input type="hidden" name="status" value="">
@if(!empty($status) && is_array($status))
@foreach($status as $k=>$v)
<input type="checkbox" lay-filter="*" data-type="status" value="{{$k}}" title="{{$v or '未知'}}" >
@endforeach
@endif
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">订单类型:</label>
<div class="layui-input-inline payment-status">
<input type="hidden" name="order_type" value="">
@if(!empty($order_type) && is_array($order_type))
@foreach($order_type as $k=>$v)
<input type="checkbox" lay-filter="*" data-type="status" value="{{$k}}" title="{{$v or '未知'}}" >
@endforeach
@endif
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">adtag:</label>
<div class="layui-input-inline">
<input type="text" name="adtag" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">ptag:</label>
<div class="layui-input-inline">
<input type="text" name="ptag" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
</div>
</div>
</div>
</div>
<div style="margin-top: 10px">
<div style="float: left;">
<button class="layui-btn" lay-submit="" lay-filter="load">立即查询</button>
<button type="reset" class="layui-btn layui-btn-primary">重置条件</button>
<button class="layui-btn export" >导出</button>
</div>
</div>
</form>
<table class="layui-table" lay-filter="test" id="list"></table>
<script type="text/html" id="cahe">
<a href="/web/PcbOrderDetail?order_id=@{{ d.order_id }}" class="btn btn-xs btn-outline btn-success"><strong>详情</strong></a>
@{{# if(d.status==1){ }}
<button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" onclick="AddPurchase(@{{ d.order_id }})">发起采购</button>
@{{# } }}
@{{# if(d.status==14){ }}
<button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.order_id }}" order_sn="@{{ d.order_sn }}" lay-filter="SendPurchase">发货</button>
@{{# } }}
</script>
<!--弹出层-->
<div id="sendPurchase" style="display: none">
<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;配送快递:&nbsp;&nbsp;
<select type='text' style='width: 200px;height: 30px;' id="shipping_id">
<?php foreach($shipping as $k=>$v){ ?>
<option value="<?= $v['shipping_id']; ?>"><?= $v['shipping_name']; ?></option>
<?php } ?>
</select><br/><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;快递单号:&nbsp;&nbsp;<input type='text' id="shipping_no" style='width: 200px;height: 30px;' ><br/><br/>
<input type='hidden' id='sure_order_id'> <input type='hidden' id='sure_order_sn'>
&nbsp;&nbsp;&nbsp;&nbsp;<button class='layui-btn' onclick='SendStock()' style="margin-left: 130px;">确定发货</button>
</div>
<form class="layui-form" id="form1">
<div class="layui-collapse layui-box" lay-filter="where">
<div class="layui-colla-item">
<h2 class="layui-colla-title" style="margin: 0">查询条件 (点击收起)</h2>
<div class="layui-colla-content layui-show">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">下单时间:</label>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="start_time" id="start_time" placeholder="开始时间" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline" style="width: 200px;">
<input type="text" name="end_time" id="end_time" placeholder="结束时间" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">会员账号:</label>
<div class="layui-input-inline">
<input type="text" name="user_account" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">交易订单编号:</label>
<div class="layui-input-inline">
<input type="text" name="order_sn" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">采购订单编号:</label>
<div class="layui-input-inline">
<input type="text" name="purchase_sn" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">订单状态:</label>
<div class="layui-input-inline payment-status" style="width: 800px !important;">
<input type="hidden" name="status" value="">
@if(!empty($status) && is_array($status))
@foreach($status as $k=>$v)
<input type="checkbox" lay-filter="*" data-type="status" value="{{$k}}" title="{{$v or '未知'}}" >
@endforeach
@endif
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">订单类型:</label>
<div class="layui-input-inline payment-status">
<input type="hidden" name="order_type" value="">
@if(!empty($order_type) && is_array($order_type))
@foreach($order_type as $k=>$v)
<input type="checkbox" lay-filter="*" data-type="status" value="{{$k}}" title="{{$v or '未知'}}" >
@endforeach
@endif
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">adtag:</label>
<div class="layui-input-inline">
<input type="text" name="adtag" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">ptag:</label>
<div class="layui-input-inline">
<input type="text" name="ptag" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
</div>
</div>
</div>
</div>
<div style="margin-top: 10px">
<div style="float: left;">
<button class="layui-btn" lay-submit="" lay-filter="load">立即查询</button>
<button type="reset" class="layui-btn layui-btn-primary">重置条件</button>
<button class="layui-btn export" >导出</button>
</div>
</div>
</form>
<table class="layui-table" lay-filter="test" id="list"></table>
<script type="text/html" id="cahe">
<a href="/web/PcbPurchaseDetail?purchase_id=@{{ d.purchase_id }}&order_id=@{{ d.order_id }}" class="btn btn-xs btn-outline btn-success"><strong>详情</strong></a>
@{{# if(d.status==3){ }}
<button class="btn btn-xs btn-outline btn-danger" lay-submit="" order_id="@{{ d.purchase_id }}" order_sn="@{{ d.purchase_sn }}" onclick="SurePurchase(@{{ d.purchase_id }})">采购确认</button>
@{{# } }}
</script>
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