From cb550401baaee3b78b5cd8b17f50a5d01146f638 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Thu, 23 Dec 2021 16:30:22 +0800 Subject: [PATCH] settter --- app/controller/api/Coupon.php | 3 ++- app/controller/manager/Business.php | 4 +++- app/controller/manager/Consumer.php | 6 ++++-- app/repository/BillRepository.php | 12 ++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index 688754c..ab1cc86 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -453,7 +453,7 @@ class Coupon extends Base Deduction::create($deductionData); //4. 商家扣钱 - $business->save(["balance"=>Db::raw("balance - {$deductionMoney}")]); + $business->save(["balance"=>Db::raw("balance - " . $deductionMoney)]); //5. 渠道商加钱 if(isset($business->agency) && $business->agency){ @@ -506,6 +506,7 @@ class Coupon extends Base Db::rollback(); return $this->json(5001, "Repository服务器错误"); }catch (\Exception $e){ + echo $e->getMessage(); Db::rollback(); return $this->json(5002, "服务器错误"); } diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index 2b704d9..95bb43a 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -39,7 +39,9 @@ class Business extends Base $page = $this->request->param('page/d', 1); $size = $this->request->param('size/d', 30); - $whereMap = [["a.state", "=", BusinessModel::state_on]]; + $whereMap = [ + ["a.state", "=", BusinessModel::state_on] + ]; $orders = ['a.id' => 'desc']; if (!empty($keyword)) { $whereMap[] = ['b.nick_name|a.business_name|a.business_subtitle', 'like', "%$keyword%"]; diff --git a/app/controller/manager/Consumer.php b/app/controller/manager/Consumer.php index 5390443..bed8e79 100644 --- a/app/controller/manager/Consumer.php +++ b/app/controller/manager/Consumer.php @@ -30,7 +30,9 @@ class Consumer extends Base $page = $this->request->param('page/d', 1); $size = $this->request->param('size/d', 30); - $whereMap = [["type", "=", Account::type_consumer]]; + $whereMap = [ + ["type", "<>", Account::type_business] + ]; $orders = ['id' => 'desc']; if (!empty($keyword)) { $whereMap[] = ['nick_name', 'like', "%$keyword%"]; @@ -132,7 +134,7 @@ class Consumer extends Base $size = $this->request->param('size/d', 30); $whereMap = [ - ["type", "=", Account::type_consumer], + //["type", "=", Account::type_consumer], ["blank_total", ">", 0], ]; $orders = ['id' => 'desc']; diff --git a/app/repository/BillRepository.php b/app/repository/BillRepository.php index f8c1d74..070f2e9 100644 --- a/app/repository/BillRepository.php +++ b/app/repository/BillRepository.php @@ -44,7 +44,7 @@ class BillRepository extends Repository ->join("account c", "a.user_code = c.user_code") ->join("coupon_main d", "a.coupon_main_id = d.id") ->when(!empty($keyword), function ($q) use ($keyword) { - $q->where("b.business_name|c.nick_name|d.name", "like", "%$keyword%"); + $q->where("b.business_name|c.nick_name|d.name", "like", "%{$keyword}%"); }) ->when(!empty($businessCode), function ($q) use ($businessCode) { $q->where("b.code", "=", $businessCode); @@ -93,10 +93,10 @@ class BillRepository extends Repository $q->where("business_code", "=", $businessCode); }) ->when(!empty($startTime), function ($q) use ($startTime) { - $q->whereTime("create_time", ">=", $startTime); + $q->whereTime("create_time", ">=", $startTime . "00:00:00"); }) ->when(!empty($endTime), function ($q) use ($endTime) { - $q->whereTime("create_time", "<=", $endTime); + $q->whereTime("create_time", "<=", $endTime . "23:59:59"); }); ; $failData["total"] = $rep->count(); @@ -249,7 +249,7 @@ class BillRepository extends Repository ->join("account c", "a.user_code = c.user_code") ->join("coupon_main d", "a.coupon_main_id = d.id") ->when(!empty($keyword), function ($q) use ($keyword) { - $q->whereTime("c.business_name|e.business_name", "like", "%" . $keyword . "%"); + $q->where("b.business_name|c.nick_name|d.name", "like", "%{$keyword}%"); }) ->when(!empty($start_time), function ($q) use ($start_time) { $q->whereTime("a.create_time", ">=", $start_time); @@ -277,10 +277,10 @@ class BillRepository extends Repository ->join("coupon_main b", "a.coupon_main_id = b.id") ->where("a.business_code",$businessCode) ->when(!empty($startTime), function ($q) use ($startTime) { - $q->whereTime("a.create_time", ">=", $startTime); + $q->whereTime("a.create_time", ">=", $startTime. "00:00:00"); }) ->when(!empty($endTime), function ($q) use ($endTime) { - $q->whereTime("a.create_time", "<=", $endTime); + $q->whereTime("a.create_time", "<=", $endTime. "23:59:59"); }) ->sum("b.deduction_money"); }