This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use enum\order\ProductOrder as ProductOrderEnum;
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductOrder extends Model
|
||||
@@ -28,4 +29,45 @@ class ProductOrder extends Model
|
||||
{
|
||||
return $this->field($fields)->where($where)->where($where_str)->order($order)->limit($limit)->fetchAll();
|
||||
}
|
||||
|
||||
//获取上月消费
|
||||
public function getLastMonthCost($agent_id =[])
|
||||
{
|
||||
$st = date('Y-m-d', strtotime(date('Y-m-01') . " - 1 month"));
|
||||
$et = date('Y-m-d', strtotime(date('Y-m-01')));
|
||||
return $this->field("sum(PaymentAmount) as pay_money,agent_id")
|
||||
->where("UpdateTime>'$st' and UpdateTime<'$et' ")->where(['agent_id'=>['in',$agent_id]])
|
||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||
->fetchAll();
|
||||
}
|
||||
//获取本月消费
|
||||
public function getMonthCost($agent_id =[])
|
||||
{
|
||||
$st = date('Y-m-d', strtotime(date('Y-m-01')));
|
||||
$et = date('Y-m-d', time());
|
||||
return $this->field("sum(PaymentAmount) as pay_money,agent_id")
|
||||
->where("UpdateTime>'$st' and UpdateTime<'$et' ")->where(['agent_id'=>['in',$agent_id]])
|
||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||
->fetchAll();
|
||||
}
|
||||
//获取上月退款
|
||||
public function getLastMonthRefund($agent_id =[])
|
||||
{
|
||||
$st = date('Y-m-d', strtotime(date('Y-m-01') . " - 1 month"));
|
||||
$et = date('Y-m-d', strtotime(date('Y-m-01')));
|
||||
return $this->field("sum(PaymentAmount) as pay_money,agent_id")
|
||||
->where("UpdateTime>'$st' and UpdateTime<'$et' ")->where(['agent_id'=>['in',$agent_id]])
|
||||
->where(['OrderState' => ['in', ProductOrderEnum::$Refunds]])
|
||||
->fetchAll();
|
||||
}
|
||||
//获取本月退款
|
||||
public function getMonthRefund($agent_id =[])
|
||||
{
|
||||
$st = date('Y-m-d', strtotime(date('Y-m-01')));
|
||||
$et = date('Y-m-d', time());
|
||||
return $this->field("sum(PaymentAmount) as pay_money,agent_id")
|
||||
->where("UpdateTime>'$st' and UpdateTime<'$et' ")->where(['agent_id'=>['in',$agent_id]])
|
||||
->where(['OrderState' => ['in', ProductOrderEnum::$Refunds]])
|
||||
->fetchAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user