Browse Source

咖啡券

linwu 1 năm trước cách đây
mục cha
commit
7d9f28f6ef

+ 60 - 19
app/love/controller/MyController.php

@@ -12,6 +12,7 @@ namespace app\love\controller;
 
 use app\common\Constant;
 use app\common\Fun;
+use app\love\model\LotteryPrizeModel;
 use app\love\model\UserFavoriteModel;
 use app\love\model\UserFriendModel;
 use app\love\model\UserGiftModel;
@@ -28,7 +29,6 @@ use think\Db;
 class MyController extends LoveBaseController
 {
     private $base_arr = ['nation', 'company', 'job', 'hobby', 'smoke', 'drink'];
-    private $mating_arr = [];
 
     /**
      * 我的
@@ -89,6 +89,16 @@ class MyController extends LoveBaseController
         ])->count();
         $this->assign('select_count', $select_count ?: '');
 
+        //是否互选
+        $select_log = 'false';
+        if ($this->user['sex'] == 1 && $this->user['use_ticket'] == 2) {
+            $log_check = UserSelectLogModel::where('user_id1', $this->user['id'])->find();
+            if (!empty($log_check)) {
+                $select_log = 'true';
+            }
+        }
+        $this->assign('select_log', $select_log);
+
         return $this->fetch();
     }
 
@@ -366,6 +376,9 @@ class MyController extends LoveBaseController
         $select = UserSelectModel::where('user_id|uid', '=', $user_id)
             ->where('is_confirm', 1)
             ->find();
+        //奖品
+        $has_prize   = LotteryPrizeModel::all();
+        $this->assign('has_prize', $has_prize->isEmpty() ? 'false' : 'true');
         if (!empty($select)) {
             //已选择
             if ($select['user_id'] == $user_id) {
@@ -459,7 +472,7 @@ class MyController extends LoveBaseController
             $user = UserSelectModel::get(['user_id' => $id, 'uid' => $user_id]);
         }
         if (!empty($user)) {
-            UserSelectLogModel::where('user_id1|user_id2', $id)->update('delete_time',time());
+            UserSelectLogModel::where('user_id1|user_id2', $id)->update(['delete_time'=>time()]);
             $user->delete();
         }
 
@@ -476,8 +489,8 @@ class MyController extends LoveBaseController
         if ($user_id == $id) {
             $this->error('不可以选择自己!');
         }
-        $user    = UserSelectModel::get(['user_id' => $id, 'uid' => $user_id]);
-        $check   = UserSelectLogModel::where('user_id1|user_id2', $id)->find();
+        $user  = UserSelectModel::get(['user_id' => $id, 'uid' => $user_id]);
+        $check = UserSelectLogModel::where('user_id1|user_id2', $id)->find();
         if (!empty($check)) {
             $this->error('对方已被选择!');
         }
@@ -534,25 +547,28 @@ class MyController extends LoveBaseController
         }
 
         //增加互选次数
-         Db::name('config')->where('id',1)->setInc('select_num');
-        /*//发送提示
+        Db::name('config')->where('id', 1)->setInc('select_num');
+        //发送提示
+        $form_id = $this->user->sex = 1 ? $user_id : $id;
+        $to_id = $this->user->sex = 1 ? $id : $user_id;
         $time = time();
         UserMessageModel::create([
-            'from_id'     => $user_id,
-            'to_id'       => $id,
-            'message'     => '我已接受你的交往请求,快来一起聊天吧!',
+            'from_id'     => $form_id,
+            'to_id'       => $to_id,
+            'message'     => '系统赠送了两张咖啡券,约个时间一起去喝咖啡吧。',
             'create_time' => $time,
         ]);
 
         //增加最后聊天消息
-        UserFriendModel::update(['last_msg' => '我:我已接受你的交往请求,快来一起聊天吧!', 'last_msg_time' => $time], ['user_id' => $user_id, 'friend_id' => $id]);
-        $friend                = UserFriendModel::get(['user_id' => $id, 'friend_id' => $user_id]);
-        $friend->last_msg      = '对方:我已接受你的交往请求,快来一起聊天吧!';
+        UserFriendModel::update(['last_msg' => '我:系统赠送了两张咖啡券,约个时间一起去喝咖啡吧。', 'last_msg_time' => $time], ['user_id' => $form_id, 'friend_id' => $to_id]);
+        $friend                = UserFriendModel::get(['user_id' => $to_id, 'friend_id' => $form_id]);
+        $friend->last_msg      = '对方:系统赠送了两张咖啡券,约个时间一起去喝咖啡吧。';
         $friend->last_msg_time = $time;
         $friend->unread_num++;
-        $friend->save();*/
+        $friend->save();
 
-        $this->success('操作成功');
+        $other = UserModel::get($id);
+        $this->success('操作成功', '', ['mobile' => $other['mobile']]);
     }
 
     /**
@@ -561,13 +577,13 @@ class MyController extends LoveBaseController
     public function marry()
     {
         $user_id = cmf_get_current_user_id();
-        $log = UserSelectLogModel::where('user_id1|user_id2', $user_id)->find();
+        $log     = UserSelectLogModel::where('user_id1|user_id2', $user_id)->find();
         if (empty($log)) {
             $this->error('请先确认关系后再结婚!');
         }
 
-        $id = $log['user_id1'] == $user_id ? $log['user_id2'] : $log['user_id1'];
-        $marry   = UserMarryModel::where(function ($query) use ($user_id, $id) {
+        $id    = $log['user_id1'] == $user_id ? $log['user_id2'] : $log['user_id1'];
+        $marry = UserMarryModel::where(function ($query) use ($user_id, $id) {
             $query->where([
                 ['user_id1', '=', $user_id],
                 ['user_id2', '=', $id],
@@ -581,11 +597,11 @@ class MyController extends LoveBaseController
         //20230423增加两个userid对调的查询,因为双方都有权利取消
         if (empty($marry)) {
             UserMarryModel::create(['user_id1' => $user_id, 'user_id2' => $id, 'create_time' => time()]);
-            UserModel::where('id','in',[$id,$user_id])->update(['is_marry'=>1]);
+            UserModel::where('id', 'in', [$id, $user_id])->update(['is_marry' => 1]);
         }
 
         //增加结婚次数
-        Db::name('config')->where('id',1)->setInc('marry_num');
+        Db::name('config')->where('id', 1)->setInc('marry_num');
 
         $this->success('操作成功');
     }
@@ -782,6 +798,31 @@ class MyController extends LoveBaseController
         }
     }
 
+    /**
+     * 咖啡券
+     */
+    public function ticket()
+    {
+        //是否互选
+        if ($this->user['sex'] == 2) {
+            $this->error('暂无咖啡券', url('index'));
+        }
+        $log_check = UserSelectLogModel::where('user_id1', $this->user['id'])->find();
+        if (empty($log_check)) {
+            $this->error('暂无咖啡券', url('index'));
+        }
+
+        return $this->fetch();
+    }
+
+    public function useTicket()
+    {
+        $this->user->use_ticket = 1;
+        $this->user->save();
+
+        $this->success('核销成功!');
+    }
+
     private function _file_name($ext)
     {
         //生成随机文件名

+ 6 - 0
public/themes/simpleboot3/love/my/index.html

@@ -92,6 +92,11 @@
                 <img src="__TMPL__/public/assets/images/my/icon_profile.svg" class="van-cell__left-icon" style="height:24px;"/>
             </template>
         </van-cell>
+        <van-cell title="我的咖啡券" is-link url="{:url('ticket')}" size="large" v-if="select_log">
+            <template #icon>
+                <img src="__TMPL__/public/assets/images/my/icon_ticket.png" class="van-cell__left-icon" style="height:24px;"/>
+            </template>
+        </van-cell>
     </van-cell-group>
 
     <!--底部-->
@@ -139,6 +144,7 @@
                     is_perfect: {$is_perfect},
                     is_mating: {$is_mating},
                     unread_num: {$unread_num},
+                    select_log: {$select_log},
                 };
             },
             methods: {

+ 27 - 15
public/themes/simpleboot3/love/my/select.html

@@ -49,10 +49,12 @@
                                 </div>
                                 <div class="text fz12 mt10 color_9 ws">{{item.user.signature}}</div>
                                 <div>
-                                    <van-button type="primary" size="mini" @click.stop="select(item.user.id)" v-if="active === 0">
+                                    <van-button type="primary" size="mini" @click.stop="select(item.user.id)"
+                                                v-if="active === 0">
                                         确认关系
                                     </van-button>
-                                    <van-button type="danger" size="mini" @click.stop="cancel(item.user.id)" v-if="active === 1">
+                                    <van-button type="danger" size="mini" @click.stop="cancel(item.user.id)"
+                                                v-if="active === 1">
                                         取消选择
                                     </van-button>
                                 </div>
@@ -68,7 +70,8 @@
     <div v-if="is_select">
         <!--头图-->
         <div class="image_box">
-            <img src="" class="image" :src="user.main_image ? user.main_image : '__TMPL__/public/assets/images/userwall/no_image.png'"/>
+            <img src="" class="image"
+                 :src="user.main_image ? user.main_image : '__TMPL__/public/assets/images/userwall/no_image.png'"/>
         </div>
         <!--简介-->
         <div class="detail_describe">
@@ -86,11 +89,14 @@
                 </p>
             </div>
             <div class="fr mr20">
-                <van-button type="primary" size="mini" @click="location.href = '{:url('Userwall/detail')}?id='+user.id">查看详情</van-button><br />
+                <van-button type="primary" size="mini" @click="location.href = '{:url('Userwall/detail')}?id='+user.id">
+                    查看详情
+                </van-button>
+                <br/>
                 <van-button type="danger" size="mini" @click.stop="cancel(user.id)">取消互选</van-button>
             </div>
             <div class="clear"></div>
-            <div class="fr mr20">
+            <div class="fr mr20" v-if="has_prize">
                 <van-button type="info" size="mini" @click.stop="marry(user.id)">确认结婚</van-button>
             </div>
             <div class="clear"></div>
@@ -105,6 +111,7 @@
                 return {
                     user: {$user},
                     is_select: {$is_select},
+                    has_prize: {$has_prize},
                     active: 0,
                     page: [1, 1],
                     list: [{$list1}, {$list2}],
@@ -158,10 +165,15 @@
                         message: '确认选择后将无法再选择其他人',
                     }).then(() => {
                         var that = this;
-                        $.post("{:url('selectConfirm')}",{id:id},function (json) {
-                            if(json.code == 1){
-                                location.reload();
-                            }else{
+                        $.post("{:url('selectConfirm')}", {id: id}, function (json) {
+                            if (json.code == 1) {
+                                that.$dialog.alert({
+                                    title: '消息提醒',
+                                    message: '系统送你们两张咖啡券,男方在我的->我的咖啡券里查看,请带上对方一起去享用吧!对方联系方式:' + json.data.mobile,
+                                }).then(() => {
+                                    location.reload();
+                                });
+                            } else {
                                 that.$toast(json.msg);
                             }
                         });
@@ -176,10 +188,10 @@
                         message: '确认取消表明心意?',
                     }).then(() => {
                         var that = this;
-                        $.post("{:url('selectCancel')}",{id:id},function (json) {
-                            if(json.code == 1){
+                        $.post("{:url('selectCancel')}", {id: id}, function (json) {
+                            if (json.code == 1) {
                                 location.reload();
-                            }else{
+                            } else {
                                 that.$toast(json.msg);
                             }
                         });
@@ -194,10 +206,10 @@
                         message: '确认结婚后进行抽奖,凭结婚证领奖,但是无法继续使用此平台',
                     }).then(() => {
                         var that = this;
-                        $.get("{:url('marry')}",function (json) {
-                            if(json.code == 1){
+                        $.get("{:url('marry')}", function (json) {
+                            if (json.code == 1) {
                                 location.href = "{:url('love/lottery/index')}";
-                            }else{
+                            } else {
                                 that.$toast(json.msg);
                             }
                         });

+ 122 - 0
public/themes/simpleboot3/love/my/ticket.html

@@ -0,0 +1,122 @@
+<extend name="public@base"/>
+<block name="css">
+    <style>
+        .block{
+            background:white;
+        }
+
+        .block h2{
+            margin:0;
+            padding:32px 16px 16px;
+            color:rgba(69, 90, 100, 0.6);
+            font-weight:normal;
+            font-size:14px;
+            line-height:16px;
+        }
+
+        .van-nav-bar .van-icon, .van-nav-bar__text{
+            color:white;
+        }
+
+        .footer{
+            display:flex;
+            position:fixed;
+            bottom:0;
+            left:0;
+            width:100%;
+        }
+
+        .van-button--normal{
+            width:50%;
+        }
+    </style>
+</block>
+<block name="body">
+    <van-nav-bar
+            class="bg-pink"
+            left-text="返回"
+            left-arrow
+            @click-left="onBack"
+    >
+        <template #title>
+            <span style="color:white;">咖啡券</span>
+        </template>
+    </van-nav-bar>
+    <div class="block">
+        <h2>店家信息</h2>
+        <van-cell-group>
+            <van-cell title="店名:B mat coffee (晋博店)"></van-cell>
+            <van-cell @click="toMap">
+                <template #title>
+                    地址:晋江市博物馆一楼 <span style="font-size:14px;color:#999;">(点击导航)</span>
+                </template>
+            </van-cell>
+            <van-cell title="营业时间:10:00-19:50"></van-cell>
+            <van-cell>
+                <template #title>
+                    <a href="tel:13799225551">联系方式:13799225551<span
+                            style="font-size:14px;color:#999;">(点击拔打电话)</span></a>
+                </template>
+            </van-cell>
+        </van-cell-group>
+    </div>
+    <div class="block">
+        <h2>使用方式</h2>
+        <van-cell-group>
+            <van-cell title="营业时间带上女方至咖啡店向店员展示该页面即可领取两杯咖啡。"></van-cell>
+        </van-cell-group>
+    </div>
+    <div class="block">
+        <h2>注意事项</h2>
+        <van-cell-group>
+            <van-cell title="">
+                <template #title>
+                    <span class="color_red">核销按钮由店员点,千万不要自己点核销按钮,一但核销,该券失效。</span>
+                </template>
+            </van-cell>
+        </van-cell-group>
+    </div>
+    <div class="footer">
+        <van-button type="primary" @click="show = true">查看咖啡券</van-button>
+        <van-button type="danger" @click="wipe">核销</van-button>
+    </div>
+    <van-popup v-model="show"><img style="width:100vw;" src="__TMPL__/public/assets/images/my/ticket.png" alt="">
+    </van-popup>
+</block>
+<block name="script">
+    <script>
+        new Vue({
+            el: '#app',
+            data() {
+                return {
+                    show: false,
+                };
+            },
+            methods: {
+                onBack() {
+                    history.back();
+                },
+                toMap() {
+                    window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:24.80107,118.56812;title:泉州市晋江市Bmat coffee(晋江博物馆店);addr: 晋江市博物馆一楼 (晋江文化体育旅游服务中心)';
+                },
+                wipe() {
+                    const self = this;
+                    this.$dialog.confirm({
+                        title: '消息提醒',
+                        message: '确认核销后,该券该无法再使用!',
+                    }).then(() => {
+                        $.get("{:url('useTicket')}",function(json){
+                            self.$dialog.alert({
+                                title: '消息提醒',
+                                message: '核销成功!',
+                            }).then(() => {
+                                window.location.href = "{:url('index')}";
+                            });
+                        },'json')
+                    }).catch(()=>{return false;});
+                },
+            },
+            computed: {}
+        });
+    </script>
+</block>

BIN
public/themes/simpleboot3/public/assets/images/my/icon_ticket.png


BIN
public/themes/simpleboot3/public/assets/images/my/ticket.jpg


BIN
public/themes/simpleboot3/public/assets/images/my/ticket.png