From fadd2daefba8a2ca5edb85f9f0d5441f29aef667 Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Thu, 17 Oct 2024 12:44:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8F=90=E7=8E=B0=E5=B1=8F=E8=94=BD=E8=A1=A8?= =?UTF-8?q?=E6=83=85=E5=9B=BE=E7=89=87=E7=AD=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/LocalStoreTypeRatio.php | 119 ++++++++++++++++++ app/api/logic/OrderLogic.php | 79 ++++++++++++ app/common/logic/PayNotifyLogic.php | 8 ++ app/common/model/AccountLog.php | 12 ++ 4 files changed, 218 insertions(+) create mode 100644 app/admin/controller/shop/LocalStoreTypeRatio.php diff --git a/app/admin/controller/shop/LocalStoreTypeRatio.php b/app/admin/controller/shop/LocalStoreTypeRatio.php new file mode 100644 index 00000000..25fe8b6e --- /dev/null +++ b/app/admin/controller/shop/LocalStoreTypeRatio.php @@ -0,0 +1,119 @@ +request->isAjax()) { + $category_tree = CategoryLogic::lists(); + // reqData方式渲染 + $treeTableData = [ + 'code' => 0, + 'msg' => '分类列表', + 'data' => json_encode($category_tree) + ]; + return json($treeTableData); + } + return view(); + } + + /** + * 添加 + */ + public function add() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $post['del'] = 0; + try { + validate(CategoryValidate::class)->scene('add')->check($post); + } catch (ValidateException $e) { + return JsonServer::error($e->getError()); + } + $res = CategoryLogic::add($post); + if ($res) { + return JsonServer::success('分类添加成功'); + } else { + return JsonServer::error('分类添加失败'); + } + } + + $category_list = CategoryLogic::categoryTwoTree(); + return view('add', ['category_list' => $category_list]); + } + + /** + * 删除 + */ + public function del() + { + $post = $this->request->post(); + try { + validate(CategoryValidate::class)->scene('del')->check($post); + } catch (ValidateException $e) { + return JsonServer::error($e->getError()); + } + $res = CategoryLogic::del($post); + if ($res) { + return JsonServer::success('删除分类成功'); + } else { + return JsonServer::error('删除分类失败'); + } + } + + + /** + * 编辑 + */ + public function edit() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $post['del'] = 0; + try { + validate(CategoryValidate::class)->scene('edit')->check($post); + } catch (ValidateException $e) { + return JsonServer::error($e->getError()); + } + $res = CategoryLogic::edit($post); + if ($res) { + return JsonServer::success('编辑分类成功'); + } else { + return JsonServer::error('编辑分类失败'); + } + } + + $id = $this->request->get('id'); + $detail = CategoryLogic::getCategory($id); + $category_list = CategoryLogic::categoryTwoTree(); + return view('edit', [ + 'detail' => $detail, + 'category_list' => $category_list + ]); + } + + /** + * 修改显示状态 + */ + public function switchStatus() + { + $post = $this->request->post(); + $res = CategoryLogic::switchStatus($post); + if ($res) { + return JsonServer::success('修改成功'); + } else { + return JsonServer::error('修改失败'); + } + } +} \ No newline at end of file diff --git a/app/api/logic/OrderLogic.php b/app/api/logic/OrderLogic.php index cf44041c..d9644592 100755 --- a/app/api/logic/OrderLogic.php +++ b/app/api/logic/OrderLogic.php @@ -15,6 +15,7 @@ use app\common\enum\ShopEnum; use app\common\enum\TeamEnum; use app\common\logic\OrderLogLogic; use app\common\logic\OrderRefundLogic; +use app\common\logic\PayNotifyLogic; use app\common\model\AccountLog; use app\common\model\Cart; use app\common\model\distribution\Distribution; @@ -1943,7 +1944,85 @@ class OrderLogic extends Logic } $subsidy = round($subsidy_ufl + $ufl, 8); } + $paynot = new PayNotifyLogic(); + $type = "pay_goods"; + $order2['order_amount'] = $value['total_pay_price']; + $order2['order_sn'] = $order['order_sn']; + $order2['id'] = $order['id']; + $paynot->atcl($order2, $store_subsidy, $type, $user, $first_leader, $other_leader); + // 店铺推广收益 + $shop_user_msg = Shop::where('id', $value['shop_id'])->find(); + if ($shop_user_msg['reference_user_id'] == 0) { + $shop_user_msg['reference_user_id'] = $order['user_id']; + } + $shop_u = Distribution::where('user_id', $shop_user_msg['reference_user_id'])->where('is_distribution', 1)->find(); + if ($shop_u != null) { + $shop_percent = round($value['total_pay_price'] * $store_subsidy / 100, 8); + Order::where('id', $order['id']) + ->inc('distribution_money', $shop_percent)->update(); + $shopDistribution_msg = UserShopDistribution::where('shop_id', $value['shop_id']) + ->find(); + if ($shopDistribution_msg == null) { + UserShopDistribution::create([ + 'shop_id' => $value['shop_id'], + 'order_num' => 1, + 'order_amount' => $shop_percent, + 'create_time' => time(), + 'update_time' => time() + ]); + } else { + UserShopDistribution::where('shop_id', $value['shop_id']) + ->inc('order_amount', $shop_percent)->update(); + UserShopDistribution::where('shop_id', $value['shop_id']) + ->inc('order_num')->update(); + } + User::where('id', $shop_user_msg['reference_user_id']) + ->inc('earnings', $shop_percent)->update(); + $earnings_buy = AccountLog::where('user_id', $shop_user_msg['reference_user_id'])->order("create_time desc")->limit(1)->value('left_amount'); + $sn = createSn('account_log', 'log_sn', '', 4); + AccountLog::create([ + 'log_sn' => $sn, + 'user_id' => $shop_user_msg['reference_user_id'], + 'source_type' => AccountLog::billions_inc_earnings, + 'source_id' => $order['id'], + 'source_sn' => $order['order_sn'], + 'change_amount' => $shop_percent, + 'left_amount' => $earnings_buy + $shop_percent, + 'change_type' => 1, + 'remark' => '百亿返补佣金增加' + ]); + DistributionOrderGoods::create([ + 'sn' => $sn, + 'user_id' => $shop_user_msg['reference_user_id'], + 'ratio' => $store_subsidy, + 'order_id' => $order['id'], + 'order_goods_id' => $value['id'], + 'goods_num' => $value['goods_num'], + 'money' => $shop_percent, + 'status' => 2, + 'create_time' => time(), + 'shop_id' => $value['shop_id'], + 'settlement_time' => time() + ]); + } } + $billions_count = Db::name("user_billions")->where("state", 0)->count(); + $data_surplus['billions_id'] = $res; + $data_surplus['subsidy_all_price'] = $subsidy; + $data_surplus['user_start_num'] = $user_start_num; + $data_surplus['user_start_subsidy'] = $user_start_subsidy; + $data_surplus['user_start_price'] = round($subsidy * $user_start_subsidy / 100, 8); + $data_surplus['user_start_avg_price'] = round($data_surplus['user_start_price'] / $user_start_num, 8); + $data_surplus['residue_price'] = $subsidy - $data_surplus['user_start_price']; + if ($billions_count > $user_start_num) { + $data_surplus['user_price'] = round(($subsidy - $data_surplus['user_start_price']) / ($billions_count - $user_start_num), 8); + } + $data_surplus['dtime'] = date("Y-m-d H:i:s"); + $rest = Db::name("user_billions_surplus")->save($data_surplus); + + } + return $rest;die; + { // $first_msg = Db::name("user_billions")->where("user_id",$user['first_leader'])->where("state",0)->select()->toArray(); $count = count($billions_msg); $arr = $arr1 = array(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 947de087..40a58f02 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -1020,6 +1020,14 @@ class PayNotifyLogic $source_type1 = AccountLog::electrodeless_billions_rechange_inc_earnings; $remark2 = "无极公司返补充值佣金"; $source_type2 = AccountLog::company_electrodeless_billions_rechange_inc_earnings; + } + if($type == "pay_goods"){ + $remark = "消费佣金"; + $source_type = AccountLog::pay_money; + $remark1 = "无极消费佣金"; + $source_type1 = AccountLog::electrodeless_pay_money; + $remark2 = "无极公司消费佣金"; + $source_type2 = AccountLog::company_electrodeless_pay_money; } if($user['first_leader']>0){ $first_leader_percent = round($order['order_amount'] * $first_leader / 100, 8); diff --git a/app/common/model/AccountLog.php b/app/common/model/AccountLog.php index 40a9bcb3..fb883ef3 100755 --- a/app/common/model/AccountLog.php +++ b/app/common/model/AccountLog.php @@ -67,6 +67,10 @@ class AccountLog extends Models const billions_rechange_inc_earnings = 416;//返补充值佣金 const electrodeless_billions_rechange_inc_earnings = 417;//无极返补充值佣金 const company_electrodeless_billions_rechange_inc_earnings = 418;//无极公司返补充值佣金 + const pay_money = 419;//消费佣金 + const electrodeless_pay_money = 420;//无极消费佣金 + const company_electrodeless_pay_money = 421;//无极公司消费佣金 + const shop_pay_money = 422;//店铺消费佣金 const money_change = [ //余额变动类型 self::admin_add_money,self::admin_reduce_money,self::recharge_money,self::balance_pay_order,self::cancel_order_refund,self::after_sale_refund , self::withdraw_to_balance,self::user_transfer_inc_balance, self::user_transfer_dec_balance, self::integral_order_dec_balance, self::integral_order_inc_balance @@ -103,6 +107,10 @@ class AccountLog extends Models self::billions_rechange_inc_earnings, //返补充值佣金 self::electrodeless_billions_rechange_inc_earnings, //无极返补充值佣金 self::company_electrodeless_billions_rechange_inc_earnings, //无极公司返补充值佣金 + self::pay_money, //消费佣金 + self::electrodeless_pay_money, //无极消费佣金 + self::company_electrodeless_pay_money, //无极公司消费佣金 + self::shop_pay_money //店铺消费佣金 ]; public static function getAcccountDesc($from = true){ @@ -139,6 +147,10 @@ class AccountLog extends Models self::electrodeless_billions_rechange_inc_earnings => '无极返补充值佣金', self::company_electrodeless_billions_rechange_inc_earnings => '无极公司返补充值佣金', self::withdraw_to_balance => '佣金提现', + self::pay_money => '消费佣金', + self::electrodeless_pay_money => '无极消费佣金', + self::company_electrodeless_pay_money => '无极公司消费佣金', + self::shop_pay_money =>'店铺消费佣金', self::withdraw_dec_earnings => '提现扣减佣金', self::withdraw_back_earnings => '拒绝提现返还佣金', self::distribution_inc_earnings => '订单结算获得佣金',