From 71770219a40ef23c6d3ab205d8b030190a5d37ac Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 30 Aug 2023 13:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=A1=E9=87=91=E7=AE=A1=E7=90=86=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyAccountLogController.php | 19 +++++++ app/api/controller/CompanyController.php | 14 +++++ app/common/logic/PayNotifyLogic.php | 22 +------- app/common/logic/finance/ShareProfit.php | 30 ++++++++-- .../model/company/CompanyAccountLog.php | 56 ++++++++++++++++++- app/job/TaskInformationJob.php | 5 +- 6 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 app/api/controller/CompanyAccountLogController.php diff --git a/app/api/controller/CompanyAccountLogController.php b/app/api/controller/CompanyAccountLogController.php new file mode 100644 index 000000000..cb3b11a8b --- /dev/null +++ b/app/api/controller/CompanyAccountLogController.php @@ -0,0 +1,19 @@ +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]); + } +} \ No newline at end of file diff --git a/app/api/controller/CompanyController.php b/app/api/controller/CompanyController.php index da477fbf3..629d60edb 100644 --- a/app/api/controller/CompanyController.php +++ b/app/api/controller/CompanyController.php @@ -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); + } } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 474e6738a..f14313dac 100755 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -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']]; - } } } } diff --git a/app/common/logic/finance/ShareProfit.php b/app/common/logic/finance/ShareProfit.php index bac02393f..1804db568 100644 --- a/app/common/logic/finance/ShareProfit.php +++ b/app/common/logic/finance/ShareProfit.php @@ -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) { diff --git a/app/common/model/company/CompanyAccountLog.php b/app/common/model/company/CompanyAccountLog.php index 90b96d90b..21b83c3e5 100644 --- a/app/common/model/company/CompanyAccountLog.php +++ b/app/common/model/company/CompanyAccountLog.php @@ -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; } \ No newline at end of file diff --git a/app/job/TaskInformationJob.php b/app/job/TaskInformationJob.php index 9be49b9c8..79b63c84a 100644 --- a/app/job/TaskInformationJob.php +++ b/app/job/TaskInformationJob.php @@ -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));