Prechádzať zdrojové kódy

Merge branch 'bonus_rate' of 121.43.114.153:/home/git/repositories/shopnc into bonus_rate

stanley-king 6 rokov pred
rodič
commit
8e9dddfc94

+ 89 - 0
data/logic/buy.logic.php

@@ -526,6 +526,16 @@ class buyLogic
         //保存数据
         $this->_order_data['goods_list'] = $goods_list;
         $this->_order_data['store_cart_list'] = $store_cart_list;
+
+
+        $limit = $this->limitBuysNum();
+        if($limit > 0){
+            throw new Exception("提交失败:该活动商品只允许每人购买{$limit}份");
+        }
+        $bool = $this->onlyOneOrder();
+        if($bool){
+            throw new Exception('提交失败:订单中含有每人限购一单的商品');
+        }
     }
 
     /**
@@ -1234,4 +1244,83 @@ class buyLogic
         }
         return true;
     }
+
+
+    private function onlyOneOrder()
+    {
+        $mod_order = Model('order_goods');
+        $member = $this->_member_info['member_id'];
+//        $filer_rules = [1693,6214,6215,6216];//goods_id a.lrlz
+        $filer_rules = [8310,8311,8312];//goods_id passport.lrlz
+
+        if(!empty($this->_order_data['goods_list']))
+        {
+            $goodslist = $this->_order_data['goods_list'];
+            foreach ($goodslist as $goodsItem){
+                $goods_id = $goodsItem["goods_id"];
+                if(in_array($goods_id,$filer_rules)){
+                    $find = $mod_order->table('order_goods')->where(["goods_id"=>$goods_id, "buyer_id"=>$member])->find();
+                    if(!empty($find)){
+                        return true;
+                    }
+                }
+            }
+        }
+
+        if(!empty($this->_order_data['store_cart_list']))
+        {
+            $cartlist = $this->_order_data['goods_list'];
+            foreach ($cartlist as $cartItem){
+                foreach ($cartItem as $goodsItem){
+                    $goods_id = $goodsItem["goods_id"];
+                    if(in_array($goods_id,$filer_rules)){
+                        $find = $mod_order->table('order_goods')->where(["goods_id"=>$goods_id, "buyer_id"=>$member])->find();
+                        if(!empty($find)){
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    private function limitBuysNum()
+    {
+//        $filer_rules = [1693,1708,6214,6215,6216];//goods_id a.lrlz
+        $filer_rules = [8310,8311,8312];//goods_id passport.lrlz
+        $limit_rules = [];
+        if(!empty($this->_order_data['goods_list']))
+        {
+            $goodslist = $this->_order_data['goods_list'];
+            foreach ($goodslist as $goodsItem){
+                $goods_id = $goodsItem["goods_id"];
+                $buy_num  = $goodsItem["goods_num"];
+                if(in_array($goods_id,$filer_rules)){
+                    $limit = isset($limit_rules[$goods_id]) ? $limit_rules[$goods_id] : 1;
+                    if($limit < $buy_num) {
+                        return $limit;
+                    }
+                }
+            }
+        }
+
+        if(!empty($this->_order_data['store_cart_list']))
+        {
+            $cartlist = $this->_order_data['goods_list'];
+            foreach ($cartlist as $cartItem){
+                foreach ($cartItem as $goodsItem){
+                    $goods_id = $goodsItem["goods_id"];
+                    $buy_num  = $goodsItem["goods_num"];
+                    if(in_array($goods_id,$filer_rules)){
+                        $limit = isset($limit_rules[$goods_id]) ? $limit_rules[$goods_id] : 1;
+                        if($limit < $buy_num) {
+                            return $limit;
+                        }
+                    }
+                }
+            }
+        }
+        return 0;
+    }
 }

+ 249 - 0
data/resource/mobile/festival/freeCollection/css/style.css

@@ -0,0 +1,249 @@
+body,
+html,
+img,
+div,
+a,
+p,
+form,
+input {
+    margin: 0;
+    padding: 0;
+    font-size: 100%;
+    font-family: "PingFang SC Light", 'Heiti SC';
+    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
+    cursor: pointer;
+    user-select: none;
+}
+html, body {
+    width: 100%;
+    overflow-x: hidden;
+    -webkit-overflow-scrolling: touch;
+}
+ul, ol, li {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+img {
+    border: none;
+}
+.container {
+    position: relative;
+    max-width: 750px;
+    margin: auto;
+    height: 3050px;
+    background: url('../image/bg.jpg') no-repeat center;
+    background-size: 100% 100%;
+}
+.bonus-price {
+    position: absolute;
+    padding-right: 18px;
+    box-sizing: border-box;
+    z-index: 2;
+    left: 0;
+    top: 774px;
+    width: 100%;
+    height: 50px;
+    line-height: 52px;
+    text-align: right;
+    font-size: 42px;
+    color: #fff;
+}
+.goods-list {
+    position: absolute;
+    left: 0;
+    top: 830px;
+    width: 100%;
+}
+.goods-item {
+    position: relative;
+    width: 100%;
+    height: 334px;
+}
+.goods-mbl {
+    background: url('../image/goods_mbl.jpg') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-gs {
+    background: url('../image/goods_gs.jpg') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-lz {
+    background: url('../image/goods_lz.jpg') no-repeat center;
+    background-size: 100% 100%;
+}
+.eggs {
+    position: relative;
+    z-index: 9;
+    margin: 42px 0 0 130px;
+    width: 568px;
+    height: 704px;
+    background: url('../image/eggs.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.eggs-btn {
+    position: absolute;
+    z-index: 22;
+    left: 0;
+    bottom: 0;
+    width: 100%;
+    height: 300px;
+}
+.rules {
+    margin: 48px 18px 0;
+    padding: 12px 52px 24px 70px;
+    border: 1px dashed #fff;
+    color: #fff;
+    border-radius: 4px;
+}
+.title {
+    height: 60px;
+    line-height: 60px;
+    font-size: 30px;
+}
+.rules-item {
+    position: relative;
+    padding-left: 38px;
+    line-height: 40px;
+    font-size: 24px;
+    color: #fff;
+}
+.rule-num {
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 40px;
+    height: 40px;
+    line-height: 40px;
+    border-radius: 50%;
+    background: #fff;
+    color: #0c0103;
+    transform: scale(.66);
+    text-align: center;
+}
+.brand {
+    margin: 34px auto 0;
+    width: 124px;
+    height: 42px;
+    background: url('../image/brand.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.nums-info {
+    position: absolute;
+    z-index:6;
+    left: 210px;
+    top: 224px;
+    width: 328px;
+    font-size: 0;
+    font-weight: bold;
+    text-align: center;
+}
+.nums-info .num {
+    display: inline-block;
+    width: 50%;
+    font-size: 60px;
+    line-height: 1;
+}
+.goods-item.receive::after, .goods-item.isReceived::after, .goods-item.invite::after {
+    content: '';
+    position: absolute;
+    z-index: 8;
+    right :48px;
+    top: 50%;
+    margin-top: -86px;
+    width: 172px;
+    height: 172px;
+
+}
+
+.goods-item.receive::after {
+    background: url('../image/receive.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-item.isReceived::after {
+    background: url('../image/isReceived.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-item.invite::after {
+    background: url('../image/invite_friend.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-item.invite::before {
+    content: '';
+    position: absolute;
+    z-index: 8;
+    left :64px;
+    top: 40px;
+    width: 198px;
+    height: 130px;
+    background: url('../image/not_enough.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.goods-item.over::before {
+    content: '';
+    position: absolute;
+    z-index: 8;
+    right: 32px;
+    top: 48px;
+    width: 274px;
+    height: 174px;
+    background: url('../image/over.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.detail-popup {
+    display: none;
+    position: fixed;
+    z-index: 99;
+    left: 0;
+    right: 0;
+    top: 0;
+    bottom: 0;
+    background: rgba(255,255,255,.6);
+}
+.refresh-btn {
+    display: none;
+    position: fixed;
+    z-index: 100;
+    left: 100px;
+    right: 100px;
+    padding: 30px;
+    top: 50%;
+    margin-top: -20px;
+    font-size: 34px;
+    color: #fff;
+    text-align: center;
+    background: #2b2b2b;
+    border-radius: 8px;
+}
+.mysterious-popup {
+    display: none;
+    position: fixed;
+    z-index: 101;
+    left: 0;
+    right: 0;
+    top: 0;
+    bottom: 0;
+    background: rgba(0,0,0,.6);
+}
+.mysterious {
+    display: none;
+    position: fixed;
+    z-index: 102;
+    left: 50%;
+    top: 50%;
+    margin-left: -297px;
+    margin-top: -460px;
+    width: 594px;
+    height: 920px;
+    background: url('../image/mysterious.png') no-repeat center;
+    background-size: 100% 100%;
+}
+.mysterious .close {
+    position: absolute;
+    z-index: 3;
+    right: -2px;
+    top: 54px;
+    width: 110px;
+    height: 110px;
+    background: url('../image/close.png') no-repeat right top;
+}

BIN
data/resource/mobile/festival/freeCollection/image/bg.jpg


BIN
data/resource/mobile/festival/freeCollection/image/brand.png


BIN
data/resource/mobile/festival/freeCollection/image/close.png


BIN
data/resource/mobile/festival/freeCollection/image/eggs.png


BIN
data/resource/mobile/festival/freeCollection/image/goods_gs.jpg


BIN
data/resource/mobile/festival/freeCollection/image/goods_lz.jpg


BIN
data/resource/mobile/festival/freeCollection/image/goods_mbl.jpg


BIN
data/resource/mobile/festival/freeCollection/image/invite_friend.png


BIN
data/resource/mobile/festival/freeCollection/image/isReceived.png


BIN
data/resource/mobile/festival/freeCollection/image/mysterious.png


BIN
data/resource/mobile/festival/freeCollection/image/not_enough.png


BIN
data/resource/mobile/festival/freeCollection/image/over.png


BIN
data/resource/mobile/festival/freeCollection/image/receive.png


+ 132 - 0
data/resource/mobile/festival/freeCollection/js/freeCollection.js

@@ -0,0 +1,132 @@
+function PageInit(url,session_id,bridge) {
+    this.url = url;
+    this.goodsItems = $('.goods-list .goods-item');
+    this.refreshBtn = $('.refresh-btn');
+    this.detailPopup = $('.detail-popup');
+    this.eggsBtn = $('.eggs-btn');
+    this.close = $('.close');
+    this.goodsList = [];
+    this.session_id = session_id;
+    this.bridge = bridge;
+
+    var self = this;
+
+    this.goodsItems.on('click', function () {
+        self.result($(this));
+    });
+    this.refreshBtn.on('click', function () {
+        self.hidePopup();
+        self.refresh();
+    });
+    this.detailPopup.on('touchmove', function (e) {
+        e.preventDefault();
+    });
+    this.eggsBtn.on('click', function () {
+        $('.mysterious-popup, .mysterious').fadeIn();
+    });
+    this.close.on('click', function () {
+        $('.mysterious-popup, .mysterious').fadeOut();
+    });
+    $('.mysterious-popup, .mysterious').on('touchmove', function (e) {
+        e.preventDefault();
+    });
+
+
+}
+
+PageInit.prototype = {
+    init: function () {
+        this.getDatas();
+    },
+    getDatas: function () {
+        var self = this;
+        $.ajax({
+            type: "get",
+            url: self.url,
+            data: {
+                act: "festval",
+                op: "ajax_freeCollection",
+                client_type: "ajax"
+            },
+            success: function (res) {
+                var res = JSON.parse(res)
+                if (res.code == 200) {
+                    self.goodsList = res.datas.goods_list
+                    self.render();
+                }
+                else {
+                    alert(res.message);
+                }
+            },
+            error: function () {
+                alert('网络错误!');
+            }
+        });
+        $.ajax({
+            type: "get",
+            url: self.url,
+            data: {
+                act: "member_bonus",
+                op: "mine_bonus",
+                client_type: "ajax"
+            },
+            success: function (res) {
+                var res = JSON.parse(res);
+                if (res.code == 200) {
+                    var usable_bonus = res.datas.usable_bonus;
+                    $('.bonus-price').html('¥ ' + usable_bonus);
+                }
+            }
+        });
+    },
+    render: function() {
+        if (!this.goodsList.length)return;
+        var self = this;
+        this.goodsItems.each(function(index, item) {
+            var goods = self.goodsList[index];
+            $(item).find('.bonus').html(goods.need_bonus);
+            $(item).find('.goods-storage').html(goods.storage);
+            $(item).attr('data-id', goods.goods);
+            $(item).attr('data-state', goods.state);
+            if (goods.state == 1) {
+                $(item).addClass('over');
+            }
+            else if (goods.state == 2) {
+                $(item).addClass('receive');
+            }
+            else if (goods.state == 3) {
+                $(item).addClass('invite');
+            }
+            else if (goods.state == 4) {
+                $(item).addClass('isReceived');
+            }
+        });
+    },
+    result: function (target) {
+        if (!this.goodsList.length)return;
+        var self = this;
+        var state = target.attr('data-state');
+        if (state == 2) {
+            var id = target.attr('data-id');
+            window.location.href = 'xmmz://p.lrlz.com/goods/goods?goodsId=' + id;
+            setTimeout(function() {
+                self.showPopup();
+            }, 10);
+            return;
+
+        }
+        else if (state == 3) {
+            window.location.href = 'xmmz://p.lrlz.com/invite/invite';
+            return;
+        }
+    },
+    showPopup: function () {
+        $('.detail-popup, .refresh-btn').fadeIn();
+    },
+    hidePopup: function () {
+        $('.detail-popup, .refresh-btn').fadeOut('fast');
+    },
+    refresh: function() {
+        this.init();
+    }
+}

+ 2 - 2
mobile/control/control.php

@@ -331,9 +331,9 @@ class mbMemberControl extends mobileControl
 
 function bonus_version()
 {
-    return "v=2018113001";
+    return "v=2018121101";
 }
 function shop_version()
 {
-    return "v=2018113001";
+    return "v=2018121101";
 }

+ 74 - 0
mobile/control/festval.php

@@ -58,6 +58,80 @@ class festvalControl extends mobileControl
         }
     }
 
+    private $freeCollection = [
+//        "0" => ["common_id"=>819,'goods_id' => 1301, 'need_bonus' => 39.90], //89
+
+//        "0" => ["common_id"=>3445,'goods_id' => 6214, 'need_bonus' => 88.00],//153
+//        "1" => ["common_id"=>3446,'goods_id' => 6215, 'need_bonus' => 88],
+//        "2" => ["common_id"=>3447,'goods_id' => 6216, 'need_bonus' => 88.0],
+
+        "0" => ["common_id"=>4706,'goods_id' => 8310, 'need_bonus' => 600],
+        "1" => ["common_id"=>4707,'goods_id' => 8311, 'need_bonus' => 600],
+        "2" => ["common_id"=>4708,'goods_id' => 8312, 'need_bonus' => 600],
+    ];
+
+    public function freeCollectionOp()
+    {
+        return self::outsuccess(null,'festival/freeCollection/index');
+    }
+
+    public function ajax_freeCollectionOp()
+    {
+        $member = session_helper::memberid();
+        if($member <= 0){
+            return self::outerr(Errcode::ErrUnLogin,"用户未登录");
+        }
+
+        $mod_order    = Model('order_goods');
+
+        $list = [];
+        $items = $this->freeCollection;
+        foreach ($items as $k => $item)
+        {
+            $common_id  = $item['common_id'];
+            $goods_id   = $item['goods_id'];
+            $need_bonus = $item['need_bonus'];
+            $goods_storage = 0;
+
+            //判断查询商品 storeage  状态1  => 不可以点击
+            $helper = new goods_helper($this->price_calcer(),false);
+            $ret = $helper->get_spu($common_id,$goods_id,$err);
+            if($ret == false) {
+                $list[$k] = ["goods" => $goods_id ,"state" => 1 ,"need_bonus"=>$need_bonus,"storage"=>$goods_storage];//商品已下架或不存在 库存清空
+                continue;
+            }
+
+            //判断用户是否可以全额用红包购买(只要可以买一份就算) 状态2 / 状态3  => 都可以点击
+            $summary = $ret['summary'];
+            foreach ($summary as $val)
+            {
+                if($goods_id == $val['goods_id']){
+                    $goods_storage = $val['goods_storage'];
+                    $gap = $val['discount_gap'];
+                    if(intval($gap * 100 + 0.5) == 0) {
+                        $list[$k] = ["goods" => $goods_id ,"state" => 2, "need_bonus"=>$need_bonus, "storage"=>$goods_storage];//可以点击 去商品详情
+                    } else {
+                        $list[$k] = ["goods" => $goods_id ,"state" => 3, "need_bonus"=>$need_bonus, "storage"=>$goods_storage];//邀请送红包
+                    }
+                }
+            }
+
+            //判断用户是否已经购买过该商品  状态4 => 不可以点击
+            $find = $mod_order->table('order_goods')->where(["goods_id"=>$goods_id, "buyer_id"=>$member])->find();
+            if(!empty($find)){
+                $list[$k] = ["goods" => $goods_id ,"state" => 4,"need_bonus"=>$need_bonus,"storage"=>$goods_storage];
+            }
+        }
+
+        $ret = [
+            "goods_list"   => $list
+        ];
+        return self::outsuccess($ret);
+        //下单处需要添加补丁:  控制每人每个商品 能且仅能购买一单 (每单不限数量)
+    }
+
+
+
     private function activity_validate($begin,$end)
     {
         $now = time();

+ 2 - 1
mobile/control/member_bonus.php

@@ -71,7 +71,8 @@ class member_bonusControl extends mbMemberControl
     {
         $result = [];
         $result['bonus_total']  = $this->mUserAccount->total_bonus();
-        return $result;
+        $result['usable_bonus'] = $this->mUserAccount->usable_bonus();
+        return self::outsuccess($result);
     }
 
     public function mine_roomsOp()

+ 121 - 0
mobile/templates/default/festival/freeCollection/index.php

@@ -0,0 +1,121 @@
+<?php ?>
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=750,user-scalable=no,target-densitydpi=device-dpi">
+    <meta name="format-detection" content="telephone=no">
+    <title>免费领大牌</title>
+    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/festival/freeCollection/css/style.css?<?php echo bonus_version(); ?>">
+</head>
+
+<body>
+<div class="container">
+    <div class="bonus-price"></div>
+    <div class="goods-list">
+        <ul>
+            <li class="goods-item goods-mbl">
+                <div class="nums-info">
+                    <div class="num bonus"></div>
+                    <div class="num goods-storage"></div>
+                </div>
+            </li>
+            <li class="goods-item goods-gs">
+                <div class="nums-info">
+                    <div class="num bonus"></div>
+                    <div class="num goods-storage"></div>
+                </div>
+            </li>
+            <li class="goods-item goods-lz">
+                <div class="nums-info">
+                    <div class="num bonus"></div>
+                    <div class="num goods-storage"></div>
+                </div>
+            </li>
+        </ul>
+        <div class="eggs">
+            <div class="eggs-btn"></div>
+        </div>
+        <div class="rules">
+            <div class="title">活动规则:</div>
+            <ul class="rules-list">
+                <li class="rules-item">
+                    <span class="rule-num">1</span>
+                    <p>用个人红包余额+群共享基金</p>
+                    <p>满足要求即可免费领取活动产品</p>
+                </li>
+                <li class="rules-item">
+                    <span class="rule-num">2</span>
+                    <p>红包不足时,每邀请一个好友可获得50元红包奖励</p>
+                </li>
+                <li class="rules-item">
+                    <span class="rule-num">3</span>
+                    <p>每种产品数量有限且只可领取一次,先拍先得</p>
+                </li>
+                <li class="rules-item">
+                    <span class="rule-num">4</span>
+                    <p>活动结束后5天内统一发货</p>
+                </li>
+            </ul>
+        </div>
+        <div class="brand"></div>
+
+    </div>
+</div>
+
+<div class="detail-popup"></div>
+<div class="refresh-btn">请点击刷新页面,获取最新内容!</div>
+
+<div class="mysterious-popup"></div>
+<div class="mysterious">
+    <div class="close"></div>
+</div>
+
+<script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/jquery-1.11.0.min.js?<?php echo bonus_version(); ?>"></script>
+<script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/new_bridge.js"></script>
+<script src="<?php echo RESOURCE_SITE_URL; ?>/mobile/festival/freeCollection/js/freeCollection.js?<?php echo bonus_version(); ?>"></script>
+<script>
+    $(function () {
+        var bridge = new Bridge();
+        var member_id = <?php echo session_helper::memberid(); ?>;
+        var session_id = '<?php echo session_helper::session_id(); ?>';
+        var url = "<?php echo BASE_SITE_URL; ?>/mobile/index.php";
+        if (url.indexOf('a.lrlz.com') != -1) {
+            url = "http://a.lrlz.com/mobile/index.php";
+        }
+
+        var pageInit = new PageInit(url,session_id, bridge);
+        var checkLogin = function () {
+            if (member_id <=0 || !session_id) {
+                bridge.call_native_handler('on_native_click', '{"action":"login"}', function (data) {
+                    var jsdata = JSON.parse(data);
+                    if (!jsdata.login) {
+                        bridge.call_native_handler('on_native_click', '{"action":"back"}', function (data) {});
+                        return;
+                    }
+                    else {
+                        window.location.reload();
+                    }
+                });
+            }
+            else {
+                if (pageInit) {
+                    pageInit.init();
+                }
+                else {
+                    new PageInit(url,session_id, bridge);
+                }
+
+
+            }
+
+        };
+
+        $(window).on('pageshow',function() {
+            checkLogin();
+        });
+    });
+</script>
+</body>
+</html>