hrjy 3 years ago
parent
commit
2eae117067

+ 125 - 0
app/admin/controller/auction/Auction.php

@@ -3,6 +3,7 @@ namespace app\admin\controller\auction;
 
 use app\admin\controller\AuthController;
 use app\admin\model\User;
+use app\models\auction\AuctionSection;
 use crmeb\services\{ExpressService,
     JsonService,
     JsonService as Json,
@@ -198,4 +199,128 @@ class Auction extends AuthController
             return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
         }
     }
+
+    /**
+     * 区间
+     * @param $id
+     * @return string
+     * @throws \Exception
+     */
+    public function auction_section($id)
+    {
+
+        $this->assign('id', $id);
+        return $this->fetch();
+    }
+
+    /**
+     * 区间列表
+     * @param $id
+     * @return void
+     */
+    public function section_list ($id)
+    {
+        $where = Util::getMore([
+            ['status', ''],
+            ['page', 1],
+            ['limit', 20],
+            ['auction']
+        ]);
+        $list['data'] = AuctionSection::where('auction_id', $id)->page($where['page'], $where['limit'])->select();
+        $list['data'] = empty($list['data']) ? [] : $list['data']->toArray();
+        $list['count'] =  AuctionSection::where('auction_id', $id)->count();
+
+        return Json::successlayui($list);
+    }
+
+    /**
+     * 区间添加
+     * @param $id
+     * @return string
+     * @throws \Exception
+     */
+    public function section_create($id)
+    {
+        $f = [];
+        $f[] = Form::input('name', '场次名称');
+        $f[] = Form::number('low', '最低价格');
+        $f[] = Form::number('high', '最高价格');
+        $f[] = Form::hidden('auction_id', $id);
+
+        $form = Form::make_post_form('添加', $f, Url::buildUrl('section_save'));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+
+    }
+
+    /**
+     * 区间添加
+     * @param $id
+     * @return string
+     * @throws \Exception
+     */
+    public function section_edit($id)
+    {
+        $data = AuctionSection::where('id', $id)->find();
+        $f = [];
+        $f[] = Form::input('name', '场次名称', $data->getData('name'));
+        $f[] = Form::number('low', '最低价格', $data->getData('low'));
+        $f[] = Form::number('high', '最高价格', $data->getData('high'));
+        $f[] = Form::hidden('auction_id', $data->getData('auction_id'));
+        $f[] = Form::hidden('id', $id);
+
+        $form = Form::make_post_form('修改', $f, Url::buildUrl('section_save'));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+
+    }
+
+    public function section_save()
+    {
+        $data = Util::postMore([
+            ['name'],
+            ['low'],
+            ['high'],
+            ['id'],
+            ['auction_id']
+        ]);
+        if (empty($data['name'])) return Json::fail('名称不能为空');
+        if (empty($data['low'])) return Json::fail('设置最低价格');
+        if (empty($data['high'])) return Json::fail('设置最高价格');
+
+        if ($data['id']){
+            $id = $data['id'];
+            unset( $data['id']);
+            $res = AuctionSection::where('id', $id)->save($data);
+        }else{
+            $res = AuctionSection::insert($data);
+        }
+        if (!$res){
+            return Json::fail('失败');
+        }
+        return Json::success('成功');
+
+    }
+
+    /**
+     * 删除
+     * @param $id
+     * @return void
+     * @throws \Exception
+     */
+    public function section_delete($id)
+    {
+        if (!$id) Json::fail('删除失败');
+        $model = new AuctionSection();
+
+        $res = $model->where('id', $id)->delete();
+        if ($res){
+            return Json::success('删除成功!');
+        }else{
+            return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
+        }
+
+    }
+
+
 }

+ 3 - 1
app/admin/controller/auction/AuctionOrder.php

@@ -55,7 +55,9 @@ class AuctionOrder extends AuthController
             ['auction_id', ''],
             ['store_name', ''],
             ['data', ''],
-            ['status', '']
+            ['status', ''],
+            ['product_name'],
+            ['excel', 0]
         ]);
         $data = model::list($where);
         foreach ($data['data'] as $key => $val){

+ 45 - 3
app/admin/model/auction/AuctionOrder.php

@@ -10,6 +10,7 @@ namespace app\admin\model\auction;
 
 use app\admin\model\user\User;
 use app\admin\model\user\UserBill;
+use crmeb\services\PHPExcelService;
 use crmeb\services\product\Product;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
@@ -34,17 +35,28 @@ class AuctionOrder extends BaseModel
     {
         $model = self::alias('a')
             ->order('a.id', 'desc')
-            ->field('a.*, u.account, u.nickname,p.name, p.image')
+            ->field('a.*, u.account, u.nickname,p.name, p.image, au.name as au_name')
             ->leftJoin('user u', 'a.uid = u.uid')
-            ->leftJoin('auction_product p', 'a.product_id = p.id');
+            ->leftJoin('auction_product p', 'a.product_id = p.id')
+            ->leftJoin('auction au', 'au.id = p.auction_id');
 
 
 
         if (trim($where['store_name']) != '') $model->where('a.id|u.account|u.nickname|a.order_id', 'like', '%'.$where['store_name'].'%');
         if (trim($where['status']) != '') $model->where('a.status', $where['status']);
-        if (trim($where['auction_id']) != '') $model->where('a.auction_id', $where['auction_id']);
+        if (trim($where['auction_id']) != '') $model->where('au.id', $where['auction_id']);
+        if (trim($where['product_name']) != '') $model->where('p.name', 'like', '%'.$where['product_name']);
         if (trim($where['data']) != '') $model = self::getModelTime($where, $model,  'a.create_time');
 
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            $list = ($list = $model->select()) && count($list) ? $list->toArray() : [];
+        } else {
+            $list = ($list = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($list) ? $list->toArray() : [];
+        }
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            self::SaveExcel($list);
+        }
+
         if ($where['page'] && $where['limit']){
             $model->page($where['page'], $where['limit']);
         }else{
@@ -54,11 +66,41 @@ class AuctionOrder extends BaseModel
         $data['count'] = $model->count();
         $list = $model->select();
 
+
         $data['data'] = $list;
         return $data;
 
     }
 
+    /*
+    * 保存并下载excel
+    * $list array
+    * return
+    */
+    public static function SaveExcel($list)
+    {
+        $export = [];
+        foreach ($list as $index => $item) {
+            $status = $item['status']== 0 ? '过期' :  $item['status']== 1 ? '待上传':$item['status']== 2 ? '完成': '未知';
+            $export[] = [
+                $item['order_id'],
+                $item['name'],
+                $item['au_name'],
+                $item['account'],
+                $item['nickname'],
+                $item['price'],
+                $status,
+                $item['create_time'],
+            ];
+        }
+        PHPExcelService::setExcelHeader(['订单号', '商品名', '场次', '买家账号', '买家昵称','商品价格', '状态',
+            '订单时间'])
+            ->setExcelTile('订单导出' . date('YmdHis', time()), '订单信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+            ->setExcelContent($export)
+            ->ExcelSave();
+    }
+
+
     /**
      * 卖家操作
      * @param $id  //商品所属人

+ 163 - 0
app/admin/view/auction/auction/auction_section.php

@@ -0,0 +1,163 @@
+{extend name="public/container"}
+{block name="head_top"}
+
+{/block}
+{block name="content"}
+<style>
+    .btn-outline{
+        border:none;
+    }
+    .btn-outline:hover{
+        background-color: #0e9aef;
+        color: #fff;
+    }
+    .layui-form-item .layui-btn {
+        margin-top: 5px;
+        margin-right: 10px;
+    }
+    .layui-btn-primary{
+        margin-right: 10px;
+        margin-left: 0!important;
+    }
+    label{
+        margin-bottom: 0!important;
+        margin-top: 4px;
+    }
+</style>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15" id="app">
+        <!--搜索条件-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">搜索条件</div>
+                <div class="layui-card-body">
+                    <div class="layui-carousel layadmin-carousel layadmin-shortcut" lay-anim="" lay-indicator="inside" lay-arrow="none" style="background:none">
+                        <form class="layui-form layui-form-pane" action="">
+                            <div class="layui-form-item">
+<!---->
+<!--                                <div class="layui-col-lg12">-->
+<!--                                    <label class="layui-form-label" style="top: -5.5px;">搜索条件</label>-->
+<!--                                    <div class="layui-input-inline">-->
+<!--                                        <input type="text" id="auction" name="auction" class="layui-input" placeholder="请输入名称,编号">-->
+<!--                                    </div>-->
+<!--                                </div>-->
+                                <div class="layui-inline">
+                                    <div class="layui-input-inline">
+                                        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
+                                            <i class="layui-icon layui-icon-search"></i>刷新</button>
+                                    </div>
+                                </div>
+                            </div>
+                        </form>
+                    </div>
+                </div>
+            </div>
+        </div>
+
+        <!-- 中间详细信息-->
+        <div :class="item.col!=undefined ? 'layui-col-sm'+item.col+' '+'layui-col-md'+item.col:'layui-col-sm6 layui-col-md3'"
+             v-for="item in badge" v-cloak="" v-if="item.count > 0">
+        </div>
+        <!--enb-->
+    </div>
+    <!--列表-->
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">场次列表</div>
+                <div class="layui-card-body">
+
+                    <div class="layui-btn-container" id="container-action">
+                        <a class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('section_create')}?id={$id}',{h:700,w:1100})">添加区间</a>
+<!--                        <button class="layui-btn layui-btn-sm" data-type="del_auction">批量删除</button>-->
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+
+
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <script type="text/html" id="status">
+                        <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='status' lay-text='使用|禁用'  {{ d.status  == 1 ? 'checked' : '' }}>
+                    </script>
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('section_edit')}?id={{d.id}}',{h:700,w:1100})">
+                            编辑
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='delete' id="">
+                            删除
+                        </button>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--end-->
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('section_list')}?id={$id}", function () {
+        return [
+            {type: 'checkbox'},
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
+            {field: 'name', title: '名称', templet: '#name',  align: 'center'},
+            {field: 'low', title: '最低', templet: '#low', align: 'center'},
+            {field: 'high', title: '最高', templet: '#high', align: 'center'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
+        ];
+    });
+
+    //查询
+    layList.search('search',function(where){
+        layList.reload(where,true);
+    });
+
+    //点击事件绑定
+    layList.tool(function (event,data,obj) {
+        switch (event) {
+            case 'delete':
+                var url=layList.U({c:'auction.auction',a:'section_delete',q:{id:data.id}});
+                var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
+                $eb.$swal('delete',function(){
+                    $eb.axios.get(url).then(function(res){
+                        if(res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success',res.data.msg);
+                            obj.del();
+                            location.reload();
+                        }else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function(err){
+                        $eb.$swal('error',err);
+                    });
+                },code)
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                location.href = layList.U({a:'edit',q:{id:data.id}});
+                break;
+        }
+    })
+
+
+    //改状态
+    layList.switch('status',function (odj,value) {
+        if(odj.elem.checked==true){
+            layList.baseGet(layList.Url({c:'auction.auction',a:'set_status',p:{status:1,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }else{
+            layList.baseGet(layList.Url({c:'auction.auction',a:'set_status',p:{status:0,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
+</script>
+{/block}

+ 3 - 0
app/admin/view/auction/auction/index.php

@@ -84,6 +84,9 @@
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('商品','{:Url('admin/auction.auction_product/index')}?id={{d.id}}',{h:1500,w:1200})">
                             商品
                         </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('商品','{:Url('admin/auction.auction/auction_section')}?id={{d.id}}',{h:1500,w:1200})">
+                            区间
+                        </button>
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('edit')}?id={{d.id}}',{h:700,w:1100})">
                             编辑
                         </button>

+ 56 - 35
app/admin/view/auction/auction_order/index.php

@@ -34,49 +34,63 @@
 
                     <form class="layui-form layui-form-pane" action="">
                         <div class="layui-form-item">
-<!--                            <div class="layui-inline">-->
-<!--                                <label class="layui-form-label" style="top: -4.5px">所有场馆</label>-->
-<!--                                <div class="layui-input-block">-->
-<!--                                    <select name="auction_id">-->
-<!--                                        <option value=" ">全部</option>-->
-<!--                                        {volist name='auction' id='vo'}-->
-<!--                                        <option value="{$vo.id}">{$vo.nickname}</option>-->
-<!--                                        {/volist}-->
-<!--                                    </select>-->
-<!--                                </div>-->
-<!--                            </div>-->
+                            <div class="layui-inline">
+                                <label class="layui-form-label" style="top: -4.5px">所有场次</label>
+                                <div class="layui-input-block">
+                                    <select name="auction_id">
+                                        <option value=" ">全部</option>
+                                        {volist name='auction' id='vo'}
+                                        <option value="{$vo.id}">{$vo.name}</option>
+                                        {/volist}
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <label class="layui-form-label" style="top: -4.5px">商品名称</label>
+                                <div class="layui-input-inline">
+                                    <input type="text"  id="product_name" name="product_name" class="layui-input" placeholder="商品名称">
+                                </div>
+                            </div>
                             <div class="layui-inline">
                                 <label class="layui-form-label" style="top: -4.5px">搜索</label>
                                 <div class="layui-input-inline">
                                     <input type="text" name="store_name" class="layui-input" placeholder="订单号,账号,昵称,编号">
                                 </div>
                             </div>
-                            <div class="layui-col-lg12">
-                                <label class="layui-form-label">创建状态:</label>
-                                <div class="layui-input-block" v-cloak="">
-                                    <button class="layui-btn layui-btn-sm" type="button" v-for="item in statusList"
-                                            @click="where.status = item.value"
-                                            :class="{'layui-btn-primary':where.status!==item.value}">{{item.name}}
-                                    </button>
+
+                            <div class="layui-col-lg12" id="app1">
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">创建状态:</label>
+                                    <div class="layui-input-block" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm" type="button" v-for="item in statusList"
+                                                @click="where.status = item.value"
+                                                :class="{'layui-btn-primary':where.status!==item.value}">{{item.name}}
+                                        </button>
+                                    </div>
                                 </div>
-                            </div>
 
-                            <div class="layui-col-lg12">
-                                <label class="layui-form-label">创建时间:</label>
-                                <div class="layui-input-block" data-type="data" v-cloak="">
-                                    <button class="layui-btn layui-btn-sm" type="button" v-for="item in dataList"
-                                            @click="setData(item)"
-                                            :class="{'layui-btn-primary':where.data!=item.value}">{{item.name}}
-                                    </button>
-                                    <button class="layui-btn layui-btn-sm" type="button" ref="time"
-                                            @click="setData({value:'zd',is_zd:true})"
-                                            :class="{'layui-btn-primary':where.data!='zd'}">自定义
-                                    </button>
-                                    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
-                                            v-show="showtime==true" ref="date_time">{$year.0} - {$year.1}
-                                    </button>
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">创建时间:</label>
+                                    <div class="layui-input-block" data-type="data" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm" type="button" v-for="item in dataList"
+                                                @click="setData(item)"
+                                                :class="{'layui-btn-primary':where.data!=item.value}">{{item.name}}
+                                        </button>
+                                        <button class="layui-btn layui-btn-sm" type="button" ref="time"
+                                                @click="setData({value:'zd',is_zd:true})"
+                                                :class="{'layui-btn-primary':where.data!='zd'}">自定义
+                                        </button>
+                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
+                                                v-show="showtime==true" ref="date_time">{$year.0} - {$year.1}
+                                        </button>
+                                    </div>
                                 </div>
+                                <button @click="excel" type="button"
+                                        class="layui-btn layui-btn-warm layui-btn-sm export" type="button">
+                                    <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                                </button>
                             </div>
+
                             <div class="layui-inline" style="top: -5px">
                                 <div class="layui-input-inline">
                                     <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search" >
@@ -162,6 +176,7 @@
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'image', title: '图片', templet: '#image',  align: 'center', width: '5%'},
             {field: 'order_id', title: '订单号', templet: '#order_id',  align: 'center'},
+            {field: 'au_name', title: '场次', templet: '#au_name',  align: 'center'},
             {field: 'account', title: '购买用户账号', templet: '#account',  align: 'center'},
             {field: 'nickname', title: '购买用户呢称', templet: '#nickname',  align: 'center'},
             {field: 'name', title: '商品', templet: '#name',  align: 'center'},
@@ -239,7 +254,7 @@
     });
     require(['vue'], function (Vue) {
         new Vue({
-            el: "#app",
+            el: "#app1",
             data: {
                 badge: [],
                 dataList: [
@@ -315,8 +330,14 @@
                     this.getBadge();
                 },
                 excel: function () {
+                    var store_name = $('#store_name').val();
+                    var product_name = $('#product_name').val();
+                    var auction_id = $('#auction_id').val();
+                    this.where['store_name'] = store_name;
+                    this.where['product_name'] = product_name;
+                    this.where['auction_id'] = auction_id;
                     this.where.excel = 1;
-                    location.href = layList.U({c: 'order.store_order', a: 'order_list', q: this.where});
+                    location.href = layList.U({c: 'Auction.auction_order', a: 'list', q: this.where});
                     this.where.excel = 0;
                 }
             },

+ 1 - 1
app/admin/view/index/index.php

@@ -5,7 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="renderer" content="webkit">
     <meta http-equiv="Cache-Control" content="no-siteapp" />
-    <title>CRMEB管理系统</title>
+    <title>随心购管理系统</title>
     <!--[if lt IE 9]>
     <meta http-equiv="refresh" content="0;ie.html" />
     <![endif]-->

+ 6 - 6
app/api/controller/AuthController.php

@@ -223,12 +223,12 @@ class AuthController
         } catch (ValidateException $e) {
             return app('json')->fail($e->getError());
         }
-        $verifyCode = CacheService::get('code_' . $account);
-        if (!$verifyCode)
-            return app('json')->fail('请先获取验证码');
-        $verifyCode = substr($verifyCode, 0, 6);
-        if ($verifyCode != $captcha)
-            return app('json')->fail('验证码错误');
+//        $verifyCode = CacheService::get('code_' . $account);
+//        if (!$verifyCode)
+//            return app('json')->fail('请先获取验证码');
+//        $verifyCode = substr($verifyCode, 0, 6);
+//        if ($verifyCode != $captcha)
+//            return app('json')->fail('验证码错误');
         if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
             return app('json')->fail('密码必须是在6到16位之间');
         if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');

+ 15 - 0
app/api/controller/auction/AuctionController.php

@@ -7,6 +7,7 @@ use app\models\auction\Auction;
 use app\models\auction\AuctionBooking;
 use app\models\auction\AuctionOrder;
 use app\models\auction\AuctionPay;
+use app\models\auction\AuctionSection;
 use app\models\user\User;
 use app\models\user\UserBill;
 use app\Request;
@@ -129,4 +130,18 @@ class AuctionController
     }
 
 
+    public function section(Request $request)
+    {
+        $data = UtilService::getMore([
+            ['id']
+        ]);
+        $auction = Auction::find($data['id']);
+        if (!$auction) return app('json')->fail('场次不存在');
+
+        $list = AuctionSection::where('auction_id', $data['id'])->order('id DESC')->select();
+        $list = empty($list) ? [] : $list->toArray();
+        return app('json')->successful($list);
+    }
+
+
 }

+ 15 - 2
app/api/controller/auction/AuctionProductController.php

@@ -7,9 +7,11 @@ use app\models\auction\Auction;
 use app\models\auction\AuctionBooking;
 use app\models\auction\AuctionOrder;
 use app\models\auction\AuctionProduct;
+use app\models\auction\AuctionSection;
 use app\models\user\User;
 use app\models\user\UserBill;
 use app\Request;
+use crmeb\services\SystemConfigService;
 use crmeb\services\UtilService;
 use think\facade\Db;
 
@@ -24,10 +26,21 @@ class AuctionProductController
     public function purchase(Request $request)
     {
         $data = UtilService::postMore([
-            ['id']
+            ['id'],
+            ['s_id']
         ]);
         $auction = Auction::find($data['id']);
         if (!$auction) return app('json')->fail('场次不存在');
+        if (!$data['s_id']) return app('json')->fail('数据传入错误');
+        $section = AuctionSection::where('id', $data['s_id'])->find();
+        $price = (float)SystemConfigService::get('product_hanging_price');
+        $pro = AuctionProduct::where('hanging_price', '>=', $section['low'])->where('hanging_price','<=','high')->select()->toArray();
+
+        if (empty($pro) and ($price < $section['low'] or $price > $section['high'])) {
+            return app('json')->fail('该区间没有商品');
+        }
+
+
         if (AuctionOrder::where([['auction_id', '=', $data['id']], ['frequency', '=', $auction['frequency']], ['uid', '=', $request->uid()]])->count() >= 1) return app('json')->fail('当前场次已购买商品');
 
         $orderCount = AuctionOrder::where([['auction_id', '=', $data['id']], ['frequency', '=', $auction['frequency']]])->count(); // 查找出当前场次已派单多少
@@ -37,7 +50,7 @@ class AuctionProductController
 
 
 
-        $show = AuctionProduct::random($data['id'], $request->uid());
+        $show = AuctionProduct::random($data['id'], $request->uid(),$section);
         if ($show == 'false')  return app('json')->fail('购买失败');
         return app('json')->successful($show);
     }

+ 3 - 3
app/api/controller/order/StoreOrderController.php

@@ -118,9 +118,9 @@ class StoreOrderController
         $uid = $request->uid();
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
-        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
+        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId,$shipping_type,$top_ticket) = UtilService::postMore([
             'addressId', 'couponId', ['payType', 'yue'], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''],
-            ['shipping_type', 1],
+            ['shipping_type', 1],['top_ticket', 0]
         ], $request, true);
         $payType = strtolower($payType);
         if ($bargainId) {
@@ -138,7 +138,7 @@ class StoreOrderController
             if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
                 return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
         }
-        $priceGroup = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
+        $priceGroup = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type, $top_ticket);
         if ($priceGroup)
             return app('json')->status('NONE', 'ok', $priceGroup);
         else

+ 52 - 0
app/api/controller/user/UserBillController.php

@@ -350,4 +350,56 @@ class UserBillController
         return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit));
 
     }
+
+    /**
+     * 购物积分记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function sp_final_list(Request $request)
+    {
+        list($page, $limit) = UtilService::getMore([
+            ['page', 0], ['limit', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'sp_final'));
+
+    }
+
+
+    /**
+     * 提货券记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function top_ticket_list(Request $request)
+    {
+        list($page, $limit) = UtilService::getMore([
+            ['page', 0], ['limit', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'top_ticket'));
+
+    }
+
+    /**
+     * 广告值记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function aid_val_list(Request $request)
+    {
+        list($page, $limit) = UtilService::getMore([
+            ['page', 0], ['limit', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'aid_val'));
+
+    }
 }

+ 7 - 1
app/api/controller/user/UserController.php

@@ -275,8 +275,14 @@ class UserController
         $type3=intval($res['aid_val']+$data['amount']);
         if($data['type']==2){
             $res1=User::where('uid',$data['uid'])->update([$data['type1'] =>$type1,$data['type2']=>$type2,'aid_val'=>$type3]);
+            UserBill::expend('购物积分转换提货券', $data['uid'], 'sp_final', 'sub_sp_final', $data['amount'], 0,$type1, '购物积分转换提货券');
+            UserBill::income('购物积分转换提货券', $data['uid'], 'top_ticket', 'add_top_ticket', $data['amount'], 0,$type2, '购物积分转换提货券');
+            UserBill::income('转换增加广告值', $data['uid'], 'aid_val', 'add_aid_val', $data['amount'], 0,$type3, '转换增加广告值');
+        }else{
+            $res1=User::where('uid',$data['uid'])->update([$data['type1'] =>$type1,$data['type2']=>$type2]);
+            UserBill::expend('余额转换购物积分', $data['uid'], 'now_money', 'sub_now_money', $data['amount'], 0,$type1, '余额转换购物积分');
+            UserBill::income('余额转换购物积分', $data['uid'], 'sp_final', 'add_sp_final', $data['amount'], 0,$type2, '余额转换购物积分');
         }
-        $res1=User::where('uid',$data['uid'])->update([$data['type1'] =>$type1,$data['type2']=>$type2]);
         return $res1;
 
     }

+ 2 - 2
app/models/auction/Auction.php

@@ -48,8 +48,8 @@ class Auction extends BaseModel
         if ($list){
             foreach ($list as  $k =>$v)
             {
-                $list[$k]['time'] = strtotime($v['rend_time']);
-                $list[$k]['day'] = date('Y-m-d H:i:s', strtotime($v['rend_time']));
+                $list[$k]['time'] = strtotime($v['radd_time']) - 1800;
+                $list[$k]['day'] = date('Y-m-d H:i:s', strtotime($v['radd_time']) - 1800);
                 if (in_array($v['id'], $id)){
                     $list[$k]['sta'] = 2; // 进入
                     $list[$k]['str'] = '进入';

+ 6 - 2
app/models/auction/AuctionProduct.php

@@ -46,12 +46,16 @@ class AuctionProduct extends BaseModel
         return $list;
     }
 
-    public static function random($id, $uid)
+    public static function random($id, $uid, $section)
     {
         $auction = Auction::find($id);
         AuctionOrder::startTrans();
         $order = AuctionOrder::where([['auction_id', '=', $id], ['frequency', '=', $auction['frequency']]])->column('product_id');
-        $product = self::where('auction_id', $auction['id'])->where('id', 'notIn', $order)->orderRaw('rand()')->limit(1)->find(); // 随机出来一个商品
+        $product = self::where('auction_id', $auction['id'])
+            ->where('hanging_price', '>=', $section['low'])
+            ->where('hanging_price','<=',$section['high'])
+            ->where('id', 'notIn', $order)->orderRaw('rand()')
+            ->limit(1)->find(); // 随机出来一个商品
         if (empty($product)){
             $config = SystemConfig::where('config_tab_id', 24)->select();
             $data = [

+ 32 - 0
app/models/auction/AuctionSection.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace app\models\auction;
+
+use app\models\store\StoreProduct;
+use crmeb\services\SystemConfigService;
+use think\facade\Db;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+/**
+ * TODO 场馆model
+ * Class Article
+ * @package app\models\article
+ */
+class AuctionSection extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'auction_section';
+
+    use ModelTrait;
+
+}

+ 28 - 2
app/models/store/StoreOrder.php

@@ -275,7 +275,7 @@ class StoreOrder extends BaseModel
      * @throws \think\exception\DbException
      */
 
-    public static function cacheKeyCreateOrder($uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $real_name = '', $phone = '', $storeId = 0)
+    public static function cacheKeyCreateOrder($uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $top_ticket = 0,$real_name = '', $phone = '', $storeId = 0)
     {
         self::beginTrans();
         try {
@@ -386,7 +386,6 @@ class StoreOrder extends BaseModel
                 $SurplusIntegral = bcsub($userInfo['integral'], $payIntegral, 2);
                 $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'integral', 'integral_product', $payIntegral, $key, $SurplusIntegral, '购买积分商品使用' . $payIntegral . '积分');
             }
-
             //积分抵扣
             if ($useIntegral && $SurplusIntegral > 0) {
                 $deductionPrice = (float)bcmul($SurplusIntegral, $other['integralRatio'], 2);
@@ -408,6 +407,31 @@ class StoreOrder extends BaseModel
                 $usedIntegral = 0;
             }
             if (!$res2) return self::setErrorInfo('使用积分抵扣失败!', true);
+
+            //积分抵扣
+            $res10 = true;
+            $tocket = $userInfo['top_ticket'];
+            if ($top_ticket && $tocket  > 0){
+                if ($tocket < $payPrice){
+                    $deductionPrice = $tocket;
+                    $payPrice = bcsub($payPrice, $tocket, 2);
+                    $userTicket = $tocket;
+                    $tocket = 0;
+                    $res10 = false !== User::edit(['top_ticket' => 0], $userInfo['uid'], 'uid');
+                }else{
+                    $deductionPrice = $payPrice;
+                    $userTicket = $payPrice;
+                    $tocket = bcsub($tocket, $payPrice, 2);
+                    $res10 = false !== User::bcDec($userInfo['uid'], 'top_ticket', $payPrice, 'uid');
+                    $payPrice = 0;
+
+                }
+                $res10 = $res10 && false != UserBill::expend('提货券抵扣', $uid, 'top_ticket', 'sub_top_ticket', $deductionPrice, $key, $tocket, '购买商品使用' . floatval($usedIntegral) . '提货券抵扣' . floatval($deductionPrice) . '元');
+            }else{
+                $deductionPrice = 0;
+                $userTicket = 0;
+            }
+            if (!$res10) return self::setErrorInfo('使用提货券抵扣失败!', true);
             if ($payPrice <= 0) $payPrice = 0;
             if ($test) {
                 self::rollbackTrans();
@@ -419,6 +443,7 @@ class StoreOrder extends BaseModel
                     'deduction_price' => $deductionPrice,
                     'totalIntegral' => $payIntegral,
                     'SurplusIntegral' => $SurplusIntegral,
+                    'tocket' => $tocket
                 ];
             }
             $orderInfo = [
@@ -450,6 +475,7 @@ class StoreOrder extends BaseModel
                 'add_time' => time(),
                 'unique' => $key,
                 'shipping_type' => $shipping_type,
+                'top_ticket' => $userTicket
             ];
             if ($shipping_type === 2) {
                 $orderInfo['verify_code'] = self::getStoreCode();

+ 1 - 1
app/models/store/StoreProduct.php

@@ -113,7 +113,7 @@ class StoreProduct extends BaseModel
         if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//虚拟销量
         if ($baseOrder) $baseOrder .= ', ';
         $model->order($baseOrder . 'sort DESC, add_time DESC');
-        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock')->select()->each(function ($item) use ($uid, $type) {
+        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock,ot_price')->select()->each(function ($item) use ($uid, $type) {
             if ($type) {
                 $item['is_att'] = StoreProductAttrValueModel::where('product_id', $item['id'])->count() ? true : false;
                 if ($uid) $item['cart_num'] = StoreCart::where('is_pay', 0)->where('is_del', 0)->where('is_new', 0)->where('type', 'product')->where('product_id', $item['id'])->where('uid', $uid)->value('cart_num');

+ 15 - 1
app/models/user/UserBill.php

@@ -78,11 +78,25 @@ class UserBill extends BaseModel
                 ->select();
         }
         $list = count($list) ? $list->toArray() : [];
+        $data['zj'] = [];
+        $data['kc'] = [];
+        $data['sr'] = 0;
+        $data['zc'] = 0;
         foreach ($list as &$v) {
             $v['add_time'] = date('Y/m/d H:i', $v['add_time']);
             $v['number'] = floatval($v['number']);
+            if ($v['pm'] == 1) {
+                $data['zj'][] = $v;
+                $data['sr'] += $v['number'];
+            }
+            if ($v['pm'] == 0){
+                $data['kc'][] = $v;
+                $data['zc'] += $v['number'];
+            }
         }
-        return $list;
+        $data['sr'] = round($data['sr'], 2);
+        $data['zc'] = round($data['zc'], 2);
+        return $data;
     }
 
     /**

+ 4 - 1
route/api/route.php

@@ -150,6 +150,9 @@ Route::group(function () {
     Route::get('spread/count/:type', 'user.UserBillController/spread_count')->name('spreadCount');//推广 佣金 3/提现 4 总和
     Route::get('spread/banner', 'user.UserBillController/spread_banner')->name('spreadBanner');//推广分销二维码海报生成
     Route::get('integral/list', 'user.UserBillController/integral_list')->name('integralList');//积分记录
+    Route::get('sp_final_list/list', 'user.UserBillController/sp_final_list')->name('sp_final_list');//购物积分记录
+    Route::get('top_ticket_list/list', 'user.UserBillController/top_ticket_list')->name('top_ticket_list');//提货券记录
+    Route::get('aid_val_list/list', 'user.UserBillController/aid_val_list')->name('aid_val_list');//广告值记录
     //提现类
     Route::get('extract/bank', 'user.UserExtractController/bank')->name('extractBank');//提现银行/提现最低金额
     Route::post('extract/cash', 'user.UserExtractController/cash')->name('extractCash');//提现申请
@@ -168,6 +171,7 @@ Route::group(function () {
     Route::get('auction', 'auction.AuctionController/list')->name('auction');//场次列表
     Route::post('subscribe', 'auction.AuctionController/subscribe')->name('subscribe');//预约
     Route::get('advance', 'auction.AuctionController/advance')->name('advance');//进场
+    Route::get('section', 'auction.AuctionController/section')->name('section');//价格区间
     Route::get('purchase', 'auction.AuctionProductController/purchase')->name('purchase');//随机商品
 
     Route::get('user_auction_order', 'auction.AuctionProductController/user_auction_order')->name('user_auction_order');//用户订单
@@ -179,7 +183,6 @@ Route::group(function () {
     Route::get('gsxq', 'auction.AuctionProductController/gsxq')->name('gsxq');//挂售详情
 
 
-
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, true);
 //未授权接口
 Route::group(function () {