v1.0

parent 5b9f3348
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Jobs\JopExportAbnormlList;
use App\Jobs\JopExportGoodsList;
use App\Jobs\JopExportOrderList;
use App\Model\CommonModel;
......@@ -61,9 +62,11 @@ class ApiController extends Controller
private function ApiOrderDetail($request, $id){
(new ServerPurModel($request->appid,$request->key))->OrderDetail($request->input());
}
//退货列表
//退货列表(寄售)
private function ApiAbnormalList($request, $id){
(new ServerPurModel($request->appid,$request->key))->AbnormalList($request->input());
$data = $request->input();
$data['picking_type'] = 2; //寄售类型
(new ServerPurModel($request->appid,$request->key))->AbnormalList($data);
}
//退货详情
private function ApiAbnormalDetail($request, $id){
......@@ -71,7 +74,12 @@ class ApiController extends Controller
}
//退货列表导出
private function ApiAbnormalListExport($request, $id){
ExportModel::ApiAbnormalListExport($request);
$data= $request->input();
$data['picking_type'] = 2; //寄售类型
$id = (new UploadLogModel())->addLog($request->account_id,1,$data);
if(!$id) return Export(20003,'任务推送失败');
dispatch(new JopExportAbnormlList($id));
Export(0,$id);
}
//获取对账单列表
private function ApiAccountCheckingList($request, $id){
......
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Jobs\JopExportAbnormlList;
use App\Jobs\JopExportGoodsList;
use App\Jobs\JopExportOrderList;
use App\Jobs\PreSaleOrder;
......@@ -92,7 +93,7 @@ class HandleController extends Controller
}
private function c(){
$s = (new JopExportOrderList($_GET['id']))->handle();
$s = (new JopExportAbnormlList($_GET['id']))->handle();
print_r($s);
die();
echo dispatch(new JopExportOrderList($_GET['id']));
......
<?php
namespace App\Jobs;
use App\Jobs\Job;
use App\Model\ExportModel;
use App\Model\Server\ServerPurModel;
use App\Model\SupplierAccountModel;
use App\Model\UploadLogModel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Storage;
use RedisDB;
use DB;
class JopExportAbnormlList extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
private $id;
public function __construct($id)
{
$this->id=$id;
}
/**
* Execute the job.
* @return void
*/
public function handle()
{
$UploadLogModel=new UploadLogModel();
$LogInfo=$UploadLogModel->LogInfo($this->id);
$log = json_decode($LogInfo['log'],true);
$query = json_decode($LogInfo['remark'],true);
$UploadLogModel->UpdateLogArr($this->id,'开始处理任务',1,$log);
#建立临时文件
$filename=date('Y-m-d-H-i-s') . '-' . uniqid() . '.csv';
$filePath = storage_path().DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$filename;
$x=fopen($filePath,'a'); //不存在则创建
$Arr = ['退货单号','创建单时间','金额','状态','币种','商品编码','型号','品牌','封装','包装方式','MPQ','数量','单价']; // 表头
foreach ($Arr as $k=>$v){
$Arr[$k]=iconv('utf-8','gbk//IGNORE',$v);
}
fputcsv($x,$Arr); //写入表头
#导出查询数据
$account = (new SupplierAccountModel())->select("appid","key")->where("id",$LogInfo['create_uid'])->first();
$query['p'] = 1;
$query['limit'] = 1000;
$res = (new ServerPurModel($account->appid,$account->key,$LogInfo['extend']))->AbnormalDetail($query,2);
if (!count($res['data']) ){
$UploadLogModel->UpdateLogArr($this->id,'没有数据',3,$log);
return true;
}
$count = ceil($res['count']/1000);
for ($p = 1; $p < $count + 1; $p++) {
sleep(1);
$query['p'] = $p;
$query['limit'] = 1000;
$list = (new ServerPurModel($account->appid,$account->key,$LogInfo['extend']))->AbnormalDetail($query,2);
if ($list['code'] > 0){
break;
}
foreach ($list['data'] as $k=>&$v){
$out = [
'abnormal_sn'=>$v['abnormal_sn'],
'create_time'=>$v['create_time'],
'withdraw_amount'=>$v['withdraw_amount'],
'status'=>$v['status'],
'currency'=>$v['currency'],
'supplier_goods_id'=>$v['supplier_goods_id'],
'goods_name'=>$v['goods_name'],
'supplier_brand_name'=>$v['supplier_brand_name'],
'encap'=>$v['encap'],
'packing_id'=>$v['packing_id'],
'mpq'=>$v['mpq'],
'real_number'=>$v['real_number'],
'initial_price'=>$v['initial_price'],
];
foreach ($out as $k1=>&$v1){
$v1= iconv('utf-8', 'gbk', $v1);
}
fputcsv($x,$out);
}
}
$UploadFileModel=new UploadLogModel();
$Url=$UploadFileModel->SaveDownFile($filename);
fclose($x);
unlink($filePath);
if(!$Url){
$UploadLogModel->UpdateLogArr($this->id,'导出失败',3,$log);
return true;
}else{
$UploadLogModel->where('id',$this->id)->update(['file_path'=>$Url]);
$UploadLogModel->UpdateLogArr($this->id,'任务完成',2,$log,['file_path'=>$Url]);
return true;
}
}
}
;!function () {
var ids = []; //选择的ids
var table_data = [];
window.app = {
init: function () {
app.tableList(1);
//搜索
$("#search").click(function () {
app.tableList(1);
})
//导出
$("#export").click(function () {
exportUrl('/api/ApiAbnormalListExport','form1','确定导出数据?')
})
//下单时间选择
layui.laydate.render({
elem: '.order-time-1',
theme: '#1080d0'
});
layui.laydate.render({
elem: '.order-time-2',
theme: '#1080d0'
});
},
//列表数据查询
tableList: function (page) {
var postData = {
'p':page,
'abnormal_sn':$("input[name='abnormal_sn']").val(),
'goods_name':$("input[name='goods_name']").val(),
'status':$("input[name='status']").val(),
'create_time1':$("input[name='create_time1']").val(),
'create_time2':$("input[name='create_time2']").val(),
}
var res = ajax_push(URL_YUNXIN + '/api/ApiAbnormalList',postData)
if (res.code == 0) {
var html = "";
if(res.data.length > 0) {
for (i = 0; i < res.data.length; i++) {
var s = res.data[i];
html += "<tr class=\"you\"> " +
"<td><span class=\"t1\">"+s.abnormal_sn+"</span></td>" +
"<td><span class=\"t1\">"+s.create_time+"</span></td>" +
"<td><span class=\"t1\">"+s.currency+"</span></td>" +
"<td><span class=\"t1\">"+s.status+"</span></td>" +
"<td><span class=\"t1\">"+s.amount+"</span></td>" +
"<td><a href=\"/web/AbnormalDetail?id="+s.abnormal_id+"\" class=\"lineBlock va-m operation-1\"><i class=\"iconfont icon-mingxi-\"></i><em>明细</em></a></td></tr>"
}
}else{
html = "<tr class=\"you\"><td colspan='9' style='text-align: center;'><span class=\"t1\" style='color: #cccccc'>没有数据</span></td></tr>";
}
init: function () {
app.tableList();
$("#shopListContent").html(html)
layui.laypage.render({
elem: 'pagination',
theme: '#1080d0',
count: res.count,
groups:10,
curr: page,
jump:function (obj, first) {
if(!first){
app.tableList(obj.curr)
}
//刷新列表
$("#search").click(function () {
app.tableList()
})
//重置表单
$("#reset").click(function () {
$('#form1')[0].reset()
})
//导出
$("#export").click(function () {
app.export()
})
//下单时间选择
layui.laydate.render({
elem: '.order-time-1',
theme: '#1080d0'
});
layui.laydate.render({
elem: '.order-time-2',
theme: '#1080d0'
});
},
tableList:function () {
layui.table.render({
elem: '#list'
,url:'/api/ApiAbnormalList'
,method:'post'
,cellMinWidth: 100 //全局定义常规单元格的最小宽度
,request: {
pageName: 'p' //页码的参数名称,默认:page
,limitName: 'limit' //每页数据量的参数名,默认:limit
}
});
} else {
alert_err(res.msg)
return false;
}
,where: formJson('form1')
,loading:true
,first: true //不显示首页
,last: false //不显示尾页
,cols: [[
{field:'abnormal_sn', title: '退货单号',align:'center'}
,{field:'create_time', title: '创建时间',align:'center'}
,{field:'currency', title: '币种',align:'center'}
,{field:'amount', title: '金额',align:'center'}
,{field:'status', title: '状态',align:'center'}
,{field:'cahe', title: '操作',templet:'#cahe',width:80,align:'center', fixed: 'right'}
]]
,id:'Abnormal'
,page:{
}
,done: function(res, curr, count) {
table_data=res.data;
}
});
},
export:function (){ //商品列表导出
common_export('/api/ApiAbnormalListExport',formJson('form1'))
}
}, $(function () {
app.init();
})
}();
\ No newline at end of file
}();
......@@ -17,6 +17,15 @@
$("#export").click(function () {
app.export()
})
//下单时间选择
layui.laydate.render({
elem: '.order-time-1',
theme: '#1080d0'
});
layui.laydate.render({
elem: '.order-time-2',
theme: '#1080d0'
});
},
tableList:function () {
layui.table.render({
......@@ -39,7 +48,7 @@
,{field:'currency', title: '结算币种',align:'center'}
,{field:'pay_type', title: '结算方式',align:'center'}
,{field:'status', title: '付款状态',align:'center'}
,{field:'cahe', title: '操作',templet:'#cahe',width:50,align:'center', fixed: 'right'}
,{field:'cahe', title: '操作',templet:'#cahe',width:80,align:'center', fixed: 'right'}
]]
,id:'Abnormal'
,page:{
......
......@@ -2,7 +2,7 @@
<div class="tit-bar">
<a href="">订单管理</a>
<span>&gt;</span>
<a href="">退货列表</a>
<a href="/web/AbnormalList">退货列表</a>
<span>&gt;</span>
<a class="text" href="">{{ $title }}</a>
</div>
......
<div class="lx-content-r fr">
<div class="tit-bar">
<a href="">库存管理</a>
<a href="">订单管理</a>
<span>&gt;</span>
<a class="text" href="">订单列表</a>
<a class="text" href="/web/AbnormalList">退货列表</a>
</div>
<div class="con-section shop-list">
<p class="text">订单列表</p>
<form action="">
<p class="text">退货列表</p>
<form action="" id="form1">
<div class="search-bar">
<div class="lineBlock input-inline va-m">
<label class="tag">退货单号:</label>
<input type="text" class="inp w180" name="order_sn" >
<input type="text" class="inp w180" name="abnormal_sn" >
</div>
<div class="lineBlock input-inline va-m">
<label class="tag">型号:</label>
......@@ -44,21 +44,13 @@
</div>
</div>
</form>
<div class="table-list" id="shopList">
<table>
<tr>
<th>退货单号<b></b></th>
<th>创建时间<b></b></th>
<th>币种<b></b></th>
<th>金额<b></b></th>
<th>状态<b></b></th>
<th>操作</th>
</tr>
<tbody id="shopListContent">
</tbody>
</table>
<div class="table-list" id="shopList">
<table class="layui-table" lay-filter="test" id="list"></table>
</div>
<div class="pagination-with" id="pagination"></div>
<script type="text/html" id="cahe">
<a class="btn btn-xs btn-outline btn-danger" href="/web/AbnormalDetail?id=@{{ d.abnormal_id }}" >明细</a>
</script>
</div>
</div>
......@@ -2,7 +2,7 @@
<div class="tit-bar">
<a href="">订单管理</a>
<span>&gt;</span>
<a href="">订单列表</a>
<a href="/web/OrderList">订单列表</a>
<span>&gt;</span>
<a class="text" href="">{{ $title }}</a>
</div>
......
......@@ -28,7 +28,7 @@
</div>
<div class="lineBlock input-inline va-m">
<label class="tag">下单时间:</label>
<input type="text" name="create_time1" class="inp w120 order-time-1" lay-key="1">
<input type="text" name="create_time1" class="inp w120 order-time-1" lay-key="1">
<span class="lineBlock va-m line">~</span>
<input type="text" name="create_time2" class="inp w120 order-time-2" lay-key="2">
</div>
......@@ -57,7 +57,7 @@
</div>
<script type="text/html" id="cahe">
<a class="btn btn-xs btn-outline btn-danger" href="/web/OrderDetail?id=@{{ d.goods_id }}" >明细</a>
<a class="btn btn-xs btn-outline btn-danger" href="/web/OrderDetail?id=@{{ d.order_id }}" >明细</a>
</script>
</div>
......
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