limu 1 year ago
commit d5e50d0418
  1. 24
      app/command/brand.php
  2. 22
      app/common/repositories/user/UserExtractRepository.php
  3. 28
      app/common/repositories/user/UserRepository.php
  4. 1
      app/controller/admin/user/UserExtract.php
  5. 21
      app/controller/api/Auth.php
  6. 19
      app/controller/api/user/User.php
  7. 5
      route/admin/user.php

@ -49,7 +49,7 @@ class brand extends Command
// 指令配置
$this->setName('clearCache')
->addArgument('cacheType', Argument::OPTIONAL, 'php think menu [1] / [2]')
->setDescription('各种积分转换');
->setDescription('增值积分自动转增值贡献值');
}
/**
@ -95,24 +95,16 @@ class brand extends Command
//用户总贡献值 = 当前总贡献值+昨日的品宣贡献值
$all_value = $brandGongxian + $v['all_value'];
//贡献值自动转换为超级积分 暂定1:1
$superBrand = $all_value;
// $superBrand = $all_value;
//超级积分自动转换为增值积分 按照每天的比例 这个是重点
$brandAdd = $superBrand;
// $brandAdd = $superBrand;
$user = userModel::getDB()->where('uid', $v['uid'])->find();
//品宣积分清0
$user->brand_integral = 0;
// //品宣积分清0
// $user->brand_integral = 0;
//总贡献清0
$user->all_value = 0;
//超级积分清0
$user->super_brand = 0;
//更新增值积分
$user->brand_add += $brandAdd;
$user->all_value = $all_value;
// //更新增值积分
// $user->brand_add += $brandAdd;
//天数+1
$user->super_days += 1;
$user->save();

@ -14,6 +14,7 @@ namespace app\common\repositories\user;
use app\common\repositories\BaseRepository;
use app\common\dao\user\UserExtractDao as dao;
use app\common\model\user\User as userModel;
use app\common\repositories\wechat\WechatUserRepository;
use crmeb\jobs\SendSmsJob;
use crmeb\services\MiniProgramService;
@ -22,6 +23,7 @@ use crmeb\services\WechatService;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Queue;
use app\common\repositories\user\UserRepository;
class UserExtractRepository extends BaseRepository
{
@ -67,6 +69,8 @@ class UserExtractRepository extends BaseRepository
*/
public function getList(array $where, $page, $limit)
{
$a = UserRepository::transAdd();
echo 13;die;
$query = $this->dao->search($where)->with(['user' => function ($query) {
$query->field('uid,avatar,nickname');
}]);
@ -102,15 +106,13 @@ class UserExtractRepository extends BaseRepository
{
event('user.extract.before', compact('user', 'data'));
$userExtract = Db::transaction(function () use ($user, $data) {
if ($user['hp_value'] < (systemConfig('user_extract_min')))
if ($user['hp_value'] < ($data['extract_price']))
throw new ValidateException('生命值不足,无法提现');
if ($user['brokerage_price'] < (systemConfig('user_extract_min')))
throw new ValidateException('可提增值积分不足');
if ($data['extract_price'] < (systemConfig('user_extract_min')))
throw new ValidateException('提现金额不得小于最低额度');
if ($user['brokerage_price'] < $data['extract_price'])
throw new ValidateException('提现金额不足');
throw new ValidateException('可提增值积分不足');
if ($data['extract_type'] == 3) {
$make = app()->make(WechatUserRepository::class);
$openid = $make->idByOpenId((int)$user['wechat_user_id']);
@ -127,6 +129,12 @@ class UserExtractRepository extends BaseRepository
$data['uid'] = $user['uid'];
$data['balance'] = $brokerage_price;
//扣除生命值
$u = userModel::where('uid', $user->uid)->find();
$u->hp_value -= $data['extract_price'];
$u->save();
return $this->dao->create($data);
});
event('user.extract', compact('userExtract'));
@ -176,6 +184,12 @@ class UserExtractRepository extends BaseRepository
$user->brokerage_price = $brokerage_price;
$user->save();
}
if ($data['status'] == -1) {
//回滚生命值
$user->hp_value += $brokerage_price;
$user->save();
}
$userExtract = $this->dao->update($id, $data);
event('user.extractStatus', compact('id', 'userExtract'));
});

@ -16,6 +16,8 @@ namespace app\common\repositories\user;
use app\common\dao\BaseDao;
use app\common\dao\user\UserDao;
use app\common\model\user\User;
use app\common\model\user\User as userModel;
use app\common\model\user\ValueContributionLog;
use app\common\model\wechat\WechatUser;
use app\common\repositories\BaseRepository;
use app\common\repositories\community\CommunityRepository;
@ -56,9 +58,12 @@ class UserRepository extends BaseRepository
* UserRepository constructor.
* @param UserDao $dao
*/
public $brand_integral;
public function __construct(UserDao $dao)
{
$this->dao = $dao;
$this->brand_integral = 100;
}
public function promoter($uid)
@ -157,7 +162,6 @@ class UserRepository extends BaseRepository
}),
Elm::radio('status', '状态', 1)->options([
['value' => 0, 'label' => '关闭'],
['value' => 1, 'label' => '开启'],
@ -926,6 +930,7 @@ class UserRepository extends BaseRepository
*/
public function bindSpread(User $user, int $spreadUid)
{
if ($spreadUid && !$user->spread_uid && $user->uid != $spreadUid && ($spread = $this->dao->get($spreadUid)) && $spread->spread_uid != $user->uid && !$spread->cancel_time) {
$config = systemConfig(['extension_limit', 'extension_limit_day', 'integral_user_give']);
event('user.spread.before', compact('user', 'spreadUid'));
@ -936,6 +941,23 @@ class UserRepository extends BaseRepository
$user->spread_limit = date('Y-m-d H:i:s', strtotime('+ ' . $config['extension_limit_day'] . ' day'));
}
$spread->spread_count++;
if ($user->isNew) {
//加到log日志
ValueContributionLog::getDB()->insert([
'type' => 2,
'types_of' => 1,
'num' => 100,
'ctime' => date('Y-m-d H:i:s'),
'memo' => '邀请好友获得100品宣积分',
'user_id' => $user->spread_uid,
]);
}
$user2 = userModel::where('uid', $user->spread_uid)->find();
$user2->brand_integral += 100;
$user2->save();
if ($config['integral_user_give'] > 0 && $user->isNew) {
$integral = (int)$config['integral_user_give'];
$spread->integral += $integral;
@ -947,6 +969,7 @@ class UserRepository extends BaseRepository
'mark' => '邀请好友奖励' . $integral . '积分',
'balance' => $spread->integral
]);
}
$spread->save();
$user->save();
@ -1483,7 +1506,8 @@ class UserRepository extends BaseRepository
});
}
public function transAdd($num,$uid)
//wmc
public function transAdd()
{
}

@ -69,6 +69,7 @@ class UserExtract extends BaseController
$data['admin_id'] = $this->request->adminId();
$data['status_time'] = date('Y-m-d H:i:s',time());
$this->repository->switchStatus($id,$data);
return app('json')->success('审核成功');
}

@ -199,6 +199,8 @@ class Auth extends BaseController
*/
public function auth()
{
if (systemConfig('is_phone_login') === '1') {
return app('json')->fail('请绑定手机号');
}
@ -225,6 +227,7 @@ class Auth extends BaseController
$user[1] = $userRepository->mainUser($user[1]);
$pid = $this->request->param('spread', 0);
$userRepository->bindSpread($user[1], intval($pid));
$tokenInfo = $userRepository->createToken($user[1]);
@ -417,7 +420,7 @@ class Auth extends BaseController
*/
public function register(UserAuthValidate $validate, UserRepository $repository)
{
$data = $this->request->params(['phone', 'sms_code', 'spread', 'pwd', 'auth_token', ['user_type', 'h5']]);
$data = $this->request->params(['phone', 'sms_code', 'spread', 'pwd', 'auth_token', ['user_type', 'h5'], 'tid']);
$validate->check($data);
$sms_code = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['sms_code'], 'login');
if (!$sms_code)
@ -434,6 +437,18 @@ class Auth extends BaseController
$tokenInfo = $repository->createToken($user);
$repository->loginAfter($user);
//上级获得推荐分
if (!empty($data['tid'])) {
$model = ValueContributionLog::getDB();
$model->save([
'type' => 2,
'num' => env('brand.brand_integral', '100'),
'types_of' => 1,
'ctime' => date('Y-m-d H:i:s'),
'memo' => '邀请好友获得品宣积分' . env('brand.brand_integral', '100'),
]);
}
//增送品宣积分
$model = userModel::getDB();
$model->where('uid', $user->uid)->update(['brand_integral' => env('brand.brand_integral', '100')]);
@ -547,6 +562,10 @@ class Auth extends BaseController
public function authLogin()
{
$auth = $this->request->param('auth');
$users = $this->authInfo($auth, systemConfig('is_phone_login') !== '1');
if (!$users)

@ -373,10 +373,21 @@ class User extends BaseController
{
$type = $this->request->param('type');
$list = ValueContributionLog::getDB()
->where('user_id', $this->user->uid)
->where('type', $type)
->page((int)$this->request->param('page'), $this->request->param('limit'))->select();
$query = ValueContributionLog::getDB()
->where('user_id', $this->user->uid);
if (!empty($type)) {
$query->where('type', $type);
}
$list = $query->page((int)$this->request->param('page'), $this->request->param('limit'))->select()->toArray();
$user = userModel::getDB()->where('uid', $this->user->uid)->find();
$list['user']['hp_value'] = $user->hp_value;
$list['user']['all_value'] = $user->all_value;
$list['user']['brokerage_price'] = $user->brokerage_price;
$list['user']['proportion'] = 1;
return app('json')->success($list);
}

@ -35,6 +35,11 @@ Route::group(function () {
'_auth' => false,
'_form' => 'systemUserLabelCreate2',
]);
Route::get('form3', '/createForm3')->name('systemUserLabelCreateForm3')->option([
'_alias' => '贡献值转换',
'_auth' => false,
'_form' => 'systemUserLabelCreate3',
]);
Route::delete(':id', '/delete')->name('systemUserLabelDelete')->option([
'_alias' => '用户标签删除',
]);

Loading…
Cancel
Save