$goods['sid']),'aid'); } empty($goods['name']) && wl_message('请填写商品名称'); empty($goods['num']) && wl_message('请填写商品数量'); if($goods['creditmoney'] > $goods['price'] && $goods['creditmoney'] > 0) wl_message('积分抵扣金额不能大于商品金额'); //判断开启多规格时 是否添加了多规格信息 if ($_GPC['optionstatus'] == 1 && count($_GPC['spec_id']) <= 0) wl_message('请设置多规格信息'); $goods['cutoffstatus'] = $_GPC['cutoffstatus']; $goods['optionstatus'] = $_GPC['optionstatus']; $goods['independent'] = $_GPC['independent']; $goods['isdistri'] = $_GPC['isdistri']; $goods['isdistristatus']= $_GPC['isdistristatus']; $goods['vipstatus'] = $_GPC['vipstatus']; $goods['detail'] = base64_encode(htmlspecialchars_decode($goods['detail'])); $goods['describe'] = base64_encode(htmlspecialchars_decode($goods['describe'])); $goods['thumbs'] = serialize($goods['thumbs']); $goods['extension_img'] = serialize($goods['extension_img']); $tag = $_GPC['tag']; $goods['tag'] = serialize($tag); $userlabel = $_GPC['userlabel']; $goods['userlabel'] = serialize($userlabel); $level = $_GPC['level']; $goods['level'] = serialize($level); $goods['name'] = htmlspecialchars_decode($goods['name']); $time = $_GPC['time']; $goods['starttime'] = strtotime($time['start']); $goods['endtime'] = strtotime($time['end']); $goods['cutofftime'] = strtotime($_GPC['cutofftime']); $goods['cateid'] = intval($_GPC['cateid']); $goods['pay_type'] = serialize($_GPC['pay_type']); $goods['cash_back'] = $_GPC['cash_back'] ? : 0; $goods['return_proportion'] = $_GPC['return_proportion'] ? : 0; $goods['yuecashback'] = sprintf("%.2f",$goods['yuecashback']); $goods['vipyuecashback'] = sprintf("%.2f",$goods['vipyuecashback']); if ($goods['cash_back'] == 1 && $goods['return_proportion'] < 1) wl_message('请填写返现比例'); if(!$id){ $goods['aid'] = pdo_getcolumn(PDO_NAME.'merchantdata',array('id'=>$goods['sid']),'aid'); } //抢购状态通过抢购时间判断 if (is_store()) { $audits = pdo_getcolumn(PDO_NAME . 'merchantdata' , ['id' => $_W['storeid']] , 'audits'); if (empty($audits)) { $goods['status'] = 5; } } if ($goods['status'] != 5) { if(!empty($_GPC['tostatus'])){ if ($goods['starttime'] > time()) { $goods['status'] = 1; } else if ($goods['starttime'] < time() && time() < $goods['endtime']) { $goods['status'] = 2; } else if ($goods['endtime'] < time()) { $goods['status'] = 3; } }else{ $goods['status'] = 4; } } //使用类型 if($goods['usestatus'] == 3){ $goods['optionstatus'] = 0; $goods['appointstatus'] = 0; $goods['allowapplyre'] = 1; $goods['overrefund'] = 0; } //定时购买 if ($goods['usedatestatus'] == 1) { $goods['week'] = serialize($goods['week']); $goods['day'] = ''; }else if ($goods['usedatestatus'] == 2) { $goods['day'] = serialize($goods['day']); $goods['week'] = ''; }else{ $goods['usedatestatus'] = 0; $goods['week'] = ''; $goods['day'] = ''; } //会员减免 if($goods['vipstatus'] == 1){ $viparray = []; $vipleid = $_GPC['vipleid']; $vipprice = $_GPC['vipprice']; $storeset = $_GPC['storeset']; foreach($vipleid as $key => $vle){ $vipa['vipprice'] = sprintf("%.2f",$vipprice[$key]); $vipa['storeset'] = sprintf("%.2f",$storeset[$key]); $viparray[$vle] = $vipa; } $goods['viparray'] = serialize($viparray); } //分销商分佣数组 if(empty($goods['isdistri'])){ $disarray = []; $disleid = $_GPC['disleid']; $onedismoney = $_GPC['onedismoney']; $twodismoney = $_GPC['twodismoney']; foreach($disleid as $dkey => $dle){ $dlea['onedismoney'] = sprintf("%.2f",$onedismoney[$dkey]); $dlea['twodismoney'] = sprintf("%.2f",$twodismoney[$dkey]); $disarray[$dle] = $dlea; } $goods['disarray'] = serialize($disarray); } //预约数组 if($goods['appointstatus']>0){ $appointarray = []; $appstartTime = $_GPC['appstartTime']; $appendTime = $_GPC['appendTime']; $peoplenums = $_GPC['peoplenums']; if(!is_array($appstartTime)){ wl_message('请设置预约时间段信息!'); } foreach($appstartTime as $appkey => $appoint){ $appinta['startTime'] = $appstartTime[$appkey]; $appinta['endTime'] = $appendTime[$appkey]; $appinta['peoplenums'] = $peoplenums[$appkey]; $appointarray[] = $appinta; } $goods['appointarray'] = serialize($appointarray); } if ($plugin == 'rush') { //商品阶梯价操作 $goods['lp_status'] = $_GPC['lp_status'] ? : 0; $goods['lp_set'] = is_array($_GPC['ld']) ? serialize(array_values($_GPC['ld'])) : ''; // 特定商品类型参数 if (empty($_GPC['cc_id']) || !is_numeric($_GPC['cc_id'])) wl_message('请选择商品类型,若显示为空,请联系管理员'); if (empty($_GPC['cc_child_id']) || !is_numeric($_GPC['cc_child_id'])) wl_message('请选择商品分类'); $goods['cc_id'] = $_GPC['cc_id']; $goods['cc_child_id'] = $_GPC['cc_child_id']; $goods['diyformid_enroll'] = $_GPC['diyformid_enroll'] ?: 0; if ($goods['lp_status'] == 1 && is_array($_GPC['ld'])) { $lpSet = array_values($_GPC['ld']); $maxMax = max(array_column($lpSet , 'max')); if ($maxMax > $goods['num']) { wl_message('阶梯价上限不可超过最大库存!'); } } if (!empty($id)) { Rush::updateActive($goods , ['id' => $id]); } else { $id = Rush::saveRushActive($goods); } } else if ($plugin == 'groupon') { if (!empty($id)) { Groupon::updateActive($goods , ['id' => $id]); } else { $id = Groupon::savegrouponActive($goods); } } else if ($plugin == 'fightgroup') { if($goods['peoplenum'] <= 1) wl_message('成团人数最小为2'); if($goods['grouptime'] <= 0) wl_message('请填写组团时间'); $goods['merchantid'] = $goods['sid']; unset($goods['sid']); $goods['listorder'] = $goods['sort']; unset($goods['sort']); $goods['limitstarttime'] = $goods['starttime']; unset($goods['starttime']); $goods['limitendtime'] = $goods['endtime']; unset($goods['endtime']); $goods['logo'] = $goods['thumb']; unset($goods['thumb']); $goods['adv'] = $goods['thumbs']; unset($goods['thumbs']); $goods['stock'] = $goods['num']; unset($goods['num']); $goods['falsesalenum'] = $goods['allsalenum']; unset($goods['allsalenum']); $goods['vipdiscount'] = $goods['vipprice']; unset($goods['vipprice']); $goods['specstatus'] = $goods['optionstatus']; unset($goods['optionstatus']); $goods['categoryid'] = $goods['cateid']; unset($goods['cateid']); unset($goods['pftid']); if($goods['is_lucky'] > 0){ $goods['luckynum'] = floor($goods['luckynum']); if($goods['luckynum'] <= 1) { $goods['luckynum'] = 1; } if($goods['luckynum'] > $goods['peoplenum']){ wl_message('幸运人数不能超过组团人数:'.$goods['peoplenum'].'人'); } $goods['luckymoney'] = sprintf("%.2f",$goods['luckymoney']); } if (!empty($id)) { Wlfightgroup::updateGoods($goods , $id); } else { $id = Wlfightgroup::saveGoods($goods); } } else if ($plugin == 'bargain') { //砍价规则 $rule_pice = $_GPC['rule_pice']; $rule_start = $_GPC['rule_start']; $rule_end = $_GPC['rule_end']; $len = count($rule_pice); $bargainrule = []; for ($k = 0 ; $k < $len ; $k++) { $bargainrule[$k]['rule_pice'] = $rule_pice[$k]; $bargainrule[$k]['rule_start'] = $rule_start[$k]; $bargainrule[$k]['rule_end'] = $rule_end[$k]; } $bargainrule = serialize($bargainrule); $goods['rules'] = $bargainrule; $goods['bar_image'] = $_GPC['bar_image']; $goods['bar_bgc'] = $_GPC['bar_bgc']; $goods['stock'] = $goods['num']; unset($goods['num']); $goods['falsejoinnum'] = $goods['allsalenum']; unset($goods['allsalenum']); unset($goods['optionstatus']); unset($goods['pftid']); if (!empty($id)) { Bargain::updateActive($goods , ['id' => $id]); } else { $id = Bargain::saveActive($goods); } } //清理海报缓存 Tools::clearposter(); //保存规格 if ($goods['optionstatus'] || $goods['specstatus']) { $this->spec_save($id , $plugin); if($plugin == 'rush'){ $optionList = pdo_getall(PDO_NAME."goods_option",['type'=>1,'goodsid'=>$id],['stock']); $totalnum = array_sum(array_column($optionList,'stock')); pdo_update('wlmerchant_rush_activity',array('num' => $totalnum),array('id' => $id)); }else if($plugin == 'groupon'){ $optionList = pdo_getall(PDO_NAME."goods_option",['type'=>3,'goodsid'=>$id],['stock']); $totalnum = array_sum(array_column($optionList,'stock')); pdo_update('wlmerchant_groupon_activity',array('num' => $totalnum),array('id' => $id)); }else if($plugin == 'fightgroup'){ $optionList = pdo_getall(PDO_NAME."goods_option",['type'=>2,'goodsid'=>$id],['stock']); $totalnum = array_sum(array_column($optionList,'stock')); pdo_update('wlmerchant_fightgroup_goods',array('stock' => $totalnum),array('id' => $id)); } } $page = $_GPC['page']; //编辑商品成功 $this->save_success($goods , $plugin,$page); } /*************************************************************************************************************/ //商品分类 $cate = pdo_getall('wlmerchant_' . $plugin . '_category' , [ 'uniacid' => $_W['uniacid'] , 'aid' => $_W['aid'] , 'is_show' => 0 ]); if ($plugin == 'rush') { //专题分类 $specials = pdo_getall('wlmerchant_rush_special' , ['uniacid' => $_W['uniacid'] , 'aid' => $_W['aid']]); } //运费模板 if(is_store()){ $express = pdo_fetchall("SELECT * FROM ".tablename('wlmerchant_express_template')."WHERE uniacid = {$_W['uniacid']} AND aid = {$_W['aid']} AND sid IN (0,{$_W['storeid']}) ORDER BY id DESC"); }else{ $express = pdo_fetchall("SELECT * FROM ".tablename('wlmerchant_express_template')."WHERE uniacid = {$_W['uniacid']} AND aid = {$_W['aid']} ORDER BY id DESC"); } //社群 $communitylist = pdo_getall('wlmerchant_community' , [ 'uniacid' => $_W['uniacid'] , 'aid' => $_W['aid'] ] , ['id' , 'communname']); //分销设置 $distriset = p('distribution') ? Setting::wlsetting_read('distribution') : []; //分销商等级 if($distriset['switch'] > 0){ $dislevel = pdo_getall('wlmerchant_dislevel', array('uniacid' => $_W['uniacid']),['id','name']); } //用户标签 $labels = pdo_getall('wlmerchant_userlabel' , ['uniacid' => $_W['uniacid']] , [ 'id' , 'name' ] , '' , 'sort DESC'); //一卡通等级 $levels = pdo_fetchall("SELECT * FROM " . tablename('wlmerchant_halflevel') . "WHERE uniacid = {$_W['uniacid']} AND status = 1 ORDER BY sort DESC"); //商品标签 $tag_type = ['rush' => 1 , 'groupon' => 3 , 'bargain' => 4 , 'fightgroup' => 2]; $presettags = pdo_getall('wlmerchant_tags' , [ 'uniacid' => $_W['uniacid'] , 'aid' => $_W['aid'] , 'type' => $tag_type[$plugin] ] , ['id' , 'title'] , '' , 'sort DESC'); //自定义海报 if (p('diyposter')) { $poster_type = ['rush' => 2 , 'groupon' => 5 , 'bargain' => 7 , 'fightgroup' => 6]; $posters = pdo_getall(PDO_NAME . 'poster' , [ 'uniacid' => $_W['uniacid'] , 'type' => $poster_type[$plugin] ] , ['id' , 'title']); } //支付有礼 if(p('paidpromotion')){ $paidlist = pdo_getall('wlmerchant_payactive',array('uniacid' => $_W['uniacid'],'aid' => $_W['aid'],'status' => 1),array('id','title')); } //锦鲤抽奖 if(agent_p('luckydraw')){ $drawlist = pdo_getall('wlmerchant_luckydraw',array('uniacid' => $_W['uniacid'],'aid' => $_W['aid'],'status' => 1),array('id','title')); } if ($id > 0) { if ($plugin == 'rush') { $goods = Rush::getSingleActive($id , '*'); $goods['lp_set'] = unserialize($goods['lp_set']); } else if ($plugin == 'groupon') { $goods = Groupon::getSingleActive($id , '*'); } else if ($plugin == 'bargain') { $goods = Bargain::getSingleActive($id , '*'); $goods['rules'] = unserialize($goods['rules']); $goods['num'] = $goods['stock']; $goods['allsalenum'] = $goods['falsejoinnum']; if(empty($goods['bar_bgc'])){ $goods['bar_bgc'] = '#68d3ff'; } } else if ($plugin == 'fightgroup') { $goods = Wlfightgroup::getSingleGood($id , '*'); $goods['sid'] = $goods['merchantid']; $goods['sort'] = $goods['listorder']; $goods['starttime'] = $goods['limitstarttime']; $goods['endtime'] = $goods['limitendtime']; $goods['thumb'] = $goods['logo']; $goods['thumbs'] = $goods['adv']; $goods['num'] = $goods['stock']; $goods['allsalenum'] = $goods['falsesalenum']; $goods['vipprice'] = $goods['vipdiscount']; $goods['optionstatus'] = $goods['specstatus']; $goods['cateid'] = $goods['categoryid']; } $merchant = Rush::getSingleMerchant($goods['sid'] , 'id,storename,logo,groupid'); $goods['thumbs'] = unserialize($goods['thumbs']); $tags = unserialize($goods['tag']); $orderinfo = unserialize($goods['orderinfo']); $userlabel = unserialize($goods['userlabel']); $goods['level'] = unserialize($goods['level']); //规格 $data = $this->spec_html($id , $plugin); $html = $data['html']; $allspecs = $data['allspecs']; $options = $data['options']; if(!empty($options)){ foreach($options as &$option){ $option['viparray'] = unserialize($option['viparray']); $option['disarray'] = unserialize($option['disarray']); } } if ($goods['usedatestatus'] == 1) { $goods['week'] = unserialize($goods['week']); } if ($goods['usedatestatus'] == 2) { $goods['day'] = unserialize($goods['day']); } if($goods['vipstatus'] == 1){ $viparray = unserialize($goods['viparray']); } if(empty($goods['isdistri'])){ $disarray = unserialize($goods['disarray']); } if(!empty($goods['appointarray'])){ $goods['appointarray'] = unserialize($goods['appointarray']); } } if (empty($goods['starttime']) || empty($goods['endtime'])) {//初始化时间 $goods['starttime'] = time(); $goods['endtime'] = strtotime('+1 month'); $goods['cutofftime'] = strtotime('+2 month'); } //推广图片反序列化 $goods['extension_img'] = unserialize($goods['extension_img']); //支付方式 $goods['pay_type'] = unserialize($goods['pay_type']); //满减活动 if(p('fullreduce')){ $fullreducelist = pdo_getall('wlmerchant_fullreduce_list',array('aid' => $_W['aid'],'uniacid' => $_W['uniacid']),array('id','title')); } //获取自定义表单信息 $diyFormList = FormTemplate::getAllDiyFormList($_W); //富文本处理 if(is_base64($goods['detail'])) $goods['detail'] = htmlspecialchars_decode(base64_decode($goods['detail'])); if(is_base64($goods['describe'])) $goods['describe'] = htmlspecialchars_decode(base64_decode($goods['describe'])); // 获取特殊商品类型 if (!is_store() && empty($goods['pftid'])) { $cc_data = Category::getStoreCategory(); } else { $cc_data = Category::getStoreCategoryAll($_W['storeid']); } include wl_template('goodshouse/createactive'); } /** * 添加规格子项 */ public function spec() { global $_W , $_GPC; $spec = ['id' => random(32) , 'title' => $_GPC['title']]; include wl_template('goodshouse/spec'); } /** * 添加规格项 */ public function spec_item() { global $_W , $_GPC; $spec = ['id' => $_GPC['specid']]; $specitem = ['id' => random(32) , 'title' => $_GPC['title'] , 'show' => 1]; include wl_template('goodshouse/spec_item'); } /** * 完善图片链接 */ public function jstomedia(){ global $_W , $_GPC; $thumb = tomedia($_GPC['thumb']); die($thumb); } /** * 根据规格生成html * @param $id * @param $plugin * @param $distriset * @return string */ private function spec_html($id , $plugin) { global $_W; $html = ''; if ($plugin == 'bargain') { return $html; } $type = $this->spec_type($plugin); $allspecs = pdo_fetchall('select * from ' . tablename('wlmerchant_goods_spec') . ' where goodsid=:id AND type = :type order by displayorder asc' , [ ':id' => $id , ':type' => $type ]); foreach ($allspecs as &$s) { $s['items'] = pdo_fetchall("SELECT * FROM " . tablename('wlmerchant_goods_spec_item') . "WHERE uniacid = {$_W['uniacid']} AND specid = {$s['id']} ORDER BY displayorder ASC"); } unset($s); $options = pdo_fetchall('select * from ' . tablename('wlmerchant_goods_option') . ' where goodsid=:id and type = :type order by id asc' , [ ':id' => $id , ':type' => $type ]); $specs = []; if (0 < count($options)) { $specitemids = explode('_' , $options[0]['specs']); foreach ($specitemids as $itemid) { foreach ($allspecs as $ss) { $items = $ss['items']; foreach ($items as $it) { while ($it['id'] == $itemid) { $specs[] = $ss; break; } } } } $html = ''; $html .= '
| ' . $specs[$i]['title'] . ' | '; $itemlen = count($specs[$i]['items']); if ($itemlen <= 0) { $itemlen = 1; } $newlen *= $itemlen; $h = []; $j = 0; while ($j < $newlen) { $h[$i][$j] = []; ++$j; } $l = count($specs[$i]['items']); $rowspans[$i] = 1; $j = $i + 1; while ($j < $len) { $rowspans[$i] *= count($specs[$j]['items']); ++$j; } ++$i; } //已售 $html .= '已售 | ';
//缩略图
$html .= '预览图 | ';
if ($plugin == 'fightgroup') {
$html .= ''; $html .= ' | '; $html .= ' | '; if(!is_store()){ $html .= ' | '; } //$html .= ' | '; //if(!is_store()) $html .= ' | '; } else { $html .= ' | '; $html .= ' | '; //$html .= ' | '; if(!is_store()) { $html .= ' | '; } //$html .= ' | '; //if(!is_store()) $html .= ' | '; } // if ($distriset['ranknum'] > 1) { // if(!is_store()) $html .= ' | '; // } // if ($distriset['ranknum'] > 2) { // if(!is_store()) $html .= ' | '; // } $html .= ' | ' . $specs[$m]['items'][$kid]['title'] . ' | ' , 'id' => $specs[$m]['items'][$kid]['id'] ]; } else { $h[$m][$j] = ['html' => '' , 'id' => $specs[$m]['items'][$kid]['id']]; } ++$n; if ($n == $rowspan) { ++$kid; if ((count($specs[$m]['items']) - 1) < $kid) { $kid = 0; } $n = 0; } ++$j; } ++$m; } $hh = ''; $i = 0; while ($i < $newlen) { $hh .= '
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ';
$hh .= ' '.$val['salenum'].' | ';
//图片
$hh .= '';
$hh .= '';
$hh .= ' | ';
$hh .= ''; $hh .= ''; $hh .= ' | '; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; if($plugin == 'fightgroup'){ $hh .= ' | '; } if(!is_store()) { $hh .= ' | '; } //$hh .= ' | '; // if(!is_store()) $hh .= ' | '; // if ($distriset['ranknum'] > 1) { // if(!is_store()) $hh .= ' | '; // } // if ($distriset['ranknum'] > 2) { // if(!is_store()) $hh .= ' | '; // } $hh .= ' |