mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 05:50:50 +00:00
代理商后台添加问题修复
This commit is contained in:
parent
0129d6222d
commit
92721fca42
@ -60,7 +60,7 @@ class AgentManage extends AuthController
|
||||
public function get_badge()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['data', ''],
|
||||
['data', '', '', 'time'],
|
||||
['nickname', ''],
|
||||
]);
|
||||
return app('json')->success(['res' => $this->services->getSpreadBadge($where)]);
|
||||
|
||||
@ -121,19 +121,24 @@ class Division extends AuthController
|
||||
* 保存代理商
|
||||
* @param UserServices $userServices
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function divisionAgentSave(UserServices $userServices)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['division_id', 0],
|
||||
['uid', 0],
|
||||
['division_percent', 0],
|
||||
['division_end_time', ''],
|
||||
['division_status', 1],
|
||||
['edit', 0],
|
||||
]);
|
||||
$userInfo = $userServices->get((int)$data['uid']);
|
||||
$userInfo = $userServices->count(['uid' => (int)$data['uid']]);
|
||||
if (!$userInfo) throw new AdminException(100100);
|
||||
$data['division_id'] = $this->adminInfo['division_id'];
|
||||
$divisionUserInfo = $userServices->count(['uid' => (int)$data['division_id'], 'is_division' => 1, 'division_id' => $data['division_id']]);
|
||||
if (!$divisionUserInfo) throw new AdminException(100100);
|
||||
$this->services->divisionAgentSave($data);
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
@ -304,13 +304,14 @@ abstract class BaseDao
|
||||
$with = [];
|
||||
$otherWhere = [];
|
||||
$responses = new \ReflectionClass($this->setModel());
|
||||
|
||||
foreach ($where as $key => $value) {
|
||||
$method = 'search' . Str::studly($key) . 'Attr';
|
||||
if ($responses->hasMethod($method)) {
|
||||
$with[] = $key;
|
||||
} else {
|
||||
if ($key != 'timeKey') {
|
||||
$otherWhere[] = $value;
|
||||
$otherWhere[] = is_array($value) ? $value : [$key, '=', $value];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,6 +321,7 @@ abstract class BaseDao
|
||||
/**
|
||||
* 根据搜索器获取搜索内容
|
||||
* @param $where
|
||||
* @param $search
|
||||
* @return BaseModel
|
||||
* @throws \ReflectionException
|
||||
* @author 吴汐
|
||||
|
||||
@ -176,6 +176,7 @@ class UserDao extends BaseDao
|
||||
* 获取推广员ids
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getAgentUserIds(array $where)
|
||||
{
|
||||
|
||||
@ -222,9 +222,11 @@ class DivisionServices extends BaseServices
|
||||
if ($uid && !$userInfo) throw new AdminException(400214);
|
||||
$field = [];
|
||||
if ($uid) {
|
||||
$field[] = Form::number('division_id', '事业部UID', $userInfo['division_id'] ?? '')->disabled(true)->style(['width' => '173px']);
|
||||
$field[] = Form::number('uid', '用户UID', $userInfo['uid'] ?? '')->disabled(true)->style(['width' => '173px']);
|
||||
$field[] = Form::hidden('edit', 1);
|
||||
} else {
|
||||
$field[] = Form::number('division_id', '事业部UID')->style(['width' => '173px']);
|
||||
$field[] = Form::number('uid', '用户UID')->style(['width' => '173px']);
|
||||
$field[] = Form::hidden('edit', 0);
|
||||
}
|
||||
@ -238,20 +240,24 @@ class DivisionServices extends BaseServices
|
||||
* 保存代理商
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function divisionAgentSave($data)
|
||||
{
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$uid = $data['uid'];
|
||||
$userInfo = $userServices->getUserInfo($uid, 'is_division,division_id,agent_id');
|
||||
$agentData = [
|
||||
'division_id' => $data['division_id'],
|
||||
'division_status' => $data['division_status'],
|
||||
'division_percent' => $data['division_percent'],
|
||||
'division_change_time' => time(),
|
||||
'division_end_time' => strtotime($data['division_end_time']),
|
||||
'division_type' => 2,
|
||||
];
|
||||
$division_info = $userServices->getUserInfo($userInfo['division_id'], 'division_end_time,division_percent');
|
||||
$division_info = $userServices->getUserInfo($data['division_id'], 'division_end_time,division_percent');
|
||||
if ($division_info) {
|
||||
if ($agentData['division_percent'] > $division_info['division_percent']) throw new AdminException(400448);
|
||||
if ($agentData['division_end_time'] > $division_info['division_end_time']) throw new AdminException(400449);
|
||||
|
||||
@ -237,6 +237,7 @@ class UserServices extends BaseServices
|
||||
* 获取分销员ids
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getAgentUserIds(array $where)
|
||||
{
|
||||
|
||||
@ -27,6 +27,11 @@
|
||||
<Card :bordered="false" dis-hover class="ivu-mt">
|
||||
<Row class="ivu-mt box-wrapper">
|
||||
<Col :xs="24" :sm="24" ref="rightBox">
|
||||
<Row type="flex">
|
||||
<Col v-bind="grid">
|
||||
<Button type="primary" @click="groupAdd('0')" class="mr20">添加代理商</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data="userLists"
|
||||
@ -179,11 +184,6 @@ export default {
|
||||
slot: 'division_percent',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
title: '订单数量',
|
||||
key: 'order_count',
|
||||
minWidth: 100,
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
|
||||
@ -179,24 +179,19 @@ export default {
|
||||
slot: 'nickname',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '邀请码',
|
||||
key: 'division_invite',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '分销比例',
|
||||
slot: 'division_percent',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
title: '用户数量',
|
||||
key: 'user_count',
|
||||
minWidth: 100,
|
||||
title: '到期时间',
|
||||
key: 'division_end_time',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
title: '订单数量',
|
||||
key: 'order_count',
|
||||
title: '员工数量',
|
||||
key: 'agent_count',
|
||||
minWidth: 100,
|
||||
},
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user