hrjy 2 vuotta sitten
vanhempi
commit
480e85c8c3

+ 2 - 2
app/admin/controller/auction/AuctionOrder.php

@@ -250,9 +250,9 @@ class AuctionOrder extends AuthController
             $res = $product->save();
             if ($res){
                 if ($uid > 0){
-                    model::earn($uid,$data['price'] ,$product); // 卖家
+                    \app\models\auction\AuctionOrder::earn($uid,$data['price'] ,$product); // 卖家
                 }
-                model::return($id); // 买家
+                \app\models\auction\AuctionOrder::return($id); // 买家
                 $data['status'] = 3;
                 $data->save();
                 \app\admin\model\auction\AuctionProduct::commitTrans();

+ 2 - 4
app/admin/controller/auction/AuctionProduct.php

@@ -259,13 +259,11 @@ class AuctionProduct extends AuthController
             'hanging_price',
             'slider_image',
             'description',
-            'give'
+            'give',
+            'uid'
         ]);
         $data['slider_image'] = json_encode($data['slider_image']);
         $data['description'] = htmlspecialchars($data['description']);
-        $auction = \app\admin\model\auction\Auction::where('id' ,$data['auction_id'])->find();
-        $auction_gu = \app\admin\model\auction\AuctionGu::where('id' ,$auction['auction_gu_id'])->find();
-        $data['uid'] = $auction_gu['uid'];
         $res = model::create($data);
         if ($res){
             return Json::success('修改成功!');

+ 11 - 1
app/admin/view/auction/auction/fz.php

@@ -269,6 +269,15 @@
                                             </div>
                                         </div>
                                     </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <div class="layui-input-inline">
+                                                    <input type="hidden" name="uid" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.uid" maxlength="100" value="0">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
                                     <label class="layui-form-label" style="left: +1%">商品详情:</label>
                                     <div class="layui-row layui-col-space15">
                                         <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
@@ -332,7 +341,8 @@
                 auction_id: auction_id,
                 hanging_price: '',
                 slider_image: [],
-                give: 0
+                give: 0,
+                uid:''
 
             },
             rule: { //多图选择规则

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

@@ -123,7 +123,7 @@
             {field: 'anticipate', title: '预约价格', templet: '#anticipate',  align: 'center',style : 'color: #DC143C;'},
             {field: 'image', title: '封面', templet: '#image', align: 'center', width: '5%'},
             {field: 'status', title: '状态', templet: '#status', align: 'center'},
-            {field: 'goods_time', title: '自动放货(分钟)', templet: '#status', align: 'center'},
+            {field: 'goods_time', title: '自动放货(分钟)', templet: '#goods_time', align: 'center'},
             {field: 'add_time', title: '预约开始', templet: '#add_time',  align: 'center'},
             {field: 'end_time', title: '预约结束', templet: '#end_time', align: 'center'},
             {field: 'radd_time', title: '入场开始', templet: '#radd_time',  align: 'center'},

+ 12 - 2
app/admin/view/auction/auction_product/fz.php

@@ -281,6 +281,15 @@
                                             </div>
                                         </div>
                                     </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <div class="layui-input-inline">
+                                                    <input type="hidden" name="uid" lay-verify="title" autocomplete="off" class="layui-input" v-model="formData.uid" maxlength="100" value="0">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
                                     <label class="layui-form-label" style="left: +1%">商品详情:</label>
                                     <div class="layui-row layui-col-space15">
                                         <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
@@ -343,7 +352,8 @@
                 auction_id: '',
                 hanging_price: '',
                 slider_image: [],
-                give: 0
+                give: 0,
+                uid:''
 
             },
             rule: { //多图选择规则
@@ -825,7 +835,7 @@
                 }
                 that.formData.auction_id = auction_id;
                 that.formData.description = that.getContent();
-                that.requestPost(that.U({c:'auction.auctionProduct',a:'update',p:{id:that.id}}),that.formData).then(function (res) {
+                that.requestPost(that.U({c:'auction.auctionProduct',a:'fzsp',p:{id:that.id}}),that.formData).then(function (res) {
                     that.confirm();
                 }).catch(function (res) {
                     that.showMsg(res.msg);

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

@@ -313,7 +313,7 @@
             {type:'checkbox'},
             {field: 'uid', title: '编号',event:'uid',width:'4%',align:'center'},
             {field: 'avatar', title: '头像', event:'open_image', width: '6%',align:'center', templet: '<p lay-event="open_image"><img class="avatar" style="cursor: pointer" class="open_image" data-image="{{d.avatar}}" src="{{d.avatar}}" alt="{{d.nickname}}"></p>'},
-            {field: 'nickname', title: '姓名',templet:'#nickname',align:'center',width: '10%'},
+            {field: 'nickname', title: '姓名',templet:'#nickname',align:'center'},
             {field: 'group_name', title: '分组',templet:'#group_name',align:'center'},
             {field: 'phone', title: '手机号',align:'center',width:'8%'},
             {field: 'now_money', title: '余额',width:'6%',sort:true,event:'now_money',align:'center'},

+ 14 - 7
app/api/controller/auction/AuctionOrderController.php

@@ -95,16 +95,23 @@ class AuctionOrderController
     public function edit_voucher(Request $request)
     {
 
-        $data = UtilService::postMore([
-            'order_id',
-            'image'
+        $data = UtilService::getMore([
+            ['order_id'],
+            ['image']
         ]);
+        if (!$data['image'] || !$data['order_id'])  return app('json')->fail('请上传打款凭证');
+
         $order = AuctionOrder::where('order_id', $data['order_id'])->find();
-        if (!$order) return app('json')->fail('没有此订单');// 失败
+        if (!$order) return app('json')->fail('订单不存在');
         $order['upload_image'] = $data['image'];
-        $res = $order->save();
-        if (!$res)  return app('json')->fail('修改失败');// 失败
-        return app('json')->success('修改成功');// 失败
+        $order['status'] = 2;
+        $order['voucher_time'] = time();
+
+        if ($order->save()){
+            return app('json')->successful('上传成功');
+        }else{
+            return app('json')->fail('上传失败');
+        }
     }
 
 

+ 63 - 19
app/api/controller/auction/AuctionProductController.php

@@ -7,6 +7,7 @@ use app\admin\model\system\SystemConfig;
 use app\common\model\Config;
 use app\models\auction\Auction;
 use app\models\auction\AuctionBooking;
+use app\models\auction\AuctionFrozen;
 use app\models\auction\AuctionOrder;
 use app\models\auction\AuctionProduct;
 use app\models\auction\AuctionTime;
@@ -84,7 +85,6 @@ class AuctionProductController
 
         $product = AuctionProduct::where('id', $data['product_id'])->find();
         if ($product['is_show'] == 0) return app('json')->fail('商品未挂售');
-        $product_ids = AuctionProduct::where('auction_id', $product['auction_id'])->column('id');
         $auction  = Auction::where('id', $product['auction_id'])->find();
 
         $user = $request->user();
@@ -112,14 +112,28 @@ class AuctionProductController
         if ($product){
             AuctionOrder::beginTrans();
             // 查询商品是否以卖出
-            $order = AuctionOrder::where('product_id', $data['product_id'])->where('status', '>', 0)->whereBetweenTime('create_time', date('Y-m-d H:i:s', strtotime(date('Y-m-d'))), date('Y-m-d H:i:s', strtotime('+1 day')))->find();
+            $order = AuctionOrder::where('product_id', $data['product_id'])->where('status', '>', 0)->where('frequency', $auction['frequency'])->find();
             if ($order){
                 return app('json')->fail('商品已卖出');
             }
+            $order_id = getNewOrderId();
+            if ($count >= 1){
+                if ($user['anticipate'] < 200) return app('json')->fail('艺金券不足');
+                $user['anticipate'] -= 200;
+                User::where('uid', $user['uid'])->update(['anticipate' => $user['anticipate']]);
+                UserBill::expend('冻结艺金券',$user['uid'], 'anticipate', 'fz_anticipate', 200, $user['spread_uid'], $user['anticipate'], '购买订单'.$order_id.'冻结艺金券');
+
+                AuctionFrozen::create([
+                    'order_id' => $order_id,
+                    'uid' => $request->uid(),
+                    'anticipate' => 200
+                ]);
+            }
+
             $res = AuctionOrder::create([
                 'uid' => $request->uid(),
                 'collection_id' => $product['uid'],// 商品拥有有人
-                'order_id' => getNewOrderId(),
+                'order_id' => $order_id,
                 'name' => $product['name'],
                 'product_id' => $product['id'],
                 'auction_id' => $auction['id'],
@@ -313,18 +327,18 @@ class AuctionProductController
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-   public function gsxq(Request $request)
-   {
-       $data = UtilService::getMore([
-           ['id']
-       ]);
-       $product = AuctionProduct::where('id', $data['id'])->find();
-       if (!$product) return app('json')->fail('商品不存在');
+    public function gsxq(Request $request)
+    {
+        $data = UtilService::getMore([
+            ['id']
+        ]);
+        $product = AuctionProduct::where('id', $data['id'])->find();
+        if (!$product) return app('json')->fail('商品不存在');
 
-       $data = AuctionProduct::bs($data['id']);
-       return app('json')->successful($data);
+        $data = AuctionProduct::bs($data['id']);
+        return app('json')->successful($data);
 
-   }
+    }
 
 
     /**
@@ -356,7 +370,7 @@ class AuctionProductController
         $product['is_show'] = 1; // 上架
         $product['is_admin'] = 2;
         $user['anticipate'] -= $datas['anticipate']; // 扣除预约券
-        $user['anticipate'] += $datas['give'];
+        $user['integral'] += $datas['give'];
         try {
             Db::startTrans();
             // 新增挂售时间段
@@ -370,8 +384,8 @@ class AuctionProductController
             $product->save();
             $user->save();
             AuctionOrder::where([['uid', '=', $request->uid()], ['product_id', '=', $product['id']], ['is_gs', '=', 0]])->update(['is_gs' => 1]);// 修改订单挂售
-            UserBill::expend('挂售扣除预约券', $user['uid'], 'anticipate', 'gs_anticipate', $datas['anticipate'], $user['spread_uid'], $user['anticipate'], '挂售扣除预约券');
-            UserBill::income('赠送预约券', $user['uid'], 'anticipate', 'gs_anticipate', $datas['give'], $user['spread_uid'], $user['anticipate'], '挂售赠送预约券');
+            UserBill::expend('挂售扣除预约券', $user['uid'], 'anticipate', 'gs_anticipate', $datas['anticipate'], $user['spread_uid'], $user['anticipate'], '挂售扣除艺金券');
+            UserBill::income('赠送趣豆', $user['uid'], 'integral', 'gs_integral', $datas['give'], $user['spread_uid'], $user['integral'], '挂售赠送趣豆');
 
             Db::commit();
             return app('json')->successful('挂售成功');
@@ -403,11 +417,40 @@ class AuctionProductController
         $order = AuctionOrder::where([['product_id', '=', $details['id']], ['status', '<', 3], ['status', '>', 0]])->find();
         if ($order) return app('json')->fail('商品已出售,无法取消');
 
+
+        $auction = Auction::where('id', $details['auction_id'])->find();
+        $data['time'] = explode(',', $auction['site']);
+
+        $date = date('w', time()); // 今天星期几
+        $bs = 0;
+        if (in_array(1, $data['time'])){
+            if ($date >= 1 and $date <= 2){
+                $bs = 3 - $date;
+            }elseif ($date >= 3 and $date <= 4){
+                $bs = 5 - $date;
+            }elseif ($date >= 5 or $date == 0){
+                if ($date == 5) $bs = 3;
+                if ($date == 6) $bs = 2;
+                if ($date == 0) $bs = 1;
+            }
+
+        }else if (in_array(2, $data['time'])){
+            if ($date >= 2 and $date <= 3){
+                $bs = 4 - $date;
+            }elseif ($date >= 4 and $date <= 5){
+                $bs = 6 - $date;
+            }elseif ($date >= 6 or $date == 0 or $date == 1){
+                if ($date == 6) $bs = 3;
+                if ($date == 0) $bs = 2;
+                if ($date == 1) $bs = 1;
+            }
+        }
         $user = User::where('uid', $request->uid())->find();
         $anticipate = round($details['price'] * $details['deduct']/100, 2);
         $details['hanging_price'] = $details['price']; // 价格变=回未挂售前;
-        $details['is_show'] = 0; // 价格变=回未挂售前;
-        $user['anticipate'] += $anticipate*2;// 退回挂售扣除的预约预约券
+        $details['is_show'] = 0; // 价格变回未挂售前;
+        $user['anticipate'] += $anticipate*$bs;// 退回挂售扣除的预约预约券
+        $user['integral'] -=  round(($details['price'] * $details['give']/100)*$bs, 2);// 挂售赠送趣豆
 
 
         try {
@@ -415,7 +458,8 @@ class AuctionProductController
             $details->save();
             $user->save();
             AuctionOrder::where('order_id', $details['order'])->save(['is_gs' => 0]);
-            UserBill::income('取消挂售退回预约券', $request->uid(), 'anticipate', 'gsth_anticipate', $anticipate*2, 0, $user['anticipate'], '取消挂售退回预约券');
+            UserBill::income('取消挂售退回预约券', $request->uid(), 'anticipate', 'gsth_anticipate', $anticipate*$bs, 0, $user['anticipate'], '取消挂售退回预约券');
+            UserBill::expend('取消挂售扣除趣豆', $request->uid(), 'integral', 'gsth_integral',  round(($details['price'] * $details['give']/100)*$bs, 2), 0, $user['integral'], '取消挂售扣除赠送趣豆');
             AuctionTime::where([['uid', '=', $request->uid()], ['product_id', '=', $data['id']]])->delete(); // 删除上架时间
             Db::commit();
 

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

@@ -47,6 +47,8 @@ class Auction extends BaseModel
             foreach ($list['data'] as  $k =>$v)
             {
                 $list['data'][$k]['time'] = strtotime($v['end_time']);
+                $list['data'][$k]['start_time'] = strtotime($v['radd_time']);
+                $list['data'][$k]['top_time'] = strtotime($v['rend_time']);
                 $list['data'][$k]['day'] = date('Y-m-d H:i:s', strtotime($v['end_time']));
                 $booking = AuctionBooking::where([['uid', '=', $uid], ['frequency', '=', $v['frequency']]])->field('auction_id')->select();
                 foreach ($booking as $value) {

+ 34 - 0
app/models/auction/AuctionFrozen.php

@@ -0,0 +1,34 @@
+<?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 AuctionFrozen extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'auction_frozen';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+}

+ 128 - 99
app/models/auction/AuctionOrder.php

@@ -40,9 +40,9 @@ class AuctionOrder extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function userOrder($data,$uid)
+    public static function userOrder($data, $uid)
     {
-        if ($data['order_id']){
+        if ($data['order_id']) {
             $list = self::alias('a')
                 ->field('a.*,u.nickname,u.avatar,u.uid as user_id,c.nickname as c_nickname,pay.phone')
                 ->leftJoin('user u', 'a.uid = u.uid')
@@ -55,44 +55,44 @@ class AuctionOrder extends BaseModel
             $list['zfb'] = [];
             $list['bank'] = [];
             $list['time'] = strtotime($list['create_time']);
-            if ($pay){
-                foreach ($pay as $k => $v){
-                    if ($v['type'] == 1){
+            if ($pay) {
+                foreach ($pay as $k => $v) {
+                    if ($v['type'] == 1) {
                         $list['wx'] = $v;
-                    }elseif ($v['type'] == 2){
+                    } elseif ($v['type'] == 2) {
                         $list['zfb'] = $v;
-                    }elseif ($v['type'] == 3){
+                    } elseif ($v['type'] == 3) {
                         $list['bank'] = $v;
                     }
                 }
             }
-        }else{
-            if ($data['type'] == 1){
-                $list = self::where([['uid', '=', $uid], ['status', '=', 1]])->page($data['page'], $data['limit'])->select(); //待上传订单
+        } else {
+            if ($data['type'] == 1) {
+                $list = self::where([['uid', '=', $uid], ['status', '=', 1]])->order('id DESC')->page($data['page'], $data['limit'])->select(); //待上传订单
 
-            }else if($data['type'] == 2){
-                $list = self::where([['uid', '=', $uid], ['status', '=', 2]])->page($data['page'], $data['limit'])->select(); //待审核订单
+            } else if ($data['type'] == 2) {
+                $list = self::where([['uid', '=', $uid], ['status', '=', 2]])->order('id DESC')->page($data['page'], $data['limit'])->select(); //待审核订单
 
-            }else if($data['type'] == 3) {
-                $list = self::where([['uid', '=', $uid], ['status', '=', 3], ['is_gs', '=', 1]])->page($data['page'], $data['limit'])->select(); //完成订单
-            }else if($data['type'] == 4) {
+            } else if ($data['type'] == 3) {
+                $list = self::where([['uid', '=', $uid], ['status', '=', 3], ['is_gs', '=', 1]])->order('id DESC')->page($data['page'], $data['limit'])->select(); //完成订单
+            } else if ($data['type'] == 4) {
 
                 $list = AuctionProduct::where([['uid', '=', $uid], ['is_show', '=', 0]])
                     ->page($data['page'], $data['limit'])
                     ->select();
-                if ($list){
-                    foreach ($list as $k => $v){
+                if ($list) {
+                    foreach ($list as $k => $v) {
                         $list[$k]['product_id'] = $v['id'];
                         $list[$k]['is_gs'] = 0;
                         $list[$k]['order_id'] = $list[$k]['order'];
                     }
                 }
-            }else{
-                $list = self::where([['uid', '=', $uid]])->page($data['page'], $data['limit'])->select(); //过期订单
+            } else {
+                $list = self::where([['uid', '=', $uid]])->order('id DESC')->page($data['page'], $data['limit'])->select(); //过期订单
             }
         }
 
-        $list = !empty($list)? $list->toArray(): [];
+        $list = !empty($list) ? $list->toArray() : [];
         return $list;
     }
 
@@ -105,24 +105,24 @@ class AuctionOrder extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function seller_list($data,$uid)
+    public static function seller_list($data, $uid)
     {
-        if ($data['order_id']){
+        if ($data['order_id']) {
             $list = self::alias('a')
                 ->field('a.*,u.nickname,u.avatar,u.uid as user_id')
                 ->leftJoin('user u', 'a.uid = u.uid')
                 ->where('a.order_id', $data['order_id'])->find(); //详细订单
-        }else{
-            if ($data['type'] == 1){
+        } else {
+            if ($data['type'] == 1) {
                 $status = 1;
-            }else if($data['type'] == 2){
+            } else if ($data['type'] == 2) {
                 $status = 2;
-            }else if($data['type'] == 3) {
+            } else if ($data['type'] == 3) {
                 $status = 3;
-            }else{
+            } else {
                 $status = 0;
             }
-            if ($data['type'] == 4){
+            if ($data['type'] == 4) {
                 $product = AuctionTime::alias('a')
                     ->field('FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as gs_time,au.nickname,b.*')
                     ->order('a.id DESC')
@@ -130,8 +130,8 @@ class AuctionOrder extends BaseModel
                     ->leftJoin('auction_product b', 'a.product_id = b.id')
                     ->leftJoin('auction au', 'au.id = a.auction_id')
                     ->select();
-            }else{
-                if ($status == 0){
+            } else {
+                if ($status == 0) {
                     $list = self::alias('a')
                         ->field('a.*,u.nickname,u.avatar,u.uid as user_id')
                         ->leftJoin('user u', 'a.uid = u.uid')
@@ -139,7 +139,7 @@ class AuctionOrder extends BaseModel
                         ->where([['a.collection_id', '=', $uid]])
                         ->page($data['page'], $data['limit'])
                         ->select(); //待上传订单
-                }else{
+                } else {
                     $list = self::alias('a')
                         ->field('a.*,u.nickname,u.avatar,u.uid as user_id')
                         ->leftJoin('user u', 'a.uid = u.uid')
@@ -153,15 +153,15 @@ class AuctionOrder extends BaseModel
 
         }
 
-        if ($data['type'] != 4){
-            $list = !empty($list)? $list->toArray(): [];
+        if ($data['type'] != 4) {
+            $list = !empty($list) ? $list->toArray() : [];
             foreach ($list as $k => $v) {
                 $pay = AuctionPay::where('uid', $v['uid'])->find();
                 $list[$k]['phone'] = $pay['phone'];
             }
             return $list;
-        }else{
-            $product = empty($product) ? []: $product->toArray();
+        } else {
+            $product = empty($product) ? [] : $product->toArray();
             return $product;
         }
 
@@ -170,7 +170,7 @@ class AuctionOrder extends BaseModel
 
     /**
      * 卖家操作
-     * @param $id  //商品所属人
+     * @param $id //商品所属人
      * @param $price //卖出价格
      * @param $product //商品详情
      * @return void
@@ -178,12 +178,12 @@ class AuctionOrder extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function earn($id, $price,$product)
+    public static function earn($id, $price, $product)
     {
         $userModel = new \app\models\user\User();
         $productModel = new AuctionProduct();
         $user = $userModel->find($id);
-        if ($user['spread_uid'] > 0){
+        if ($user['spread_uid'] > 0) {
             $s_price = round(($price - $product['price']) * 0.1, 2); // 卖出价格减去购买价格的百分之十 为上级直推奖励
             $spread = $userModel->find($user['spread_uid']);
             $spread['integral'] = $spread['integral'] + $s_price; //积分增加
@@ -213,21 +213,22 @@ class AuctionOrder extends BaseModel
         $productModel = new AuctionProduct();
         $auctionModel = new Auction();
         $bookingModel = new AuctionBooking();
+        $frozenModel = new AuctionFrozen();
 
 
         $user = $userModel->find($data['uid']);
-        if ($user['is_new'] == 1){
+        if ($user['is_new'] == 1) {
 
             if ($user['spread_uid']) {
                 $spread = $userModel->where('uid', $user['spread_uid'])->find();
-                if ($spread['green_time'] !=  strtotime(date('Y-m-d', strtotime('+1 day')))){
+                if ($spread['green_time'] != strtotime(date('Y-m-d', strtotime('+1 day')))) {
                     $spread['green_time'] = strtotime(date('Y-m-d', strtotime('+1 day'))); // 开启明天的绿色通道
                     $spread->save();
                 }
 
             }
-            $orderCount = AuctionOrder::where([['uid', '=',  $user['uid']], ['status','=', 3]])->count();
-            if ($orderCount >= 5){
+            $orderCount = AuctionOrder::where([['uid', '=', $user['uid']], ['status', '=', 3]])->count();
+            if ($orderCount >= 5) {
                 $user['is_new'] = 0;
             }
 
@@ -235,28 +236,28 @@ class AuctionOrder extends BaseModel
         }
         $product = $productModel->where('id', $data['product_id'])->find();
         $auction = $auctionModel->where('id', $product['auction_id'])->find();
-        $time = strtotime(date('Y-m-d' ,strtotime($data['create_time']))); // 订单当天时间段
-        $totime = strtotime(date('Y-m-d' ,strtotime($data['create_time']))) + 86400; // 订单凌晨时间段
-        $booking = $bookingModel->where('auction_id', $auction['id'])->where('uid', $user['uid'])->whereBetweenTime('create_time', $time, $totime)->find();
-        if ($booking['status'] > 0){
-            $booking['status'] = 0;
-            $booking->save();
-            $anticipate = $booking['anticipate'] - $booking['deduction'];
+
+        $booking = $bookingModel->where('auction_id', $auction['id'])->where('uid', $user['uid'])->where('frequency', $data['frequency'])->find();
+        $fz = $frozenModel->where('order_id', $data['order_id'])->where('status', 1)->where('uid', $user['uid'])->find();
+        if ($fz){
+            $fz['status'] = 0;
+            $anticipate = $fz['anticipate'] - $fz['deduction'];
             $user['anticipate'] = $user['anticipate'] + $anticipate;// 退还预约卷
-            $user->save();
 
+            $user->save();
+            $fz->save();
+            UserBill::income('艺金券退还',$user['uid'], 'anticipate', 'th_anticipate', $anticipate, $user['spread_uid'], $user['anticipate'], '退还订单'.$data['order_id'].'艺金券,扣除' . $fz['deduction']);
 
-            \app\models\user\UserBill::create([
-                'uid' => $user['uid'],
-                'pm' => 1,
-                'title' => '艺金券退还',
-                'category' => 'anticipate',
-                'type' => 'th_anticipate',
-                'mark' => '退还'.$anticipate.'艺金券扣除'.$booking['deduction'],
-                'add_time' => time(),
-                'number' => $anticipate,
-                'balance' => $user['anticipate']
-            ]);
+        }else{
+            if ($booking['status'] > 0) {
+                $booking['status'] = 0;
+                $anticipate = $booking['anticipate'] - $booking['deduction'];
+                $user['anticipate'] = $user['anticipate'] + $anticipate;// 退还预约卷
+
+                $user->save();
+                $booking->save();
+                UserBill::income('艺金券退还',$user['uid'], 'anticipate', 'th_anticipate', $anticipate, $user['spread_uid'], $user['anticipate'], '退还预约艺金券扣除' . $booking['deduction']);
+            }
         }
     }
 
@@ -271,43 +272,75 @@ class AuctionOrder extends BaseModel
     {
         $one = (int)SystemConfigService::get('one_time');
         $tow = (int)SystemConfigService::get('tow_time');
-        $hour = time()-($one*60); // 一小时以前
-        $time =  time()-($tow*60); // 一个半小时
+        $hour = time() - ($one * 60); // 一小时以前
+        $time = time() - ($tow * 60); // 一个半小时
         $order = AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->select(); // 查询不在当前一个半小时内的所有订单
-        if ($order){
-            foreach ($order as $K => $v){
+        if ($order) {
+            foreach ($order as $K => $v) {
                 $product = AuctionProduct::where('id', $v['product_id'])->find();
                 $auction = Auction::where('id', $product['auction_id'])->find();
                 $booking = AuctionBooking::where([['uid', '=', $v['uid']], ['status', '=', 1], ['auction_id', '=', $auction['id']], ['frequency', '=', $auction['frequency']]])->find(); // 找到预约订单
-                if (strtotime($v['create_time']) <= $hour and strtotime($v['create_time']) > $time){
-                    // 订单在一个小时到一个半小时内
-                    if ($booking){
-                        if ($booking['deduction'] == 0){
+                $fz = AuctionFrozen::where('order_id', $v['order_id'])->where('status', 1)->find();
+                if ($fz) {
+                    if (strtotime($v['create_time']) <= $hour and strtotime($v['create_time']) > $time) {
+                        // 订单在一个小时到一个半小时内
+                        if ($fz['deduction'] == 0) {
                             $user = \app\models\user\User::where('uid', $v['collection_id'])->find();
-                            $user['anticipate'] = $user['anticipate'] + $booking['anticipate']/2; // 卖家增加预约卷
-                            $booking['deduction'] = $booking['anticipate']/2;
-                            UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate',  $booking['anticipate']/2, $v['uid'], $user['anticipate'], '('.$user['nickname'].'-'.$user['uid'].')超时付款');
-                            UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate',  $booking['anticipate']/2, $v['uid'], $booking['anticipate']/2, '超时付款,扣除冻结'.($booking['anticipate']/2).'艺金券');
-                            $booking->save();
+                            $user['anticipate'] = $user['anticipate'] + $fz['anticipate'] / 2; // 卖家增加预约卷
+                            $fz['deduction'] = $fz['anticipate'] / 2;
+                            UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate', $fz['anticipate'] / 2, $v['uid'], $user['anticipate'], '(' . $user['nickname'] . '-' . $user['uid'] . ')超时付款,增加艺金券');
+                            UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate', $fz['anticipate'] / 2, $v['uid'], $fz['anticipate'] / 2, '超时付款,扣除订单'.$v['order_id'].'冻结'. ($fz['anticipate'] / 2) . '艺金券');
+                            $fz->save();
                             $user->save();
                         }
-                    }
-                }elseif (strtotime($v['create_time']) <= $time){
-                    if ($booking) {
+                    } elseif (strtotime($v['create_time']) <= $time) {
+
                         $user = \app\models\user\User::where('uid', $v['collection_id'])->find(); //卖家
-                        $dedu = $booking['anticipate'] - $booking['deduction'];
+                        $dedu = $fz['anticipate'] - $fz['deduction'];
                         $user['anticipate'] += $dedu; // 卖家增加预约卷
-                        $booking['deduction'] = $booking['anticipate'];
+                        $fz['deduction'] = $fz['anticipate'];
+                        $fz['status'] = 2;
 
                         $user->save();
-                        \app\models\user\User::where('uid', $v['uid'])->update(['status' => 0,'freeze_time' => strtotime('+1 day')]); // 冻结用户
-                        UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate', $dedu, $v['uid'], $user['anticipate'], '('.$user['nickname'].'-'.$user['uid'].')超时付款');
-                        UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate',  $dedu, $v['uid'], 0, '超时付款,扣除冻结'.$dedu.'艺金券');
-                        $booking->save();
+                        \app\models\user\User::where('uid', $v['uid'])->update(['status' => 0, 'freeze_time' => strtotime('+1 day')]); // 冻结用户
+                        UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate', $dedu, $v['uid'], $user['anticipate'], '(' . $user['nickname'] . '-' . $user['uid'] . ')超时付款,增加艺金券');
+                        UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate', $dedu, $v['uid'], 0, '超时付款,扣除订单'.$v['order_id'].'冻结' . $dedu . '艺金券');
+                        $fz->save();
 
-                        AuctionBooking::where('id', $booking['id'])->update(['status' => 2]); // 修改预约订单状态 为扣除
                         AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['status' => 0]); // 修改为已过期订单
                     }
+
+                } else {
+                    if (strtotime($v['create_time']) <= $hour and strtotime($v['create_time']) > $time) {
+                        // 订单在一个小时到一个半小时内
+                        if ($booking) {
+                            if ($booking['deduction'] == 0) {
+                                $user = \app\models\user\User::where('uid', $v['collection_id'])->find();
+                                $user['anticipate'] = $user['anticipate'] + $booking['anticipate'] / 2; // 卖家增加预约卷
+                                $booking['deduction'] = $booking['anticipate'] / 2;
+                                UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate', $booking['anticipate'] / 2, $v['uid'], $user['anticipate'], '(' . $user['nickname'] . '-' . $user['uid'] . ')超时付款,增加艺金券');
+                                UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate', $booking['anticipate'] / 2, $v['uid'], $booking['anticipate'] / 2, '超时付款,扣除预约冻结' . ($booking['anticipate'] / 2) . '艺金券');
+                                $booking->save();
+                                $user->save();
+                            }
+                        }
+                    } elseif (strtotime($v['create_time']) <= $time) {
+                        if ($booking) {
+                            $user = \app\models\user\User::where('uid', $v['collection_id'])->find(); //卖家
+                            $dedu = $booking['anticipate'] - $booking['deduction'];
+                            $user['anticipate'] += $dedu; // 卖家增加预约卷
+                            $booking['deduction'] = $booking['anticipate'];
+                            $booking['status'] = 2;
+
+                            $user->save();
+                            \app\models\user\User::where('uid', $v['uid'])->update(['status' => 0, 'freeze_time' => strtotime('+1 day')]); // 冻结用户
+                            UserBill::income('超时增加', $v['collection_id'], 'anticipate', 'ad_anticipate', $dedu, $v['uid'], $user['anticipate'], '(' . $user['nickname'] . '-' . $user['uid'] . ')超时付款,增加艺金券');
+                            UserBill::expend('超时扣除', $v['uid'], 'anticipate', 'dec_anticipate', $dedu, $v['uid'], 0, '超时付款,扣除预约冻结' . $dedu . '艺金券');
+                            $booking->save();
+
+                            AuctionOrder::where('create_time', '<', $hour)->where('status', '=', 1)->update(['status' => 0]); // 修改为已过期订单
+                        }
+                    }
                 }
             }
 
@@ -324,15 +357,15 @@ class AuctionOrder extends BaseModel
     public static function th()
     {
         $auction = Auction::where('rend_time', '<', date('H:i:s', time()))->select();
-        if ($auction){
-            foreach ($auction as $k => $v){
+        if ($auction) {
+            foreach ($auction as $k => $v) {
 
-                $booking = AuctionBooking::where([['auction_id', '=', $v['id']], ['status','=' , 1]])->select();
-                if ($booking){
-                    foreach ($booking as $key => $value){
+                $booking = AuctionBooking::where([['auction_id', '=', $v['id']], ['status', '=', 1]])->select();
+                if ($booking) {
+                    foreach ($booking as $key => $value) {
                         $product = AuctionProduct::where('auction_id', $value['auction_id'])->column('id');
                         $order = AuctionOrder::where([['product_id', 'in', $product], ['frequency', '=', $value['frequency']], ['uid', '=', $value['uid']]])->find();
-                        if (!$order){
+                        if (!$order) {
                             $find = AuctionBooking::find($value['id']);
                             $find['status'] = 0;
 
@@ -341,7 +374,7 @@ class AuctionOrder extends BaseModel
 
                             $user->save();
                             $find->save();
-                            UserBill::income('退回艺金券',$user['uid'], 'anticipate', 'add_anticipate', $value['anticipate'], 0, $user['anticipate'], '艺金券'.$value['anticipate'].'退回');
+                            UserBill::income('退回艺金券', $user['uid'], 'anticipate', 'add_anticipate', $value['anticipate'], 0, $user['anticipate'], '艺金券' . $value['anticipate'] . '退回');
                         }
                     }
                 }
@@ -353,12 +386,11 @@ class AuctionOrder extends BaseModel
     public static function goods()
     {
         $order = AuctionOrder::where('status', 2)->select();
-        if ($order){
-            foreach ($order as &$item)
-            {
+        if ($order) {
+            foreach ($order as &$item) {
                 $auction = Auction::where('id', $item['auction_id'])->value('goods_time');
                 $time = $item['voucher_time'] + ($auction * 60); // 自动放货时间
-                if (time() > $time){
+                if (time() > $time) {
                     // 如果当前时间已经过了
                     $product = AuctionProduct::where('id', $item['product_id'])->find();
                     $product['uid'] = $item['uid'];// 商品拥有人更新
@@ -366,7 +398,7 @@ class AuctionOrder extends BaseModel
                     $product['order'] = $item['order_id'];
 
                     self::where('id', $item['id'])->update(['status' => 3]);
-                    self::earn($item['uid'],$item['price'], $product);
+                    self::earn($item['uid'], $item['price'], $product);
                     self::return($item['id']);
                     $product->save();
                 }
@@ -377,7 +409,4 @@ class AuctionOrder extends BaseModel
     }
 
 
-
-
-
 }

+ 24 - 12
app/models/auction/AuctionProduct.php

@@ -137,9 +137,18 @@ class AuctionProduct extends BaseModel
                             if (in_array($value, $productId))unset($productId[$value]);
                         }
                     }
+                    if ($productId){
+                        foreach ($productId as $item){
+                            $product = AuctionProduct::where([['id', '=', $item], ['is_admin', '=', 2]])->find();// 查找今天场次没买出去的商品下架
+                            if ($product){
+                                $product['is_show'] = 0;
+                                $product['hanging_price'] = $product['price'];
+                                $product->save();
+                            }
+                        }
+                    }
                     $order = AuctionProduct::where([['id', 'in', $productId], ['auction_id', '=', $v['id']], ['is_admin', '=', 2]])->column('order');// 查找今天场次没买出去的商品订单
                     AuctionOrder::where('order_id', 'in', $order)->save(['is_gs' => 0]);//订单为未挂售状态
-                    AuctionProduct::where([['id', 'in', $productId], ['auction_id', '=', $v['id']], ['is_admin', '=', 2]])->save(['is_show' => 0]);// 查找今天场次没买出去的商品下架
                     AuctionTime::where('auction_id', '=', $v['id'])->where('add_time', '<=', strtotime(date('Y-m-d', time())))->delete(); // 清除今天挂售时间
                 }
             }
@@ -162,36 +171,39 @@ class AuctionProduct extends BaseModel
         if (in_array(1, $data['time'])){
             if ($date >= 1 and $date <= 2){
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Wednesday")); // 星期三
-                $bs = 2;
+                $bs = 3 - $date;
             }elseif ($date >= 3 and $date <= 4){
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Friday")); // 星期五
-                $bs = 2;
+                $bs = 5 - $date;
             }elseif ($date >= 5 or $date == 0){
+                if ($date == 5) $bs = 3;
+                if ($date == 6) $bs = 2;
+                if ($date == 0) $bs = 1;
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Monday")); // 下个星期一
-                $bs = 3;
             }
 
         }else if (in_array(2, $data['time'])){
             if ($date >= 2 and $date <= 3){
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Thursday")); // 星期四
-                $bs = 2;
+                $bs = 4 - $date;
             }elseif ($date >= 4 and $date <= 5){
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Saturday")); // 星期六
-                $bs = 2;
+                $bs = 6 - $date;
             }elseif ($date >= 6 or $date == 0 or $date == 1){
                 $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Tuesday")); // 下个星期二
-                $bs = 3;
+                if ($date == 6) $bs = 3;
+                if ($date == 0) $bs = 2;
+                if ($date == 1) $bs = 1;
             }
         }
-
         $hanging_price = round($product['hanging_price'] * $product['rise']/100, 2); //  溢价
         $anticipate = round($product['hanging_price'] * $product['deduct']/100, 2); // 扣除
-        $give = round($product['hanging_price'] * $product['give']/100);// 赠送趣豆
+        $give = round($product['hanging_price'] * $product['give']/100, 2);// 赠送趣豆
 
         $data['price'] = $product['hanging_price'];
-        $data['hanging_price'] = (int)$product['hanging_price'] + ($hanging_price * $bs);
-        $data['anticipate'] = $anticipate*2;
-        $data['give'] = $give;
+        $data['hanging_price'] = $product['hanging_price'] + ($hanging_price * $bs);
+        $data['anticipate'] = round($anticipate*$bs,2);
+        $data['give'] = round($give*$bs,2);
 
 
         return $data;

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

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