初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\agent;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Goods extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_agent_goods';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
//禁止uniacid绑定
|
||||
protected $uniacid = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1'),'2' => __('Status 2')];
|
||||
}
|
||||
|
||||
public function getModeList()
|
||||
{
|
||||
return ['1' => __('Mode 1'),'2' => __('Mode 2'),'3' => __('Mode 3')];
|
||||
}
|
||||
|
||||
|
||||
public function course()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\Course', 'goods_id', 'id', [], 'RIGHT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\agent;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Member extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_agent_member';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1')];
|
||||
}
|
||||
|
||||
public function getAuditList()
|
||||
{
|
||||
return [
|
||||
'0' => __('Audit 0'),
|
||||
'1' => __('Audit 1'),
|
||||
'2' => __('Audit 2'),
|
||||
'3' => __('Audit 3')
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'RIGHT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function relation()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\app\agent\Relation', 'user_id', 'user_id', [], 'left')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\agent;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_agent_order';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'type_text',
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getTypeList()
|
||||
{
|
||||
return ['commission' => __('Commission'), 'subordinate' => __('Subordinate')];
|
||||
}
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1'),'0' => __('Status 0'),'2' => __('Status 2')];
|
||||
}
|
||||
|
||||
public function getModeList()
|
||||
{
|
||||
return ['1' => __('Mode 1'),'2' => __('Mode 2'),'3' => __('Mode 3')];
|
||||
}
|
||||
|
||||
|
||||
public function getTypeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
|
||||
$list = $this->getTypeList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
public function orderuser()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'order_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function beneficiaryuser()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'beneficiary_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function course()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\Course', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\order\Item', 'order_item_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function ordersource()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\order\Order', 'order_no', 'order_no', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\agent;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Relation extends Model
|
||||
{
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_agent_relation';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'parent_id', 'id', [], 'right')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置上下级关系
|
||||
* @param $userId 用户
|
||||
* @param $parentId 上级
|
||||
* @return void
|
||||
*/
|
||||
public function setRalation($userId,$parentId)
|
||||
{
|
||||
if(!$userId){
|
||||
return false;
|
||||
}
|
||||
//判断有没有这条记录,没有添加,有的话判断是否相同,不相同就修改
|
||||
$relation = self::where(['user_id'=>$userId])->find();
|
||||
|
||||
if(!$parentId){
|
||||
self::where(['user_id'=>$userId])->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$relation){
|
||||
self::insert([
|
||||
'uniacid' => 1,
|
||||
'createtime' => time(),
|
||||
'user_id' => $userId,
|
||||
'parent_id' => $parentId
|
||||
]);
|
||||
|
||||
}else{
|
||||
if($relation->parent_id != $parentId){
|
||||
$relation->parent_id = $parentId;
|
||||
$relation->save();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\agent;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Withdraw extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_agent_withdraw';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['refuse' => __('Status refuse'), 'success' => __('Status success'), 'waiting' => __('Status waiting')];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'RIGHT')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\app\agent\Member', 'user_id', 'user_id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user