|
@@ -5,7 +5,11 @@ namespace app\cxinv\controller;
|
|
|
|
|
|
|
|
|
use app\cxinv\model\PayInvoice;
|
|
|
-use app\cxinv\model\PayReturn;use app\cxinv\model\RoleAction;use app\user\model\AccountCompany;use think\App;use think\facade\Validate;
|
|
|
+use app\cxinv\model\PayReturn;
|
|
|
+use app\cxinv\model\RoleAction;
|
|
|
+use app\user\model\AccountCompany;
|
|
|
+use think\App;
|
|
|
+use think\facade\Validate;
|
|
|
class Payinv extends Base{
|
|
|
public function __construct(App $app) {
|
|
|
parent::__construct($app);
|
|
@@ -138,18 +142,6 @@ class Payinv extends Base{
|
|
|
try{
|
|
|
$save= $info->save();
|
|
|
if ($save===false) throw new \Exception("修改失败");
|
|
|
- if ($params['status']==4){
|
|
|
- $invoice->check_time=date('Y-m-d H:i:s');
|
|
|
- $invoice->status=4;
|
|
|
- $res = $invoice->save();
|
|
|
- if ($res===false) throw new \Exception("发票状态修改失败");
|
|
|
- }
|
|
|
- if(in_array($params['status'],[5,6,7,8,13])){
|
|
|
- $invoice->status=2;
|
|
|
- $res = $invoice->save();
|
|
|
- if ($res===false) throw new \Exception('发票状态修改失败');
|
|
|
- \app\cxinv\model\InvoiceItem::rmInvoice($param['hpNo']);
|
|
|
- }
|
|
|
$this->model->commit();
|
|
|
}catch (\Exception $e){
|
|
|
$this->model->rollback();
|
|
@@ -157,7 +149,66 @@ class Payinv extends Base{
|
|
|
}
|
|
|
return success("修改成功");
|
|
|
}
|
|
|
+ /**批量上传待认证发票
|
|
|
+ * @param hpNo array 回票申请编号集合 必传
|
|
|
+ * @param relaComNo string 业务公司编号 企业账户
|
|
|
+ * @param companyNo string 业务公司编号 超管账户
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ */
|
|
|
+
|
|
|
+ //回票申请批量认证
|
|
|
+ public function hpBatchImport()
|
|
|
+ {
|
|
|
+ $post = $this->request->only(['list' => [], 'relaComNo' => '', 'companyNo' => ''], 'post');
|
|
|
+ $valid = Validate::rule([
|
|
|
+ 'list|回票申请编号集合' => 'require|array|max:100',
|
|
|
+ 'relaComNo|关联公司' => 'requireWithout:companyNo|max:255',
|
|
|
+ 'companyNo|公司编号' => 'requireWithout:relaComNo|max:255',
|
|
|
+ ]);
|
|
|
+ if ($valid->check($post) == false) return error_show(1004, $valid->getError());
|
|
|
+ $companyNo = $post['relaComNo'] ?: $post['companyNo'];
|
|
|
+ $payArr = $this->model
|
|
|
+ ->alias('a')
|
|
|
+ ->leftJoin('invoice b', 'a.payNo=b.InvCode')
|
|
|
+ ->where(['a.is_del' => 0])
|
|
|
+ ->whereIn('a.hpNo', array_column($post['list'], 'hpNo'))
|
|
|
+ ->column('a.id,a.payNo,a.hpNo,a.invoiceType,a.inv_fee as invoice_fee,a.status,b.companyNo,a.remark', 'a.hpNo');
|
|
|
+
|
|
|
+ $val_hpNo = Validate::rule([
|
|
|
+ 'hpNo|回票申请编号' => 'require',
|
|
|
+ 'status|审核状态' => 'require|number|in:4,7',
|
|
|
+ 'remark|审核备注' => 'requireIf:status,7|max:255'
|
|
|
+ ]);
|
|
|
+ $unique=[];
|
|
|
+ foreach ($post['list'] as $item) {
|
|
|
+ if (!$val_hpNo->check($item)) return error_show(1004, $val_hpNo->getError());
|
|
|
+ if(in_array($item['hpNo'],$unique))return error_show(1004, "{$item['hpNo']} 发票重复提交");
|
|
|
+ $unique[]=$item['hpNo'];
|
|
|
+ }
|
|
|
+ $this->model->startTrans();
|
|
|
+ try {
|
|
|
+ $saveAll=[];
|
|
|
+ foreach ($post['list'] as $val) {
|
|
|
+
|
|
|
+ if (!$val_hpNo->check($val)) throw new \Exception($val_hpNo->getError());
|
|
|
+ if (!isset($payArr[$val['hpNo']])) throw new \Exception("{$val['hpNo']}记录不存在");
|
|
|
|
|
|
+ $value = $payArr[$val['hpNo']];
|
|
|
+ $payinfo =Invoice::where(['InvCode'=>$payArr[$val['hpNo']]['payNo'],'status'=>3,'is_del'=>0])->findOrEmpty();
|
|
|
+ if(empty($payinfo)) throw new \Exception("{$value['hpNo']}发票信息有误");
|
|
|
+ if ($payinfo['companyNo'] == '') throw new \Exception("{$value['hpNo']}发票业务公司信息有误");
|
|
|
+ if ($payinfo['companyNo'] != $companyNo) throw new \Exception("{$value['hpNo']}不属于当前业务公司发票");
|
|
|
+ if ($value['status'] != '3') throw new \Exception("{$value['hpNo']}状态有误");
|
|
|
+ $saveAll[]=["id"=>$val['id'],"status"=>$val['status'],"remark"=>$val['status']==4?$value['remark']:$val['remark']];
|
|
|
+ }
|
|
|
+ $this->model->saveAll($saveAll);
|
|
|
+ $this->model->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->model->rollback();
|
|
|
+ return error_show(1004, $e->getMessage());
|
|
|
+ }
|
|
|
+ return app_show(0, '回票申请认证成功');
|
|
|
+ }
|
|
|
public function Back(){
|
|
|
$param= $this->request->param(['hpNo'=>'','reason'=>''],'post','trim');
|
|
|
$valide=Validate::rule([
|