网培系统设置开关和商品配置
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
meng 2023-02-17 04:05:07 +08:00
parent 59e477799e
commit e93d5db2d7
6 changed files with 581 additions and 467 deletions

View File

@ -1378,6 +1378,10 @@ class System_EweiShopV2Model
array( array(
'title'=>'其他', 'title'=>'其他',
'items'=>array( 'items'=>array(
array(
'title'=>'网培服务设置',
'route'=>'wpfw'
),
array( array(
'title'=>'会员设置', 'title'=>'会员设置',
'route'=>'member' 'route'=>'member'

60
core/model/wpfw.php Normal file
View File

@ -0,0 +1,60 @@
<?php
/*
* 网培服务类
*
*/
if (!defined('IN_IA')) {
exit('Access Denied');
}
/*
CREATE TABLE `ims_ewei_shop_good_wpfw` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`uniacid` int(11) NOT NULL,
`goods_id` int(11) NOT NULL,
`url` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`api_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted` tinyint(3) DEFAULT '0',
PRIMARY KEY (`id`,`goods_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
*/
class Wpfw_EweiShopV2Model {
public function good_get_wpset($goods_id,$sysset=array())
{
global $_W;
if(empty($sysset)){
$sysset = m("common")->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)));
}
}
}

View File

@ -18,15 +18,13 @@ $shopset_level = intval($_W['shopset']['commission']['level']);
$id = intval($_GPC['id']); $id = intval($_GPC['id']);
if (!empty($id)) { if (!empty($id)) {
pdo_update('ewei_shop_goods', array('newgoods' => 0), array('id' => $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'] = 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_start'] = date('Y-m-d H:i', $item['isdiscount_time_start']);
if(!empty($item)&&$item['type']==5&&!empty($item['opencard'])&&!empty($item['cardid'])) 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'])); $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')) {
@ -119,8 +117,8 @@ $commission_level =array_merge(array(
), $commission_level); ), $commission_level);
$com_virtual = com('virtual'); $com_virtual = com('virtual');
//todo获取网培服务的默认配置
$wpfwset = m("common")->getSysset("wpfwset");
if ($_W['ispost']) { if ($_W['ispost']) {
if (empty($id)) { if (empty($id)) {
@ -234,41 +232,16 @@ if ($_W['ispost']) {
'deduct2' => $_GPC['deduct2'], 'deduct2' => $_GPC['deduct2'],
'virtual' => $goodstype == 3 ? intval($_GPC['virtual']) : 0, 'virtual' => $goodstype == 3 ? intval($_GPC['virtual']) : 0,
// 'discounts' => is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array()), // 'discounts' => is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array()),
'ednum' => intval($_GPC['ednum']) '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']),
, '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']) 'isshowfreight' => intval($_GPC['isshowfreight'])
); );
if (isset($_GPC['video_url']) && $_GPC['video_type'] == 2) { if (isset($_GPC['video_url']) && $_GPC['video_type'] == 2) {
$data['end_video_url'] = parseTencentVideo($_GPC['video_url']); $data['end_video_url'] = parseTencentVideo($_GPC['video_url']);
} }
if (isset($_GPC['video_url']) && $_GPC['video_type'] == 1) { if (isset($_GPC['video_url']) && $_GPC['video_type'] == 1) {
$data['video'] = ($_GPC['video']); $data['video'] = ($_GPC['video']);
if(empty($data['video'])) if (empty($data['video'])) {
{
show_json(0, '请上传视频'); show_json(0, '请上传视频');
} }
} }
@ -304,68 +277,53 @@ if ($_W['ispost']) {
$intervalfloor = 0; $intervalfloor = 0;
$intervalprice = ""; $intervalprice = "";
if($goodstype==4) if ($goodstype == 4) {
{
//批发商品 阶梯价格设置 //批发商品 阶梯价格设置
$intervalfloor = intval($_GPC['intervalfloor']); $intervalfloor = intval($_GPC['intervalfloor']);
if($intervalfloor>3||$intervalfloor<1) if ($intervalfloor > 3 || $intervalfloor < 1) {
{
show_json(0, '请至少添加一个区间价格!'); show_json(0, '请至少添加一个区间价格!');
} }
$intervalprices = array(); $intervalprices = array();
if($intervalfloor>0) if ($intervalfloor > 0) {
{
if(intval($_GPC['intervalnum1'])<=0) if (intval($_GPC['intervalnum1']) <= 0) {
{
show_json(0, '请设置起批发量!'); show_json(0, '请设置起批发量!');
} }
if(floatval($_GPC['intervalprice1'])<=0) if (floatval($_GPC['intervalprice1']) <= 0) {
{
show_json(0, '批发价必须大于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 ($intervalfloor > 1) {
{ if (intval($_GPC['intervalnum2']) <= 0) {
if(intval($_GPC['intervalnum2'])<=0)
{
show_json(0, '请设置起批发量!'); show_json(0, '请设置起批发量!');
} }
if(intval($_GPC['intervalnum2'])<=intval($_GPC['intervalnum1'])) if (intval($_GPC['intervalnum2']) <= intval($_GPC['intervalnum1'])) {
{
show_json(0, '批发量需大于上级批发量!'); show_json(0, '批发量需大于上级批发量!');
} }
if(floatval($_GPC['intervalprice2'])>=floatval($_GPC['intervalprice1'])) if (floatval($_GPC['intervalprice2']) >= floatval($_GPC['intervalprice1'])) {
{
show_json(0, '批发价需小于上级批发价!'); 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 ($intervalfloor > 2) {
{ if (intval($_GPC['intervalnum3']) <= 0) {
if(intval($_GPC['intervalnum3'])<=0)
{
show_json(0, '请设置起批发量!'); show_json(0, '请设置起批发量!');
} }
if(intval($_GPC['intervalnum3'])<=intval($_GPC['intervalnum2'])) if (intval($_GPC['intervalnum3']) <= intval($_GPC['intervalnum2'])) {
{
show_json(0, '批发量需大于上级批发量!'); show_json(0, '批发量需大于上级批发量!');
} }
if(floatval($_GPC['intervalprice3'])>=floatval($_GPC['intervalprice2'])) if (floatval($_GPC['intervalprice3']) >= floatval($_GPC['intervalprice2'])) {
{
show_json(0, '批发价需小于上级批发价!'); show_json(0, '批发价需小于上级批发价!');
} }
@ -474,14 +432,11 @@ if ($_W['ispost']) {
//兼容 1.x //兼容 1.x
if ($c['level'] == 1) { //一级 if ($c['level'] == 1) { //一级
$pcateid = $cid; $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'])); $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']; $pcateid = $crow['parentid'];
$ccateid = $cid; $ccateid = $cid;
} else if ($c['level'] == 3) {
}
else if($c['level']==3){
$tcateid = $cid; $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'])); $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']; $ccateid = $tcate['parentid'];
@ -489,10 +444,7 @@ if ($_W['ispost']) {
$pcateid = $ccate['parentid']; $pcateid = $ccate['parentid'];
} }
} }
} }
} }
$data['pcate'] = $pcateid; $data['pcate'] = $pcateid;
@ -589,9 +541,6 @@ if ($_W['ispost']) {
unset($thumb_url[0]); unset($thumb_url[0]);
$data['thumb_url'] = serialize(m('common')->array_images($thumb_url)); $data['thumb_url'] = serialize(m('common')->array_images($thumb_url));
} }
if (p('threen')) { if (p('threen')) {
$threen = $_GPC['threen']; $threen = $_GPC['threen'];
@ -607,8 +556,7 @@ if ($_W['ispost']) {
$data['threen'] = json_encode($threen); $data['threen'] = json_encode($threen);
} }
//记次时商品 //记次时商品
if($goodstype==5) if ($goodstype == 5) {
{
//可核销次数 //可核销次数
$verifygoodsnum = intval($_GPC['verifygoodsnum']); $verifygoodsnum = intval($_GPC['verifygoodsnum']);
@ -617,11 +565,9 @@ if ($_W['ispost']) {
//统一过期时间 //统一过期时间
if(!empty($_GPC['verifygoodslimitdate'])) if (!empty($_GPC['verifygoodslimitdate'])) {
{
$verifygoodslimitdate = strtotime($_GPC['verifygoodslimitdate']); $verifygoodslimitdate = strtotime($_GPC['verifygoodslimitdate']);
}else } else {
{
$verifygoodslimitdate = 0; $verifygoodslimitdate = 0;
} }
@ -629,21 +575,17 @@ if ($_W['ispost']) {
//可核销天数 //可核销天数
$verifygoodsdays = intval($_GPC['verifygoodsdays']); $verifygoodsdays = intval($_GPC['verifygoodsdays']);
if(empty($verifygoodslimittype)) if (empty($verifygoodslimittype)) {
{ if (empty($verifygoodsdays)) {
if(empty($verifygoodsdays))
{
$verifygoodsdays = 365; $verifygoodsdays = 365;
} }
} }
if(com('wxcard')) if (com('wxcard')) {
{
$opencard = intval($_GPC['opencard']); $opencard = intval($_GPC['opencard']);
if(!empty($opencard)) if (!empty($opencard)) {
{
//记次时商品]); //记次时商品]);
if (strlen($_GPC['custom_cell1_url']) > 128) { if (strlen($_GPC['custom_cell1_url']) > 128) {
show_json(0, '入口跳转链接不能超过128个字符'); show_json(0, '入口跳转链接不能超过128个字符');
@ -687,8 +629,7 @@ if ($_W['ispost']) {
"custom_cell1_url" => $_GPC['custom_cell1_url'] "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($card)) {
if (empty($_GPC['card_logoimg'])) { if (empty($_GPC['card_logoimg'])) {
show_json(0, 'logo图片不能为空'); show_json(0, 'logo图片不能为空');
@ -707,14 +648,11 @@ if ($_W['ispost']) {
$img = $img['content']; $img = $img['content'];
if(strlen($img) != 0) if (strlen($img) != 0) {
{
file_put_contents($imgurl, $img); file_put_contents($imgurl, $img);
}else } else {
{
show_json(0, "上传的logo图片限制文件大小限制1MB像素为300*300仅支持JPG、PNG格式。"); show_json(0, "上传的logo图片限制文件大小限制1MB像素为300*300仅支持JPG、PNG格式。");
} }
} }
$result = com('wxcard')->wxCardUpdateImg($imgurl); $result = com('wxcard')->wxCardUpdateImg($imgurl);
@ -727,14 +665,10 @@ if ($_W['ispost']) {
$carddata['card_logowxurl'] = $result["url"]; $carddata['card_logowxurl'] = $result["url"];
} }
if(!empty($_GPC['card_backgroundtype'])) if (!empty($_GPC['card_backgroundtype'])) {
{ if (empty($card) || $card['card_backgroundimg'] != $_GPC['card_backgroundimg']) {
if(empty($card)||$card['card_backgroundimg']!=$_GPC['card_backgroundimg']) if (empty($card)) {
{ if (empty($_GPC['card_logoimg'])) {
if(empty($card))
{
if(empty($_GPC['card_logoimg']))
{
show_json(0, '设置使用背景图片时图片不能为空'); show_json(0, '设置使用背景图片时图片不能为空');
} }
} }
@ -751,11 +685,9 @@ if ($_W['ispost']) {
$img = $img['content']; $img = $img['content'];
if(strlen($img) != 0) if (strlen($img) != 0) {
{
file_put_contents($imgurl, $img); file_put_contents($imgurl, $img);
}else } else {
{
show_json(0, "上传的背景图片限制文件大小限制1MB像素为1000*600仅支持JPG、PNG格式"); show_json(0, "上传的背景图片限制文件大小限制1MB像素为1000*600仅支持JPG、PNG格式");
} }
} }
@ -768,9 +700,7 @@ if ($_W['ispost']) {
$carddata['card_backgroundimg'] = $_GPC['card_backgroundimg']; $carddata['card_backgroundimg'] = $_GPC['card_backgroundimg'];
$carddata['card_backgroundwxurl'] = $result["url"]; $carddata['card_backgroundwxurl'] = $result["url"];
} } else if (!empty($card) && $card['card_backgroundimg'] == $_GPC['card_backgroundimg']) {
else if(!empty($card) &&$card['card_backgroundimg']== $_GPC['card_backgroundimg'])
{
$carddata['card_backgroundimg'] = $card['card_backgroundimg']; $carddata['card_backgroundimg'] = $card['card_backgroundimg'];
$carddata['card_backgroundwxurl'] = $card['card_backgroundwxurl']; $carddata['card_backgroundwxurl'] = $card['card_backgroundwxurl'];
} }
@ -782,11 +712,9 @@ if ($_W['ispost']) {
$change = com('wxcard')->checkchange($card, $carddata); $change = com('wxcard')->checkchange($card, $carddata);
if($change) if ($change) {
{
$result = com('wxcard')->verifygoodcard($carddata, $card['card_id']); $result = com('wxcard')->verifygoodcard($carddata, $card['card_id']);
if($result['errcode']==48001) if ($result['errcode'] == 48001) {
{
show_json(0, "您尚未开通微信会员卡。"); show_json(0, "您尚未开通微信会员卡。");
} }
if (is_wxerror($result)) { if (is_wxerror($result)) {
@ -796,22 +724,17 @@ if ($_W['ispost']) {
pdo_update('ewei_shop_goods_cards', $carddata, array('id' => $card['id'])); pdo_update('ewei_shop_goods_cards', $carddata, array('id' => $card['id']));
} }
$cardid = $card['id']; $cardid = $card['id'];
} else {
}else if (strlen($_GPC['title']) > 25) {
{
if(strlen($_GPC['title'])>25)
{
show_json(0, '会员卡标题不能超过25个字符'); show_json(0, '会员卡标题不能超过25个字符');
} }
if(strlen($_GPC['card_brand_name'])>30) if (strlen($_GPC['card_brand_name']) > 30) {
{
show_json(0, '商户名字不能超过30个字符'); show_json(0, '商户名字不能超过30个字符');
} }
if(intval($_GPC['card_totalquantity'])>9999999||intval($_GPC['card_totalquantity'])<1) if (intval($_GPC['card_totalquantity']) > 9999999 || intval($_GPC['card_totalquantity']) < 1) {
{
show_json(0, "会员卡库存需设置再1与9999999之间"); show_json(0, "会员卡库存需设置再1与9999999之间");
} }
@ -825,28 +748,24 @@ if ($_W['ispost']) {
$carddata["deliver"] = $_GPC['deliver'] == "on" ? 1 : 0; $carddata["deliver"] = $_GPC['deliver'] == "on" ? 1 : 0;
$result = com('wxcard')->verifygoodcard($carddata); $result = com('wxcard')->verifygoodcard($carddata);
if($result['errcode']==48001) if ($result['errcode'] == 48001) {
{
show_json(0, "您尚未开通微信会员卡。"); show_json(0, "您尚未开通微信会员卡。");
} }
if (is_wxerror($result)) { if (is_wxerror($result)) {
show_json(0, "卡券信息填写有误。"); show_json(0, "卡券信息填写有误。");
}else } else {
{
$carddata['card_id'] = $result['card_id']; $carddata['card_id'] = $result['card_id'];
} }
pdo_insert('ewei_shop_goods_cards', $carddata); pdo_insert('ewei_shop_goods_cards', $carddata);
$cardid = pdo_insertid(); $cardid = pdo_insertid();
} }
$data['cardid'] = $cardid; $data['cardid'] = $cardid;
} }
$data['opencard'] = $opencard; $data['opencard'] = $opencard;
} }
$data['verifygoodsnum'] = intval($verifygoodsnum); $data['verifygoodsnum'] = intval($verifygoodsnum);
$data['verifygoodslimittype'] = intval($verifygoodslimittype); $data['verifygoodslimittype'] = intval($verifygoodslimittype);
@ -858,7 +777,6 @@ if ($_W['ispost']) {
if ($data['verifytype'] == 0) { if ($data['verifytype'] == 0) {
$data['verifygoodsnum'] = 1; $data['verifygoodsnum'] = 1;
} }
} }
//如果有多规格则清除商品的条码 //如果有多规格则清除商品的条码
@ -1043,13 +961,11 @@ if ($_W['ispost']) {
'virtual' => $data['type'] == 3 ? $optionArray['option_virtual'][$k] : 0, 'virtual' => $data['type'] == 3 ? $optionArray['option_virtual'][$k] : 0,
); );
if($goodstype==4) if ($goodstype == 4) {
{
$a['presellprice'] = 0; $a['presellprice'] = 0;
$a['productprice'] = 0; $a['productprice'] = 0;
$a['costprice'] = 0; $a['costprice'] = 0;
$a['marketprice'] = floatval($_GPC['intervalprice1']); $a['marketprice'] = floatval($_GPC['intervalprice1']);
} }
$totalstocks += $a['stock']; $totalstocks += $a['stock'];
@ -1075,30 +991,23 @@ if ($_W['ispost']) {
$isDiscountsArray[$level['key']]['option' . $option_id] = $isdiscountDiscountsArray['isdiscount_discounts_' . $level['key']][$k]; $isDiscountsArray[$level['key']]['option' . $option_id] = $isdiscountDiscountsArray['isdiscount_discounts_' . $level['key']][$k];
} }
foreach ($commission_level as $level) { foreach ($commission_level as $level) {
if($level['key']=='default') if ($level['key'] == 'default') {
{
$commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['key'] . "_" . $ids]; $commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['key'] . "_" . $ids];
} } else {
else
{
$commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['id'] . "_" . $ids]; $commissionArray[$level['key']]['option' . $option_id] = $commissionArrayPost['commission']['commission_level_' . $level['id'] . "_" . $ids];
} }
} }
} }
//更新discounts //更新discounts
if ((int)$_GPC['discounts']['type'] == 1 && $data['hasoption']) if ((int)$_GPC['discounts']['type'] == 1 && $data['hasoption']) {
{
$discounts_arr = array( $discounts_arr = array(
'type' => (int)$_GPC['discounts']['type'], 'type' => (int)$_GPC['discounts']['type'],
); );
$discounts_arr = array_merge($discounts_arr, $levelArray); $discounts_arr = array_merge($discounts_arr, $levelArray);
$discounts_json = json_encode($discounts_arr); $discounts_json = json_encode($discounts_arr);
} } else {
else
{
$discounts_json = is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array()); $discounts_json = is_array($_GPC['discounts']) ? json_encode($_GPC['discounts']) : json_encode(array());
} }
@ -1114,24 +1023,17 @@ if ($_W['ispost']) {
$has_merch = 1; $has_merch = 1;
} }
if (!empty($isDiscountsArray) && $data['hasoption']) if (!empty($isDiscountsArray) && $data['hasoption']) {
{
$is_discounts_arr = array_merge(array('type' => 1), $isDiscountsArray); $is_discounts_arr = array_merge(array('type' => 1), $isDiscountsArray);
if ($has_merch == 1) { if ($has_merch == 1) {
$is_discounts_arr['merch'] = $old_isdiscount_discounts['merch']; $is_discounts_arr['merch'] = $old_isdiscount_discounts['merch'];
} }
$is_discounts_json = json_encode($is_discounts_arr); $is_discounts_json = json_encode($is_discounts_arr);
} } else {
else foreach ($levels as $level) {
{ if ($level['key'] == 'default') {
foreach ($levels as $level)
{
if ($level['key']=='default')
{
$isDiscountsDefaultArray[$level['key']]['option0'] = $_GPC['isdiscount_discounts_level_' . $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"]; $isDiscountsDefaultArray[$level['key']]['option0'] = $_GPC['isdiscount_discounts_level_' . $level['id'] . "_default"];
} }
} }
@ -1144,32 +1046,22 @@ if ($_W['ispost']) {
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 //更新commission
if(!empty($commissionArray) && $data['hasoption']) if (!empty($commissionArray) && $data['hasoption']) {
{
$commissionArray = array_merge(array('type' => (int)$_GPC['commission_type']), $commissionArray); $commissionArray = array_merge(array('type' => (int)$_GPC['commission_type']), $commissionArray);
$commission_arr = array( $commission_arr = array(
'commission' => is_array($commissionArray) ? json_encode($commissionArray) : json_encode(array()) 'commission' => is_array($commissionArray) ? json_encode($commissionArray) : json_encode(array())
); );
} } else {
else
{
foreach ($commission_level as $level) { foreach ($commission_level as $level) {
if ($level['key']=='default') if ($level['key'] == 'default') {
{ if (!empty($_GPC['commission_level_' . $level['key'] . "_default"])) {
if ( !empty($_GPC['commission_level_' . $level['key'] . "_default"]) ) foreach ($_GPC['commission_level_' . $level['key'] . "_default"] as $key => $value) {
{
foreach ($_GPC['commission_level_' . $level['key'] . "_default"] as $key=>$value)
{
$commissionDefaultArray[$level['key']]['option0'][] = $value; $commissionDefaultArray[$level['key']]['option0'][] = $value;
} }
} }
} } else {
else if (!empty($_GPC['commission_level_' . $level['id'] . "_default"])) {
{ foreach ($_GPC['commission_level_' . $level['id'] . "_default"] as $key => $value) {
if ( !empty($_GPC['commission_level_' . $level['id'] . "_default"]) )
{
foreach ($_GPC['commission_level_' . $level['id'] . "_default"] as $key=>$value)
{
$commissionDefaultArray[$level['key']]['option0'][] = $value; $commissionDefaultArray[$level['key']]['option0'][] = $value;
} }
} }
@ -1224,6 +1116,14 @@ if ($_W['ispost']) {
pdo_update("ewei_shop_goods", array("total" => $totalstocks), array("id" => $id)); pdo_update("ewei_shop_goods", array("total" => $totalstocks), array("id" => $id));
} }
} }
//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']))))); show_json(1, array('url' => webUrl('goods/edit', array('id' => $id, 'tab' => str_replace("#tab_", "", $_GPC['tab'])))));
} }
@ -1239,8 +1139,7 @@ if (!empty($id)) {
//佣金设置 //佣金设置
$commission = json_decode($item['commission'], true); $commission = json_decode($item['commission'], true);
if (isset($commission['type'])) if (isset($commission['type'])) {
{
$commission_type = $commission['type']; $commission_type = $commission['type'];
unset($commission['type']); unset($commission['type']);
} }
@ -1364,8 +1263,7 @@ if (!empty($id)) {
$html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">编码</div><div class="input-group"><input type="text" class="form-control input-sm option_goodssn_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_goodssn\');"></a></span></div></div></th>'; $html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">编码</div><div class="input-group"><input type="text" class="form-control input-sm option_goodssn_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_goodssn\');"></a></span></div></div></th>';
$html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">条码</div><div class="input-group"><input type="text" class="form-control input-sm option_productsn_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_productsn\');"></a></span></div></div></th>'; $html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">条码</div><div class="input-group"><input type="text" class="form-control input-sm option_productsn_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_productsn\');"></a></span></div></div></th>';
$html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">重量(克)</div><div class="input-group"><input type="text" class="form-control input-sm option_weight_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_weight\');"></a></span></div></div></th>'; $html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">重量(克)</div><div class="input-group"><input type="text" class="form-control input-sm option_weight_all" VALUE=""/><span class="input-group-addon"><a href="javascript:;" class="fa fa-angle-double-down" title="批量设置" onclick="setCol(\'option_weight\');"></a></span></div></div></th>';
} } else {
else {
foreach ($levels as $level) { foreach ($levels as $level) {
$discounts_html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">' . $level['levelname'] . '</div></div></th>'; $discounts_html .= '<th><div class=""><div style="padding-bottom:10px;text-align:center;">' . $level['levelname'] . '</div></div></th>';
@ -1474,10 +1372,8 @@ if (!empty($id)) {
foreach ($commission_level as $level) { foreach ($commission_level as $level) {
$temp = is_string($commission[$level['key']]) ? '' : $commission[$level['key']]['option' . $o['id']]; $temp = is_string($commission[$level['key']]) ? '' : $commission[$level['key']]['option' . $o['id']];
if (is_array($temp)) if (is_array($temp)) {
{ foreach ($temp as $t_val) {
foreach ($temp as $t_val)
{
$commission_val[$level['key']][] = $t_val; $commission_val[$level['key']][] = $t_val;
} }
} }
@ -1490,13 +1386,10 @@ if (!empty($id)) {
foreach ($levels as $level) { foreach ($levels as $level) {
$dd .= '<td>'; $dd .= '<td>';
$isdd .= '<td>'; $isdd .= '<td>';
if($level['key']=='default') if ($level['key'] == 'default') {
{
$dd .= '<input data-name="discount_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control discount_' . $level['key'] . ' discount_' . $level['key'] . '_' . $ids . '" value="' . $discounts_val[$level['key']] . '"/> '; $dd .= '<input data-name="discount_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control discount_' . $level['key'] . ' discount_' . $level['key'] . '_' . $ids . '" value="' . $discounts_val[$level['key']] . '"/> ';
$isdd .= '<input data-name="isdiscount_discounts_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control isdiscount_discounts_' . $level['key'] . ' isdiscount_discounts_' . $level['key'] . '_' . $ids . '" value="' . $isdiscounts_val[$level['key']] . '"/> '; $isdd .= '<input data-name="isdiscount_discounts_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control isdiscount_discounts_' . $level['key'] . ' isdiscount_discounts_' . $level['key'] . '_' . $ids . '" value="' . $isdiscounts_val[$level['key']] . '"/> ';
} } else {
else
{
$dd .= '<input data-name="discount_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control discount_level' . $level['id'] . ' discount_level' . $level['id'] . '_' . $ids . '" value="' . $discounts_val['level' . $level['id']] . '"/> '; $dd .= '<input data-name="discount_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control discount_level' . $level['id'] . ' discount_level' . $level['id'] . '_' . $ids . '" value="' . $discounts_val['level' . $level['id']] . '"/> ';
$isdd .= '<input data-name="isdiscount_discounts_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control isdiscount_discounts_level' . $level['id'] . ' isdiscount_discounts_level' . $level['id'] . '_' . $ids . '" value="' . $isdiscounts_val['level' . $level['id']] . '"/> '; $isdd .= '<input data-name="isdiscount_discounts_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control isdiscount_discounts_level' . $level['id'] . ' isdiscount_discounts_level' . $level['id'] . '_' . $ids . '" value="' . $isdiscounts_val['level' . $level['id']] . '"/> ';
} }
@ -1518,40 +1411,26 @@ if (!empty($id)) {
foreach ($commission_level as $level) { foreach ($commission_level as $level) {
$cc .= '<td>'; $cc .= '<td>';
if(!empty($commission_val) && isset($commission_val[$level['key']])) if (!empty($commission_val) && isset($commission_val[$level['key']])) {
{ foreach ($commission_val as $c_key => $c_val) {
foreach ($commission_val as $c_key=>$c_val) if ($c_key == $level['key']) {
{ if ($level['key'] == 'default') {
if($c_key == $level['key']) for ($c_i = 0; $c_i < $shopset_level; $c_i++) {
{
if($level['key']=='default')
{
for ($c_i = 0;$c_i < $shopset_level;$c_i ++)
{
$cc .= '<input data-name="commission_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control commission_' . $level['key'] . ' commission_' . $level['key'] . '_' . $ids . '" value="' . $c_val[$c_i] . '" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> '; $cc .= '<input data-name="commission_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control commission_' . $level['key'] . ' commission_' . $level['key'] . '_' . $ids . '" value="' . $c_val[$c_i] . '" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> ';
} }
} } else {
else for ($c_i = 0; $c_i < $shopset_level; $c_i++) {
{
for ($c_i = 0;$c_i < $shopset_level;$c_i ++)
{
$cc .= '<input data-name="commission_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control commission_level' . $level['id'] . ' commission_level' . $level['id'] . '_' . $ids . '" value="' . $c_val[$c_i] . '" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> '; $cc .= '<input data-name="commission_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control commission_level' . $level['id'] . ' commission_level' . $level['id'] . '_' . $ids . '" value="' . $c_val[$c_i] . '" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> ';
} }
} }
} }
} }
} } else {
else if ($level['key'] == 'default') {
{
if($level['key']=='default')
{
for ($c_i = 0; $c_i < $shopset_level; $c_i++) { for ($c_i = 0; $c_i < $shopset_level; $c_i++) {
$cc .= '<input data-name="commission_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control commission_' . $level['key'] . ' commission_' . $level['key'] . '_' . $ids . '" value="" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> '; $cc .= '<input data-name="commission_level_' . $level['key'] . '_' . $ids . '" type="text" class="form-control commission_' . $level['key'] . ' commission_' . $level['key'] . '_' . $ids . '" value="" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> ';
} }
} } else {
else
{
for ($c_i = 0; $c_i < $shopset_level; $c_i++) { for ($c_i = 0; $c_i < $shopset_level; $c_i++) {
$cc .= '<input data-name="commission_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control commission_level' . $level['id'] . ' commission_level' . $level['id'] . '_' . $ids . '" value="" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> '; $cc .= '<input data-name="commission_level_' . $level['id'] . '_' . $ids . '" type="text" class="form-control commission_level' . $level['id'] . ' commission_level' . $level['id'] . '_' . $ids . '" value="" style="display:inline;width: ' . (96 / $shopset_level) . '%;"/> ';
} }
@ -1646,8 +1525,6 @@ if (!empty($id)) {
$salers = pdo_fetchall("select id,nickname,avatar,openid from " . tablename('ewei_shop_member') . ' where openid in (' . implode(",", $openids) . ") and uniacid={$_W['uniacid']}"); $salers = pdo_fetchall("select id,nickname,avatar,openid from " . tablename('ewei_shop_member') . ' where openid in (' . implode(",", $openids) . ") and uniacid={$_W['uniacid']}");
} }
} }
} }
} }
@ -1689,6 +1566,14 @@ if(p('diypage')){
$detailPages = p('diypage')->getPageList('allpage', " and type=5 "); $detailPages = p('diypage')->getPageList('allpage', " and type=5 ");
$detailPages = $detailPages['list']; $detailPages = $detailPages['list'];
} }
//TODO:商品的网培服务相关
if ($item['wpfw_type'] == 2) {
$goods_wpfw = m("wpfw")->good_get_wpset($item['id'], $wpfwset);
$item['wpfw_url'] = $goods_wpfw['wpfw_url'];
$item['wpfw_api_key'] = $goods_wpfw['wpfw_api_key'];
}
load()->func('tpl'); load()->func('tpl');
include $this->template('goods/post'); include $this->template('goods/post');
exit; exit;

31
core/web/sysset/wpfw.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/**
* 网培服务总设置
*/
if (!defined("IN_IA")) {
exit("Access Denied");
}
//todo:网培服务向goods表添加字段
if(!pdo_fieldexists('ewei_shop_goods', 'wpfw_type')) {
pdo_query("ALTER TABLE ".tablename('ewei_shop_goods')." ADD `wpfw_type` tinyint(3) NOT NULL DEFAULT '0';");
}
class Wpfw_EweiShopV2Page extends WebPage
{
public function main()
{
global $_W;
global $_GPC;
if ($_W["ispost"]) {
$data = is_array($_GPC["data"]) ? $_GPC["data"] : array();
m("common")->updateSysset(array("wpfwset" => $data));
plog("sysset.goods.edit", "保存网培服务设置");
show_json(1);
}
$data = m("common")->getSysset("wpfwset");
include $this->template();
}
}
?>

View File

@ -1,3 +1,60 @@
<!-- 网培服务 商品配置 -->
{if $wpfwset['open_wpfw'] == 1}
<div class="region-goods-details row">
<div class="region-goods-left col-sm-2">网培服务</div>
<div class="region-goods-right col-sm-10">
<div class="alert alert-info">
当前默认地址为:{$wpfwset['default_url']} ,如果选择自定义则本商品优先使用自定义的地址。
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">网培推送配置</label>
{ife 'goods' $item}
<div class="col-sm-9 col-xs-12">
<label class="radio radio-inline" style="float: left;">
<input type="radio" value="0" name="wpfw_type" {if empty($item['wpfw_type'])}checked="true" {/if}>关闭
</label>
<label class="radio radio-inline" style="float: left;">
<input type="radio" value="2" name="wpfw_type" {if $item['wpfw_type']==2}checked="true" {/if}> 自定义
</label>
<label class="radio radio-inline" style="float: left;">
<input type="radio" value="1" name="wpfw_type" {if $item['wpfw_type']==1}checked="true" {/if}>使用默认
</label>
</div>
{else}
<div class='form-control-static'>
{if empty($item['wpfw_type'])}
关闭
{else}
开启
{$value['title']}
{/if}
</div>
{/if}
</div>
<div class="wpfwtype-group" style="margin:0 25px; {if $item['wpfw_type']!=2}display:none;{/if}">
<div class="form-group {if $item['wpfwtype'] !=2}style="display:none;" {/if}">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">网培推送配置</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wpfw_url" class="form-control" value="{$item['wpfw_url']}" data-rule-required='true'>
</div>
</div>
<div class="form-group {if $item['wpfwtype'] !=2}style="display:none;" {/if}">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">API_KEY</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="wpfw_api_key" class="form-control" value="{$item['wpfw_api_key']}" data-rule-required='true'>
</div>
</div>
</div>
</div>
</div>
{/if}
<!-- end -->
<div class="region-goods-details row"> <div class="region-goods-details row">
<div class="region-goods-left col-sm-2" >自定义表单</div> <div class="region-goods-left col-sm-2" >自定义表单</div>
<div class="region-goods-right col-sm-10"> <div class="region-goods-right col-sm-10">
@ -106,6 +163,16 @@
$('.diyform-group').hide(); $('.diyform-group').hide();
} }
}) })
//todo:网培服务商品配置切换
$(':radio[name=wpfw_type]').click(function () {
window.type = $("input[name='wpfw_type']:checked").val();
if(window.type=='2'){
$('.wpfwtype-group').show();
} else {
$('.wpfwtype-group').hide();
}
})
}) })
</script> </script>

View File

@ -0,0 +1,67 @@
{template '_header'}
<div class="page-header"> 当前位置:<span class="text-primary">网培服务设置</span></div>
<div class="page-content">
<form method="post" class="form-horizontal form-validate">
<div class="form-group">
<label class="col-lg control-label">是否开启</label>
<div class="col-sm-9">
{ifp 'sysset.wpfw.edit'}
<label class="radio-inline"><input type="radio" name="data[open_wpfw]" value="1" {if $data['open_wpfw']==1} checked="checked"{/if} onclick="open_wpfw(true)"/>开启</label>
<label class="radio-inline"><input type="radio" name="data[open_wpfw]" value="0" {if empty($data['open_wpfw'])} checked="checked"{/if} onclick="open_wpfw(false)"/>关闭</label>
<span class="help-block">开启网培服务后可以配置商品的推送地址</span>
{else}
<div class='form-control-static'>{if $data['open_wpfw']==1}开启{else}关闭{/if}</div>
{/if}
</div>
</div>
<div id='open_wpfw' {if empty($data['open_wpfw'])}style='display:none'{/if}>
<div class="form-group " >
<label class="col-lg control-label must">默认推送地址</label>
<div class="col-sm-9">
{ifp 'sysset.wpfw.edit'}
<input type="text" name="data[default_url]" class="form-control" value="{$data['default_url']}" data-rule-required='true'>
{else}
<div class='form-control-static'>{$data['default_url']}</div>
{/if}
<span class='help-block'>
<p>如果商品开启了推送但是没有设置推送地址则会被推送到本地址</p>
<p>如果商品设置了推送地址则优先推送到商品自定义的地址</p>
</span>
</div>
</div>
<div class="form-group " >
<label class="col-lg control-label must">API_KEY</label>
<div class="col-sm-9">
{ifp 'sysset.qiniu.edit'}
<input type="text" name="data[api_key]" class="form-control" value="{$data['api_key']}" data-rule-required='true'>
{else}
<div class='form-control-static'>{$data['api_key']}</div>
{/if}
<span class='help-block'>
<p>接收方的api_key,签名方法为md5(时间戳+api_key)</p>
</span>
</div>
</div>
</div>
{ifp 'sysset.wpfw.edit'}
<div class="form-group">
<label class="col-lg control-label "></label>
<div class="col-sm-9">
<input type="submit" value="提交" class="btn btn-primary"/>
</div>
</div>
{/if}
<script language="javascript">
function open_wpfw(open) {
if (open) {
$('#open_wpfw').show();
} else {
$('#open_wpfw').hide();
}
}
</script>
</form>
</div>
{template '_footer'}