更新到账管理
This commit is contained in:
parent
dcc2a64222
commit
abcf1dce71
|
@ -52,11 +52,14 @@ class FinanceIncome extends ApiController
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$param = get_params();
|
$param = get_params();
|
||||||
|
$this->uid = JWT_UID;
|
||||||
$auth = isAuthIncome($this->uid);
|
$auth = isAuthIncome($this->uid);
|
||||||
if (request()->isAjax()) {
|
if($auth == 0){
|
||||||
if($auth == 0){
|
$this->apiError("你没有到账管理权限,请联系管理员或者HR");
|
||||||
return to_assign(1, "你没有到账管理权限,请联系管理员或者HR");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$inid = $param['inid'];
|
$inid = $param['inid'];
|
||||||
$admin_id = $this->uid;
|
$admin_id = $this->uid;
|
||||||
//计算已到账的金额
|
//计算已到账的金额
|
||||||
|
@ -141,39 +144,7 @@ class FinanceIncome extends ApiController
|
||||||
return to_assign();
|
return to_assign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($auth == 0){
|
|
||||||
return view('../../base/view/common/roletemplate');
|
|
||||||
}
|
|
||||||
$id = isset($param['id']) ? $param['id']: 0 ;
|
|
||||||
$model = new Invoice();
|
|
||||||
$detail = $model->detail($id);
|
|
||||||
if(empty($detail)){
|
|
||||||
throw new \think\exception\HttpException(406, '找不到记录');
|
|
||||||
}
|
|
||||||
if($detail['file_ids'] !=''){
|
|
||||||
$fileArray = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
|
||||||
$detail['fileArray'] = $fileArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($detail['other_file_ids'] !=''){
|
|
||||||
$fileArrayOther = Db::name('File')->where('id','in',$detail['other_file_ids'])->select();
|
|
||||||
$detail['fileArrayOther'] = $fileArrayOther;
|
|
||||||
}
|
|
||||||
$detail['not_income'] = ($detail['amount']*100 - $detail['enter_amount']*100)/100;
|
|
||||||
//已到账的记录
|
|
||||||
$detail['income'] = InvoiceIncome::field('i.*,a.name as admin')
|
|
||||||
->alias('i')
|
|
||||||
->join('Admin a', 'a.id = i.admin_id', 'LEFT')
|
|
||||||
->where(['i.inid'=>$id,'i.status'=>1])
|
|
||||||
->order('i.enter_time desc')
|
|
||||||
->select();
|
|
||||||
View::assign('uid', $this->uid);
|
|
||||||
View::assign('id', $id);
|
|
||||||
View::assign('detail', $detail);
|
|
||||||
return view();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//查看
|
//查看
|
||||||
public function view()
|
public function view()
|
||||||
|
@ -210,29 +181,29 @@ class FinanceIncome extends ApiController
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$param = get_params();
|
$param = get_params();
|
||||||
if (request()->isAjax()) {
|
$this->uid = JWT_UID;
|
||||||
//作废初始化发票到账数据
|
//作废初始化发票到账数据
|
||||||
$income =InvoiceIncome::where(['id'=>$param['id']])->find();
|
$income =InvoiceIncome::where(['id'=>$param['id']])->find();
|
||||||
$invoice = Invoice::where(['id'=>$income['inid']])->find();
|
$invoice = Invoice::where(['id'=>$income['inid']])->find();
|
||||||
if($income){
|
if($income){
|
||||||
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
|
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
|
||||||
if($res!==false){
|
if($res!==false){
|
||||||
if($income['amount']*100 == $invoice['amount']*100){
|
if($income['amount']*100 == $invoice['amount']*100){
|
||||||
//发票全部反到账
|
//发票全部反到账
|
||||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
|
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
|
||||||
}
|
|
||||||
else if($income['amount']*100 < $invoice['amount']*100){
|
|
||||||
$incomeTotal=InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
|
|
||||||
//发票部分到账
|
|
||||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
|
|
||||||
}
|
|
||||||
add_log('enter',$income['inid'],$invoice);
|
|
||||||
return to_assign();
|
|
||||||
}
|
}
|
||||||
else{
|
else if($income['amount']*100 < $invoice['amount']*100){
|
||||||
return to_assign(1,'操作失败');
|
$incomeTotal=InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
|
||||||
|
//发票部分到账
|
||||||
|
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
|
||||||
}
|
}
|
||||||
|
add_log('enter',$income['inid'],$invoice);
|
||||||
|
$this->apiSuccess('操作成功');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->apiError('操作失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue