|
@@ -9,6 +9,7 @@ namespace app\admin\controller\user;
|
|
|
|
|
|
use app\admin\controller\AuthController;
|
|
|
use app\models\system\CardInfo;
|
|
|
+use app\models\user\UserBill;
|
|
|
use crmeb\repositories\UserRepository;
|
|
|
use crmeb\traits\CurdControllerTrait;
|
|
|
use think\facade\Route as Url;
|
|
@@ -19,7 +20,13 @@ use app\admin\model\wechat\WechatMessage;
|
|
|
use app\admin\model\store\{StoreVisit, StoreCouponUser};
|
|
|
use app\admin\model\system\{SystemUserLevel, SystemUserTask};
|
|
|
use crmeb\services\{FormBuilder as Form, upload\Upload, UtilService as Util, JsonService as Json, UtilService};
|
|
|
-use app\admin\model\user\{User as UserModel, UserBill as UserBillAdmin, UserLevel, UserGroup, UserTaskFinish,UserSystemRecharge};
|
|
|
+use app\admin\model\user\{User as UserModel,
|
|
|
+ UserBill as UserBillAdmin,
|
|
|
+ UserLevel,
|
|
|
+ UserGroup,
|
|
|
+ UserTaskFinish,
|
|
|
+ UserSystemRecharge
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* 用户管理控制器
|
|
@@ -71,7 +78,7 @@ class User extends AuthController
|
|
|
list($group_id) = Util::postMore([
|
|
|
['group_id', 0],
|
|
|
], $this->request, true);
|
|
|
- $uids = explode(',',$uid);
|
|
|
+ $uids = explode(',', $uid);
|
|
|
$res = UserModel::whereIn('uid', $uids)->update(['group_id' => $group_id]);
|
|
|
if ($res) {
|
|
|
return Json::successful('设置成功');
|
|
@@ -114,7 +121,7 @@ class User extends AuthController
|
|
|
public function edit_other($uid)
|
|
|
{
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::radio('money_status', '修改余额', 1)->options([['value' => 1, 'label' => '增加'], ['value' => 2, 'label' => '减少']]);
|
|
@@ -125,49 +132,49 @@ class User extends AuthController
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
}
|
|
|
+
|
|
|
public function pay($uid)
|
|
|
{
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::radio('brokerage_status', '充值余额', 1)->options([['value' => 1, 'label' => '增加'], ['value' => 0, 'label' => '减少']]);
|
|
|
$f[] = Form::number('money', '金额')->min(0);
|
|
|
$f[] = Form::uploadFiles('evaluation', '付款凭证', Url::buildUrl('file_upload'))->name('file');
|
|
|
- $form = Form::make_post_form('修改其他', $f, Url::buildUrl('pay_update', array('uid' => $uid)),5);
|
|
|
+ $form = Form::make_post_form('修改其他', $f, Url::buildUrl('pay_update', array('uid' => $uid)), 5);
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
}
|
|
|
+
|
|
|
public function pay_update($uid)
|
|
|
{
|
|
|
$data = Util::postMore([
|
|
|
['brokerage_status', 0],
|
|
|
['money', 0],
|
|
|
- ['type','now_money'],
|
|
|
+ ['type', 'now_money'],
|
|
|
], $this->request);
|
|
|
-
|
|
|
+
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
- if(is_array(input('evaluation')))
|
|
|
- {
|
|
|
- $cdata = ['number'=>$data['money'],'way'=>$data['brokerage_status'],'evaluation'=>join(",",input('evaluation'))];
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $cdata = ['number'=>$data['money'],'way'=>$data['brokerage_status']];
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
+ if (is_array(input('evaluation'))) {
|
|
|
+ $cdata = ['number' => $data['money'], 'way' => $data['brokerage_status'], 'evaluation' => join(",", input('evaluation'))];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $cdata = ['number' => $data['money'], 'way' => $data['brokerage_status']];
|
|
|
}
|
|
|
- $cdata['create_admin_id'] = $this->adminId;
|
|
|
+ $cdata['create_admin_id'] = $this->adminId;
|
|
|
$cdata['create_admin_time'] = time();
|
|
|
$cdata['uid'] = $uid;
|
|
|
$cdata['type'] = $data['type'];
|
|
|
UserSystemRecharge::create($cdata);
|
|
|
-
|
|
|
- return Json::successful('充值已提交,等操作员确认');
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ return Json::successful('充值已提交,等操作员确认');
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- /**
|
|
|
+
|
|
|
+ /**
|
|
|
* 文件上传
|
|
|
* */
|
|
|
public function file_upload()
|
|
@@ -177,6 +184,7 @@ class User extends AuthController
|
|
|
if ($res === false) Json::fail($upload->getError());
|
|
|
Json::successful('上传成功!', ['filePath' => $res->filePath]);
|
|
|
}
|
|
|
+
|
|
|
public function update_other($uid = 0)
|
|
|
{
|
|
|
$data = Util::postMore([
|
|
@@ -186,7 +194,7 @@ class User extends AuthController
|
|
|
['integration', 0],
|
|
|
], $this->request);
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
BaseModel::beginTrans();
|
|
|
$res1 = false;
|
|
@@ -238,7 +246,7 @@ class User extends AuthController
|
|
|
} else {
|
|
|
$res2 = true;
|
|
|
}
|
|
|
- if ($edit) $res3 = UserModel::where('uid',$uid)->update($edit);
|
|
|
+ if ($edit) $res3 = UserModel::where('uid', $uid)->update($edit);
|
|
|
else $res3 = true;
|
|
|
if ($res1 && $res2 && $res3) $res = true;
|
|
|
else $res = false;
|
|
@@ -318,6 +326,27 @@ class User extends AuthController
|
|
|
return Json::fail('清除失败');
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * 清除会员等级
|
|
|
+ * @param int $uid
|
|
|
+ * @return json
|
|
|
+ * */
|
|
|
+ public function clear_gf($uid = 0)
|
|
|
+ {
|
|
|
+ if (!$uid) return Json::fail('缺少参数');
|
|
|
+ $user = UserModel::get($uid);
|
|
|
+ if ($user['gf'] <= 0) return Json::successful('清除成功');
|
|
|
+ else {
|
|
|
+ $res = true;
|
|
|
+ $res = $res && UserBill::expend('清除股份', $uid, 'gf', 'clear_gf', $user['gf'], 0, 0, '后台清除股份');
|
|
|
+ $res = $res && \app\admin\model\user\User::where('uid', $uid)->update(['gf' => 0]);
|
|
|
+ }
|
|
|
+ if ($res)
|
|
|
+ return Json::successful('清除成功');
|
|
|
+ else
|
|
|
+ return Json::fail('清除失败');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改user表状态
|
|
|
*
|
|
@@ -365,31 +394,34 @@ class User extends AuthController
|
|
|
]);
|
|
|
return Json::successlayui(UserModel::getUserList($where));
|
|
|
}
|
|
|
+
|
|
|
public function add()
|
|
|
{
|
|
|
$f = array();
|
|
|
$f[] = Form::text('account', '手机号', '');
|
|
|
- $f[] = Form::input('real_name', '真实姓名','');
|
|
|
+ $f[] = Form::input('real_name', '真实姓名', '');
|
|
|
$f[] = Form::input('password', '输入密码');
|
|
|
- $f[] = Form::input('spread', '推荐人编号',0);
|
|
|
- $f[] = Form::input('addres', '地址信息','');
|
|
|
- $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('save',[], 5));
|
|
|
+ $f[] = Form::input('spread', '推荐人编号', 0);
|
|
|
+ $f[] = Form::input('addres', '地址信息', '');
|
|
|
+ $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('save', [], 5));
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
}
|
|
|
+
|
|
|
public function save()
|
|
|
{
|
|
|
- list($account,$password,$spread,$real_name,$addres) = Util::postMore([
|
|
|
+ list($account, $password, $spread, $real_name, $addres) = Util::postMore([
|
|
|
['account', ''],
|
|
|
['password', ''],
|
|
|
['spread', 0],
|
|
|
- ['real_name',''],
|
|
|
- ['addres',''],
|
|
|
- ],$this->request,true);
|
|
|
- $res = \app\models\user\User::register($account, $password, $spread,$real_name,$addres);
|
|
|
+ ['real_name', ''],
|
|
|
+ ['addres', ''],
|
|
|
+ ], $this->request, true);
|
|
|
+ $res = \app\models\user\User::register($account, $password, $spread, $real_name, $addres);
|
|
|
if ($res) return Json::successful('创建成功!');
|
|
|
else return Json::fail('创建失败');
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 编辑模板消息
|
|
|
* @param $id
|
|
@@ -398,7 +430,7 @@ class User extends AuthController
|
|
|
public function edit($uid)
|
|
|
{
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::input('account', '用户账号', $user->getData('account'))->disabled(1);
|
|
@@ -432,17 +464,15 @@ class User extends AuthController
|
|
|
['status', 0],
|
|
|
]);
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
BaseModel::beginTrans();
|
|
|
$edit = array();
|
|
|
- if(input('pwd','')!='')
|
|
|
- {
|
|
|
- if(strlen(input('pwd',''))<6)
|
|
|
- {
|
|
|
+ if (input('pwd', '') != '') {
|
|
|
+ if (strlen(input('pwd', '')) < 6) {
|
|
|
return Json::fail('密码不能少于6位!');
|
|
|
}
|
|
|
- $edit['pwd']= md5(input('pwd',''));
|
|
|
+ $edit['pwd'] = md5(input('pwd', ''));
|
|
|
}
|
|
|
$res1 = false;
|
|
|
$res2 = false;
|
|
@@ -880,10 +910,10 @@ class User extends AuthController
|
|
|
{
|
|
|
return Json::successful(UserBillAdmin::getOneBalanceChangList(compact('uid', 'page', 'limit')));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- *充值审核列表
|
|
|
- */
|
|
|
+ *充值审核列表
|
|
|
+ */
|
|
|
public function recharge_auth()
|
|
|
{
|
|
|
$this->assign([
|
|
@@ -893,6 +923,7 @@ class User extends AuthController
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
+
|
|
|
public function recharge_list()
|
|
|
{
|
|
|
$where = Util::getMore([
|
|
@@ -903,26 +934,24 @@ class User extends AuthController
|
|
|
['limit', 20],
|
|
|
['excel', 0]
|
|
|
]);
|
|
|
-
|
|
|
- return Json::successlayui( UserSystemRecharge::systemPage($where));
|
|
|
+
|
|
|
+ return Json::successlayui(UserSystemRecharge::systemPage($where));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 审核保存
|
|
|
- */
|
|
|
- public function recharge_auth_save($id,$auth_status)
|
|
|
+ */
|
|
|
+ public function recharge_auth_save($id, $auth_status)
|
|
|
{
|
|
|
if (!$id) return Json::fail('缺少参数');
|
|
|
if (!$auth_status) return Json::fail('缺少参数');
|
|
|
$info = UserSystemRecharge::find($id);
|
|
|
-
|
|
|
- if($info)
|
|
|
- {
|
|
|
+
|
|
|
+ if ($info) {
|
|
|
$data = $info->toarray();
|
|
|
- $user = UserModel::where('uid',$info['uid'])->find();
|
|
|
- UserSystemRecharge::edit(['auth_status'=>$auth_status,'auth_admin_id'=>$this->adminId,'auth_admin_time'=>time()],$info['id']);
|
|
|
- if($auth_status==1)
|
|
|
- {
|
|
|
+ $user = UserModel::where('uid', $info['uid'])->find();
|
|
|
+ UserSystemRecharge::edit(['auth_status' => $auth_status, 'auth_admin_id' => $this->adminId, 'auth_admin_time' => time()], $info['id']);
|
|
|
+ if ($auth_status == 1) {
|
|
|
if ($data['way'] == 1) {//增加
|
|
|
$edit[$data['type']] = bcadd($user[$data['type']], $data['number'], 2);
|
|
|
$res1 = UserBillAdmin::income('系统增加余额', $user['uid'], $data['type'], 'system_add', $data['number'], $this->adminId, $edit[$data['type']], '系统增加了' . floatval($data['number']) . '数量');
|
|
@@ -930,18 +959,18 @@ class User extends AuthController
|
|
|
$edit[$data['type']] = bcsub($user[$data['type']], $data['number'], 2);
|
|
|
$res1 = UserBillAdmin::expend('系统减少余额', $user['uid'], $data['type'], 'system_sub', $data['number'], $this->adminId, $edit[$data['type']], '系统扣除了' . floatval($data['number']) . '数量');
|
|
|
}
|
|
|
- UserModel::edit($edit,$data['uid'],'uid');
|
|
|
+ UserModel::edit($edit, $data['uid'], 'uid');
|
|
|
}
|
|
|
return Json::successful('审核成功');
|
|
|
- }
|
|
|
- else
|
|
|
+ } else
|
|
|
return Json::fail('审核失败');
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- public function exchange($uid=0)
|
|
|
+
|
|
|
+ public function exchange($uid = 0)
|
|
|
{
|
|
|
if (!$uid) return $this->failed('数据不存在');
|
|
|
- $user = UserModel::where('uid',$uid)->find();
|
|
|
+ $user = UserModel::where('uid', $uid)->find();
|
|
|
if (!$user) return Json::fail('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::input('account', '用户账号', $user->getData('account'))->disabled(1);
|
|
@@ -952,14 +981,15 @@ class User extends AuthController
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
}
|
|
|
+
|
|
|
public function exchange_save($uid)
|
|
|
{
|
|
|
- list($card_number,$card_password) = UtilService::postMore([
|
|
|
- ['card_number',''],
|
|
|
- ['card_password',''],
|
|
|
- ],$this->request,true);
|
|
|
- $rs = CardInfo::verification($card_number,$card_password,$uid,1,0,1);
|
|
|
- if(!$rs) return Json::fail(CardInfo::getErrorInfo());
|
|
|
+ list($card_number, $card_password) = UtilService::postMore([
|
|
|
+ ['card_number', ''],
|
|
|
+ ['card_password', ''],
|
|
|
+ ], $this->request, true);
|
|
|
+ $rs = CardInfo::verification($card_number, $card_password, $uid, 1, 0, 1);
|
|
|
+ if (!$rs) return Json::fail(CardInfo::getErrorInfo());
|
|
|
return Json::fail('兑换完成');
|
|
|
}
|
|
|
}
|