hrjy 3 years ago
parent
commit
83a8461051

+ 2 - 1
app/admin/controller/finance/UserExtract.php

@@ -150,7 +150,8 @@ class UserExtract extends AuthController
         $res = UserExtractModel::changeSuccess($id);
         if ($res) {
             $user['now_money'] -= $charge;
-            UserBill::income('收取提现手续费', $user['uid'], 'now_money', 'sub_now_money', $charge, $user['spread_uid'], $user['now_money'], '收取提现'.$charge.'手续费');
+            $user->save();
+            UserBill::expend('收取提现手续费', $user['uid'], 'now_money', 'sub_now_money', $charge, $user['spread_uid'], $user['now_money'], '收取提现'.$charge.'手续费');
             UserExtractModel::commitTrans();
             return JsonService::successful('操作成功!');
         } else {

+ 1 - 0
app/admin/controller/order/StoreOrder.php

@@ -419,6 +419,7 @@ class StoreOrder extends AuthController
             $f = [];
             $f[] = Form::select('delivery_name', '快递公司')->setOptions(function () {
                 $list = Express::where('is_show', 1)->order('sort DESC')->column('name', 'id');
+                halt($list);
                 $menus = [];
                 foreach ($list as $k => $v) {
                     $menus[] = ['value' => $v, 'label' => $v];

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

@@ -193,9 +193,9 @@ class AuctionProductController
         $hanging_price = round($product['hanging_price'] + $product['hanging_price'] * 0.06, 2); // 第二天溢价
         if ($user['aid_val'] < $aid_val) return app('json')->fail('挂售需要广告值不足');
 
-        $order = AuctionOrder::where([['uid', '=', $request->uid()], ['product_id', '=', $product['id']]])->find();
+        $auction = Auction::where([['id', '=', $product['auction_id']]])->find();
 
-        $bk = AuctionBooking::where([['uid', '=', $request->uid()], ['auction_id', '=', $order['auction_id']], ['frequency', '=', $order['frequency']], ['status', '=', 1]])->find();
+        $bk = AuctionBooking::where([['uid', '=', $request->uid()], ['auction_id', '=', $auction['id']], ['frequency', '=', $auction['frequency']], ['status', '=', 1]])->find();
         if ($bk){
             $bk['status'] = 0; //解冻广告值
             $user['aid_val'] += $bk['advert']; // 退回用户广告值
@@ -205,6 +205,7 @@ class AuctionProductController
 
         $product['hanging_price'] = $hanging_price;
         $product['is_show'] = 1;
+        $product['gs_time'] = time();
         $user['aid_val'] -= $aid_val;
         try {
             User::beginTrans();

+ 5 - 5
app/api/controller/user/UserController.php

@@ -282,9 +282,9 @@ class UserController
     public function change($data){
         //取出类型1的值
         $res=User::where('uid',$data['uid'])->find();
-        $type1=intval($res[$data['type1']]-$data['amount']);
-        $type2=intval($res[$data['type2']]+$data['amount']);
-        $type3=intval($res['aid_val']+$data['amount']);
+        $type1=floatval($res[$data['type1']]-$data['amount']);
+        $type2=floatval($res[$data['type2']]+$data['amount']);
+        $type3=floatval($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, '购物积分转换提货券');
@@ -714,8 +714,8 @@ class UserController
         try {
             $user->save();
             $userInfo->save();
-            UserBill::expend('给用户'.$data['phone'].'转账'.$data['money'], $userInfo['uid'], 'now_money', 'sub_now_money', $data['money'], $userInfo['uid'], $userInfo['now_money'], '给用户'.$data['phone'].'转账'.$data['money']);
-            UserBill::income('用户'.$userInfo['account'].'给你转账'.$data['money'], $user['uid'], 'now_money', 'add_now_money', $data['money'], $user['uid'], $user['now_money'], '用户'.$userInfo['account'].'给你转账'.$data['money']);
+            UserBill::expend('转账'.$data['money'], $userInfo['uid'], 'now_money', 'sub_now_money', $data['money'], $userInfo['uid'], $userInfo['now_money'], '给用户'.$data['phone'].'转账'.$data['money']);
+            UserBill::income('账'.$data['money'], $user['uid'], 'now_money', 'add_now_money', $data['money'], $user['uid'], $user['now_money'], '用户'.$userInfo['account'].'给你转账'.$data['money']);
             User::commitTrans();
             return app('json')->success('成功');
         } catch (\Exception $e) {

+ 23 - 29
app/models/auction/Auction.php

@@ -100,41 +100,35 @@ class Auction extends BaseModel
         $recovery = (int)SystemConfigService::get('recovery');
         if ($auction){
             foreach ($auction as $k => $v) {
-                if (strtotime($v['rend_time'])-300 < time()){
+                if (strtotime($v['rend_time'])-600 < time()){
                     //关闭场次五分钟前
-                    $orderCount = AuctionOrder::where('auction_id', '=', $v['id'])->where('status', '>',0)->where('price', '<', $recovery)->count();// 当前订单数量
+                    $orderCount = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->count();// 当前订单数量
                     $bok = AuctionBooking::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']]])->count();
                     $count = ceil($bok * ($v['dispatch']/100));
                     $orderId = AuctionOrder::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']], ['status', '>', 0]])->column('product_id');
-                    if ($orderCount < $count){
+                    if ($orderCount < $count){;
                         // 如果购买人数没有到放单人数
-                        for ($x=1 ; $x <= $count; $x++){
-                            $orderId = AuctionOrder::where([['auction_id', '=', $v['id']], ['frequency', '=', $v['frequency']], ['status', '>', 0]])->column('product_id');
-                            $product = AuctionProduct::where([['auction_id', '=', $v['id']],
-                                ['is_show', '=', 1],
-                                ['id', 'notIn', $orderId],
-                                ['uid', '<>', 1],
-                                ['hanging_price', '<', $recovery]]
-                            )->orderRaw('rand()')
-                                ->limit(1)
-                                ->find(); // 随机出来一个商品
-                            $orderData = [
-                                'uid' => 1,
-                                'collection_id' => $product['uid'],
-                                'order_id' => getNewOrderId(),
-                                'auction_id' => $v['id'],
-                                'product_id' => $product['id'],
-                                'name' => $product['name'],
-                                'image' => $product['image'],
-                                'price' => $product['hanging_price'],
-                                'actual_price' => $product['hanging_price'] - $product['price'],
-                                'create_time' => time(),
-                                'frequency' => $v['frequency']
-                            ];
-                            AuctionOrder::create($orderData);
-                            unset($orderData);// 清空数组
+                        $dayo = AuctionOrder::where('auction_id', '=', $v['id'])->where('frequency', '=', $v['frequency'])->where('status', '>',0)->where('price', '<', $recovery)->column('product_id');// 当前出售商品
+                        $product = AuctionProduct::where([['id', 'notIn', $dayo], ['uid', '>', 1], ['price', '<', $recovery], ['auction_id', '=', $v['id']]])->select();
+                        if ($product){
+                            foreach ($product as &$item){
+                                $orderData = [
+                                    'uid' => 1,
+                                    'collection_id' => $item['uid']? $item['uid']: 0,
+                                    'order_id' => getNewOrderId(),
+                                    'auction_id' => $v['id'],
+                                    'product_id' => $item['id'],
+                                    'name' => $item['name'],
+                                    'image' => $item['image'],
+                                    'price' => $item['hanging_price'],
+                                    'actual_price' => $item['hanging_price'] - $item['price'],
+                                    'create_time' => time(),
+                                    'frequency' => $v['frequency']
+                                ];
+                                AuctionOrder::create($orderData);
+                                unset($orderData);// 清空数组
+                            }
                         }
-
                     }
                     $auctionProduct = AuctionProduct::where([['auction_id', '=', $v['id']], ['is_show', '=', 1],['id', 'notIn', $orderId],['hanging_price', '>', $recovery]])->select();// 如果又商品成功回收价格
                     if ($auctionProduct){

+ 13 - 2
app/models/auction/AuctionOrder.php

@@ -166,10 +166,21 @@ class AuctionOrder extends BaseModel
                             $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){
-                                $userBok = AuctionBooking::where('uid', '=',$value['uid'])->where('deduct_advert', '>', 0)->count(); //预约未购买退回的次数
-                                $bf =  (0.1+($userBok/100) >= 0.2)? 0.2: 0.1+($userBok/100); // 0.1 * 退回次数
+                                $date = date("Y-m-d");
+                                $firstday = date('Y-m-01 00:00:00', strtotime($date));  //本月第一天
+                                $lastday = date('Y-m-d 23:59:59', strtotime("$firstday +1 month -1 day")); //本月最后一天
+                                $userBok = AuctionBooking::where('uid', '=',$value['uid'])->where('th', '=', 1)->whereBetweenTime('create_time', $firstday, $lastday)->count(); //预约未购买退回的次数
+                                if ($userBok >= 3){
+                                    $userBok++;
+                                    if ($userBok == 4) $bf = 0.1;
+                                    if ($userBok == 5) $bf = 0.2;
+                                    if ($userBok >= 6) $bf = 0.5;
+                                }else{
+                                    $bf = 0;
+                                }
                                 $find = AuctionBooking::find($value['id']);
                                 $find['status'] = 0;
+                                $find['th'] = 1;
                                 $find['deduct_advert'] = $value['advert']*$bf; // 扣除广告书
                                 $user = User::where('uid', $value['uid'])->find();
                                 $user['aid_val'] = $user['aid_val'] + ($value['advert'] - ($value['advert'] * $bf)); // 增加用户广告值

+ 17 - 9
app/models/user/User.php

@@ -509,6 +509,7 @@ class User extends BaseModel
         if (!count($userStair)) return [];
         if ($grade == 0) return self::getUserSpreadCountList(implode(',', $userStair), $orderBy, $keyword, $page, $limit);
         $userSecondary = self::where('spread_uid', 'in', implode(',', $userStair))->column('uid');
+        halt(self::getUserSpreadCountList(implode(',', $userSecondary), $orderBy, $keyword, $page, $limit));
         return self::getUserSpreadCountList(implode(',', $userSecondary), $orderBy, $keyword, $page, $limit);
     }
 
@@ -530,13 +531,13 @@ class User extends BaseModel
             ->where('o.is_del', 0)->where('o.is_system_del', 0)->alias('o')->fetchSql(true)->select();
         $model = $model->join("(" . $sql . ") p", 'u.uid = p.uid', 'LEFT');
         $model = $model->where('u.uid', 'IN', $uid);
-        $model = $model->field("u.uid,u.nickname,u.avatar,from_unixtime(u.add_time,'%Y/%m/%d') as time,u.spread_count as childCount,u.pay_count as orderCount,p.numberCount");
+        $model = $model->field("u.uid,u.nickname,u.phone,from_unixtime(u.add_time,'%Y/%m/%d') as time,u.spread_count as childCount,u.pay_count as orderCount,p.numberCount,u.account");
         if (strlen(trim($keyword))) $model = $model->where('u.nickname|u.phone', 'like', "%$keyword%");
         $model = $model->group('u.uid');
         $model = $model->order($orderBy);
         $model = $model->page($page, $limit);
         $list = $model->select();
-        if ($list) return $list->toArray();
+        if ($list) return $list;
         else return [];
     }
 
@@ -749,11 +750,13 @@ class User extends BaseModel
         foreach ($auction as $key => $value) {
             $auctionPush = AuctionPush::where('auction_id', '=',$value['id'])->where('add_time', '=', strtotime(date('Y-m-d',  time())))->find();
             if (!$auctionPush){
+                AuctionPush::beginTrans();
                 if (strtotime($value['rend_time'])+1800 <= time()){
                     //当前场次结束半个小时
                     $order = AuctionOrder::alias('a')
+                        ->field('a.*')
                         ->leftJoin('auction_product p', 'a.product_id = p.id')
-                        ->where([['a.auction_id', '=', $value['id']], ['a.status', '=', 2], ['p.is_show', '=', 1 ]])
+                        ->where([['a.auction_id', '=', $value['id']], ['a.status', '=', 2], ['p.is_show', '=', 1 ], ['frequency', '=', $value['frequency']]])
                         ->select();
                     if ($order){
                         foreach ($order as $k => $v) {
@@ -765,19 +768,24 @@ class User extends BaseModel
                                     $money =  round($v['price'] * 0.003, 2);
                                     $spread['sp_final'] += $money;
                                     $spread->save();
-                                    UserBill::income('奖励购物积分', $spread['uid'], 'sp_final', 'add_sp_final', $money, $user['uid'], $spread['sp_final'], '用户'.$user['nickname'].'购买成功,奖励购物积分');
+                                    UserBill::income('奖励购物积分', $spread['uid'], 'sp_final', 'add_sp_final', $money, $user['uid'], $spread['sp_final'], '用户'.$user['account'].'购买成功,奖励购物积分');
                                 }
-
                             }
                         }
                     }
-                    AuctionPush::create([
-                        'auction_id' => $value['id'],
-                        'add_time' => strtotime(date('Y-m-d',  time()))
-                    ]);
+                    try {
+                        AuctionPush::create([
+                            'auction_id' => $value['id'],
+                            'add_time' => strtotime(date('Y-m-d',  time()))
+                        ]);
+                        AuctionPush::commitTrans();
+                    } catch (\Exception $e) {
+                        AuctionPush::rollbackTrans();
+                    }
                 }
             }
         }
+
     }
 
     /**