update 用户邀请码

This commit is contained in:
chenbo 2024-01-12 10:53:25 +08:00
parent b9b8e1aaec
commit 924a0fa2f9
3 changed files with 147 additions and 2 deletions

View File

@ -2,8 +2,10 @@
namespace app\adminapi\controller;
use app\common\model\task_template\TaskTemplate;
use app\common\model\user\User;
use think\facade\Db;
use app\common\model\user\Task;
use app\common\model\Task\Task;
class TaskController extends BaseAdminController
{
@ -211,5 +213,64 @@ class TaskController extends BaseAdminController
}
}
// 任务列表
public function taskList()
{
$param = $this->request->param();
[$page, $limit] = $this->getPage();
$list = Task::where('company_id', $param['company_id'])
->with(['directorInfo'])
->page($page, $limit)
->order(['id' => 'desc'])
->select();
$count = Task::where('company_id', $param['company_id'])->count();
$data = [
'lists' => $list,
'count' => $count,
'page_no' => $page,
'page_size' => $limit,
];
return $this->success('任务列表', $data);
}
// 添加新版任务
public function addTask()
{
$params = $this->request->param(); // user_id title content
$arr = [
'template_id' => 0,
'scheduling_plan_id' => 0,
'company_id' => $params['company_id'],
'title' => $params['title'],
'money' => 0,
'type' => 0,
'content' => $params['content'],
'start_time' => time(),
'end_time' => time() + 86400*365,
'director_uid' => $params['director_uid'], // 指派给负责人
'create_time' => time(),
'update_time' => time(),
];
$task_id = (new Task())->insertGetId($arr);
return $this->success('添加成功', ['task_id' => $task_id]);
}
public function editTask()
{
$params = $this->request->param(); // user_id title content
$task = Task::where('id', $params['id'])->find();
$arr = [
'title' => $params['title'],
'content' => $params['content'],
'status' => $params['status'],
'update_time' => time(),
];
$task->save($arr);
return $this->success('成功');
}
}

View File

@ -28,7 +28,9 @@ use app\common\model\user\User;
use app\common\model\user\UserAccountLog;
use app\common\model\user\Withdraw;
use Common;
use Symfony\Component\HttpClient\HttpClient;
use think\facade\Db;
use think\facade\Log;
/**
* 用户控制器
@ -242,4 +244,77 @@ class UserController extends BaseApiController
return $this->success('发送成功', $res);
}
// 交易任务进度
public function getTradeTaskInfo()
{
$company = Company::where('id', $this->userInfo['company_id'])->find();
$start_time = date('Y-m-d');
$time = strtotime($start_time) + 86399;
$end_time = date('Y-m-d H:i:s', $time);
$parmas = [
"start_date" => $start_time,
"end_date" => $end_time
];
$parmas['brigade_id'] = $company['responsible_area'];
$parmas['village_code'] = $company['village'];
$parmas['street_code'] = $company['street'];
$parmas['district_code'] = $company['area'];
$parmas['city_code'] = $company['city'];
// 查询片区每日交易额
$res = HttpClient::create()->request('GET', env('url.shop_prefix') . '/api/order/statistics', [
'query' => $parmas,
]);
$response = json_decode($res->getContent(), true);
// 日实际交易金额
$actualTradeAmount = $response['data']['total_price'];
// 月目标交易金额 2.1w x 实际导入户数100 / 12(个月)
$monthTargetTradeAmount = bcdiv(bcmul(21000, 100, 2),12,2);
// 完成进度占比
$rate = bcdiv($actualTradeAmount, $monthTargetTradeAmount, 2);
// 个人每月总补贴 2.1w x 实际导入户数100 / 12(个月) x 0.023
$userMonthTotalMoney = bcmul(bcdiv(bcmul(21000, 100, 2),12,2), 0.023, 2);
// 当日可获得补贴 个人每月总补贴 x 实际完成交易额率 x 自定义点率
$dayTotalMoney = self::countDayMoney($userMonthTotalMoney, $rate);
$dayMoney = bcdiv($dayTotalMoney, 2, 2);
$dayDeposity = $dayMoney;
return $this->success('成功', compact('rate', 'dayMoney', 'dayDeposity'));
}
public static function countDayMoney($userMonthTotalMoney, $rate)
{
// 个人每月总补贴 x 实际完成交易额率 x 自定义点率
if ($rate == 0) {
return 0;
}
// rate < 29% 50%
if ($rate <= 0.29) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 0.5, 2);
}
// 30% <= rate < 39% 60%
if (0.3 <= $rate && $rate <= 0.49) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 0.6, 2);
}
// 30% <= rate < 39% 70%
if (0.5 <= $rate && $rate <= 0.69) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 0.7, 2);
}
// 30% <= rate < 39% 80%
if (0.7 <= $rate && $rate <= 0.89) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 0.8, 2);
}
// rate >= 90% 90%
if (0.9 <= $rate && $rate < 1) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 0.9, 2);
}
// rate >= 90% 100%
if ( $rate >= 1) {
return bcmul(bcmul($userMonthTotalMoney, $rate, 2), 1, 2);
}
}
}

View File

@ -88,6 +88,8 @@ class CompanyLogic extends BaseLogic
'qualification' => $params['qualification'],
'responsible_area' => $params['responsible_area'],
'admin_id' => 0,
'is_contract' => 1, // todo 暂时默认为已签约
'is_authentication' => 1, // todo 暂时默认为已认证
];
$data = Company::create($arr);
$passwordSalt = Config::get('project.unique_identification');
@ -115,7 +117,14 @@ class CompanyLogic extends BaseLogic
elseif ($params['company_type']==18) {
//小组服务公司
AdminLogic::insertRole($admin_id, [6]);
$admin['group_id']=5;
$village = Db::name('geo_village')->where('village_code', $params['village'])->find();
// 判断字符串是否包含子串
if (mb_strpos($village['village_name'], '社区') !== false) {
$admin['group_id']=18; // 社区队长
} else {
$admin['group_id']=2; // 生产队队长
}
} elseif ($params['company_type']==41) {
//镇农科公司
AdminLogic::insertRole($admin_id, [7]); //后台角色