更新联营物料

parent e4c488cc
......@@ -177,6 +177,10 @@ class ApiController extends Controller
Export(2,"没完成");
}
}
//商品列表
private function ApiSkuList($request){
ExportLayui2((new ServerFoostoneModel($request->appid,$request->key))->SkuList($request->input(),2));
}
//批量上传联营物料
private function ApiUploadSkuList($request,$id){
$res = (new UploadLogModel())->uploadSkuFile($request->appid,$request->key,$request->mobile,$request->account_id);
......
......@@ -1166,6 +1166,9 @@ function getHostUrl($sys,$current_domain='')
if($current_domain === "yunxin.liexin.com")
{
return Config('yunxin_conf.'.$sys.'.local');
}elseif ($current_domain === "yunxin.liexin.net")
{
return Config('yunxin_conf.'.$sys.'.local');
}elseif ($current_domain === "yunxin.ichunt.com")
{
return Config('yunxin_conf.'.$sys.'.release');
......
......@@ -21,6 +21,7 @@ class JopExportGoodsComList extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
private $id;
const limit = 100; //分页条数
public function __construct($id)
{
$this->id=$id;
......@@ -31,6 +32,7 @@ class JopExportGoodsComList extends Job implements ShouldQueue
*/
public function handle()
{
set_time_limit(0);
$UploadLogModel=new UploadLogModel();
$LogInfo=$UploadLogModel->LogInfo($this->id);
......@@ -50,8 +52,8 @@ class JopExportGoodsComList extends Job implements ShouldQueue
fputcsv($x,$Arr); //写入表头
#查询es数据
$s = [
'p'=>1,
'offset'=>1000,
'is_scroll'=>1, //游标
'offset'=>self::limit,
'supplier_id'=>17,
'canal/condition'=>$query['supplier_com_code'],
];
......@@ -62,47 +64,87 @@ class JopExportGoodsComList extends Job implements ShouldQueue
$searchArr = (new ServerEsModel())->searchSku($s);
$total = @$searchArr['data']['total'];
if (@$searchArr['error_code'] > 0 || !count($total) ){
$UploadLogModel->UpdateLogArr($this->id,'没有数据',3,$log);
$UploadLogModel->UpdateLogArr($this->id,'1001:没有数据',3,$log);
return true;
}
$ServerEsModel = new ServerEsModel();
$ServerMicModel = new ServerMicModel();
$count = ceil($total/1000);
for ($p = 1; $p < $count + 1; $p++) {
sleep(1);
$query['p'] = $p;
$query['limit'] = 1000;
$searchArr = $ServerEsModel->searchSku($s);
if ($searchArr['error_code'] > 0){
break;
}
$p = [
'goods_id'=>$searchArr['data']['goods_id']
$count = ceil($total/self::limit); //总页数
#先写入第一页
$micData = [
'goods_id'=>$searchArr['data']['goods_id']
];
$res = $ServerMicModel->synchronization($micData,2);
if ($res['code'] > 0){
$UploadLogModel->UpdateLogArr($this->id,'1002:没有数据',3,$log);
return true;
}
foreach ($res['data'] as $k=>&$v){
if(!$v) continue;
$out = [
'goods_id'=>$k."\t",
'goods_name'=>@$v['goods_name'],
'goods_type_name'=> @GoodsMap::$goods_type[$v['goods_type']],
'supplier_name'=>@$v['supplier_name'],
'brand_name'=>@$v['brand_name'],
'canal'=>@$v['canal'],
'encoded'=>@$v['encoded'],
'stock'=>@$v['stock'],
'goods_status_name'=>@GoodsMap::$status[$v['goods_status']],
'expire'=>@GoodsMap::$expire[$v['status']],
'update_time'=>timeToDate($v['update_time']),
];
$res = $ServerMicModel->synchronization($p,2);
foreach ($res['data'] as $k=>&$v){
$out = [
'goods_id'=>$k,
'goods_name'=>$v['goods_name'],
'goods_type_name'=> GoodsMap::$goods_type[$v['goods_type']],
'supplier_name'=>$v['supplier_name'],
'brand_name'=>$v['brand_name'],
'canal'=>$v['canal'],
'encoded'=>$v['encoded'],
'stock'=>$v['stock'],
'goods_status_name'=>GoodsMap::$status[$v['goods_status']],
'expire'=>GoodsMap::$expire[$v['status']],
'update_time'=>timeToDate($v['update_time']),
foreach ($out as $k1=>&$v1){
$v1= iconv('utf-8', 'gbk', $v1);
}
fputcsv($x,$out);
}
if ($count > 1) {
for ($i=2; $i<=$count; $i++) {
sleep(1);
$s['scroll_id'] = $searchArr['data']['scroll_id'];
$s['limit'] = self::limit;
$searchArr = $ServerEsModel->searchSku($s);
if ($searchArr['error_code'] > 0){
$UploadLogModel->UpdateLogArr($this->id,'1003:没有数据',3,$log);
return true;
}
$micData = [
'goods_id'=>$searchArr['data']['goods_id']
];
foreach ($out as $k1=>&$v1){
$v1= iconv('utf-8', 'gbk', $v1);
$res = $ServerMicModel->synchronization($micData,2);
if ($res['code'] > 0){
$UploadLogModel->UpdateLogArr($this->id,'1004:没有数据',3,$log);
return true;
}
foreach ($res['data'] as $k=>&$v){
if(!$v) continue;
$out = [
'goods_id'=>$k."\t",
'goods_name'=>@$v['goods_name'],
'goods_type_name'=> @GoodsMap::$goods_type[$v['goods_type']],
'supplier_name'=>@$v['supplier_name'],
'brand_name'=>@$v['brand_name'],
'canal'=>@$v['canal'],
'encoded'=>@$v['encoded'],
'stock'=>@$v['stock'],
'goods_status_name'=>@GoodsMap::$status[$v['goods_status']],
'expire'=>@GoodsMap::$expire[$v['status']],
'update_time'=>timeToDate($v['update_time']),
];
foreach ($out as $k1=>&$v1){
$v1= iconv('utf-8', 'gbk', $v1);
}
fputcsv($x,$out);
}
fputcsv($x,$out);
}
}
$UploadFileModel=new UploadLogModel();
$Url=$UploadFileModel->SaveDownFile($filename);
fclose($x);
......
......@@ -66,7 +66,7 @@ class ServerMicModel
];
$res = $this->synchronization($p,2);
foreach ($res['data'] as $k=>&$v){
$v['goods_id'] = $k;
$v['goods_id'] = sprintf("%s", $k);;
$v['update_time'] = timeToDate($v['update_time']);
$v['goods_status_name'] = GoodsMap::$status[$v['goods_status']];
$v['expire'] = GoodsMap::$expire[$v['status']];
......
......@@ -3,11 +3,11 @@
namespace App\Model;
use App\Jobs\UploadChangePrice;
use App\Map\UploadLogMap;
use App\Model\Server\ServerFoostoneModel;
use Illuminate\Database\Eloquent\Model;
use RedisDB;
use Request;
use App\map\UploadLogMap;
use Illuminate\Support\Facades\Storage;
use DB;
......@@ -29,6 +29,7 @@ class UploadLogModel extends Model
//查数据
$list=$this->where('type',$type)->where("create_uid",$create_uid)->orderBy('id','desc')->paginate($limit,['*'],'p',$p)->toArray();
$data = $list['data'];
if ($type == UploadLogMap::type_import_sku){
//如果是联营sku导入,查询状态
$ids = arrayToCommaStr($data,'extend',1);
......
......@@ -37,6 +37,10 @@
,loading:true
,first: true //不显示首页
,last: false //不显示尾页
,page:layui.laypage.render({
'prev':"上一页",
"layout":['prev', 'next']
})
,cols: [[
{field:'goods_id', title: '商品ID',width:190,align:'center',templet: function(d){
return d.goods_id
......@@ -47,6 +51,7 @@
{field:'brand_name', title: '制造商',align:'center'},
{field:'canal', title: '渠道标签',align:'center'},
{field:'goods_images', title: '图片',align:'center',templet: function(d){
return ""
if(d.goods_images == ""){
return d.goods_images
}else{
......
......@@ -65,7 +65,7 @@ function common_export(url,data) {
alert_err(res.msg)
return false;
}
layer.msg('后台正在导出,请别关闭页面并耐心等待...', {
layer.msg('后台正在导出,如果数据量过多需要几分钟,请别关闭网页并耐心等待...', {
icon: 16
,time:0
,shade: 0.6
......
......@@ -40,7 +40,7 @@
<span>查询</span>
</a>
</div>
<a href="" style="color:red">下载导入模板</a>
<a href="http://img.ichunt.com/doc/excel/template/%E4%BA%91%E8%8A%AF%E8%81%94%E8%90%A5sku%E4%B8%8A%E4%BC%A0%E6%A8%A1%E6%9D%BF.csv" style="color:red">下载导入模板</a>
<div class="lineBlock input-inline va-m" id="BatchAdd">
<a href="javascript:;" class="export-btn">
<i class="iconfont icon-daochu-"></i>
......
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