股金管理更新

This commit is contained in:
mkm 2023-08-30 13:50:50 +08:00
parent 9d13dd82ea
commit 71770219a4
6 changed files with 118 additions and 28 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace app\api\controller;
use app\common\model\company\CompanyAccountLog;
class CompanyAccountLogController extends BaseApiController{
public function lists(){
[$page,$limit]=$this->getPage();
$where=[];
$where['company_id']=$this->userInfo['company_id'];
$where['change_object']=CompanyAccountLog::SHAREHOLDER;
$where['change_type']=CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY;
$count=CompanyAccountLog::where($where)->count();
$lists=CompanyAccountLog::where($where)->page($page,$limit)->order('id','desc')->select();
return $this->success('ok',['count'=>$count,'list'=>$lists]);
}
}

View File

@ -187,4 +187,18 @@ class CompanyController extends BaseApiController
return $this->fail(ContractLogic::getError());
}
}
/**
* 股金管理
*/
public function shareholder_info(){
// $params = $this->request->param();
$find=Company::where('id',$this->userInfo['company_id'])->field('is_contract,shareholder_money')->find()->toArray();
if($find &&$find['is_contract']==1){
$find['contract_url']=Contract::where('party_b',$this->userInfo['company_id'])->value('contract_url');
}else{
$find['contract_url']='';
}
return $this->success('ok',$find);
}
}

View File

@ -16,6 +16,7 @@ namespace app\common\logic;
use app\common\enum\PayEnum;
use app\common\enum\user\AccountLogEnum;
use app\common\model\company\CompanyAccountLog;
use app\common\model\recharge\RechargeOrder;
use app\common\model\task\Task;
use app\common\model\task_template\TaskTemplate;
@ -84,29 +85,12 @@ class PayNotifyLogic extends BaseLogic
$order->pay_status = PayEnum::ISPAID;
$order->pay_time = time();
$order->save();
if ($order && isset($order['extend']['type']) && $order['extend']['type'] == 1) {
$find = Task::where('id', $order['extend']['task_id'])->find();
Task::where('id', $order['extend']['task_id'])->update(['status' => 3]);
TaskTemplate::where('id', $find['template_id'])->update(['over_decimal' => $order->order_amount]);
$user_ids = User::where('company_id', $find['company_id'])->where('is_captain', 1)->field('id,nickname,brigade')->select();
$shareholder_user = User::where('id', $find['director_uid'])->field('id,nickname,brigade')->find();
foreach ($user_ids as $kkk => $vvv) {
$company_log = [
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
'company_id'=>$find['company_id'],
'change_object' => $change_object,//变动对象
'change_type' => $change_type,//变动类型
'action' => $action,//1-增加 2-减少
'left_amount' => $left_amount,//变动后数量
'change_amount' => $changeAmount,//变动数量
'status'=>1,
];
CompanyAccountLog::create($company_log);
$v['extend']['shareholder']['user_list'][$kkk] = ['info'=>$shareholder_user['nickname'].'完成了'.$vvv['brigade'].'队的股金:'.bcdiv($v['recharge'],count($user_ids),2), 'time' => $v['create_time']];
}
}
}
}

View File

@ -6,6 +6,7 @@ use app\common\enum\user\AccountLogEnum;
use app\common\logic\AccountLogLogic;
use app\common\model\Company;
use app\common\model\company\CompanyAccountLog;
use app\common\model\task\Task;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\user\User;
use think\facade\Db;
@ -13,7 +14,7 @@ use think\facade\Log;
class ShareProfit
{
public function first($data, $company)
public function first($data, $company,$datas=[])
{
// if ($company['day_count'] <= $data['proportion_one']) {
// $proportion = $data['proportion_one'];
@ -58,12 +59,33 @@ class ShareProfit
Company::where('id', $data['company_id'])->update(['deposit'=>Db::raw('deposit+' . $master_maoney), 'company_money'=>Db::raw('company_money+' .$master_maoney)]);
}elseif($data['company_account_type']==2){
$company_money_count = bcadd($company['shareholder_money'], $master_maoney,2);
$this->AccountLog($data['company_id'],$company_money_count,$master_maoney,1,2);
$company_money_count = bcadd($company['shareholder_money'], $data['money'],2);
$this->AccountLog($data['company_id'],$company_money_count,$data['money'],1,2);
Company::where('id', $data['company_id'])->update(['shareholder_money'=>Db::raw('shareholder_money+' . $master_maoney)]);
Company::where('id', $data['company_id'])->update(['shareholder_money'=>Db::raw('shareholder_money+' . $data['money'])]);
}
if(isset($datas['template_info']['type']) && $datas['template_info']['type'] ==35){
$user_ids = User::where('company_id', $datas['company_id'])->where('is_captain', 1)->field('id,nickname,brigade')->select();
$director_uid = Task::where('id', $datas['task_id'])->value('director_uid');
$shareholder_user = User::where('id', $director_uid)->field('id,nickname,brigade')->find();
$money=bcdiv($data['money'],count($user_ids),2);
foreach ($user_ids as $kkk => $vvv) {
$company_log = [
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
'company_id'=>$datas['company_id'],
'change_object' => CompanyAccountLog::SHAREHOLDER,//变动对象
'change_type' => CompanyAccountLog::TASK_INC_SHAREHOLDER_MONEY,//变动类型
'action' => CompanyAccountLog::INC,//1-增加 2-减少
'left_amount' =>bcadd($company['shareholder_money'],$money,2),//变动后数量
'change_amount' => $money,//变动数量
'remark' =>$shareholder_user['nickname'].'完成了'.$vvv['brigade'].'队的股金:',
'status'=>1,
];
CompanyAccountLog::create($company_log);
}
}
Db::commit();
return true;
} catch (\Exception $e) {

View File

@ -27,6 +27,60 @@ class CompanyAccountLog extends BaseModel
use SoftDelete;
protected $deleteTime = 'delete_time';
/**
* 变动类型命名规则对象_动作_简洁描述
* 动作 DEC-减少 INC-增加
* 对象 TASK 任务金额
*/
/**
* 变动对象
*/
/**
* 金额
*/
const TASK = 1;
/**
* 股金
*/
const SHAREHOLDER = 2;
/**
* 动作
* INC 增加
* DEC 减少
*/
const INC = 1;
const DEC = 2;
/**
* 用户余额减少类型
*/
/**
* 任务
*/
const TASK_DEC_DEPOSIT = 100;
/**
* 股金
*/
const SHAREHOLDER_DEC_DEPOSIT = 101;
/**
* 用户余额增加类型
*/
/**
* 保证金
*/
const TASK_INC_DEPOSIT = 200;
/**
* 收益
*/
const TASK_INC_COMPANY_MONEY = 201;
/**
* 股金
*/
const TASK_INC_SHAREHOLDER_MONEY = 202;
}

View File

@ -5,12 +5,9 @@ namespace app\job;
use app\api\controller\RemoteController;
use app\common\logic\finance\ShareProfit;
use app\common\model\task\Task;
use Symfony\Component\HttpClient\HttpClient;
use think\queue\Job;
use think\facade\Log;
use app\common\model\Company;
use app\common\model\informationg\UserInformationg;
use think\facade\App;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\task_template\TaskTemplate;
@ -122,7 +119,7 @@ class TaskInformationJob
return false;
}
if ($arr['status'] == 1) {
(new ShareProfit())->first($arr, $company);
(new ShareProfit())->first($arr, $company,$data);
} else {
Task::where('id', $data['task_id'])->update(['status' => 5,'extend'=>json_encode($shang_date_total_price)]);
Log::info('任务status=0结算失败' . $data['template_info']['title'] . '未完成' . json_encode($data));