From 26c9f6ecdd43f54c477f8f74e4e7353b0aaf8f5b Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Mon, 26 Aug 2024 16:23:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9C=AC=E5=9C=B0=E7=94=9F=E6=B4=BB=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E6=94=AF=E4=BB=98=E7=9B=B8=E5=85=B3=E6=94=B9?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/User.php | 2 +- app/api/logic/LocalStoreLogic.php | 3 ++- app/api/logic/PayLogic.php | 12 +++++---- app/common/logic/PayNotifyLogic.php | 41 ++++++++++++++++++++++++++++- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/app/api/controller/User.php b/app/api/controller/User.php index a9986421..8fd13e5c 100755 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -271,7 +271,7 @@ class User extends Api // and b.store_state = 1 group by a.first_leader"; // $count = Db::query($sql); // $count = $count[0]['cont']; - $count = $local_count = Db::name("local_store") + $count = $local_count = Db::name("local_store") ->alias("a") ->join("user b","a.user_id = b.id","left") ->where("b.first_leader",$user_id) diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index a73e18f9..de9f4a9b 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -23,6 +23,7 @@ class LocalStoreLogic extends Logic $count = $model->where('is_delete',0) ->where($s1) + ->where("store_state",1) ->where("shopLogo is not null") ->count(); // $lists = $model->where('is_delete',0) @@ -35,7 +36,7 @@ class LocalStoreLogic extends Logic // $sql = "SELECT *, ST_Distance_Sphere(POINT(".$data['longitude'].",".$data['latitude']."),POINT(longitude, latitude)) AS distance // FROM ls_local_store where is_delete = 0 $s // ORDER BY distance limit $page,$size"; - $sql = "SELECT * FROM ls_local_store where is_delete = 0 and shopLogo is not null $s ORDER BY lstore_id asc limit ".$page.",".$size; + $sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s ORDER BY lstore_id asc limit ".$page.",".$size; // var_dump($sql); $lists = Db::query($sql); foreach($lists as $key=>$value){ diff --git a/app/api/logic/PayLogic.php b/app/api/logic/PayLogic.php index 049fe250..14bbfaac 100755 --- a/app/api/logic/PayLogic.php +++ b/app/api/logic/PayLogic.php @@ -682,7 +682,7 @@ class PayLogic extends Logic $dt['lstore_id'] = $post['lid']; $dt['payment_type'] = $company['bankType']; $dt['total_amount'] = $post['money']; - $dt['account_name'] = $company['store_nickname']; + $dt['account_name'] = $company['shopName']; $dt['bank_name'] = $company['bankName']; $dt['bank_card'] = $company['bankCard']; $dt['large_number'] = $company['largeNumber']; @@ -690,6 +690,7 @@ class PayLogic extends Logic $dt['create_time'] = date("Y-m-d H:i:s"); $dt['user_id'] = $user_id; $dt['order_no'] = $out_trade_no; + $dt['pay_shop_type'] = 1; $r = Db::name("local_store_order")->save($dt); // 基本户 5% $dt1['lstore_id'] = $post['lid']; @@ -722,7 +723,8 @@ class PayLogic extends Logic $dt3['payment_type'] = 1; $dt3['account_name'] = "东龙汇"; $dt3['bank_name'] = "中国工商银行"; - $dt3['bank_card'] = "1204064419000115357"; +// $dt3['bank_card'] = "1204064419000115357"; + $dt3['bank_card'] = "1204068809100138961"; $dt3['large_number'] = "102335006448"; $dt3['separate_account'] = round($post['money']*0.1,2); $dt3['create_time'] = date("Y-m-d H:i:s"); @@ -784,13 +786,12 @@ class PayLogic extends Logic 'remark' => '本地商家支付佣金增加' ]); } - } $company = Db::name("local_store")->where("lstore_id",$post['lid'])->where("is_delete",0)->find(); $dt['lstore_id'] = $post['lid']; $dt['payment_type'] = $company['bankType']; - $dt['account_name'] = $company['store_nickname']; + $dt['account_name'] = $company['shopName']; $dt['bank_name'] = $company['bankName']; $dt['bank_card'] = $company['bankCard']; $dt['total_amount'] = $post['money']; @@ -844,7 +845,8 @@ class PayLogic extends Logic $dt3['payment_type'] = 1; $dt3['account_name'] = "东龙汇"; $dt3['bank_name'] = "中国工商银行"; - $dt3['bank_card'] = "1204064419000115357"; +// $dt3['bank_card'] = "1204064419000115357"; + $dt3['bank_card'] = "1204068809100138961"; $dt3['large_number'] = "102335006448"; $dt3['separate_account'] = round($post['money']*0.1,2); $dt3['create_time'] = date("Y-m-d H:i:s"); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index d57b6ec4..cad7d80e 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -235,6 +235,7 @@ class PayNotifyLogic if($result != null){ $d['pay_time'] = date("Y-m-d H:i:s"); $d['pay_status'] = 1; + $order['lstore_id']= $result['local_id']; $r = Db::name("local_pay")->where("id",$result['id'])->update($d); } $order['id']= 0; @@ -705,9 +706,47 @@ class PayNotifyLogic // END // WHERE billions_id IN ($billion_arr_id)"; // $query = Db::query($sql); + // 本地生活微信支付 推广商家收益 + if(isset($order['lstore_id'])){ + $local_msg = Db::name("local_store") + ->where("lstore_id",$order['lstore_id']) + ->where("is_delete",0) + ->where("store_state",1) + ->find(); + if($local_msg != null){ + $local_first_leader = Db::name("user") + ->where("id",$local_msg['user_id']) + ->where("del",0) + ->where("disable",0) + ->find(); + if($local_first_leader != null){ + if($local_first_leader['first_leader']!=0){ + $is_local_d = Distribution::where('user_id', $local_first_leader['first_leader'] )->where('is_distribution', 1 )->find(); + if($is_local_d!=null){ + $local_earnings = round($order['order_amount']*$store_subsidy/100,2); + User::where('id', $local_first_leader['first_leader']) + ->inc('earnings', $local_earnings)->update(); + $local_earnings_buy = AccountLog::where('user_id', $local_first_leader['first_leader'])->order("create_time desc")->limit(1)->value('left_amount'); + $sn = createSn('account_log', 'log_sn', '', 4); + AccountLog::create([ + 'log_sn' => $sn, + 'user_id' => $local_first_leader['first_leader'], + 'source_type' => AccountLog::local_inc_earnings, //todo 改为充值类型 + 'source_id' => 0, //todo 改为充值订单主键 + 'source_sn' => 0, // todo 改为充值订单编号 + 'change_amount' => $local_earnings, + 'left_amount' => $local_earnings_buy + $local_earnings, + 'change_type' => 1, + 'remark' => '本地商家支付佣金增加' + ]); + } + } + } + } + } if($is_d!=null){ if($user['first_leader']>0){ - $first_leader_percent = round($order['order_amount'] * $first_leader / 100, 8); + $first_leader_percent = round($order['order_amount'] * $first_leader / 100, 2); // Order::where('id', $order['id']) // ->inc('distribution_money',$first_leader_percent)->update(); UserDistribution::where('user_id', $user['first_leader'])