master
wangxinglong 2021-12-22 16:46:51 +08:00
parent 3a808becd5
commit 0d1631cbb9
1 changed files with 4 additions and 2 deletions

View File

@ -225,8 +225,9 @@ class BillRepository extends Repository
*/ */
public function getAgencyMoneySum($field, $keyword = null, $start_time = null, $end_time = null) public function getAgencyMoneySum($field, $keyword = null, $start_time = null, $end_time = null)
{ {
return CouponBill::alias("a") return CouponBill::alias("a")
->join("business b", "a.business_code = b.code", "left") ->join("business b", "a.business_code = b.code")
->join("business e", "a.agency_code = e.code", "left") ->join("business e", "a.agency_code = e.code", "left")
->join("account c", "a.user_code = c.user_code") ->join("account c", "a.user_code = c.user_code")
->join("coupon_main d", "a.coupon_main_id = d.id") ->join("coupon_main d", "a.coupon_main_id = d.id")
@ -240,7 +241,7 @@ class BillRepository extends Repository
$q->whereTime("a.create_time", "<=", $end_time); $q->whereTime("a.create_time", "<=", $end_time);
}) })
->when(MemberModel::is_agency(session("auth")['roles']), function ($q) { ->when(MemberModel::is_agency(session("auth")['roles']), function ($q) {
$q->where("a.agency_code", "=", session("auth")['business_code']); $q->where("b.agency_code", "=", session("auth")['business_code']);
}) })
->sum("a." . $field); ->sum("a." . $field);
} }
@ -281,6 +282,7 @@ class BillRepository extends Repository
->join("business c", "a.business_code = c.code") ->join("business c", "a.business_code = c.code")
->join("member d", "a.member_id = d.id", "left") ->join("member d", "a.member_id = d.id", "left")
->join("business e", "c.agency_code = e.code", "left") ->join("business e", "c.agency_code = e.code", "left")
->where("a.state",Recharge::state_on)
->when(!empty($keyword), function ($q) use ($keyword) { ->when(!empty($keyword), function ($q) use ($keyword) {
$q->whereTime("c.business_name|e.business_name", "like", "%" . $keyword . "%"); $q->whereTime("c.business_name|e.business_name", "like", "%" . $keyword . "%");
}) })