This commit is contained in:
@@ -10,6 +10,7 @@ use app\agent\model\ProductPackage as PoductPackageModel;
|
|||||||
use app\agent\model\AgentPrice as AgentPriceModel;
|
use app\agent\model\AgentPrice as AgentPriceModel;
|
||||||
use app\agent\model\AgentScore as AgentScoreModel;
|
use app\agent\model\AgentScore as AgentScoreModel;
|
||||||
use app\agent\model\ProductPriceDiscount as ProductPriceDiscountModel;
|
use app\agent\model\ProductPriceDiscount as ProductPriceDiscountModel;
|
||||||
|
use app\agent\model\ProductOrder as ProductOrderModel;
|
||||||
|
|
||||||
class Agent extends Controller
|
class Agent extends Controller
|
||||||
{
|
{
|
||||||
@@ -26,6 +27,8 @@ class Agent extends Controller
|
|||||||
}
|
}
|
||||||
$agent_user_model = new AgentUser;
|
$agent_user_model = new AgentUser;
|
||||||
$user_model = new UserModel;
|
$user_model = new UserModel;
|
||||||
|
$order_model = new ProductOrderModel;
|
||||||
|
|
||||||
$user_list = $agent_user_model->getListPage($where, '*', 'id desc', "$page,50");
|
$user_list = $agent_user_model->getListPage($where, '*', 'id desc', "$page,50");
|
||||||
|
|
||||||
//获取代理商下的用户数
|
//获取代理商下的用户数
|
||||||
@@ -36,10 +39,36 @@ class Agent extends Controller
|
|||||||
$agent_ids[] = $info['id'];
|
$agent_ids[] = $info['id'];
|
||||||
$list[$info['id']] = $info;
|
$list[$info['id']] = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$last_month_cost_money = $order_model->getLastMonthCost($agent_ids);
|
||||||
|
$last_month_refund_money = $order_model->getLastMonthRefund($agent_ids);
|
||||||
|
$month_cost_money = $order_model->getMonthCost($agent_ids);
|
||||||
|
$month_refund_money = $order_model->getMonthRefund($agent_ids);
|
||||||
|
|
||||||
|
$last_cost_list = $last_refund_list = $cost_list = $refund_list = [];
|
||||||
|
|
||||||
|
foreach ($last_month_cost_money as $info){
|
||||||
|
$last_cost_list[$info['agent_id']] = $info['pay_money'];
|
||||||
|
}
|
||||||
|
foreach ($last_month_refund_money as $info){
|
||||||
|
$last_refund_list[$info['agent_id']] = $info['pay_money'];
|
||||||
|
}
|
||||||
|
foreach ($month_cost_money as $info){
|
||||||
|
$cost_list[$info['agent_id']] = $info['pay_money'];
|
||||||
|
}
|
||||||
|
foreach ($month_refund_money as $info){
|
||||||
|
$refund_list[$info['agent_id']] = $info['pay_money'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$agent_user_num = $user_model->getAgentUser(['agent_id'=>['in',$agent_ids]]);
|
$agent_user_num = $user_model->getAgentUser(['agent_id'=>['in',$agent_ids]]);
|
||||||
foreach ($agent_user_num as $info){
|
foreach ($agent_user_num as $info){
|
||||||
$list[$info['agent_id']]['user_num'] = $info['num'];
|
$list[$info['agent_id']]['user_num'] = $info['num'];
|
||||||
|
$list[$info['agent_id']]['last_cost'] = round($last_cost_list[$info['agent_id']] - $last_refund_list[$info['agent_id']],2);
|
||||||
|
$list[$info['agent_id']]['cost'] = round($cost_list[$info['agent_id']] - $refund_list[$info['agent_id']],2);
|
||||||
}
|
}
|
||||||
|
// dump($list);die;
|
||||||
$list = array_merge($list);
|
$list = array_merge($list);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace app\agent\model;
|
namespace app\agent\model;
|
||||||
|
|
||||||
|
use enum\order\ProductOrder as ProductOrderEnum;
|
||||||
use fastphp\base\Model;
|
use fastphp\base\Model;
|
||||||
|
|
||||||
class ProductOrder extends 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();
|
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