hrjy 2 éve
szülő
commit
cd6e4f200f

+ 25 - 23
app/admin/controller/auction/Auction.php

@@ -92,7 +92,7 @@ class Auction extends AuthController
         $f[] = Form::input('sort', '排序', '0');
         $f[] = Form::input('sort', '排序', '0')->col(12);
         $f[] = Form::input('goods_time', '放货时间(分钟)', '0')->col(12);
-        $f[] =  Form::checkbox('site', '开场日期', [1,3,5])->options([
+        $f[] =  Form::checkbox('site', '开场日期')->options([
             ['value' => 1, 'label' => '周一'],
             ['value' => 2, 'label' => '周二'],
             ['value' => 3, 'label' => '周三'],
@@ -165,19 +165,20 @@ class Auction extends AuthController
         ]);
 
         $data['site'] = implode($data['site'], ',');
-        if ($data['site'] == '1,3,5'  or  $data['site'] == '2,4,6') {
-            if (!$validate->check($data)) {
-                return Json::fail($validate->getError());
-            }
-            $res = $mode->save($data);
-            if ($res){
-                return Json::success('添加成功!');
-            }else{
-                return Json::fail('添加失败');
-            }
+        if (!$validate->check($data)) {
+            return Json::fail($validate->getError());
+        }
+        $res = $mode->save($data);
+        if ($res){
+            return Json::success('添加成功!');
         }else{
-            return Json::fail('请选择正确的日期,1,3,5 或者 2,4,6');
+            return Json::fail('添加失败');
         }
+//        if ($data['site'] == '1,3,5'  or  $data['site'] == '2,4,6') {
+//
+//        }else{
+//            return Json::fail('请选择正确的日期,1,3,5 或者 2,4,6');
+//        }
 
 
     }
@@ -320,20 +321,21 @@ class Auction extends AuthController
             'goods_time.gt' => '放货时间大于0',
         ]);
         $data['site'] = implode($data['site'], ',');
-        if ($data['site'] == '1,3,5'  or  $data['site'] == '2,4,6') {
-            if (!$validate->check($data)) {
-                return Json::fail($validate->getError());
-            }
+        if (!$validate->check($data)) {
+            return Json::fail($validate->getError());
+        }
 
-            $res = \app\admin\model\auction\Auction::update($data);
-            if ($res){
-                return Json::success('修改成功!');
-            }else{
-                return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
-            }
+        $res = \app\admin\model\auction\Auction::update($data);
+        if ($res){
+            return Json::success('修改成功!');
         }else{
-            return Json::fail('请选择正确的日期,1,3,5 或者 2,4,6');
+            return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
         }
+//        if ($data['site'] == '1,3,5'  or  $data['site'] == '2,4,6') {
+//
+//        }else{
+//            return Json::fail('请选择正确的日期,1,3,5 或者 2,4,6');
+//        }
 
 
 

+ 16 - 0
app/admin/controller/auction/AuctionOrder.php

@@ -293,4 +293,20 @@ class AuctionOrder extends AuthController
 
     }
 
+    public function thaw($id)
+    {
+        if (!$id) return Json::fail('没有数据');
+        $data = model::find($id);// 订单数据
+        if ($data['appeal'] != 1) return Json::fail('订单未冻结');
+
+        $res = \app\models\auction\AuctionProduct::where('id', $data['product_id'])->update(['frozen' => 0]);
+        $data['appeal'] = 0;
+
+        if ($res && $data->save()){
+            return Json::successful('解冻成功!');
+        }else{
+            return Json::successful('解冻失败!');
+        }
+    }
+
 }

+ 21 - 0
app/admin/view/auction/auction_order/index.php

@@ -219,6 +219,11 @@
 
                     </script>
                     <script type="text/html" id="act">
+                        {{#  if(d.appeal  ==  1){ }}
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='jd' id="">
+                            解冻
+                        </button>
+                        {{#  } }}
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='qd' id="">
                             通过
                         </button>
@@ -296,6 +301,22 @@
                     });
                 },code)
                 break;
+            case 'jd':
+                var url=layList.U({c:'auction.auction_order',a:'thaw',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;

+ 34 - 21
app/api/controller/auction/AuctionProductController.php

@@ -427,35 +427,48 @@ class AuctionProductController
         $details = $productModel->find($data['id']);
         if (!$details)  return app('json')->fail('商品不存在');
         if ($details['uid'] != $request->uid()) return app('json')->fail('当前商品不属于你');
+        if ($details['is_show'] != 1) return app('json')->fail('商品未挂售');
         $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']);
+        $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;
-            }
+        if ($date == 0) $date = 7;//星期天
+
+        $count = count($time);
+
+        $week = [
+            1 => 'Monday', // 星期一
+            2 => 'Tuesday', // 星期二
+            3 => 'Wednesday', // 星期三
+            4 => 'Thursday', // 星期四
+            5 => 'Friday', // 星期五
+            6 => 'Saturday', // 星期六
+            7 => 'Sunday', //星期天
+        ];
 
-        }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;
+        $bs = 0;
+        if ($count <= 1){
+            $toweek = $week[$time[0]];
+            $bs = (strtotime("next ".$toweek) - strtotime('today'))/86400;
+        }else{
+            $node = 0;
+            foreach ($time as $item)
+            {
+                $node ++;
+                if ($node < $count){
+                    if ($date >= $item and $date < $time[$node]){
+                        $bs = $time[$node] - $date;
+                    }
+                }else{
+                    if ($date >= $item){
+                        $toweek = $week[$time[0]];
+                        $bs = (strtotime("next ".$toweek) - strtotime('today'))/86400;
+                    }
+                }
             }
         }
         $user = User::where('uid', $request->uid())->find();

+ 40 - 29
app/models/auction/AuctionProduct.php

@@ -114,49 +114,60 @@ class AuctionProduct extends BaseModel
         $auction = Auction::where('id', $product['auction_id'])->find();
         if (!$product) return app('json')->fail('商品不存在');
 
-        $data['time'] = explode(',', $auction['site']);
+        $time = explode(',', $auction['site']);
 
         $date = date('w', time()); // 今天星期几
+
+        if ($date == 0) $date = 7;//星期天
+
+        $count = count($time);
+
+        $week = [
+            1 => 'Monday', // 星期一
+            2 => 'Tuesday', // 星期二
+            3 => 'Wednesday', // 星期三
+            4 => 'Thursday', // 星期四
+            5 => 'Friday', // 星期五
+            6 => 'Saturday', // 星期六
+            7 => 'Sunday', //星期天
+        ];
+
         $data['gs_time'] = '';
         $bs = 0;
-        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 = 3 - $date;
-            }elseif ($date >= 3 and $date <= 4){
-                $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Friday")); // 星期五
-                $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")); // 下个星期一
-            }
-
-        }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 = 4 - $date;
-            }elseif ($date >= 4 and $date <= 5){
-                $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Saturday")); // 星期六
-                $bs = 6 - $date;
-            }elseif ($date >= 6 or $date == 0 or $date == 1){
-                $data['gs_time'] = date('Y-m-d H:i:s', strtotime("Tuesday")); // 下个星期二
-                if ($date == 6) $bs = 3;
-                if ($date == 0) $bs = 2;
-                if ($date == 1) $bs = 1;
+        if ($count <= 1){
+            $toweek = $week[$time[0]];
+            $bs = (strtotime("next ".$toweek) - strtotime('today'))/86400;
+            $data['gs_time'] = date('Y-m-d H:i:s', strtotime("next ".$toweek));
+        }else{
+            $node = 0;
+            foreach ($time as $item)
+            {
+                $node ++;
+                if ($node < $count){
+                    if ($date >= $item and $date < $time[$node]){
+                        $bs = $time[$node] - $date;
+                        $data['gs_time'] = date('Y-m-d H:i:s', strtotime($week[$time[$node]]));
+                    }
+                }else{
+                    if ($date >= $item){
+                        $toweek = $week[$time[0]];
+                        $bs = (strtotime("next ".$toweek) - strtotime('today'))/86400;
+                        $data['gs_time'] = date('Y-m-d H:i:s', strtotime("next ".$toweek));
+                    }
+                }
             }
         }
+
         $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, 2);// 赠送趣豆
+        $give = $product['hanging_price'] * $product['give']/100;// 赠送趣豆
+
 
         $data['price'] = $product['hanging_price'];
         $data['hanging_price'] = ($product['hanging_price'] + ($hanging_price * $bs));
         $data['anticipate'] = round($anticipate*$bs,2);
         $data['give'] = round($give*$bs,2);
 
-
         return $data;
     }