master
wangxinglong 2021-12-23 16:30:22 +08:00
parent c9c145607f
commit cb550401ba
4 changed files with 15 additions and 10 deletions

View File

@ -453,7 +453,7 @@ class Coupon extends Base
Deduction::create($deductionData); Deduction::create($deductionData);
//4. 商家扣钱 //4. 商家扣钱
$business->save(["balance"=>Db::raw("balance - {$deductionMoney}")]); $business->save(["balance"=>Db::raw("balance - " . $deductionMoney)]);
//5. 渠道商加钱 //5. 渠道商加钱
if(isset($business->agency) && $business->agency){ if(isset($business->agency) && $business->agency){
@ -506,6 +506,7 @@ class Coupon extends Base
Db::rollback(); Db::rollback();
return $this->json(5001, "Repository服务器错误"); return $this->json(5001, "Repository服务器错误");
}catch (\Exception $e){ }catch (\Exception $e){
echo $e->getMessage();
Db::rollback(); Db::rollback();
return $this->json(5002, "服务器错误"); return $this->json(5002, "服务器错误");
} }

View File

@ -39,7 +39,9 @@ class Business extends Base
$page = $this->request->param('page/d', 1); $page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30); $size = $this->request->param('size/d', 30);
$whereMap = [["a.state", "=", BusinessModel::state_on]]; $whereMap = [
["a.state", "=", BusinessModel::state_on]
];
$orders = ['a.id' => 'desc']; $orders = ['a.id' => 'desc'];
if (!empty($keyword)) { if (!empty($keyword)) {
$whereMap[] = ['b.nick_name|a.business_name|a.business_subtitle', 'like', "%$keyword%"]; $whereMap[] = ['b.nick_name|a.business_name|a.business_subtitle', 'like', "%$keyword%"];

View File

@ -30,7 +30,9 @@ class Consumer extends Base
$page = $this->request->param('page/d', 1); $page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30); $size = $this->request->param('size/d', 30);
$whereMap = [["type", "=", Account::type_consumer]]; $whereMap = [
["type", "<>", Account::type_business]
];
$orders = ['id' => 'desc']; $orders = ['id' => 'desc'];
if (!empty($keyword)) { if (!empty($keyword)) {
$whereMap[] = ['nick_name', 'like', "%$keyword%"]; $whereMap[] = ['nick_name', 'like', "%$keyword%"];
@ -132,7 +134,7 @@ class Consumer extends Base
$size = $this->request->param('size/d', 30); $size = $this->request->param('size/d', 30);
$whereMap = [ $whereMap = [
["type", "=", Account::type_consumer], //["type", "=", Account::type_consumer],
["blank_total", ">", 0], ["blank_total", ">", 0],
]; ];
$orders = ['id' => 'desc']; $orders = ['id' => 'desc'];

View File

@ -44,7 +44,7 @@ class BillRepository extends Repository
->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")
->when(!empty($keyword), function ($q) use ($keyword) { ->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) { ->when(!empty($businessCode), function ($q) use ($businessCode) {
$q->where("b.code", "=", $businessCode); $q->where("b.code", "=", $businessCode);
@ -93,10 +93,10 @@ class BillRepository extends Repository
$q->where("business_code", "=", $businessCode); $q->where("business_code", "=", $businessCode);
}) })
->when(!empty($startTime), function ($q) use ($startTime) { ->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) { ->when(!empty($endTime), function ($q) use ($endTime) {
$q->whereTime("create_time", "<=", $endTime); $q->whereTime("create_time", "<=", $endTime . "23:59:59");
}); });
; ;
$failData["total"] = $rep->count(); $failData["total"] = $rep->count();
@ -249,7 +249,7 @@ class BillRepository extends Repository
->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")
->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->where("b.business_name|c.nick_name|d.name", "like", "%{$keyword}%");
}) })
->when(!empty($start_time), function ($q) use ($start_time) { ->when(!empty($start_time), function ($q) use ($start_time) {
$q->whereTime("a.create_time", ">=", $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") ->join("coupon_main b", "a.coupon_main_id = b.id")
->where("a.business_code",$businessCode) ->where("a.business_code",$businessCode)
->when(!empty($startTime), function ($q) use ($startTime) { ->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) { ->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"); ->sum("b.deduction_money");
} }