diff --git a/application/index/controller/Goods.php b/application/index/controller/Goods.php index ddb2da5bc..99b0cca11 100755 --- a/application/index/controller/Goods.php +++ b/application/index/controller/Goods.php @@ -10,6 +10,7 @@ // +---------------------------------------------------------------------- namespace app\index\controller; +use think\facade\Hook; use app\service\GoodsService; use app\service\SeoService; @@ -69,6 +70,51 @@ class Goods extends Common // 商品收藏总数 $ret['data'][0]['favor_count'] = GoodsService::GoodsFavorTotal(['goods_id'=>$id]); + // 商品页面基础信息顶部钩子 + $this->assign('plugins_view_goods_detail_base_top_data', Hook::listen('plugins_view_goods_detail_base_top', + [ + 'hook_name' => 'plugins_view_goods_detail_base_top', + 'is_backend' => false, + 'goods_id' => $id, + 'goods' => &$ret['data'][0], + ])); + + // 商品页面基础信息面板底部钩子 + $this->assign('plugins_view_goods_detail_panel_bottom_data', Hook::listen('plugins_view_goods_detail_panel_bottom', + [ + 'hook_name' => 'plugins_view_goods_detail_panel_bottom', + 'is_backend' => false, + 'goods_id' => $id, + 'goods' => &$ret['data'][0], + ])); + + // 商品页面tabs顶部钩子 + $this->assign('plugins_view_goods_detail_tabs_top_data', Hook::listen('plugins_view_goods_detail_tabs_top', + [ + 'hook_name' => 'plugins_view_goods_detail_tabs_top', + 'is_backend' => false, + 'goods_id' => $id, + 'goods' => &$ret['data'][0], + ])); + + // 商品页面tabs顶部钩子 + $this->assign('plugins_view_goods_detail_tabs_bottom_data', Hook::listen('plugins_view_goods_detail_tabs_bottom', + [ + 'hook_name' => 'plugins_view_goods_detail_tabs_bottom', + 'is_backend' => false, + 'goods_id' => $id, + 'goods' => &$ret['data'][0], + ])); + + // 商品页面左侧顶部钩子 + $this->assign('plugins_view_goods_detail_left_top_data', Hook::listen('plugins_view_goods_detail_left_top', + [ + 'hook_name' => 'plugins_view_goods_detail_left_top', + 'is_backend' => false, + 'goods_id' => $id, + 'goods' => &$ret['data'][0], + ])); + // 商品数据 $this->assign('goods', $ret['data'][0]); diff --git a/application/index/view/default/goods/index.html b/application/index/view/default/goods/index.html index d474064fa..0d5063d42 100755 --- a/application/index/view/default/goods/index.html +++ b/application/index/view/default/goods/index.html @@ -80,18 +80,32 @@

{{$goods.title}}

- + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_base_top +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_base_top_data) and is_array($plugins_view_goods_detail_base_top_data)}} + {{foreach $plugins_view_goods_detail_base_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} + +
- {{if isset($goods['original_price']) and $goods['original_price'] gt 0}} + {{if isset($goods['original_price']) and $goods['original_price'] gt 0 and !empty($goods['show_field_original_price_text'])}}
-
原价
+
{{$goods.show_field_original_price_text|raw}}
¥ {{$goods.original_price}}
{{/if}}
-
销售价
+
{{if empty($goods['show_field_price_text'])}}销售价{{else /}}{{$goods.show_field_price_text|raw}}{{/if}}
¥ {{$goods.price}} @@ -101,17 +115,31 @@
+ + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_panel_bottom +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_panel_bottom_data) and is_array($plugins_view_goods_detail_panel_bottom_data)}} + {{foreach $plugins_view_goods_detail_panel_bottom_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}}
@@ -237,9 +265,24 @@
- +
+ + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_left_top +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_left_top_data) and is_array($plugins_view_goods_detail_left_top_data)}} + {{foreach $plugins_view_goods_detail_left_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} + +
    @@ -263,7 +306,24 @@
+ +
+ + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_tabs_top +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_tabs_top_data) and is_array($plugins_view_goods_detail_tabs_top_data)}} + {{foreach $plugins_view_goods_detail_tabs_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} + +
  • @@ -329,6 +389,20 @@
+ + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_tabs_bottom +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_tabs_bottom_data) and is_array($plugins_view_goods_detail_tabs_bottom_data)}} + {{foreach $plugins_view_goods_detail_tabs_bottom_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} diff --git a/application/plugins/answers/Admin.php b/application/plugins/answers/Admin.php index 7e222072c..9d00a5d7c 100644 --- a/application/plugins/answers/Admin.php +++ b/application/plugins/answers/Admin.php @@ -133,14 +133,16 @@ class Admin extends Controller public function sliderinfo($params = []) { // 数据 + $data = []; if(!empty($params['id'])) { $data_params = array( 'where' => ['id'=>intval($params['id'])], ); $ret = Service::SlideList($data_params); - $this->assign('data', empty($ret['data'][0]) ? [] : $ret['data'][0]); + $data = empty($ret['data'][0]) ? [] : $ret['data'][0]; } + $this->assign('data', $data); return $this->fetch('../../../plugins/view/answers/admin/sliderinfo'); } diff --git a/application/plugins/answers/Hook.php b/application/plugins/answers/Hook.php index 9263af62d..0360e4607 100644 --- a/application/plugins/answers/Hook.php +++ b/application/plugins/answers/Hook.php @@ -37,7 +37,7 @@ class Hook extends Controller if(is_array($params['header'])) { // 获取应用数据 - $ret = PluginsService::PluginsData('answers', ['images']); + $ret = PluginsService::PluginsData('answers', ['images', 'images_bottom']); if($ret['code'] == 0 && !empty($ret['data']['application_name'])) { $nav = [ diff --git a/application/plugins/answers/Index.php b/application/plugins/answers/Index.php index dfd9785b9..53e649466 100644 --- a/application/plugins/answers/Index.php +++ b/application/plugins/answers/Index.php @@ -39,7 +39,7 @@ class Index extends Controller public function index($params = []) { // 基础数据 - $base = PluginsService::PluginsData('answers', ['images']); + $base = PluginsService::PluginsData('answers', ['images', 'images_bottom']); $this->assign('plugins_answers_data', isset($base['data']) ? $base['data'] : []); // 幻灯片 @@ -93,7 +93,7 @@ class Index extends Controller public function detail($params = []) { // 基础数据 - $base = PluginsService::PluginsData('answers', ['images']); + $base = PluginsService::PluginsData('answers', ['images', 'images_bottom']); $this->assign('plugins_answers_data', isset($base['data']) ? $base['data'] : []); // 商品数据 @@ -148,7 +148,7 @@ class Index extends Controller return redirect(PluginsHomeUrl('answers', 'index', 'search', ['answers_keywords'=>$answers_keywords])); } else { // 基础数据 - $base = PluginsService::PluginsData('answers', ['images']); + $base = PluginsService::PluginsData('answers', ['images', 'images_bottom']); $this->assign('plugins_answers_data', isset($base['data']) ? $base['data'] : []); // 商品数据 diff --git a/application/plugins/answers/Service.php b/application/plugins/answers/Service.php index 4c8bd7f5e..dbe30a5e8 100644 --- a/application/plugins/answers/Service.php +++ b/application/plugins/answers/Service.php @@ -87,6 +87,7 @@ class Service [ 'checked_type' => 'fun', 'key_name' => 'url', + 'is_checked' => 1, 'checked_data' => 'CheckUrl', 'error_msg' => 'url格式有误', ], @@ -240,7 +241,7 @@ class Service $field = 'g.id,g.title'; // 获取数据 - return GoodsService::CategoryGoodsList(['where'=>$where, 'm'=>0, 'n'=>100, 'field'=>$field]); + return GoodsService::CategoryGoodsList(['where'=>$where, 'm'=>0, 'n'=>100, 'field'=>$field, 'is_admin_access'=>1]); } /** diff --git a/application/plugins/freightfee/Hook.php b/application/plugins/freightfee/Hook.php index 7ec097b72..b7506a163 100644 --- a/application/plugins/freightfee/Hook.php +++ b/application/plugins/freightfee/Hook.php @@ -111,7 +111,7 @@ class Hook $params['data']['extension_data'][] = [ 'name' => $show_name, 'price' => $price, - 'type' => 0, + 'type' => 1, 'tips' => '+¥'.$price.'元', ]; diff --git a/application/plugins/newuserreduction/Admin.php b/application/plugins/newuserreduction/Admin.php new file mode 100644 index 000000000..53e0a1fbe --- /dev/null +++ b/application/plugins/newuserreduction/Admin.php @@ -0,0 +1,85 @@ +assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/newuserreduction/admin/index'); + } else { + return $ret['msg']; + } + } + + /** + * 编辑页面 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function saveinfo($params = []) + { + $ret = PluginsService::PluginsData('newuserreduction'); + if($ret['code'] == 0) + { + // 是否 + $is_whether_list = [ + 0 => array('id' => 0, 'name' => '否', 'checked' => true), + 1 => array('id' => 1, 'name' => '是'), + ]; + + $this->assign('is_whether_list', $is_whether_list); + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/newuserreduction/admin/saveinfo'); + } else { + return $ret['msg']; + } + } + + /** + * 数据保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function save($params = []) + { + return PluginsService::PluginsDataSave(['plugins'=>'newuserreduction', 'data'=>$params]); + } +} +?> \ No newline at end of file diff --git a/application/plugins/newuserreduction/Hook.php b/application/plugins/newuserreduction/Hook.php new file mode 100644 index 000000000..8d447b952 --- /dev/null +++ b/application/plugins/newuserreduction/Hook.php @@ -0,0 +1,153 @@ +ReductionCalculate($params); + break; + + default : + $ret = ''; + } + return $ret; + } + } + + /** + * 立减计算 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-21 + * @desc description + * @param [array] $params [输入参数] + */ + public function ReductionCalculate($params = []) + { + $ret = PluginsService::PluginsData('newuserreduction'); + if($ret['code'] == 0) + { + // 是否设置需满金额 + if(isset($ret['data']['full_amount']) && $ret['data']['full_amount'] > 0 && $params['data']['base']['total_price'] < $ret['data']['full_amount']) + { + return DataReturn('无需处理', 0); + } + + // 默认金额 + $price = isset($ret['data']['price']) ? (float) $ret['data']['price'] : 0; + $unit = '元'; + $price_show = $price; + if($price > 0 && $this->IsNewUser($params)) + { + // 是否随机 + if(isset($ret['data']['is_random']) && $ret['data']['is_random'] == 1) + { + // 随机金额需要提交步骤生效 + if(!isset($params['params']['is_order_submit']) || $params['params']['is_order_submit'] != 1) + { + $price = 0; + $price_show = '随机减'; + $unit = ''; + } else { + $price = $this->RandomFloat(0, $price); + $price_show = $price; + } + } + + // 扩展展示数据 + $show_name = empty($ret['data']['show_name']) ? '新用户立减' : $ret['data']['show_name']; + $params['data']['extension_data'][] = [ + 'name' => $show_name, + 'price' => $price, + 'type' => 0, + 'tips' => '-¥'.$price_show.$unit, + ]; + + // 金额 + $params['data']['base']['increase_price'] -= $price; + $params['data']['base']['actual_price'] -= $price; + } + return DataReturn('无需处理', 0); + } else { + return $ret['msg']; + } + } + + /** + * 是否满足新用户条件 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-25 + * @desc description + * @param [array] $params [输入参数] + */ + private function IsNewUser($params = []) + { + // 用户信息是否存在 + if(empty($params['params']['user'])) + { + return false; + } + + // 获取用户订单 + // 订单状态(0待确认, 1已确认/待支付, 2已支付/待发货, 3已发货/待收货, 4已完成, 5已取消, 6已关闭) + $where = [ + ['user_id', '=', intval($params['params']['user']['id'])], + ['status', '<=', 4], + ]; + $temp = Db::name('Order')->where($where)->count(); + return empty($temp); + } + + /** + * 生成随机金额 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-25 + * @desc description + * @param [int] $min [最小值] + * @param [int] $max [最大值] + */ + private function RandomFloat($min = 0, $max = 10) + { + return sprintf("%.2f", $min+mt_rand()/mt_getrandmax()*($max-$min)); + } +} +?> \ No newline at end of file diff --git a/application/plugins/newuserreduction/config.json b/application/plugins/newuserreduction/config.json new file mode 100644 index 000000000..ebc2908e9 --- /dev/null +++ b/application/plugins/newuserreduction/config.json @@ -0,0 +1,28 @@ +{ + "base":{ + "plugins":"newuserreduction", + "name":"新用户立减", + "logo":"\/static\/upload\/images\/plugins_newuserreduction\/2019\/03\/25\/1553483752670109.jpg", + "author":"Devil", + "author_url":"https:\/\/shopxo.net\/", + "version":"1.0.0", + "desc":"新用户立减优惠", + "apply_terminal":[ + "pc", + "h5", + "app", + "alipay", + "weixin", + "baidu" + ], + "apply_version":[ + "1.4.0" + ], + "is_home":false + }, + "hook":{ + "plugins_service_buy_handle":[ + "app\\plugins\\newuserreduction\\Hook" + ] + } +} \ No newline at end of file diff --git a/application/plugins/touristbuy/Hook.php b/application/plugins/touristbuy/Hook.php index b6a05f344..71dfc90be 100644 --- a/application/plugins/touristbuy/Hook.php +++ b/application/plugins/touristbuy/Hook.php @@ -168,7 +168,7 @@ class Hook extends Controller // 获取应用数据 $ret = PluginsService::PluginsData('touristbuy'); $login_name = empty($ret['data']['login_name']) ? '游客登录' : $ret['data']['login_name']; - return ''.$ret['data']['login_name'].''; + return ''.$login_name.''; } return ''; } diff --git a/application/plugins/usernotloginhidegoodsprice/Hook.php b/application/plugins/usernotloginhidegoodsprice/Hook.php index bf11c6529..5ec927fd6 100755 --- a/application/plugins/usernotloginhidegoodsprice/Hook.php +++ b/application/plugins/usernotloginhidegoodsprice/Hook.php @@ -90,11 +90,11 @@ class Hook extends Controller $original_price_placeholder = isset($ret['data']['original_price_placeholder']) ? $ret['data']['original_price_placeholder'] : ''; // 销售价 - $price_placeholder = isset($ret['data']['price_placeholder']) ? $ret['data']['price_placeholder'] : ''; + $price_placeholder = empty($ret['data']['price_placeholder']) ? '登录可见' : $ret['data']['price_placeholder']; switch($params['hook_name']) { - // 商品数据处理前 + // 商品数据处理后 case 'plugins_service_goods_handle_end' : // 商品原价 if(isset($params['goods']['original_price'])) diff --git a/application/plugins/view/answers/admin/sliderinfo.html b/application/plugins/view/answers/admin/sliderinfo.html index 97fc7d37d..ffd6e6802 100644 --- a/application/plugins/view/answers/admin/sliderinfo.html +++ b/application/plugins/view/answers/admin/sliderinfo.html @@ -24,7 +24,7 @@
- +
diff --git a/application/plugins/view/answers/index/index.html b/application/plugins/view/answers/index/index.html index ee202f4d9..3a613090b 100644 --- a/application/plugins/view/answers/index/index.html +++ b/application/plugins/view/answers/index/index.html @@ -22,7 +22,7 @@