diff --git a/core/model/system.php b/core/model/system.php
index e11480e..6d169a3 100644
--- a/core/model/system.php
+++ b/core/model/system.php
@@ -1378,6 +1378,10 @@ class System_EweiShopV2Model
array(
'title'=>'其他',
'items'=>array(
+ array(
+ 'title'=>'网培服务设置',
+ 'route'=>'wpfw'
+ ),
array(
'title'=>'会员设置',
'route'=>'member'
diff --git a/core/model/wpfw.php b/core/model/wpfw.php
new file mode 100644
index 0000000..04902e3
--- /dev/null
+++ b/core/model/wpfw.php
@@ -0,0 +1,60 @@
+getSysset("wpfwset");
+ }
+ $wpset = pdo_fetch("select * from " . tablename('ewei_shop_good_wpfw') . ' where deleted=0 and goods_id=:goods_id and uniacid=:uniacid Limit 1', array(':goods_id' => $goods_id, ':uniacid' => $_W['uniacid']));
+ if(empty($wpset)){
+ return array('wpfw_url'=>$sysset['default_url'],'wpfw_api_key'=>$sysset['api_key']);
+ }else{
+ return array('wpfw_url'=>$wpset['url'],'wpfw_api_key'=>$wpset['api_key']);
+ }
+ }
+ public function good_set_wpset($goods_id,$url,$api_key)
+ {
+ global $_W,$_GPC;
+ $data = array("goods_id" => intval($goods_id),"url" => $url,"api_key" => $api_key,'uniacid'=>$_W['uniacid']);
+ $wpset = pdo_fetch("select * from " . tablename('ewei_shop_good_wpfw') . ' where goods_id=:goods_id and uniacid=:uniacid Limit 1', array(':goods_id' => $goods_id, ':uniacid' => $_W['uniacid']));
+
+ if(!empty($wpset['id'])){
+ pdo_update("ewei_shop_good_wpfw", $data, array("id" => $wpset['id']));
+ }else{
+ pdo_insert("ewei_shop_good_wpfw", $data);
+ }
+ }
+ public function good_del_wpset($goods_id)
+ {
+ global $_W;
+ if(empty($sysset)){
+ $sysset = m("common")->getSysset("wpfwset");
+ }
+ $wpset = pdo_fetch("select * from " . tablename('ewei_shop_good_wpfw') . ' where goods_id=:goods_id and uniacid=:uniacid Limit 1', array(':goods_id' => $goods_id, ':uniacid' => $_W['uniacid']));
+ if(!empty($wpset)){
+ pdo_delete("ewei_shop_good_wpfw", array("uniacid" => $_W["uniacid"], "goods_id" => intval($goods_id)));
+ }
+
+ }
+
+}
diff --git a/core/web/goods/post.php b/core/web/goods/post.php
index d2d6b6c..4170fd6 100644
--- a/core/web/goods/post.php
+++ b/core/web/goods/post.php
@@ -1,55 +1,53 @@
0),array('id'=>$id));
-
+if (!empty($id)) {
+ pdo_update('ewei_shop_goods', array('newgoods' => 0), array('id' => $id));
}
-$item = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_goods') . " WHERE id = :id and uniacid = :uniacid", array(':id' => $id,':uniacid'=>$_W['uniacid']));
+$item = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_goods') . " WHERE id = :id and uniacid = :uniacid", array(':id' => $id, ':uniacid' => $_W['uniacid']));
-$item['isdiscount_time'] = date('Y-m-d H:i',$item['isdiscount_time']);
-$item['isdiscount_time_start'] = date('Y-m-d H:i',$item['isdiscount_time_start']);
+$item['isdiscount_time'] = date('Y-m-d H:i', $item['isdiscount_time']);
+$item['isdiscount_time_start'] = date('Y-m-d H:i', $item['isdiscount_time_start']);
-if(!empty($item)&&$item['type']==5&&!empty($item['opencard'])&&!empty($item['cardid']))
-{
- $card = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_goods_cards') . " WHERE id = :id and uniacid = :uniacid", array(':id' => $item['cardid'],':uniacid'=>$_W['uniacid']));
+if (!empty($item) && $item['type'] == 5 && !empty($item['opencard']) && !empty($item['cardid'])) {
+ $card = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_goods_cards') . " WHERE id = :id and uniacid = :uniacid", array(':id' => $item['cardid'], ':uniacid' => $_W['uniacid']));
}
-if(p('offic')){
+if (p('offic')) {
$item['officthumb'] = set_medias($item['officthumb']);
}
$status = $item['status'];
-if(json_decode($item['labelname'],true)){
- $labelname = json_decode($item['labelname'],true);
-}else{
+if (json_decode($item['labelname'], true)) {
+ $labelname = json_decode($item['labelname'], true);
+} else {
$labelname = unserialize($item['labelname']);
}
$endtime = empty($item['endtime']) ? date('Y-m-d H:i', time()) : date('Y-m-d H:i', $item['endtime']);
-$item['statustimestart'] = $item['statustimestart']>0 ? $item['statustimestart'] : time();
-$item['statustimeend'] = $item['statustimeend']>0 ? $item['statustimeend'] : strtotime('+1 month');
+$item['statustimestart'] = $item['statustimestart'] > 0 ? $item['statustimestart'] : time();
+$item['statustimeend'] = $item['statustimeend'] > 0 ? $item['statustimeend'] : strtotime('+1 month');
//解密
-$intervalprices =iunserializer($item['intervalprice']);
+$intervalprices = iunserializer($item['intervalprice']);
-if(empty($labelname)){
+if (empty($labelname)) {
$labelname = array();
}
-foreach($labelname as $key => $value){
+foreach ($labelname as $key => $value) {
$label[$key]['id'] = $value;
$label[$key]['labelname'] = $value;
}
@@ -88,68 +86,68 @@ if ($ccard_plugin) {
$ccard = 1;
}
-$category = m('shop')->getFullCategory(true,true);
+$category = m('shop')->getFullCategory(true, true);
$levels = m('member')->getLevels();
-foreach($levels as &$l){
- $l['key'] ='level'.$l['id'];
+foreach ($levels as &$l) {
+ $l['key'] = 'level' . $l['id'];
}
unset($l);
-$levels =array_merge(array(
+$levels = array_merge(array(
array(
- 'id'=>0,
- 'key'=>'default',
- 'levelname'=>empty($_W['shopset']['shop']['levelname'])?'默认会员':$_W['shopset']['shop']['levelname']
+ 'id' => 0,
+ 'key' => 'default',
+ 'levelname' => empty($_W['shopset']['shop']['levelname']) ? '默认会员' : $_W['shopset']['shop']['levelname']
)
-),$levels);
+), $levels);
$groups = m('member')->getGroups();
//佣金计算
$commission_level = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_commission_level') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY commission1 asc");
-foreach($commission_level as &$l){
- $l['key'] ='level'.$l['id'];
+foreach ($commission_level as &$l) {
+ $l['key'] = 'level' . $l['id'];
}
unset($l);
-$commission_level =array_merge(array(
+$commission_level = array_merge(array(
array(
- 'key'=>'default',
- 'levelname'=>empty($_W['shopset']['commission']['levelname'])?'默认等级':$_W['shopset']['commission']['levelname']
+ 'key' => 'default',
+ 'levelname' => empty($_W['shopset']['commission']['levelname']) ? '默认等级' : $_W['shopset']['commission']['levelname']
)
-),$commission_level);
+), $commission_level);
$com_virtual = com('virtual');
-
-
+//todo:获取网培服务的默认配置
+$wpfwset = m("common")->getSysset("wpfwset");
if ($_W['ispost']) {
- if (empty($id)) {
+ if (empty($id)) {
$goodstype = intval($_GPC['type']);
} else {
$goodstype = intval($_GPC['goodstype']);
}
-// if ($diyform) {
-// if ($goodstype == 1 && $_GPC['diyformtype'] == 2) {
-// show_json(0,array('message'=>'替换模式只试用于虚拟物品类型,实体物品无效!请重新选择!'));
-// }
-// }
- if($goodstype!=1 && intval($_GPC['status'])==2){
- show_json(0,"赠品只能是实体商品");
+ // if ($diyform) {
+ // if ($goodstype == 1 && $_GPC['diyformtype'] == 2) {
+ // show_json(0,array('message'=>'替换模式只试用于虚拟物品类型,实体物品无效!请重新选择!'));
+ // }
+ // }
+ if ($goodstype != 1 && intval($_GPC['status']) == 2) {
+ show_json(0, "赠品只能是实体商品");
}
- if($_GPC['isverify'] ==2 && intval($_GPC['status'])==2){
- show_json(0,"赠品不支持核销");
+ if ($_GPC['isverify'] == 2 && intval($_GPC['status']) == 2) {
+ show_json(0, "赠品不支持核销");
}
- if(intval($_GPC['hasoption']) == 1 && intval($_GPC['status'])==2){
- show_json(0,"赠品不支持多规格");
+ if (intval($_GPC['hasoption']) == 1 && intval($_GPC['status']) == 2) {
+ show_json(0, "赠品不支持多规格");
}
- if($_GPC['isverify'] ==2 && $id){
+ if ($_GPC['isverify'] == 2 && $id) {
//判断是否为此商品设置了赠品
$nowtime = TIMESTAMP;
- $gift = pdo_fetch("select id,title from ".tablename('ewei_shop_gift')." WHERE goodsid = :goodsid and uniacid=:uniacid and endtime>=:endtime", array(':goodsid' => $id, ':uniacid' => $_W['uniacid'],':endtime' => $nowtime));
- if($gift) show_json(0,"已为此商品指定了赠品不支持线下核销");
+ $gift = pdo_fetch("select id,title from " . tablename('ewei_shop_gift') . " WHERE goodsid = :goodsid and uniacid=:uniacid and endtime>=:endtime", array(':goodsid' => $id, ':uniacid' => $_W['uniacid'], ':endtime' => $nowtime));
+ if ($gift) show_json(0, "已为此商品指定了赠品不支持线下核销");
}
$act_time = $_GPC['act_time'];
@@ -172,7 +170,7 @@ if ($_W['ispost']) {
'presellprice' => floatval($_GPC['presellprice']), // 预售价格
'presellstart' => intval($_GPC['presellstart']), // 是否开启预售开始时间
'presellend' => intval($_GPC['presellend']), // 是否开启预售结束时间
- 'preselltimestart' => intval($_GPC['presellstart'])>0 ? strtotime($_GPC['preselltimestart']) : 0, // 预售开始时间
+ 'preselltimestart' => intval($_GPC['presellstart']) > 0 ? strtotime($_GPC['preselltimestart']) : 0, // 预售开始时间
'preselltimeend' => intval($_GPC['presellend']) > 0 ? strtotime($_GPC['preselltimeend']) : 0, // 预售结束时间
'presellsendtype' => intval($_GPC['presellsendtype']), // 预售发货时间类型
'presellsendstatrttime' => strtotime($_GPC['presellsendstatrttime']), // 预售固定发货时间
@@ -183,7 +181,7 @@ if ($_W['ispost']) {
'ishot' => intval($_GPC['ishot']),
'isnew' => intval($_GPC['isnew']),
'isdiscount' => intval($_GPC['isdiscount']),
- 'isdiscount_title' => trim(mb_substr($_GPC['isdiscount_title'],0,5,'UTF-8')),
+ 'isdiscount_title' => trim(mb_substr($_GPC['isdiscount_title'], 0, 5, 'UTF-8')),
/*'isdiscount_time' => strtotime($_GPC['isdiscount_time']),*/
'isdiscount_time_start' => strtotime($act_time['start']),
'isdiscount_time' => strtotime($act_time['end']),
@@ -214,8 +212,8 @@ if ($_W['ispost']) {
'sales' => intval($_GPC['sales']),
'share_icon' => trim($_GPC['share_icon']),
'share_title' => trim($_GPC['share_title']),
- 'status' => $status!=2 ? intval($_GPC['status']) : $status ,
- 'groupstype' => intval($_GPC['groupstype']),//是否支持拼团
+ 'status' => $status != 2 ? intval($_GPC['status']) : $status,
+ 'groupstype' => intval($_GPC['groupstype']), //是否支持拼团
'virtualsend' => intval($_GPC['virtualsend']),
'virtualsendcontent' => trim($_GPC['virtualsendcontent']),
'buyshow' => intval($_GPC['buyshow']),
@@ -232,48 +230,23 @@ if ($_W['ispost']) {
'manydeduct' => $_GPC['manydeduct'],
'manydeduct2' => $_GPC['manydeduct2'],
'deduct2' => $_GPC['deduct2'],
- 'virtual'=>$goodstype==3?intval($_GPC['virtual']):0,
-// 'discounts' => is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array()),
- 'ednum' => intval($_GPC['ednum'])
- , 'edareas' => trim($_GPC['edareas'])
- , 'edareas_code' => trim($_GPC['edareas_code'])
- , 'edmoney' => trim($_GPC['edmoney'])
- , 'invoice' => intval($_GPC['invoice'])
- , 'repair' => intval($_GPC['repair'])
- , 'seven' => intval($_GPC['seven'])
- , 'money'=>trim($_GPC['money'])
- , 'province'=>trim($_GPC['province'])
- , 'city'=>trim($_GPC['city'])
- , 'quality'=>intval($_GPC['quality'])
- , 'sharebtn'=>intval($_GPC['sharebtn'])
- , 'autoreceive'=>intval($_GPC['autoreceive'])
- , 'cannotrefund'=>intval($_GPC['cannotrefund'])
- , 'refund'=>intval($_GPC['refund'])
- , 'returngoods'=>intval($_GPC['returngoods'])
- , 'exchange'=>intval($_GPC['exchange'])
- , 'buyagain'=>floatval($_GPC['buyagain'])
- , 'buyagain_islong'=>intval($_GPC['buyagain_islong'])
- , 'buyagain_condition'=>intval($_GPC['buyagain_condition'])
- , 'buyagain_sale'=>intval($_GPC['buyagain_sale'])
- , 'diypage'=>intval($_GPC['diypage'])
- , 'cashier'=>intval($_GPC['cashier'])
- , 'video'=>trim($_GPC['video']),
- 'isshowfreight' => intval($_GPC['isshowfreight'])
+ 'virtual' => $goodstype == 3 ? intval($_GPC['virtual']) : 0,
+ // 'discounts' => is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array()),
+ 'ednum' => intval($_GPC['ednum']), 'edareas' => trim($_GPC['edareas']), 'edareas_code' => trim($_GPC['edareas_code']), 'edmoney' => trim($_GPC['edmoney']), 'invoice' => intval($_GPC['invoice']), 'repair' => intval($_GPC['repair']), 'seven' => intval($_GPC['seven']), 'money' => trim($_GPC['money']), 'province' => trim($_GPC['province']), 'city' => trim($_GPC['city']), 'quality' => intval($_GPC['quality']), 'sharebtn' => intval($_GPC['sharebtn']), 'autoreceive' => intval($_GPC['autoreceive']), 'cannotrefund' => intval($_GPC['cannotrefund']), 'refund' => intval($_GPC['refund']), 'returngoods' => intval($_GPC['returngoods']), 'exchange' => intval($_GPC['exchange']), 'buyagain' => floatval($_GPC['buyagain']), 'buyagain_islong' => intval($_GPC['buyagain_islong']), 'buyagain_condition' => intval($_GPC['buyagain_condition']), 'buyagain_sale' => intval($_GPC['buyagain_sale']), 'diypage' => intval($_GPC['diypage']), 'cashier' => intval($_GPC['cashier']), 'video' => trim($_GPC['video']),
+ 'isshowfreight' => intval($_GPC['isshowfreight'])
);
- if (isset($_GPC['video_url']) && $_GPC['video_type'] == 2) {
- $data['end_video_url'] = parseTencentVideo($_GPC['video_url']);
-
+ if (isset($_GPC['video_url']) && $_GPC['video_type'] == 2) {
+ $data['end_video_url'] = parseTencentVideo($_GPC['video_url']);
+ }
+ if (isset($_GPC['video_url']) && $_GPC['video_type'] == 1) {
+ $data['video'] = ($_GPC['video']);
+ if (empty($data['video'])) {
+ show_json(0, '请上传视频');
}
- if (isset($_GPC['video_url']) && $_GPC['video_type'] == 1) {
- $data['video'] = ($_GPC['video']);
- if(empty($data['video']))
- {
- show_json(0,'请上传视频');
- }
- }
+ }
- if(p('offic')){
+ if (p('offic')) {
//文案营销专用缩略图
$data['officthumb'] = save_media($_GPC['officthumb']);
}
@@ -283,93 +256,78 @@ if ($_W['ispost']) {
$statustimeend = strtotime($_GPC['statustime']['end']);
$data['statustimestart'] = $statustimestart;
$data['statustimeend'] = $statustimeend;
- if($data['status']==1 && $data['isstatustime'] > 0){
+ if ($data['status'] == 1 && $data['isstatustime'] > 0) {
/*if(!($statustimestart < time() && $statustimeend > time())){
show_json(0,'上架时间不符合要求!');
}*/
- if($statustimeend <= time()){
- show_json(0,'上架时间不符合要求!');
+ if ($statustimeend <= time()) {
+ show_json(0, '上架时间不符合要求!');
}
}
//开启了自动上下架
- if($data['status'] < 2 && $data['isstatustime'] == 1){
- if($data['statustimestart'] < time() && $data['statustimeend'] > time()){
+ if ($data['status'] < 2 && $data['isstatustime'] == 1) {
+ if ($data['statustimestart'] < time() && $data['statustimeend'] > time()) {
$data['status'] = 1;
- }else{
+ } else {
$data['status'] = 0;
}
}
- $intervalfloor=0;
- $intervalprice="";
+ $intervalfloor = 0;
+ $intervalprice = "";
- if($goodstype==4)
- {
+ if ($goodstype == 4) {
//批发商品 阶梯价格设置
$intervalfloor = intval($_GPC['intervalfloor']);
- if($intervalfloor>3||$intervalfloor<1)
- {
- show_json(0,'请至少添加一个区间价格!');
+ if ($intervalfloor > 3 || $intervalfloor < 1) {
+ show_json(0, '请至少添加一个区间价格!');
}
$intervalprices = array();
- if($intervalfloor>0)
- {
+ if ($intervalfloor > 0) {
- if(intval($_GPC['intervalnum1'])<=0)
- {
- show_json(0,'请设置起批发量!');
+ if (intval($_GPC['intervalnum1']) <= 0) {
+ show_json(0, '请设置起批发量!');
}
- if(floatval($_GPC['intervalprice1'])<=0)
- {
- show_json(0,'批发价必须大于0!');
+ if (floatval($_GPC['intervalprice1']) <= 0) {
+ show_json(0, '批发价必须大于0!');
}
- $intervalprices[]=array("intervalnum"=>intval($_GPC['intervalnum1']),"intervalprice"=>floatval($_GPC['intervalprice1']));
-
+ $intervalprices[] = array("intervalnum" => intval($_GPC['intervalnum1']), "intervalprice" => floatval($_GPC['intervalprice1']));
}
- if($intervalfloor>1)
- {
- if(intval($_GPC['intervalnum2'])<=0)
- {
- show_json(0,'请设置起批发量!');
+ if ($intervalfloor > 1) {
+ if (intval($_GPC['intervalnum2']) <= 0) {
+ show_json(0, '请设置起批发量!');
}
- if(intval($_GPC['intervalnum2'])<=intval($_GPC['intervalnum1']))
- {
- show_json(0,'批发量需大于上级批发量!');
+ if (intval($_GPC['intervalnum2']) <= intval($_GPC['intervalnum1'])) {
+ show_json(0, '批发量需大于上级批发量!');
}
- if(floatval($_GPC['intervalprice2'])>=floatval($_GPC['intervalprice1']))
- {
- show_json(0,'批发价需小于上级批发价!');
-
+ if (floatval($_GPC['intervalprice2']) >= floatval($_GPC['intervalprice1'])) {
+ show_json(0, '批发价需小于上级批发价!');
}
- $intervalprices[]=array("intervalnum"=>intval($_GPC['intervalnum2']),"intervalprice"=>floatval($_GPC['intervalprice2']));
+ $intervalprices[] = array("intervalnum" => intval($_GPC['intervalnum2']), "intervalprice" => floatval($_GPC['intervalprice2']));
}
- if($intervalfloor>2)
- {
- if(intval($_GPC['intervalnum3'])<=0)
- {
- show_json(0,'请设置起批发量!');
+ if ($intervalfloor > 2) {
+ if (intval($_GPC['intervalnum3']) <= 0) {
+ show_json(0, '请设置起批发量!');
}
- if(intval($_GPC['intervalnum3'])<=intval($_GPC['intervalnum2']))
- {
- show_json(0,'批发量需大于上级批发量!');
+ if (intval($_GPC['intervalnum3']) <= intval($_GPC['intervalnum2'])) {
+ show_json(0, '批发量需大于上级批发量!');
}
- if(floatval($_GPC['intervalprice3'])>=floatval($_GPC['intervalprice2']))
- {
- show_json(0,'批发价需小于上级批发价!');
+ if (floatval($_GPC['intervalprice3']) >= floatval($_GPC['intervalprice2'])) {
+ show_json(0, '批发价需小于上级批发价!');
}
- $intervalprices[]=array("intervalnum"=>intval($_GPC['intervalnum3']),"intervalprice"=>floatval($_GPC['intervalprice3']));
+ $intervalprices[] = array("intervalnum" => intval($_GPC['intervalnum3']), "intervalprice" => floatval($_GPC['intervalprice3']));
}
//加密
$intervalprice = iserializer($intervalprices);
@@ -385,9 +343,9 @@ if ($_W['ispost']) {
}
- if(intval($_GPC['ispresell'])==1){ //如果开启预售,自动上下架,限时购和促销关闭
- if(floatval($_GPC['presellprice']<=0)){
- show_json(0,'请填写预售价格!');
+ if (intval($_GPC['ispresell']) == 1) { //如果开启预售,自动上下架,限时购和促销关闭
+ if (floatval($_GPC['presellprice'] <= 0)) {
+ show_json(0, '请填写预售价格!');
}
$data['isdiscount'] = 0;
$data['istime'] = 0;
@@ -396,7 +354,7 @@ if ($_W['ispost']) {
$data['statustimeend'] = 0;
}
$buyagain_commission = is_array($_GPC['buyagain_commission']) ? $_GPC['buyagain_commission'] : array();
- if (!empty($buyagain_commission)){
+ if (!empty($buyagain_commission)) {
$buyagain_commission['type'] = 0;
$data['buyagain_commission'] = json_encode($buyagain_commission);
}
@@ -432,7 +390,7 @@ if ($_W['ispost']) {
//记计核销商品直接就是核销商品,不加购物车,还有联系人
$data['isforceverifystore'] = intval($_GPC['isforceverifystore']);
- if($goodstype==5){
+ if ($goodstype == 5) {
$data['isverify'] = 2;
$data['isforceverifystore'] = intval($_GPC['isforceverifystore_verifygoods']);
$data['storeids'] = is_array($_GPC['storeids_verifygoods']) ? implode(',', $_GPC['storeids_verifygoods']) : '';
@@ -451,37 +409,34 @@ if ($_W['ispost']) {
$tcates = array();
$fcates = array();
$cates = array();
- $pcateid=0;
+ $pcateid = 0;
$ccateid = 0;
$tcateid = 0;
if (is_array($_GPC['cates'])) {
$cates = $_GPC['cates'];
- foreach ($cates as $key=>$cid) {
+ foreach ($cates as $key => $cid) {
$c = pdo_fetch('select level from ' . tablename('ewei_shop_category') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $cid, ':uniacid' => $_W['uniacid']));
- if($c['level']==1){ //一级
+ if ($c['level'] == 1) { //一级
$pcates[] = $cid;
- } else if($c['level']==2){ //二级
+ } else if ($c['level'] == 2) { //二级
$ccates[] = $cid;
- } else if($c['level']==3){ //三级
- $tcates[] =$cid;
+ } else if ($c['level'] == 3) { //三级
+ $tcates[] = $cid;
}
- if($key==0){
+ if ($key == 0) {
//兼容 1.x
- if($c['level']==1){ //一级
+ if ($c['level'] == 1) { //一级
$pcateid = $cid;
- }
- else if($c['level']==2){
+ } else if ($c['level'] == 2) {
$crow = pdo_fetch('select parentid from ' . tablename('ewei_shop_category') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $cid, ':uniacid' => $_W['uniacid']));
$pcateid = $crow['parentid'];
$ccateid = $cid;
-
- }
- else if($c['level']==3){
+ } else if ($c['level'] == 3) {
$tcateid = $cid;
$tcate = pdo_fetch('select id,parentid from ' . tablename('ewei_shop_category') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $cid, ':uniacid' => $_W['uniacid']));
$ccateid = $tcate['parentid'];
@@ -489,10 +444,7 @@ if ($_W['ispost']) {
$pcateid = $ccate['parentid'];
}
}
-
-
}
-
}
$data['pcate'] = $pcateid;
@@ -589,26 +541,22 @@ if ($_W['ispost']) {
unset($thumb_url[0]);
$data['thumb_url'] = serialize(m('common')->array_images($thumb_url));
-
-
-
}
- if (p('threen')){
+ if (p('threen')) {
$threen = $_GPC['threen'];
- if (!empty($threen['discount']) && !empty($threen['price'])){
- show_json(0,'3N营销优惠只能设置一个');
+ if (!empty($threen['discount']) && !empty($threen['price'])) {
+ show_json(0, '3N营销优惠只能设置一个');
}
- $threen['price'] = floatval(round($threen['price'],2));
- $threen['discount'] = floatval(round($threen['discount'],2));
- if (!empty($threen['price']) && !$threen['price'] > 0){
- show_json(0,'3N营销会员价必须大于0');
+ $threen['price'] = floatval(round($threen['price'], 2));
+ $threen['discount'] = floatval(round($threen['discount'], 2));
+ if (!empty($threen['price']) && !$threen['price'] > 0) {
+ show_json(0, '3N营销会员价必须大于0');
}
- if (!empty($threen['discount'])&&($threen['discount'] >10 ||$threen <0.1))show_json(0,'3N营销优惠需在0.1-10之间');
+ if (!empty($threen['discount']) && ($threen['discount'] > 10 || $threen < 0.1)) show_json(0, '3N营销优惠需在0.1-10之间');
$data['threen'] = json_encode($threen);
}
//记次时商品
- if($goodstype==5)
- {
+ if ($goodstype == 5) {
//可核销次数
$verifygoodsnum = intval($_GPC['verifygoodsnum']);
@@ -617,50 +565,44 @@ if ($_W['ispost']) {
//统一过期时间
- if(!empty($_GPC['verifygoodslimitdate']))
- {
+ if (!empty($_GPC['verifygoodslimitdate'])) {
$verifygoodslimitdate = strtotime($_GPC['verifygoodslimitdate']);
- }else
- {
- $verifygoodslimitdate=0;
+ } else {
+ $verifygoodslimitdate = 0;
}
//可核销天数
$verifygoodsdays = intval($_GPC['verifygoodsdays']);
- if(empty($verifygoodslimittype))
- {
- if(empty($verifygoodsdays))
- {
- $verifygoodsdays=365;
+ if (empty($verifygoodslimittype)) {
+ if (empty($verifygoodsdays)) {
+ $verifygoodsdays = 365;
}
}
- if(com('wxcard'))
- {
+ if (com('wxcard')) {
$opencard = intval($_GPC['opencard']);
- if(!empty($opencard))
- {
+ if (!empty($opencard)) {
//记次时商品]);
if (strlen($_GPC['custom_cell1_url']) > 128) {
show_json(0, '入口跳转链接不能超过128个字符');
}
- $prerogative = htmlspecialchars($_GPC['prerogative'],ENT_QUOTES);
- $prerogative =istripslashes($prerogative);
+ $prerogative = htmlspecialchars($_GPC['prerogative'], ENT_QUOTES);
+ $prerogative = istripslashes($prerogative);
- $card_description = htmlspecialchars($_GPC['card_description'],ENT_QUOTES);
- $card_description =istripslashes($card_description);
+ $card_description = htmlspecialchars($_GPC['card_description'], ENT_QUOTES);
+ $card_description = istripslashes($card_description);
if (empty($prerogative)) {
show_json(0, '会员卡特权说明不能为空');
}
- if (mb_strlen($prerogative,'UTF-8') > 300) {
+ if (mb_strlen($prerogative, 'UTF-8') > 300) {
show_json(0, '会员卡特权不能超过300个字符');
}
@@ -669,93 +611,83 @@ if ($_W['ispost']) {
}
- if (mb_strlen($card_description,'UTF-8') > 300) {
+ if (mb_strlen($card_description, 'UTF-8') > 300) {
show_json(0, '使用须知不能超过300个字符');
}
$carddata = array(
- "uniacid"=>$_W['uniacid'],
- "card_backgroundtype"=>$_GPC['card_backgroundtype'],
+ "uniacid" => $_W['uniacid'],
+ "card_backgroundtype" => $_GPC['card_backgroundtype'],
"color" => $_GPC['color'],
"color2" => $_GPC['color2'],
- "prerogative"=>$_GPC['prerogative'],
- "card_description"=>$_GPC['card_description'],
- "custom_cell1"=>$_GPC['custom_cell1'],
- "custom_cell1_name"=>$_GPC['custom_cell1_name'],
- "custom_cell1_tips"=>$_GPC['custom_cell1_tips'],
- "custom_cell1_url"=>$_GPC['custom_cell1_url']
+ "prerogative" => $_GPC['prerogative'],
+ "card_description" => $_GPC['card_description'],
+ "custom_cell1" => $_GPC['custom_cell1'],
+ "custom_cell1_name" => $_GPC['custom_cell1_name'],
+ "custom_cell1_tips" => $_GPC['custom_cell1_tips'],
+ "custom_cell1_url" => $_GPC['custom_cell1_url']
);
- if(empty($card)||$card['card_logoimg']!=$_GPC['card_logoimg'])
- {
+ if (empty($card) || $card['card_logoimg'] != $_GPC['card_logoimg']) {
if (empty($card)) {
if (empty($_GPC['card_logoimg'])) {
show_json(0, 'logo图片不能为空');
}
}
- $imgurl =ATTACHMENT_ROOT.$_GPC['card_logolocalpath'];
+ $imgurl = ATTACHMENT_ROOT . $_GPC['card_logolocalpath'];
if (!is_file($imgurl)) {
$img = tomedia($_GPC['card_logolocalpath']);
$img = ihttp_get($img);
- if(is_error($img)){
+ if (is_error($img)) {
show_json(0, "上传的logo图片限制文件大小限制1MB,像素为300*300,仅支持JPG、PNG格式。");
}
$img = $img['content'];
- if(strlen($img) != 0)
- {
+ if (strlen($img) != 0) {
file_put_contents($imgurl, $img);
- }else
- {
+ } else {
show_json(0, "上传的logo图片限制文件大小限制1MB,像素为300*300,仅支持JPG、PNG格式。");
}
-
}
$result = com('wxcard')->wxCardUpdateImg($imgurl);
if (is_wxerror($result)) {
- show_json(0,"上传的logo图片限制文件大小限制1MB,像素为300*300,仅支持JPG、PNG格式。" );
+ show_json(0, "上传的logo图片限制文件大小限制1MB,像素为300*300,仅支持JPG、PNG格式。");
}
- $carddata['card_logoimg']=$_GPC['card_logoimg'];
- $carddata['card_logowxurl']=$result["url"];
+ $carddata['card_logoimg'] = $_GPC['card_logoimg'];
+ $carddata['card_logowxurl'] = $result["url"];
}
- if(!empty($_GPC['card_backgroundtype']))
- {
- if(empty($card)||$card['card_backgroundimg']!=$_GPC['card_backgroundimg'])
- {
- if(empty($card))
- {
- if(empty($_GPC['card_logoimg']))
- {
- show_json(0,'设置使用背景图片时图片不能为空');
+ if (!empty($_GPC['card_backgroundtype'])) {
+ if (empty($card) || $card['card_backgroundimg'] != $_GPC['card_backgroundimg']) {
+ if (empty($card)) {
+ if (empty($_GPC['card_logoimg'])) {
+ show_json(0, '设置使用背景图片时图片不能为空');
}
}
- $imgurl =ATTACHMENT_ROOT.$_GPC['card_backgroundimg_localpath'];
+ $imgurl = ATTACHMENT_ROOT . $_GPC['card_backgroundimg_localpath'];
if (!is_file($imgurl)) {
$img = tomedia($_GPC['card_backgroundimg_localpath']);
$img = ihttp_get($img);
- if(is_error($img)){
+ if (is_error($img)) {
show_json(0, "上传的背景图片限制文件大小限制1MB,像素为1000*600,仅支持JPG、PNG格式");
}
$img = $img['content'];
- if(strlen($img) != 0)
- {
+ if (strlen($img) != 0) {
file_put_contents($imgurl, $img);
- }else
- {
+ } else {
show_json(0, "上传的背景图片限制文件大小限制1MB,像素为1000*600,仅支持JPG、PNG格式");
}
}
@@ -763,14 +695,12 @@ if ($_W['ispost']) {
$result = com('wxcard')->wxCardUpdateImg($imgurl);
if (is_wxerror($result)) {
- show_json(0,"上传的背景图片限制文件大小限制1MB,像素为1000*600,仅支持JPG、PNG格式" );
+ show_json(0, "上传的背景图片限制文件大小限制1MB,像素为1000*600,仅支持JPG、PNG格式");
}
- $carddata['card_backgroundimg']=$_GPC['card_backgroundimg'];
- $carddata['card_backgroundwxurl']=$result["url"];
- }
- else if(!empty($card) &&$card['card_backgroundimg']== $_GPC['card_backgroundimg'])
- {
+ $carddata['card_backgroundimg'] = $_GPC['card_backgroundimg'];
+ $carddata['card_backgroundwxurl'] = $result["url"];
+ } else if (!empty($card) && $card['card_backgroundimg'] == $_GPC['card_backgroundimg']) {
$carddata['card_backgroundimg'] = $card['card_backgroundimg'];
$carddata['card_backgroundwxurl'] = $card['card_backgroundwxurl'];
}
@@ -780,111 +710,99 @@ if ($_W['ispost']) {
if (!empty($card)) {
//$carddata['id']=$card['id'];
- $change = com('wxcard')->checkchange($card,$carddata);
+ $change = com('wxcard')->checkchange($card, $carddata);
- if($change)
- {
- $result = com('wxcard')->verifygoodcard($carddata,$card['card_id']);
- if($result['errcode']==48001)
- {
+ if ($change) {
+ $result = com('wxcard')->verifygoodcard($carddata, $card['card_id']);
+ if ($result['errcode'] == 48001) {
show_json(0, "您尚未开通微信会员卡。");
}
if (is_wxerror($result)) {
- show_json(0,"卡券信息填写有误。" );
+ show_json(0, "卡券信息填写有误。");
}
pdo_update('ewei_shop_goods_cards', $carddata, array('id' => $card['id']));
}
$cardid = $card['id'];
+ } else {
- }else
- {
-
- if(strlen($_GPC['title'])>25)
- {
- show_json(0,'会员卡标题不能超过25个字符');
+ if (strlen($_GPC['title']) > 25) {
+ show_json(0, '会员卡标题不能超过25个字符');
}
- if(strlen($_GPC['card_brand_name'])>30)
- {
- show_json(0,'商户名字不能超过30个字符');
+ if (strlen($_GPC['card_brand_name']) > 30) {
+ show_json(0, '商户名字不能超过30个字符');
}
- if(intval($_GPC['card_totalquantity'])>9999999||intval($_GPC['card_totalquantity'])<1)
- {
- show_json(0,"会员卡库存需设置再1与9999999之间");
+ if (intval($_GPC['card_totalquantity']) > 9999999 || intval($_GPC['card_totalquantity']) < 1) {
+ show_json(0, "会员卡库存需设置再1与9999999之间");
}
- $carddata["card_title"]=$_GPC['card_title'];
- $carddata["card_brand_name"]=$_GPC['card_brand_name'];
- $carddata["card_totalquantity"]=$_GPC['card_totalquantity'];
- $carddata["card_quantity"]=$_GPC['card_totalquantity'];
- $carddata["freewifi"]=$_GPC['freewifi']=="on"?1:0;
- $carddata["withpet"]=$_GPC['withpet']=="on"?1:0;
- $carddata["freepark"]=$_GPC['freepark']=="on"?1:0;
- $carddata["deliver"]=$_GPC['deliver']=="on"?1:0;
+ $carddata["card_title"] = $_GPC['card_title'];
+ $carddata["card_brand_name"] = $_GPC['card_brand_name'];
+ $carddata["card_totalquantity"] = $_GPC['card_totalquantity'];
+ $carddata["card_quantity"] = $_GPC['card_totalquantity'];
+ $carddata["freewifi"] = $_GPC['freewifi'] == "on" ? 1 : 0;
+ $carddata["withpet"] = $_GPC['withpet'] == "on" ? 1 : 0;
+ $carddata["freepark"] = $_GPC['freepark'] == "on" ? 1 : 0;
+ $carddata["deliver"] = $_GPC['deliver'] == "on" ? 1 : 0;
$result = com('wxcard')->verifygoodcard($carddata);
- if($result['errcode']==48001)
- {
+ if ($result['errcode'] == 48001) {
show_json(0, "您尚未开通微信会员卡。");
}
if (is_wxerror($result)) {
- show_json(0,"卡券信息填写有误。" );
- }else
- {
- $carddata['card_id']=$result['card_id'];
+ show_json(0, "卡券信息填写有误。");
+ } else {
+ $carddata['card_id'] = $result['card_id'];
}
pdo_insert('ewei_shop_goods_cards', $carddata);
$cardid = pdo_insertid();
-
}
$data['cardid'] = $cardid;
}
$data['opencard'] = $opencard;
-
}
$data['verifygoodsnum'] = intval($verifygoodsnum);
$data['verifygoodslimittype'] = intval($verifygoodslimittype);
- $data['verifygoodsdays'] =intval( $verifygoodsdays);
+ $data['verifygoodsdays'] = intval($verifygoodsdays);
$data['verifygoodslimitdate'] = intval($verifygoodslimitdate);
$data['verifygoodstype'] = intval($_GPC['verifygoodstype']);
$data['verifytype'] = intval($_GPC['verify_type1']);
- if ($data['verifytype'] == 0){
+ if ($data['verifytype'] == 0) {
$data['verifygoodsnum'] = 1;
}
-
}
//如果有多规格则清除商品的条码
- if($data['hasoption']!=0){
- $data['productsn']='';
+ if ($data['hasoption'] != 0) {
+ $data['productsn'] = '';
}
if (empty($id)) {
$data['merchid'] = 0;
pdo_insert('ewei_shop_goods', $data);
$id = pdo_insertid();
- plog('goods.add', "添加商品 ID: {$id}
".(!empty($data['nocommission']) ? "是否参与分销 -- 否" : "是否参与分销 -- 是"));
+ plog('goods.add', "添加商品 ID: {$id}
" . (!empty($data['nocommission']) ? "是否参与分销 -- 否" : "是否参与分销 -- 是"));
} else {
unset($data['createtime']);
- $old_data = pdo_fetch('SELECT nocommission,marketprice,total FROM '.tablename('ewei_shop_goods').' WHERE id=:id AND uniacid=:uniacid',array(':id'=>$id,':uniacid'=>$_W['uniacid']));
+ $old_data = pdo_fetch('SELECT nocommission,marketprice,total FROM ' . tablename('ewei_shop_goods') . ' WHERE id=:id AND uniacid=:uniacid', array(':id' => $id, ':uniacid' => $_W['uniacid']));
pdo_update('ewei_shop_goods', $data, array('id' => $id));
- if ($old_data['marketprice'] != $data['marketprice']){
- plog('goods.price.edit', "更改商品 ID: {$id}
价格为".$data['marketprice']);
+ if ($old_data['marketprice'] != $data['marketprice']) {
+ plog('goods.price.edit', "更改商品 ID: {$id}
价格为" . $data['marketprice']);
}
- if($old_data['nocommission'] != $data['nocommission']){
- plog('goods.edit', "编辑商品 ID: {$id}
".(!empty($data['nocommission']) ? "是否参与分销 -- 否" : "是否参与分销 -- 是"));
+ if ($old_data['nocommission'] != $data['nocommission']) {
+ plog('goods.edit', "编辑商品 ID: {$id}
" . (!empty($data['nocommission']) ? "是否参与分销 -- 否" : "是否参与分销 -- 是"));
}
- if($old_data['total'] != $data['total']){
- plog('goods.edit', "修改商品库存 ID: {$id}
库存量为".$data['total']);
+ if ($old_data['total'] != $data['total']) {
+ plog('goods.edit', "修改商品库存 ID: {$id}
库存量为" . $data['total']);
}
}
//处理商品参数
@@ -898,7 +816,7 @@ if ($_W['ispost']) {
$param_id = "";
$get_param_id = $param_ids[$k];
$a = array(
- "uniacid"=>$_W['uniacid'],
+ "uniacid" => $_W['uniacid'],
"title" => $param_titles[$k],
"value" => $param_values[$k],
"displayorder" => $k,
@@ -998,10 +916,10 @@ if ($_W['ispost']) {
pdo_query("delete from " . tablename('ewei_shop_goods_spec') . " where uniacid={$_W['uniacid']} and goodsid=$id");
}
//保存规格
- $optionArray = json_decode($_POST['optionArray'],true);
- $isdiscountDiscountsArray = json_decode($_POST['isdiscountDiscountsArray'],true);
- $discountArray = json_decode($_POST['discountArray'],true);
- $commissionArrayPost = json_decode($_POST['commissionArray'],true);
+ $optionArray = json_decode($_POST['optionArray'], true);
+ $isdiscountDiscountsArray = json_decode($_POST['isdiscountDiscountsArray'], true);
+ $discountArray = json_decode($_POST['discountArray'], true);
+ $commissionArrayPost = json_decode($_POST['commissionArray'], true);
$option_idss = $optionArray['option_ids'];
$len = count($option_idss);
$optionids = array();
@@ -1043,67 +961,58 @@ if ($_W['ispost']) {
'virtual' => $data['type'] == 3 ? $optionArray['option_virtual'][$k] : 0,
);
- if($goodstype==4)
- {
- $a['presellprice']=0;
- $a['productprice']=0;
+ if ($goodstype == 4) {
+ $a['presellprice'] = 0;
+ $a['productprice'] = 0;
$a['costprice'] = 0;
- $a['marketprice']=floatval($_GPC['intervalprice1']);
-
+ $a['marketprice'] = floatval($_GPC['intervalprice1']);
}
- $totalstocks+=$a['stock'];
+ $totalstocks += $a['stock'];
if (empty($get_option_id)) {
pdo_insert("ewei_shop_goods_option", $a);
$option_id = pdo_insertid();
-// plog('goods.option.add', "添加商品规格 ID: {$option_id}");
+ // plog('goods.option.add', "添加商品规格 ID: {$option_id}");
} else {
pdo_update("ewei_shop_goods_option", $a, array('id' => $get_option_id));
- plog('goods.price.edit', "更改多规格商品 规格ID: {$get_option_id} 属性: {$a['title']}
价格为".$a['marketprice']);
-// plog('goods.option.edit', "修改商品规格 ID: {$get_option_id}");
+ plog('goods.price.edit', "更改多规格商品 规格ID: {$get_option_id} 属性: {$a['title']}
价格为" . $a['marketprice']);
+ // plog('goods.option.edit', "修改商品规格 ID: {$get_option_id}");
//修改规格名称
- if( p('groups') ){
- pdo_update( 'ewei_shop_groups_goods_option' , array( 'title' => $a['title'],'specs' => $newids ) , array( 'goods_option_id' => $get_option_id ) );
+ if (p('groups')) {
+ pdo_update('ewei_shop_groups_goods_option', array('title' => $a['title'], 'specs' => $newids), array('goods_option_id' => $get_option_id));
}
$option_id = $get_option_id;
}
$optionids[] = $option_id;
foreach ($levels as $level) {
- $levelArray[$level['key']]['option'.$option_id] = $discountArray['discount_' . $level['key']][$k];
- $isDiscountsArray[$level['key']]['option'.$option_id] = $isdiscountDiscountsArray['isdiscount_discounts_'.$level['key']][$k];
+ $levelArray[$level['key']]['option' . $option_id] = $discountArray['discount_' . $level['key']][$k];
+ $isDiscountsArray[$level['key']]['option' . $option_id] = $isdiscountDiscountsArray['isdiscount_discounts_' . $level['key']][$k];
}
foreach ($commission_level as $level) {
- if($level['key']=='default')
- {
- $commissionArray[$level['key']]['option'.$option_id] = $commissionArrayPost['commission']['commission_level_' . $level['key'] . "_" . $ids];
+ if ($level['key'] == 'default') {
+ $commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['key'] . "_" . $ids];
+ } else {
+ $commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['id'] . "_" . $ids];
}
- else
- {
- $commissionArray[$level['key']]['option'.$option_id] = $commissionArrayPost['commission']['commission_level_' . $level['id'] . "_" . $ids];
- }
-
}
}
- //更新discounts
- if ((int)$_GPC['discounts']['type'] == 1 && $data['hasoption'])
- {
- $discounts_arr = array(
- 'type' => (int)$_GPC['discounts']['type'],
- );
- $discounts_arr = array_merge($discounts_arr,$levelArray);
- $discounts_json = json_encode($discounts_arr);
- }
- else
- {
- $discounts_json = is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array());
- }
+ //更新discounts
+ if ((int)$_GPC['discounts']['type'] == 1 && $data['hasoption']) {
+ $discounts_arr = array(
+ 'type' => (int)$_GPC['discounts']['type'],
+ );
+ $discounts_arr = array_merge($discounts_arr, $levelArray);
+ $discounts_json = json_encode($discounts_arr);
+ } else {
+ $discounts_json = is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array());
+ }
- pdo_update('ewei_shop_goods', array('discounts'=>$discounts_json), array('id' => $id));
+ pdo_update('ewei_shop_goods', array('discounts' => $discounts_json), array('id' => $id));
@@ -1114,68 +1023,51 @@ if ($_W['ispost']) {
$has_merch = 1;
}
- if (!empty($isDiscountsArray) && $data['hasoption'])
- {
- $is_discounts_arr = array_merge(array('type' => 1),$isDiscountsArray);
+ if (!empty($isDiscountsArray) && $data['hasoption']) {
+ $is_discounts_arr = array_merge(array('type' => 1), $isDiscountsArray);
if ($has_merch == 1) {
$is_discounts_arr['merch'] = $old_isdiscount_discounts['merch'];
}
$is_discounts_json = json_encode($is_discounts_arr);
- }
- else
- {
- foreach ($levels as $level)
- {
- if ($level['key']=='default')
- {
+ } else {
+ foreach ($levels as $level) {
+ if ($level['key'] == 'default') {
$isDiscountsDefaultArray[$level['key']]['option0'] = $_GPC['isdiscount_discounts_level_' . $level['key'] . "_default"];
- }
- else
- {
+ } else {
$isDiscountsDefaultArray[$level['key']]['option0'] = $_GPC['isdiscount_discounts_level_' . $level['id'] . "_default"];
}
}
- $is_discounts_arr = array_merge(array('type' => 0),$isDiscountsDefaultArray);
+ $is_discounts_arr = array_merge(array('type' => 0), $isDiscountsDefaultArray);
if ($has_merch == 1) {
$is_discounts_arr['merch'] = $old_isdiscount_discounts['merch'];
}
$is_discounts_json = is_array($is_discounts_arr) ? json_encode($is_discounts_arr) : json_encode(array());
}
- pdo_update('ewei_shop_goods', array('isdiscount_discounts'=>$is_discounts_json), array('id' => $id));
+ pdo_update('ewei_shop_goods', array('isdiscount_discounts' => $is_discounts_json), array('id' => $id));
//更新commission
- if(!empty($commissionArray) && $data['hasoption'])
- {
- $commissionArray = array_merge(array('type'=>(int)$_GPC['commission_type']),$commissionArray);
+ if (!empty($commissionArray) && $data['hasoption']) {
+ $commissionArray = array_merge(array('type' => (int)$_GPC['commission_type']), $commissionArray);
$commission_arr = array(
'commission' => is_array($commissionArray) ? json_encode($commissionArray) : json_encode(array())
);
- }
- else
- {
+ } else {
foreach ($commission_level as $level) {
- if ($level['key']=='default')
- {
- if ( !empty($_GPC['commission_level_' . $level['key'] . "_default"]) )
- {
- foreach ($_GPC['commission_level_' . $level['key'] . "_default"] as $key=>$value)
- {
+ if ($level['key'] == 'default') {
+ if (!empty($_GPC['commission_level_' . $level['key'] . "_default"])) {
+ foreach ($_GPC['commission_level_' . $level['key'] . "_default"] as $key => $value) {
$commissionDefaultArray[$level['key']]['option0'][] = $value;
}
}
- }
- else
- {
- if ( !empty($_GPC['commission_level_' . $level['id'] . "_default"]) )
- {
- foreach ($_GPC['commission_level_' . $level['id'] . "_default"] as $key=>$value)
- {
+ } else {
+ if (!empty($_GPC['commission_level_' . $level['id'] . "_default"])) {
+ foreach ($_GPC['commission_level_' . $level['id'] . "_default"] as $key => $value) {
$commissionDefaultArray[$level['key']]['option0'][] = $value;
}
}
}
}
- $commissionDefaultArray = array_merge(array('type'=>(int)$_GPC['commission_type']),$commissionDefaultArray);
+ $commissionDefaultArray = array_merge(array('type' => (int)$_GPC['commission_type']), $commissionDefaultArray);
$commission_arr = array(
'commission' => is_array($commissionDefaultArray) ? json_encode($commissionDefaultArray) : json_encode(array())
);
@@ -1185,36 +1077,36 @@ if ($_W['ispost']) {
if (count($optionids) > 0 && $data['hasoption'] !== 0) {
pdo_query("delete from " . tablename('ewei_shop_goods_option') . " where goodsid=$id and id not in ( " . implode(',', $optionids) . ")");
//删除拼团多规格
- if( p('groups') ){
+ if (p('groups')) {
pdo_query("delete from " . tablename('ewei_shop_groups_goods_option') . " where goodsid=$id and goods_option_id not in ( " . implode(',', $optionids) . ")");
}
//更新最低价和最高价
- $sql = "update ".tablename('ewei_shop_goods')." g set
- g.minprice = (select min(marketprice) from ".tablename('ewei_shop_goods_option')." where goodsid = $id),
- g.maxprice = (select max(marketprice) from ".tablename('ewei_shop_goods_option')." where goodsid = $id)
+ $sql = "update " . tablename('ewei_shop_goods') . " g set
+ g.minprice = (select min(marketprice) from " . tablename('ewei_shop_goods_option') . " where goodsid = $id),
+ g.maxprice = (select max(marketprice) from " . tablename('ewei_shop_goods_option') . " where goodsid = $id)
where g.id = $id and g.hasoption=1";
pdo_query($sql);
} else {
pdo_query("delete from " . tablename('ewei_shop_goods_option') . " where goodsid=$id");
- $sql = "update ".tablename('ewei_shop_goods')." set minprice = marketprice,maxprice = marketprice where id = $id and hasoption=0;";
+ $sql = "update " . tablename('ewei_shop_goods') . " set minprice = marketprice,maxprice = marketprice where id = $id and hasoption=0;";
pdo_query($sql);
//删除拼团多规格 修改拼团商品状态
- if( p('groups') ){
+ if (p('groups')) {
pdo_query("delete from " . tablename('ewei_shop_groups_goods_option') . " where goodsid=$id");
- pdo_update( 'ewei_shop_groups_goods' , array( 'more_spec' => 0 ) , array( 'gid' => $id ) );
+ pdo_update('ewei_shop_groups_goods', array('more_spec' => 0), array('gid' => $id));
}
}
//如果是有促销,那么更新最大最小价格
$sqlgoods = "SELECT id,title,thumb,marketprice,productprice,minprice,maxprice,isdiscount,isdiscount_time,isdiscount_discounts,sales,total,description,merchsale FROM " . tablename('ewei_shop_goods') . " where id=:id and uniacid=:uniacid limit 1";
- $goodsinfo = pdo_fetch($sqlgoods,array(':id'=>$id,':uniacid'=>$_W['uniacid']));
+ $goodsinfo = pdo_fetch($sqlgoods, array(':id' => $id, ':uniacid' => $_W['uniacid']));
$goodsinfo = m('goods')->getOneMinPrice($goodsinfo);
- pdo_update('ewei_shop_goods',array('minprice'=>$goodsinfo['minprice'],'maxprice'=>$goodsinfo['maxprice']),array('id'=>$id,'uniacid'=>$_W['uniacid']));
+ pdo_update('ewei_shop_goods', array('minprice' => $goodsinfo['minprice'], 'maxprice' => $goodsinfo['maxprice']), array('id' => $id, 'uniacid' => $_W['uniacid']));
//总库存
if ($data['type'] == 3 && $com_virtual) {
@@ -1224,7 +1116,15 @@ if ($_W['ispost']) {
pdo_update("ewei_shop_goods", array("total" => $totalstocks), array("id" => $id));
}
}
- show_json(1,array('url'=>webUrl('goods/edit', array('id' => $id,'tab'=>str_replace("#tab_","",$_GPC['tab'])))));
+ //todo:保存商品处理自定义网培服务
+ $data['wpfw_type'] = intval($_GPC['wpfw_type']);
+ if($wpfwset['open_wpfw'] == 1){
+ if($_GPC['wpfw_type'] == 2){
+ m("wpfw")->good_set_wpset($id,$_GPC['wpfw_url'],$_GPC['wpfw_api_key']);
+ }
+ pdo_update("ewei_shop_goods", array("wpfw_type" => intval($_GPC['wpfw_type'])), array("id" => $id));
+ }
+ show_json(1, array('url' => webUrl('goods/edit', array('id' => $id, 'tab' => str_replace("#tab_", "", $_GPC['tab'])))));
}
if (!empty($id)) {
@@ -1239,15 +1139,14 @@ if (!empty($id)) {
//佣金设置
$commission = json_decode($item['commission'], true);
- if (isset($commission['type']))
- {
+ if (isset($commission['type'])) {
$commission_type = $commission['type'];
unset($commission['type']);
}
$buyagain_commission = array();
- if (!empty($item['buyagain_commission'])){
+ if (!empty($item['buyagain_commission'])) {
$buyagain_commission = json_decode($item['buyagain_commission'], true);
}
//会员折扣
@@ -1267,7 +1166,7 @@ if (!empty($id)) {
//商品图片
if (!empty($item['thumb'])) {
- $piclist =array_merge( array($item['thumb']), iunserializer($item['thumb_url']) );
+ $piclist = array_merge(array($item['thumb']), iunserializer($item['thumb_url']));
}
$item['content'] = m('common')->html_to_images($item['content']);
@@ -1277,9 +1176,9 @@ if (!empty($id)) {
//处理规格项
$html = "";
- $discounts_html='';
- $commission_html='';
- $isdiscount_discounts_html='';
+ $discounts_html = '';
+ $commission_html = '';
+ $isdiscount_discounts_html = '';
$options = pdo_fetchall("select * from " . tablename('ewei_shop_goods_option') . " where goodsid=:id order by id asc", array(':id' => $id));
//排序好的specs
$specs = array();
@@ -1335,26 +1234,26 @@ if (!empty($id)) {
$l = count($specs[$i]['items']);
$rowspans[$i] = 1;
for ($j = $i + 1; $j < $len; $j++) {
- $rowspans[$i]*= count($specs[$j]['items']);
+ $rowspans[$i] *= count($specs[$j]['items']);
}
}
- $canedit = ce('goods',$item);
- if($canedit){
+ $canedit = ce('goods', $item);
+ if ($canedit) {
foreach ($levels as $level) {
- $discounts_html .= '