From 7d96e1f5345571e0df1011f9590c21bf2ffab201 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Mon, 15 Jul 2024 10:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=B7=BB=E5=8A=A0=E6=88=91?= =?UTF-8?q?=E7=9A=84=E8=BF=94=E8=A1=A5=E5=92=8C=E6=88=91=E7=9A=84=E6=8E=A8?= =?UTF-8?q?=E5=B9=BF=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/decoration/MenuDecorateLogic.php | 37 ++++-- app/admin/logic/finance/WithdrawLogic.php | 3 +- .../view/decoration/menu_decorate/lists.html | 108 ++++++++++++---- app/admin/view/finance/user/withdrawal.html | 45 ++++++- app/api/logic/BillionsLogic.php | 117 ++++++++++-------- 5 files changed, 221 insertions(+), 89 deletions(-) diff --git a/app/admin/logic/decoration/MenuDecorateLogic.php b/app/admin/logic/decoration/MenuDecorateLogic.php index 7f281de0..a66e8dc4 100644 --- a/app/admin/logic/decoration/MenuDecorateLogic.php +++ b/app/admin/logic/decoration/MenuDecorateLogic.php @@ -37,8 +37,8 @@ class MenuDecorateLogic extends Logic { $where[] = ['decorate_type','=',$get['type']]; $lists = Db::name('menu_decorate') - ->where($where) - ->paginate(['list_rows'=>$get['limit'],'page'=>$get['page']]); + ->where($where) + ->paginate(['list_rows'=>$get['limit'],'page'=>$get['page']]); $list = $lists->items(); $count = $lists->total(); @@ -126,8 +126,8 @@ class MenuDecorateLogic extends Logic { */ public static function getMenuDecorate($id){ $info = Db::name('menu_decorate') - ->where(['del'=>0,'id'=>$id]) - ->find(); + ->where(['del'=>0,'id'=>$id]) + ->find(); $info['image'] = empty($info['image']) ? '' : UrlServer::getFileUrl($info['image']); return $info; @@ -154,6 +154,12 @@ class MenuDecorateLogic extends Logic { }else{ ConfigServer::set('decoration_center','background_image',UrlServer::setFileUrl($post['background_image'] ?? '')); + ConfigServer::set('decoration_center','my_refund_image',UrlServer::setFileUrl($post['my_refund_image'] ?? '')); + ConfigServer::set('decoration_center','my_refund_name',$post['my_refund_name']); + ConfigServer::set('decoration_center','show_my_refund',$post['show_my_refund']); + ConfigServer::set('decoration_center','my_promotion_image',UrlServer::setFileUrl($post['my_promotion_image'] ?? '')); + ConfigServer::set('decoration_center','my_promotion_name',$post['my_promotion_name']); + ConfigServer::set('decoration_center','show_my_promotion',$post['show_my_promotion']); } return true; @@ -178,9 +184,24 @@ class MenuDecorateLogic extends Logic { ]; $data['background_image'] && $data['background_image'] = UrlServer::getFileUrl($data['background_image']); }else{ - $background_image = ConfigServer::get('decoration_center','background_image',''); - $background_image && $background_image = UrlServer::getFileUrl($background_image); - $data['background_image'] = $background_image; + $background_image = ConfigServer::get('decoration_center','background_image',''); + $background_image && $background_image = UrlServer::getFileUrl($background_image); + + //我的返补 + $my_refund_image = ConfigServer::get('decoration_center','my_refund_image',''); + $my_refund_image && $my_refund_image = UrlServer::getFileUrl($my_refund_image); + $data['my_refund_name'] = ConfigServer::get('decoration_center','my_refund_name',''); + $data['show_my_refund'] = ConfigServer::get('decoration_center','show_my_refund',''); + + //分销推广 + $my_promotion_image = ConfigServer::get('decoration_center','my_promotion_image',''); + $my_promotion_image && $my_promotion_image = UrlServer::getFileUrl($my_promotion_image); + $data['my_promotion_name'] = ConfigServer::get('decoration_center','my_promotion_name',''); + $data['show_my_promotion'] = ConfigServer::get('decoration_center','show_my_promotion',''); + + $data['background_image'] = $background_image; + $data['my_refund_image'] = $my_refund_image; + $data['my_promotion_image'] = $my_promotion_image; } return $data; @@ -295,7 +316,7 @@ class MenuDecorateLogic extends Logic { $hideCount = Db::name('dev_navigation') ->where(['del' => 0, 'status' => 1]) ->count(); - + if ($hideCount <= 2) { return '最少保留两个导航菜单'; } diff --git a/app/admin/logic/finance/WithdrawLogic.php b/app/admin/logic/finance/WithdrawLogic.php index 53d07289..e3330831 100644 --- a/app/admin/logic/finance/WithdrawLogic.php +++ b/app/admin/logic/finance/WithdrawLogic.php @@ -234,9 +234,10 @@ class WithdrawLogic extends Logic $model = new WithdrawApply(); $successWithdraw = $model->where(['status' => WithdrawEnum::STATUS_SUCCESS])->sum('money'); $handleWithdraw = $model->where(['status' => WithdrawEnum::STATUS_ING])->sum('money'); + $countWaitWithdraw = $model->where(['status' => WithdrawEnum::STATUS_WAIT])->count(); $totalEarnings = (new User())->where(['del' => 0])->sum('earnings'); - return ['successWithdraw' => $successWithdraw, 'handleWithdraw' => $handleWithdraw, 'totalEarnings' => $totalEarnings]; + return ['successWithdraw' => $successWithdraw, 'handleWithdraw' => $handleWithdraw, 'totalEarnings' => $totalEarnings, 'countWaitWithdraw' => $countWaitWithdraw]; } /** diff --git a/app/admin/view/decoration/menu_decorate/lists.html b/app/admin/view/decoration/menu_decorate/lists.html index 880446d6..22d04f1d 100644 --- a/app/admin/view/decoration/menu_decorate/lists.html +++ b/app/admin/view/decoration/menu_decorate/lists.html @@ -122,40 +122,81 @@ {else /} -
- -
- {if $other_set.background_image} -
- img - -
x
-
- - {else} - - {/if} +
+ +
+ {if $other_set.background_image} +
+ img + +
x
+ + {else} + + {/if}
-
- 页面顶部背景图,建议尺寸:宽400px*高400px。jpg,jpeg,png格式 -
-
-
- +
+
+ +
+ {if $other_set.my_refund_image} +
+ img + +
x
+
+ + {else} + + {/if} +
+ +
+
+ +
- - {/if} - +
+ +
+ {if $other_set.my_promotion_image} +
+ img + +
x
+
+ + {else} + + {/if} +
+ +
+
+ + +
+
+
+
+
+ +
+
+ {/if}
-
+
+ diff --git a/app/api/logic/BillionsLogic.php b/app/api/logic/BillionsLogic.php index f8363d79..1efb80e4 100644 --- a/app/api/logic/BillionsLogic.php +++ b/app/api/logic/BillionsLogic.php @@ -44,15 +44,13 @@ class BillionsLogic extends Logic $where[] = ['b.state', '=', 0]; } - // $list = Billions::alias('b')->where($where) - // ->leftjoin('order o', 'o.id = b.order_id') - // ->leftjoin('goods g', 'g.id = b.goods_id') - // ->leftjoin('shop s', 's.id = b.shop_id') - // ->field('b.*, o.order_sn, s.name') - // ->page($page,$size)->select(); - - $list = Billions::alias('b')->where($where) - ->page($page,$size)->select(); + if ($state == 1) { + $list = Billions::alias('b')->where($where)->order('billions_id', 'desc') + ->page($page,$size)->select(); + } else { + $list = Billions::alias('b')->where($where) + ->page($page,$size)->select(); + } foreach ($list as &$v) { if ($v['type'] == 1) { @@ -67,12 +65,18 @@ class BillionsLogic extends Logic $count = Billions::alias('b')->where($where)->count(); - // 消费订单笔数 - $historyOrder = Billions::where('user_id', $user_id)->count(); - // 商家最高补贴 $highSubsidy = Billions::where('user_id', $user_id)->sum('order_price', false); + // 已完成订单笔数 + $doneOrder = Billions::where([ + ['user_id', '=', $user_id], + ['state', '>', 0] + ])->count(); + + // 正在排队的数量 + $queuesNumber = Billions::where(['user_id' => $user_id, 'state' => 0])->count(); + // 已返补到的金额 $getSubsidy = Billions::where(array( ['user_id', '=', $user_id], @@ -87,9 +91,10 @@ class BillionsLogic extends Logic 'page_size' => $size, 'count' => $count, 'more' => $more, - 'historyOrder' => $historyOrder, + 'doneOrder' => $doneOrder, 'highSubsidy' => $highSubsidy, - 'getSubsidy' => $getSubsidy + 'getSubsidy' => $getSubsidy, + 'queuesNumber' => $queuesNumber ]; return $data; } @@ -295,7 +300,7 @@ class BillionsLogic extends Logic $user_subsidy = 2; // 自我补贴 $all_user_subsidy = 20; //全用户获取的比例 - $user_start_num = 5; // 补贴前几位数量 + $user_start_num = 1; // 补贴前几位数量 $user_start_subsidy = 30; //补贴前几位比例 全用户比例中扣除 $user_end_subsidy = 70; //补贴剩余部分比例 $user_first_leader = 30; // 推广者排队补贴 @@ -314,13 +319,13 @@ class BillionsLogic extends Logic $data['order_id'] = $id; $data['dtime'] = date("Y-m-d H:i:s"); $data['type'] = 3; // 类型是充值 - $data['subsidy_price'] = round($money * $user_subsidy / 100,6); + $data['subsidy_price'] = round($money * $user_subsidy / 100,8); $res = Db::name("user_billions")->save($data); - $billions_msg = Db::name("user_billions")->where("state",0)->select()->toArray(); + $subsidy = $money * $all_user_subsidy / 100; if($is_d != null){ - $ufl = round($subsidy*$user_first_leader/100,6); - $subsidy_ufl = round($subsidy - $ufl,6); + $ufl = round($subsidy*$user_first_leader/100,8); + $subsidy_ufl = round($subsidy - $ufl,8); $first_billions_msg = Db::name("user_billions")->where("user_id",$user['first_leader'])->where("state",0)->select()->toArray(); // var_dump($first_billions_msg);die; if(count($first_billions_msg) > 0){ @@ -375,9 +380,9 @@ class BillionsLogic extends Logic return -3; } // 剩余金额 - $ufl = round($ufl+$v['subsidy_price']-$v['order_price'],6); + $ufl = round($ufl+$v['subsidy_price']-$v['order_price'],8); }else{ - $subsidy_price_sum = round($v['subsidy_price']+$ufl,6); + $subsidy_price_sum = round($v['subsidy_price']+$ufl,8); Db::name("user_billions")->where("billions_id",$v['billions_id'])->update(['subsidy_price'=>$subsidy_price_sum]); // Db::name("user_billions")->where("billions_id",$v['billions_id'])->inc("subsidy_price",$ufl)->update(); $ufl = 0; @@ -385,17 +390,18 @@ class BillionsLogic extends Logic } } - $subsidy = round($subsidy_ufl + $ufl,6); + $subsidy = round($subsidy_ufl + $ufl,8); } } // $first_msg = Db::name("user_billions")->where("user_id",$user['first_leader'])->where("state",0)->select()->toArray(); + $billions_msg = Db::name("user_billions")->where("state",0)->select()->toArray(); $count = count($billions_msg); $arr = $arr1 = array(); // 数量超出前几位补贴用户 if($count > $user_start_num) { $start_subsidy = $subsidy * $user_start_subsidy / 100; - $average = round($start_subsidy / $user_start_num, 6); - $last = round($start_subsidy - $average * ($user_start_num - 1), 6); + $average = round($start_subsidy / $user_start_num, 8); + $last = round($start_subsidy - $average * ($user_start_num - 1), 8); for ($i = 0; $i < $user_start_num; $i++) { if ($i + 1 == $user_start_num) { $arr[$i] = $last; @@ -408,9 +414,9 @@ class BillionsLogic extends Logic // var_dump($count-$user_start_num); // 剩余人数补贴 - $end_average = round(($subsidy - $start_subsidy)/ ($count-$user_start_num), 6); + $end_average = round(($subsidy - $start_subsidy)/ ($count-$user_start_num), 8); // var_dump($end_average); - $end_last = round($subsidy - $start_subsidy - $end_average * ($count-$user_start_num - 1), 6); + $end_last = round($subsidy - $start_subsidy - $end_average * ($count-$user_start_num - 1), 8); // var_dump($end_last); for ($y = 0; $y < $count-$user_start_num; $y++) { if ($y + 1 == $count-$user_start_num) { @@ -422,8 +428,8 @@ class BillionsLogic extends Logic }else{ $user_start_num = $count; // 数量不超出前几位补贴用户,按全部金额计算 - $average = round($subsidy/$count, 6); - $last = round($subsidy - $average * ($count - 1), 6); + $average = round($subsidy/$count, 8); + $last = round($subsidy - $average * ($count - 1), 8); for ($i = 0; $i < $count; $i++) { if ($i + 1 == $count) { $arr[$i] = $last; @@ -496,15 +502,15 @@ class BillionsLogic extends Logic // 剩余数量 $residue_count = $user_start_num - $k - 1; // 剩余金额 - $residue_price = round($arr[$k]+$v['subsidy_price']-$v['order_price'],6); + $residue_price = round($arr[$k]+$v['subsidy_price']-$v['order_price'],8); foreach($arr as $k1=>$v1){ if($k1 > $k){ $residue_price+=$arr[$k1]; } } - $average = round($residue_price/$residue_count,6); - $last = round($residue_price - $average*($residue_count-1),6); + $average = round($residue_price/$residue_count,8); + $last = round($residue_price - $average*($residue_count-1),8); foreach($arr as $k1=>$v1){ if($k1+1 == $user_start_num){ $arr[$k1] = $last; @@ -516,14 +522,14 @@ class BillionsLogic extends Logic } }else{ - $subp = round($v['subsidy_price']+$arr[$k],6); - $billion_arr.=" when ".$v['billions_id']." then '".$subp."'"; - $billion_arr_id.=$v['billions_id'].","; + // $subp = round($v['subsidy_price']+$arr[$k],6); + // $billion_arr.=" when ".$v['billions_id']." then '".$subp."'"; + // $billion_arr_id.=$v['billions_id'].","; // $dataSet[] = [ // 'billions_id' => $v['billions_id'], // 假设每个模型数据都有一个ID字段 // 'subsidy_price' => round($v['subsidy_price']+$arr[$k],6) // 其他字段数据 // ]; - // Db::name("user_billions")->where("billions_id", $v['billions_id'])->inc("subsidy_price", $arr[$k])->update(); + Db::name("user_billions")->where("billions_id", $v['billions_id'])->inc("subsidy_price", $arr[$k])->update(); } }else{ if($v['order_price'] <= $arr1[$k - $user_start_num] + $v['subsidy_price']){ @@ -581,14 +587,14 @@ class BillionsLogic extends Logic // 剩余数量 $residue_count = $count-$user_start_num - $k+$user_start_num - 1; // 剩余金额 - $residue_price = round($arr1[$k-$user_start_num]+$v['subsidy_price']-$v['order_price'],6); + $residue_price = round($arr1[$k-$user_start_num]+$v['subsidy_price']-$v['order_price'],8); foreach($arr1 as $k1=>$v1){ if($k1 > $k - $user_start_num){ $residue_price+=$arr1[$k1]; } } - $average = round($residue_price/$residue_count,6); - $last = round($residue_price - $average*($residue_count-1),6); + $average = round($residue_price/$residue_count,8); + $last = round($residue_price - $average*($residue_count-1),8); foreach($arr1 as $k1=>$v1){ if($k1+1 == $count-$user_start_num){ $arr1[$k1] = $last; @@ -599,33 +605,34 @@ class BillionsLogic extends Logic } } }else{ - $subp = round($v['subsidy_price']+$arr1[$k-$user_start_num],6); - $billion_arr.=" when ".$v['billions_id']." then '".$subp."'"; - $billion_arr_id.=$v['billions_id'].","; + // $subp = round($v['subsidy_price']+$arr1[$k-$user_start_num],6); + // $billion_arr.=" when ".$v['billions_id']." then '".$subp."'"; + // $billion_arr_id.=$v['billions_id'].","; // $dataSet[] = [ // 'billions_id' => $v['billions_id'], // 假设每个模型数据都有一个ID字段 // 'subsidy_price' => round($v['subsidy_price']+$arr1[$k-$user_start_num],6) // 其他字段数据 // ]; - // Db::name("user_billions")->where("billions_id",$v['billions_id'])->inc("subsidy_price",$arr1[$k-$user_start_num])->update(); + Db::name("user_billions")->where("billions_id",$v['billions_id'])->inc("subsidy_price",$arr1[$k-$user_start_num])->update(); } } } - $billion_arr_id = explode(",",$billion_arr_id); - array_pop($billion_arr_id); - // print_r("
");
-        // var_dump($billion_arr_id);die;
-        $billion_arr_id = implode(",",$billion_arr_id);
-        $sql = "UPDATE `ls_user_billions` 
-        SET subsidy_price = CASE billions_id
-            $billion_arr
-        END
-        WHERE billions_id IN ($billion_arr_id)";
-        $query = Db::query($sql);
+        // $billion_arr_id = explode(",",$billion_arr_id);
+        // array_pop($billion_arr_id);
+        // // print_r("
");
+        // // var_dump($billion_arr);
+        // // var_dump($billion_arr_id);die;
+        // $billion_arr_id = implode(",",$billion_arr_id);
+        // $sql = "UPDATE `ls_user_billions`
+        // SET subsidy_price = CASE billions_id
+        //     $billion_arr
+        // END
+        // WHERE billions_id IN ($billion_arr_id)";
+        // $query = Db::query($sql);
 
         //  Db::name("billions")->updateAll($dataSet,"billions_id");
         if($is_d!=null){
             if($user['first_leader']>0){
-                $first_leader_percent = round($money * $first_leader / 100, 6);
+                $first_leader_percent = round($money * $first_leader / 100, 8);
 //                    Order::where('id', $order['id'])
 //                        ->inc('distribution_money',$first_leader_percent)->update();
                 UserDistribution::where('user_id', $user['first_leader'])
@@ -669,7 +676,7 @@ class BillionsLogic extends Logic
             }
             // 3%对公司
             if($user['divide_role_user_id'] > 0&&$state>0 ){
-                $divide_percent = round($money * $other_leader / 100, 6);
+                $divide_percent = round($money * $other_leader / 100, 8);
 //                Order::where('id', $order['id'])
 //                    ->inc('distribution_money',$divide_percent)->update();
 //                $shopDistribution_msg =  UserShopDistribution::where('shop_id', $value['shop_id'])