代理商
This commit is contained in:
80
app/agent/controller/Account.php
Normal file
80
app/agent/controller/Account.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\User as UserModel;
|
||||
use app\agent\model\ProductAccount as ProductAccountModel;
|
||||
|
||||
class Account extends Controller
|
||||
{
|
||||
//账号列表
|
||||
public function getList ()
|
||||
{
|
||||
$get_data = $_GET;
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
$where['agent_id'] = $agent_id;
|
||||
|
||||
//处理筛选
|
||||
if($get_data['UserId'] != 0){
|
||||
$where['UserId'] = $get_data['UserId'];
|
||||
}
|
||||
if(!empty($get_data['ProductIds'])){
|
||||
$where['ProductId'] = $get_data['ProductIds'];
|
||||
}
|
||||
if(!empty($get_data['PackageNames'])){
|
||||
$where['PackageName'] = $get_data['PackageNames'];
|
||||
}
|
||||
if(!empty($get_data['accountTypes'])){
|
||||
$where['AccountType'] = $get_data['accountTypes'];
|
||||
}
|
||||
if (!empty($_GET['Btime'])){
|
||||
$date1 = date('Y-m-d', strtotime($_GET['Btime']));
|
||||
$date2 = date('Y-m-d', strtotime($_GET['Etime']));
|
||||
$where_str .= " EndTime>='" . $date1 . "' and EndTime<='" . $date2 . "' ";
|
||||
}
|
||||
if (!empty($_GET['Bktime'])){
|
||||
if (mb_strlen($where_str)>0){
|
||||
$where_str .= ' AND ';
|
||||
}
|
||||
$date1 = date('Y-m-d', strtotime($_GET['Bktime']));
|
||||
$date2 = date('Y-m-d', strtotime($_GET['Ektime']));
|
||||
$where_str .= " StartTime>='" . $date1 . "' and StartTime<='" . $date2 . "' ";
|
||||
}
|
||||
if (!empty($get_data['keyWord'])){
|
||||
$where['Account'] = ['like','%'.$get_data['keyWord'].'%'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$account_model = new ProductAccountModel;
|
||||
$list = $account_model->getAgentListPage($where,$where_str, '*', 'id desc', "$page,50");
|
||||
|
||||
foreach ($list as &$info){
|
||||
$endtime = strtotime($info['EndTime']);
|
||||
if($endtime <= time()){
|
||||
$info['RestTime'] = '已过期';
|
||||
} else {
|
||||
$day = ceil(($endtime - time())/86400);
|
||||
$info['RestTime'] = $day.'天';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
'TotalCount' => (int)$account_model->getCount($where)['count'],
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
235
app/agent/controller/Agent.php
Normal file
235
app/agent/controller/Agent.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\User as UserModel;
|
||||
use app\agent\model\Product as PoductModel;
|
||||
use app\agent\model\ProductPackage as PoductPackageModel;
|
||||
use app\agent\model\AgentPrice as AgentPriceModel;
|
||||
use app\agent\model\AgentScore as AgentScoreModel;
|
||||
|
||||
class Agent extends Controller
|
||||
{
|
||||
//代理商列表
|
||||
public function getList ()
|
||||
{
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
if(!empty($_GET['keyWord'])){
|
||||
$where['username'] = $_GET['keyWord'];
|
||||
}
|
||||
$agent_user_model = new AgentUser;
|
||||
$user_model = new UserModel;
|
||||
$user_list = $agent_user_model->getListPage($where, '*', 'id desc', "$page,50");
|
||||
|
||||
//获取代理商下的用户数
|
||||
$agent_ids = [];
|
||||
$list = [];
|
||||
foreach ($user_list as &$info){
|
||||
$info['password'] = '';
|
||||
$agent_ids[] = $info['id'];
|
||||
$list[$info['id']] = $info;
|
||||
}
|
||||
$agent_user_num = $user_model->getAgentUser(['agent_id'=>['in',$agent_ids]]);
|
||||
foreach ($agent_user_num as $info){
|
||||
$list[$info['agent_id']]['user_num'] = $info['num'];
|
||||
}
|
||||
$list = array_merge($list);
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
'TotalCount' => (int)$agent_user_model->getCount($where)['count'],
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//设置代理商最低价格价格表
|
||||
public function price()
|
||||
{
|
||||
$id = $_GET['userId'];
|
||||
$list = [];
|
||||
$product_model = new PoductModel;
|
||||
$package_model = new PoductPackageModel;
|
||||
$price_model = new AgentPriceModel;
|
||||
$product = $product_model->getList(['OnLine'=>1,'Id'=>['<>',11]], '*', 'Sort asc');
|
||||
$package = $package_model->getList([], '*', 'TenantId asc');
|
||||
$price = $price_model->getList(['agent_id'=>$id], '*');
|
||||
|
||||
//按照套餐整理价格
|
||||
$price_list = [];
|
||||
foreach($price as $info){
|
||||
$price_list[$info['package_id']] = $info;
|
||||
}
|
||||
|
||||
|
||||
//按照产品整理价格
|
||||
$package_list = [];
|
||||
foreach($package as $info){
|
||||
$package_list[$info['ProductId']][] = $info;
|
||||
}
|
||||
|
||||
//处理数据
|
||||
foreach ($product as $p_info){
|
||||
$temp = [];
|
||||
$temp['Product'] = $p_info;
|
||||
$package_temp = [];
|
||||
|
||||
//套餐分离
|
||||
foreach ($package_list[$p_info['Id']] as $pack_info){
|
||||
$pack_temp = [];
|
||||
$pack_temp['Package'] = $pack_info;
|
||||
//若没有价格 默认价格
|
||||
if(empty($price_list[$pack_info['Id']])){
|
||||
$price_list[$pack_info['Id']]['refund'] = $p_info['RefundDayPrice'];
|
||||
$price_list[$pack_info['Id']]['price'] = $pack_info['Price'];
|
||||
}
|
||||
$pack_temp['UserPrice'] = $price_list[$pack_info['Id']];
|
||||
$package_temp[] = $pack_temp;
|
||||
}
|
||||
$temp['PackageUserPrices'] = $package_temp;
|
||||
|
||||
$list[] = $temp;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//设置最低价
|
||||
public function setPrice()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$price_model = new AgentPriceModel;
|
||||
|
||||
$update_data = [
|
||||
'product_id' => $data['ProductId'],
|
||||
'package_id' => $data['PackageId'],
|
||||
'agent_id' => $data['UserId'],
|
||||
'price' => $data['UserPrice'],
|
||||
'refund' => $data['RefundDayPrice'],
|
||||
];
|
||||
|
||||
$where = [
|
||||
'package_id' => $data['PackageId'],
|
||||
'agent_id' => $data['UserId']
|
||||
];
|
||||
|
||||
$agent_price = $price_model->getOne($where);
|
||||
|
||||
if(empty($agent_price)){
|
||||
$price_model->add($update_data);
|
||||
} else {
|
||||
$price_model->updateOne($where,$update_data);
|
||||
}
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
|
||||
//是否启用修改后的价格
|
||||
public function setPriceStatus()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$price_model = new AgentPriceModel;
|
||||
$id = $data['id'];
|
||||
$update_data['status'] = $data['status'];
|
||||
|
||||
$where = ['id'=>$id];
|
||||
if($price_model->updateOne($where,$update_data)){
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
die;
|
||||
} else {
|
||||
$retuen_data = [
|
||||
'Code' => -10000,
|
||||
'Message' => '操作失败',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
//添加代理商
|
||||
public function addAgent()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$data['password'] = cToMd5($data['password']);
|
||||
$agent_user_model = new AgentUser;
|
||||
|
||||
$agent_user_model->add($data);
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '操作成功',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
die;
|
||||
}
|
||||
|
||||
//代理商充值扣款
|
||||
public function account()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$agent_user_model = new AgentUser;
|
||||
$score_model = new AgentScoreModel;
|
||||
|
||||
$update_data = [];
|
||||
$score = [];
|
||||
$id = $data['id'];
|
||||
|
||||
$agent = $agent_user_model->getOne(['id'=>$id]);
|
||||
if($data['opAmountType'] == 1){
|
||||
$update_data['account'] = $data['rest'] + $data['amount'];
|
||||
$score['agent_id'] = $id;
|
||||
$score['order_id'] = 0;
|
||||
$score['score_type'] = 3;
|
||||
$score['score_value'] = $data['amount'];
|
||||
$score['agent_name'] = $agent['username'];
|
||||
$score['op_user'] = $this->userinfo['LoginName'];
|
||||
$score['rest_amount1'] = $agent['account'];
|
||||
$score['rest_amount2'] = $update_data['account'];
|
||||
$score['remark'] = $data['attchInfo'];
|
||||
} else {
|
||||
$update_data['account'] = $data['rest'] - $data['amount'];
|
||||
$score['agent_id'] = $id;
|
||||
$score['order_id'] = 0;
|
||||
$score['score_type'] = 4;
|
||||
$score['score_value'] = $data['amount'];
|
||||
$score['agent_name'] = $agent['username'];
|
||||
$score['op_user'] = $this->userinfo['LoginName'];
|
||||
$score['rest_amount1'] = $agent['account'];
|
||||
$score['rest_amount2'] = $update_data['account'];
|
||||
$score['remark'] = $data['attchInfo'];
|
||||
}
|
||||
|
||||
|
||||
if($agent_user_model->updateOne(['id'=>$id],$update_data)){
|
||||
|
||||
$score_model->add($score);
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '操作成功',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class Index
|
||||
'OperaterID' => $userinfo['id'],
|
||||
'TenantId' => 1157,
|
||||
'iat' => time(),
|
||||
'exp' => time() + 60 * 60
|
||||
'exp' => time() + 180 * 60
|
||||
];
|
||||
|
||||
$token = $jwt::getToken($payload);
|
||||
|
||||
58
app/agent/controller/Order.php
Normal file
58
app/agent/controller/Order.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\User as UserModel;
|
||||
use app\agent\model\ProductOrder as ProductOrderModel;
|
||||
|
||||
class Order extends Controller
|
||||
{
|
||||
//账号列表
|
||||
public function getList ()
|
||||
{
|
||||
$get_data = $_GET;
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
$where['agent_id'] = $agent_id;
|
||||
|
||||
if(!empty($get_data['ProductIds'])){
|
||||
$where['ProductId'] = $get_data['ProductIds'];
|
||||
}
|
||||
if(!empty($get_data['PackageNames'])){
|
||||
$where['PackageName'] = $get_data['PackageNames'];
|
||||
}
|
||||
if(!empty($get_data['OrderTypes'])){
|
||||
$where['OrderType'] = $get_data['OrderTypes'];
|
||||
}
|
||||
if (!empty($_GET['Btime'])){
|
||||
$date1 = date('Y-m-d', strtotime($_GET['Btime']));
|
||||
$date2 = date('Y-m-d', strtotime($_GET['Etime']));
|
||||
$where_str .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
||||
}
|
||||
if (!empty($get_data['keyWord'])){
|
||||
$where['UserName'] = ['like','%'.$get_data['keyWord'].'%'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$order_model = new ProductOrderModel;
|
||||
$list = $order_model->getAgentListPage($where,$where_str, '*', 'id desc', "$page,50");
|
||||
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
'TotalCount' => (int)$order_model->getCount($where)['count'],
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
77
app/agent/controller/Score.php
Normal file
77
app/agent/controller/Score.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\User as UserModel;
|
||||
use app\agent\model\AgentScore as AgentScoreModel;
|
||||
|
||||
class Score extends Controller
|
||||
{
|
||||
//账号列表
|
||||
public function getList ()
|
||||
{
|
||||
$get_data = $_GET;
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
$where['agent_id'] = $agent_id;
|
||||
|
||||
if (!empty($_GET['Btime'])){
|
||||
$date1 = date('Y-m-d', strtotime($_GET['Btime']));
|
||||
$date2 = date('Y-m-d', strtotime($_GET['Etime']));
|
||||
$where_str .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$score_model = new AgentScoreModel;
|
||||
$list = $score_model->getAgentListPage($where,$where_str, '*', 'id desc', "$page,50");
|
||||
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
'TotalCount' => (int)$score_model->getCount($where)['count'],
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//账号列表
|
||||
public function getScoreList ()
|
||||
{
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$where = [];
|
||||
$where_str = '';
|
||||
|
||||
if (!empty($_GET['Btime'])){
|
||||
$date1 = date('Y-m-d', strtotime($_GET['Btime']));
|
||||
$date2 = date('Y-m-d', strtotime($_GET['Etime']));
|
||||
$where_str .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$score_model = new AgentScoreModel;
|
||||
$list = $score_model->getAgentListPage($where,$where_str, '*', 'id desc', "$page,50");
|
||||
|
||||
|
||||
$data = [
|
||||
'Code' => 10000,
|
||||
'Data' => $list,
|
||||
'Message' => '',
|
||||
'TotalCount' => (int)$score_model->getCount($where)['count'],
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace app\agent\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\agent\model\AgentUser;
|
||||
use app\agent\model\ProductUserPrice;
|
||||
use app\agent\model\AgentPrice as AgentPriceModel;
|
||||
use app\agent\model\User as UserModel;
|
||||
|
||||
class Userinfo extends Controller
|
||||
@@ -23,6 +25,57 @@ class Userinfo extends Controller
|
||||
echo json_encode($info);
|
||||
}
|
||||
|
||||
//代理商修改密码
|
||||
public function updatePass()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$agent_user_model = new AgentUser;
|
||||
$userinfo = $agent_user_model->getOne(['id'=>$this->userinfo['OperaterID']]);
|
||||
if($userinfo['password'] != cToMd5($data['old_pass'])){
|
||||
$info = [
|
||||
'Code' => -10000,
|
||||
'Message' => '旧密码错误',
|
||||
];
|
||||
echo json_encode($info);
|
||||
die;
|
||||
}
|
||||
$update = [
|
||||
'password' => cToMd5($data['new_pass'])
|
||||
];
|
||||
if($agent_user_model->updateOne(['id'=>$this->userinfo['OperaterID']],$update)){
|
||||
$info = [
|
||||
'Code' => 10000,
|
||||
'Message' => '更新成功',
|
||||
];
|
||||
echo json_encode($info);
|
||||
die;
|
||||
} else {
|
||||
$info = [
|
||||
'Code' => -10000,
|
||||
'Message' => '更新失败',
|
||||
];
|
||||
echo json_encode($info);
|
||||
}
|
||||
}
|
||||
|
||||
//验证是否是该代理的用户
|
||||
public function verify()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$user_id = $data['user_id'];
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
$user_model = new UserModel;
|
||||
$userinfo = $user_model->getOne(['Id'=>$user_id]);
|
||||
if($userinfo['agent_id'] != $agent_id){
|
||||
die;
|
||||
}
|
||||
$info = [
|
||||
'Code' => 20000,
|
||||
'Message' => '请正确操作',
|
||||
];
|
||||
echo json_encode($info);
|
||||
}
|
||||
|
||||
//代理商下的用户
|
||||
public function getList ()
|
||||
{
|
||||
@@ -56,4 +109,85 @@ class Userinfo extends Controller
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
//获取代理最低价
|
||||
public function getAgentPrice()
|
||||
{
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
$agent_price_model = new AgentPriceModel;
|
||||
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
|
||||
$where = [
|
||||
'agent_id' => $agent_id,
|
||||
'package_id' => $data['Id']
|
||||
];
|
||||
|
||||
$price = $agent_price_model->getOne($where);
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 30000,
|
||||
'Data' => $price,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
|
||||
//设置价格
|
||||
public function setPrice()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$price_model = new ProductUserPrice;
|
||||
$agent_price_model = new AgentPriceModel;
|
||||
|
||||
$agent_id = $this->userinfo['OperaterID'];
|
||||
|
||||
$where = [
|
||||
'agent_id' => $agent_id,
|
||||
'package_id' => $data['PackageId']
|
||||
];
|
||||
|
||||
$agent_price = $agent_price_model->getOne($where);
|
||||
|
||||
if($data['UserPrice']<$agent_price['price'] || $data['RefundDayPrice']<$agent_price['refund']){
|
||||
$retuen_data = [
|
||||
'Code' => -10000,
|
||||
'Message' => '低于最低价格',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
die;
|
||||
}
|
||||
|
||||
$update_data = [
|
||||
'TenantId' => 0,
|
||||
'ProductId' => $data['ProductId'],
|
||||
'PackageId' => $data['PackageId'],
|
||||
'UserId' => $data['UserId'],
|
||||
'UserPrice' => $data['UserPrice'],
|
||||
'RefundDayPrice' => $data['RefundDayPrice'],
|
||||
'Status' => 1,
|
||||
'DeleteTag' => 0
|
||||
];
|
||||
|
||||
$where = [
|
||||
'PackageId' => $data['PackageId'],
|
||||
'UserId' => $data['UserId']
|
||||
];
|
||||
|
||||
$user_price = $price_model->getOne($where);
|
||||
|
||||
if(empty($user_price)){
|
||||
$price_model->add($update_data);
|
||||
} else {
|
||||
$price_model->updateOne($where,$update_data);
|
||||
}
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
}
|
||||
10
app/agent/model/AgentPrice.php
Normal file
10
app/agent/model/AgentPrice.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class AgentPrice extends Model
|
||||
{
|
||||
protected $table = 'agent_price';
|
||||
}
|
||||
22
app/agent/model/AgentScore.php
Normal file
22
app/agent/model/AgentScore.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class AgentScore extends Model
|
||||
{
|
||||
protected $table = 'agent_score';
|
||||
|
||||
/**
|
||||
* 按照页数获取数据
|
||||
* @param $fields 'id,count(1)...'
|
||||
* @param $order 'id desc'/'id asc'
|
||||
* @param $limit = '100' 限制查询100条
|
||||
* $limit = '2,100' 查询第二页 100条数据
|
||||
*/
|
||||
public function getAgentListPage($where = [],$where_str = '', $fields = '*', $order = 'id desc', $limit = '50')
|
||||
{
|
||||
return $this->field($fields)->where($where)->where($where_str)->order($order)->limit($limit)->fetchAll();
|
||||
}
|
||||
}
|
||||
19
app/agent/model/Product.php
Normal file
19
app/agent/model/Product.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-22 16:13:41
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2020-12-03 16:28:11
|
||||
*/
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
protected $table = 'product';
|
||||
}
|
||||
31
app/agent/model/ProductAccount.php
Normal file
31
app/agent/model/ProductAccount.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-22 16:13:41
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2020-12-03 16:28:11
|
||||
*/
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductAccount extends Model
|
||||
{
|
||||
protected $table = 'product_account';
|
||||
|
||||
/**
|
||||
* 按照页数获取数据
|
||||
* @param $fields 'id,count(1)...'
|
||||
* @param $order 'id desc'/'id asc'
|
||||
* @param $limit = '100' 限制查询100条
|
||||
* $limit = '2,100' 查询第二页 100条数据
|
||||
*/
|
||||
public function getAgentListPage($where = [],$where_str = '', $fields = '*', $order = 'id desc', $limit = '50')
|
||||
{
|
||||
return $this->field($fields)->where($where)->where($where_str)->order($order)->limit($limit)->fetchAll();
|
||||
}
|
||||
}
|
||||
31
app/agent/model/ProductOrder.php
Normal file
31
app/agent/model/ProductOrder.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-22 16:13:41
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2020-12-03 16:28:11
|
||||
*/
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductOrder extends Model
|
||||
{
|
||||
protected $table = 'product_order';
|
||||
|
||||
/**
|
||||
* 按照页数获取数据
|
||||
* @param $fields 'id,count(1)...'
|
||||
* @param $order 'id desc'/'id asc'
|
||||
* @param $limit = '100' 限制查询100条
|
||||
* $limit = '2,100' 查询第二页 100条数据
|
||||
*/
|
||||
public function getAgentListPage($where = [],$where_str = '', $fields = '*', $order = 'id desc', $limit = '50')
|
||||
{
|
||||
return $this->field($fields)->where($where)->where($where_str)->order($order)->limit($limit)->fetchAll();
|
||||
}
|
||||
}
|
||||
19
app/agent/model/ProductPackage.php
Normal file
19
app/agent/model/ProductPackage.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-22 16:13:41
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2020-12-03 16:28:11
|
||||
*/
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductPackage extends Model
|
||||
{
|
||||
protected $table = 'product_package';
|
||||
}
|
||||
10
app/agent/model/ProductUserPrice.php
Normal file
10
app/agent/model/ProductUserPrice.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductUserPrice extends Model
|
||||
{
|
||||
protected $table = 'product_user_price';
|
||||
}
|
||||
@@ -19,4 +19,9 @@ class User extends Model
|
||||
{
|
||||
return $this->field($fields)->where($where)->fetch();
|
||||
}
|
||||
|
||||
//获取代理商的用户数量
|
||||
public function getAgentUser($where = []){
|
||||
return $this->field('agent_id,count(1) as num')->where($where)->group(['agent_id'])->fetchAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user