网培系统设置开关和商品配置
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)));
}
}
}

File diff suppressed because it is too large Load Diff

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'}