<?php
/*
* [JINYUN!] (C)2001-2099 Jinyunweb.com
* This is NOT a freeware, use is subject to license terms
*商品管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$manage_op=array('confirm','cancel','agree','disagree');
if(in_array($_RQ['op'],$manage_op)){
$id=intval($_RQ['id']);
if(!$id){
exi('请先选择商品!','error');
}
}
$return=array();
$tabs=array(
array('op'=>'edit','title'=>'添加商品_ADD Goods'),
);
$return['status']=array('0'=>'下架','1'=>'上架','2'=>'售罄','3'=>'回收站');
//上架商品
if($_RQ['op']=='list'){
$params=array();
$params['uniacid']=$_SESSION['uniacid'];
$params['status']='1';
if(!empty($_RQ['title'])){
$params['title like']='%'.trim($_RQ['title']).'%';
$return['params']['title']=$_RQ['title'];
}
if(!empty($_RQ['pcate'])){
$params['pcate']=intval($_RQ['pcate']);
$this->session('pcate',intval($_RQ['pcate']));
$return['params']['pcate']=intval($_RQ['pcate']);
}
$tip='【温馨提示】:所属商户如果为“无”,表示商户已经不存在!排序,越大越靠前!<red>商品价格解释:如果门店设置了商品价格,将以门店价格为准!规格的库存,价格也是以门店的为准!</red>';
$onepluginname=$this->model('goods')->is_onegoods($_SESSION['current_plugin'],$_RQ['pluginname']);
if($onepluginname){//开启独立商品
pdo_update('jy_weishop_goods',array('onepluginname'=>$onepluginname),array('pluginname'=>$onepluginname,'onepluginname'=>'','uniacid'=>$_SESSION['uniacid']));
$params['onepluginname']=$onepluginname;
$return['params']['onepluginname']=$onepluginname;
$tip .='</br><red>【注意】:如果本场景已开启独立商品展示,将只显示本场景下的商品!</red>';
}else{
$params['onepluginname']='';
$tip .='</br><red>【注意】:如果本场景已开启独立商品展示,将剔除其他独立场景的商品!</red>';
}
$install = check_permission('jy_poster');
if(!$install){
$tip .='</br><red>【注意】:还未安装《活动海报》!商品详情不显示生成海报按钮!</red>';
}
$tip .='</br>【<red>一键更新商品权限</red>】:是指新版多选权限格式的更新(之前是单选)</br>[温馨提示]:设为公共分类后,该分类其他场景共享!';
$pc_set=$this->plugin_setting('pc_set');
$substrlength=8;
if($pc_set['is_en']==1){
$tip='';
$substrlength=20;
}
$pindex = max(1, intval($_RQ['page']));
$psize = 10;
if($_RQ['num']){
$psize=$_RQ['num'];
}
$total='';
$fields=array('id','merchid','pluginname','star','uniacid','paixu','title','image','pcate','ccate','price','status','createtime','total','salenum','unit','saletype');
$list=pdo_getslice('jy_weishop_goods',$params,array($pindex,$psize),$total,$fields,'','paixu desc,star desc, saletype desc, id desc');
if($list){
if($this->plugin_exists('jy_merch')){
$jy_merch=true;
}
foreach($list as &$item){
$item['title']=cfc('tools')->substr($item['title'],0,$substrlength);
$item['pcatetitle']=pdo_getcolumn('jy_weishop_goods_group',array('id'=>$item['pcate']),'title');
$item['ccatetitle']=pdo_getcolumn('jy_weishop_goods_group',array('id'=>$item['ccate']),'title');
$item['url']=custom_url('jy_weishop/goods.detail//id='.$item['id'],true);
$item['salenum2']=$this->pdo_getsum('order_goods',array('goodsid'=>$item['id']),'total')?:0;
if($jy_merch){
$merch=pdo_get('jy_merch_user',array('id'=>$item['merchid'],'uniacid'=>$_SESSION['uniacid']),array('id','merchname','logo','salecate'));
}
$item['merchname']=$merch['merchname']?:'';
$item['merchlogo']=$merch['logo'];
$item['salecate']=$merch['salecate']?:'';
if($pc_set['is_en']==1){
$shopset=$this->plugin_setting('shopset');
$item['merchname']=$merch['merchname']?:$shopset['title'];
$item['salecate']=$merch['salecate']?:'NO';
$item['salenum2']=$item['salenum']?:$item['salenum2'];
$item['pcatetitle']=$item['pcatetitle']?:$shopset['title'];
$item['ccatetitle']=$item['ccatetitle']?:'NO';
$item['unit']=$item['unit']?'/'.$item['unit']:'/A';
}else{
$item['merchname']=$merch['merchname']?:'平台自营';
$item['salecate']=$merch['salecate']?:'无';
$item['unit']=$item['unit']?'/'.$item['unit']:'/件';
$item['pcatetitle']=$item['pcatetitle']?$item['pcatetitle']:'无';
$item['ccatetitle']=$item['ccatetitle']?$item['ccatetitle']:'无';
}
if($item['salenum']>=10000){
$wans=$item['salenum']/10000;
$wans=sprintf('%.1f',$wans);
$item['salenum']=$wans.'万';
}
}
}
$return['list']=$list;
$totalpage=ceil($total/$psize);
$totalpage=intval($totalpage);
$return['totalpage'] =$totalpage;
$return['params']['page'] =$pindex;
$htmls=array(
'type'=>'list',
'tabs'=>$tabs,
'list'=>array('data'=>'list','tip'=>$tip,'edit'=>true,'del_one'=>true,'delall'=>true,'list'=>array(
array('name'=>'paixu','title'=>'排序_The sorting','type'=>'string'),
array('name'=>'star','title'=>'星数_Star','type'=>'star','set'=>'star'),
array('type'=>'img_string','title'=>'所属商户_Merch title',
'data'=>array(
array('title'=>'名称:_Merch:','name'=>'merchname'),
array('title'=>'项目:_Cate:','name'=>'salecate')
)
),
array('type'=>'img_string','title'=>'商品名称_Goods title','img'=>'image',
'data'=>array(
array('title'=>'','name'=>'title'),
//array('title'=>'价格:¥','name'=>'price')
)
),
array('type'=>'img_string','title'=>'商品分类_Goods group',
'data'=>array(
array('title'=>'一级:_Level 1:','name'=>'pcatetitle'),
array('title'=>'二级:_Level 2:','name'=>'ccatetitle')
)
),
array('type'=>'img_string','title'=>'库存/销量_Inventory/Sales',
'data'=>array(
array('title'=>'库存:_Inventory:','name'=>'total'),
array('title'=>'销量:_Sales:','name'=>'salenum2','unit'=>'unit')
)
),
array('name'=>'price','title'=>'价格(点击编辑↓)_Price','type'=>'string','set'=>'set'),
//array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
array('name'=>'saletype','title'=>'商品属性_attribute','type'=>'checkbox','options'=>'saletypes'),
array('name'=>'url','title'=>'复制链接_Copy Link','type'=>'copy'),
),'action'=>array(
array('type'=>'href','action'=>'activity.buyagain.list','title'=>'设置活动_Set activity'),
),'batch'=>array(
array('type'=>'post','url'=>'jy_weishop/goods.list/setstatus0/','title'=>'一键下架_Shelves'),
array('type'=>'post','url'=>'jy_weishop/goods.list/setstatus2/','title'=>'一键售罄_Sold out'),
array('type'=>'post','url'=>'jy_weishop/goods.list/setstatus3/','title'=>'一键加入回收站_Recycle'),
array('type'=>'post','url'=>'jy_weishop/goods.list/upgoods/','title'=>'一键更新商品权限_Upgoods'),
array('type'=>'post','url'=>'jy_weishop/goods.list/uplegao/','title'=>'设为公共商品_Uplegao'),
)),
'search'=>array(
array('name'=>'title','width'=>15,'type'=>'string','title'=>'商品名称_Goods'),
array('name'=>'pcate','width'=>15,'type'=>'select','title'=>'商品分类_Groups','options'=>'groups'),
array('name'=>'saletype','width'=>15,'type'=>'radio','title'=>'属性_Saletype','options'=>'saletypes'),
)
);
$groupspram=array('uniacid'=>$_SESSION['uniacid'],'mid'=>0,'isshow'=>1,'parentid'=>0);
$onepluginname=$this->model('goods')->is_onegoods($_SESSION['current_plugin'],$_RQ['pluginname']);
if($onepluginname){//开启独立商品
$groupspram['onepluginname']=$onepluginname;
$return['params']['onepluginname']=$onepluginname;
}else{
$groupspram['onepluginname']='';
}
$return['groups']=pdo_getall('jy_weishop_goods_group',$groupspram,array('id','title'),'id');
$return['type']=$this->goods_types;
$return['saletypes']=$this->saletypes;
$return['htmls']=$htmls;
if($this->plugin_exists('jy_merch')){
$merchs=pdo_getall('jy_merch_user',array('uniacid