Payment.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <?php
  2. namespace app\cxinv\controller;
  3. use app\cxinv\model\CgdInfo;use app\cxinv\model\FhdChild;use app\cxinv\model\InvoicePay;use app\cxinv\model\InvoicePool;use app\cxinv\model\OrderCategory;use app\cxinv\model\Pay;use app\cxinv\model\PayInfo;use app\cxinv\model\RoleAction;use app\cxinv\model\TagLog;use app\cxinv\model\Track;use app\user\model\AccountCompany;use app\user\model\Business;use app\user\model\Supplier;use think\App;use think\facade\Validate;
  4. class Payment extends Base{
  5. public function __construct(App $app) {
  6. parent::__construct($app);
  7. $this->model = new Pay();
  8. }
  9. public function create(){
  10. $params = $this->request->param(['cids'=>[]],"post","trim");
  11. $valid=Validate::rule(["cids|采购单id集合"=>"require|array"]);
  12. if ($valid->check($params)===false) return error($valid->getError());
  13. $cgdlist = CgdInfo::whereIn("id",$params['cids'])
  14. ->field("sequenceNo,supplierNo,totalPrice,companyNo,wpay_fee,winv_fee")->select();
  15. if($cgdlist->isEmpty())return error("采购单数据不能为空");
  16. $supplier =array_unique($cgdlist->column('supplierNo')) ;
  17. $company = array_unique($cgdlist->column("companyNo"));
  18. if (count($supplier)>1) return error("采购单数据供应商不一致");
  19. if (count($company)>1) return error("采购单数据业务公司不一致");
  20. if($this->level==2){
  21. $isBool = AccountCompany::SupplierHasAcount($supplier[0]);
  22. if ($isBool) return error('该供应商已经开通账号,不允许当前账号操作');
  23. }
  24. $orderCate = OrderCategory::where(['code'=>$cgdlist->column('sequenceNo')])->column("*","code");
  25. if(empty($orderCate)) return error("采购单数据商品进项类目不存在");
  26. $payNo=makeNo("PAY");
  27. $payinfo = [];
  28. $totalPrice='0';
  29. $wpay_fee = 0;
  30. $winv_fee=0;
  31. foreach ($cgdlist as $k=>$v){
  32. $temp= [
  33. "cgdNo"=>$v['sequenceNo'],
  34. "total_fee"=>$v['totalPrice'],
  35. "wapy_fee"=>$v['wpay_fee'],
  36. "winv_fee"=>$v['winv_fee'],
  37. "payNo"=>$payNo
  38. ];
  39. if (!isset($orderCate[$v['sequenceNo']])) return error("采购单{$v['sequenceNo']}数据商品进项类目不存在");
  40. if($v['status']==1) return error("采购单{$v['sequenceNo']}数据已付款");
  41. if($v['status']==2) return error("采购单{$v['sequenceNo']}数据不结算");
  42. $payinfo[]=$temp;
  43. $totalPrice+=$v['totalPrice'];
  44. $wpay_fee+=$v['wpay_fee'];
  45. $winv_fee+=$v['winv_fee'];
  46. }
  47. $paydata=[
  48. 'payNo'=>$payNo,
  49. 'apply_id'=>$this->uid,
  50. 'apply_name'=>$this->uname,
  51. 'total_fee'=>$totalPrice,
  52. 'is_comon'=>0,
  53. 'supplierNo'=>$supplier[0],
  54. 'supplierName'=>Supplier::where('code',$supplier[0])->value("name",''),
  55. 'companyNo'=>$company[0],
  56. 'companyName'=>Business::where("companyNo",$company[0])->value("company",""),
  57. 'wpay_fee'=>$wpay_fee,
  58. 'apay_fee'=>0,
  59. 'ainv_fee'=>0,
  60. 'winv_fee'=>$winv_fee,
  61. 'remark'=>'',
  62. 'status'=>1,
  63. ];
  64. $this->model->startTrans();
  65. try{
  66. $pay=$this->model->save($paydata);
  67. if(!$pay) throw new \Exception("创建付款单失败");
  68. $paysace =(new PayInfo())->saveAll($payinfo);
  69. if(!$paysace) throw new \Exception("创建付款单详情失败");
  70. $up= CgdInfo::whereIn("sequenceNo",array_column($payinfo,"cgdNo"))->update(['status'=>1]);
  71. if(!$up) throw new \Exception("更新采购单状态失败");
  72. $this->model->commit();
  73. }catch (\Exception $e){
  74. $this->model->rollback();
  75. return error($e->getMessage());
  76. }
  77. event("report_code",["type"=>"add","key"=>"payNo","value"=>$payNo,"main"=>['key'=>'cgdNo','value'=>array_column($payinfo,'cgdNo')]]);
  78. return success('创建付款单成功');
  79. }
  80. public function list(){
  81. $params = $this->request->param(['page'=>1,'size'=>20,'startTime'=>'',"endTime"=>"","supplierNo"=>"","payNo"=>"",
  82. "supplierName"=>"","pay_status"=>"","inv_status"=>"","tag_id"=>"","status"=>"",'companyNo'=>'','pay_type'=>1,
  83. 'companyName'=>'','is_comon'=>'',"relaComNo"=>""],"post","trim");
  84. $where=[['is_del','=',0],['pay_type','=',$params['pay_type']]];
  85. $check = RoleAction::checkRole($this->roleid, [77,117]);
  86. if ($check) $where[]=['apply_id','=',$this->uid];
  87. if ($params['startTime']!=="") $where[]=['addtime','>=',startTime($params['startTime'])];
  88. if ($params['endTime']!=="") $where[]=['addtime','<=',endTime($params['endTime'])];
  89. if ($params['supplierNo']!=="") $where[]=['supplierNo','like','%'.$params['supplierNo'].'%'];
  90. if ($params['payNo']!=="") $where[]=['payNo','like','%'.$params['payNo'].'%'];
  91. if ($params['supplierName']!=="") $where[]=['supplierName','like','%'.$params['supplierName'].'%'];
  92. if ($params['pay_status']!==""){
  93. if($params['pay_status']==0)$where[]=['pay_status','<>',3];
  94. else $where[]=['pay_status','=',$params['pay_status']];
  95. }
  96. if ($params['inv_status']!==""){
  97. if($params['inv_status']==0)$where[]=['inv_status','<>',3];
  98. else $where[]=['inv_status','=',$params['inv_status']];
  99. }
  100. if ($params['status']!=="") $where[]=['status','=',$params['status']];
  101. if ($params['tag_id']!=="") {
  102. $conditions_map = [
  103. 1 => ['inv_tag', '=', 1],
  104. 2 => ['pay_tag', '=', 1],
  105. 3 => ["pay_tag|inv_tag", '=', 1],
  106. 4 => ['pay_tag&inv_tag', '=', 1],
  107. ];
  108. $where[]=$conditions_map[$params['tag_id']];
  109. }
  110. if ($params['companyNo']!=="") $where[]=['companyNo','=',$params['companyNo']];
  111. if ($params['companyName']!=="") $where[]=['companyName','like','%'.$params['companyName'].'%'];
  112. if ($params['is_comon']!=="") $where[]=['is_comon','=',$params['is_comon']];
  113. if($params['relaComNo']!=="") $where[]=['companyNo|supplierNo','=',$params['relaComNo']];
  114. $list = $this->model->where($where)->order("id desc")->paginate(["list_rows"=>$params['size'],"page"=>$params['page']]);
  115. foreach ($list->items() as $k=>&$v){
  116. $v['cgd_inv_tag_total']=0;
  117. $v['cgd_pay_tag_total'] = 0;
  118. if( $v['pay_type']==1){
  119. $cgdNo = PayInfo::where(['payNo'=>$v['payNo'],'is_del'=>0,'status'=>1])->column("cgdNo");
  120. $cgdInfo = CgdInfo::where(['sequenceNo'=>$cgdNo,'is_del'=>0,'status'=>1])->select();
  121. if(!empty($cgdInfo)){
  122. $v['cgd_inv_tag_total'] =array_sum($cgdInfo->column('inv_tag_fee')) ;
  123. $v['cgd_pay_tag_total'] = array_sum($cgdInfo->column('pay_tag_fee'));
  124. }
  125. }
  126. $v['orderNum'] = PayInfo::where([['payNo','=',$v['payNo']],['is_del','=',0],['status','=',1]])->count();
  127. $v['inv_tag_name']='';
  128. $v['pay_tag_name']='';
  129. $v['pay_tag_img']='';
  130. $v['inv_tag_id']='0';
  131. $v['pay_tag_id']='0';
  132. $v['pay_tag_remark']='';
  133. $v['inv_tag_img']='';
  134. $v['inv_tag_remark']='';
  135. if($v['inv_tag']==1 || $v['pay_tag']==1){
  136. $tag = TagLog::alias("a")
  137. ->leftJoin("order_tag b", "a.tag_id=b.id")
  138. ->where(['code'=>$v['payNo'],'a.status'=>[1,2]])
  139. ->order("a.id desc")
  140. ->column('a.id,b.tag_name,a.tag_img,a.tag_remark','b.type');
  141. if($v['inv_tag']==1){
  142. $v['inv_tag_name']=$tag['2']['tag_name']??"";
  143. $v['inv_tag_img']=$tag['2']['tag_img']??'';
  144. $v['inv_tag_remark']=$tag['2']['tag_remark']??'';
  145. $v['inv_tag_id']=$tag['2']['id']??'';
  146. }
  147. if($v['pay_tag']==1){
  148. $v['pay_tag_name']=$tag['1']['tag_name']??'';
  149. $v['pay_tag_img']=$tag['1']['tag_img']??'';
  150. $v['pay_tag_remark']=$tag['1']['tag_remark']??'';
  151. $v['pay_tag_id']=$tag['1']['id']??'';
  152. }
  153. }
  154. $v['has_account'] = AccountCompany::SupplierHasAcount($v['supplierNo']);
  155. }
  156. return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
  157. }
  158. public function save(){
  159. $params = $this->request->param(["cids"=>[],"payNo"=>""],"post","trim");
  160. $valid=Validate::rule(["cids|采购单集合数据"=>"require|array","payNo|对账单编号"=>"require|max:255"]);
  161. if(!$valid->check($params)) return error($valid->getError());
  162. $pay = $this->model->where(['payNo'=>$params['payNo']])->findOrEmpty();
  163. if($pay->isEmpty()) return error("对账单不存在");
  164. if($pay['status']!=1) return error("对账单已提交审核");
  165. $cgdlist = CgdInfo::whereIn('id',$params['cids'])
  166. ->field('sequenceNo,supplierNo,totalPrice,companyNo,wpay_fee,winv_fee')->select();
  167. if($cgdlist->isEmpty())return error('采购单数据不能为空');
  168. $supplier =array_unique($cgdlist->column('supplierNo')) ;
  169. $company = array_unique($cgdlist->column('companyNo'));
  170. if (count($supplier)>1) return error('采购单数据供应商不一致');
  171. if (count($company)>1) return error('采购单数据业务公司不一致');
  172. if($this->level==2){
  173. $isBool = AccountCompany::SupplierHasAcount($supplier[0]);
  174. if ($isBool) return error('该供应商已经开通账号,不允许当前账号操作');
  175. }
  176. $orderCate = OrderCategory::where(['code'=>$cgdlist->column('sequenceNo')])->column('*','code');
  177. if(empty($orderCate)) return error('采购单数据商品进项类目不存在');
  178. $payCgd = PayInfo::where([['payNo','=',$params['payNo']],['is_del','=',0]])->column("cgdNo");
  179. if (!empty($payCgd)){
  180. $add = array_diff($cgdlist->column('sequenceNo'),$payCgd);
  181. $remove = array_diff($payCgd,$cgdlist->column('sequenceNo'));
  182. }
  183. $payinfo = [];
  184. $totalPrice='0';
  185. $wpay_fee = 0;
  186. $winv_fee=0;
  187. foreach ($cgdlist as $k=>$v){
  188. if(!empty($add)&& in_array($v['sequenceNo'],$add)){
  189. $temp= [
  190. 'cgdNo'=>$v['sequenceNo'],
  191. 'total_fee'=>$v['totalPrice'],
  192. 'wapy_fee'=>$v['wpay_fee'],
  193. 'winv_fee'=>$v['winv_fee'],
  194. 'payNo'=>$params['payNo']
  195. ];
  196. if (!isset($orderCate[$v['sequenceNo']])) return error("采购单{$v['sequenceNo']}数据商品进项类目不存在");
  197. if($v['status']==1) return error("采购单{$v['sequenceNo']}数据已付款");
  198. if($v['status']==2) return error("采购单{$v['sequenceNo']}数据不结算");
  199. $payinfo[]=$temp;
  200. }
  201. $totalPrice+=$v['totalPrice'];
  202. $wpay_fee+=$v['wpay_fee'];
  203. $winv_fee+=$v['winv_fee'];
  204. }
  205. $paydata=[
  206. 'total_fee'=>$totalPrice,
  207. 'supplierNo'=>$supplier[0],
  208. 'supplierName'=>Supplier::where('code',$supplier[0])->value('name',''),
  209. 'companyNo'=>$company[0],
  210. 'companyName'=>Business::where('companyNo',$company[0])->value('company',''),
  211. 'wpay_fee'=>$wpay_fee,
  212. 'winv_fee'=>$winv_fee,
  213. ];
  214. $this->model->startTrans();
  215. try{
  216. $paySave=$pay->save($paydata);
  217. if($paySave==false) throw new \Exception("对账单保存失败");
  218. if(!empty($payinfo)){
  219. $payinfoSave = (new \app\cxinv\model\PayInfo)->saveAll($payinfo);
  220. if($payinfoSave==false) throw new \Exception("对账单明细保存失败");
  221. $up = CgdInfo::where([['sequenceNo','in',$add],['status','=',0]])->save(['status'=>1, 'updatetime'=>date('Y-m-d H:i:s')]);
  222. if($up==false) throw new \Exception("采购单状态修改失败");
  223. }
  224. if (!empty($remove)){
  225. $payRemove = PayInfo::where([['cgdNo','in',$remove],['payNo','=',$params['payNo']]])->save(['is_del'=>1, 'updatetime'=>date('Y-m-d H:i:s')]);
  226. if($payRemove==false) throw new \Exception("对账单明细删除失败");
  227. $up = CgdInfo::where([['sequenceNo','in',$remove],['status','=',1]])->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  228. if($up==false) throw new \Exception("采购单状态修改失败");
  229. }
  230. $this->model->commit();
  231. event('report_code',['type'=>'add','key'=>'payNo','value'=>$params['payNo'],'main'=>['key'=>'cgdNo','value'=>$add]]);
  232. event('report_code',['type'=>'sub','key'=>'payNo','value'=>$params['payNo'],'main'=>['key'=>'cgdNo','value'=>$remove]]);
  233. }catch (\Exception $exception){
  234. $this->model->rollback();
  235. return error($exception->getMessage());
  236. }
  237. return success('保存成功');
  238. }
  239. public function status(){
  240. $params = $this->request->param(["payNo"=>"","status"=>"","remark"=>""],"post","trim");
  241. $valid = Validate::rule(["payNo|对账申请编号"=>"require|max:255","status|状态"=>"require|in:1,2,3,4","remark|备注"=>"max:255"]);
  242. if(!$valid->check($params)) return error($valid->getError());
  243. $pay = $this->model->where(['payNo'=>$params['payNo'],"is_del"=>0])->findOrEmpty();
  244. if($pay->isEmpty()) return error("对账单不存在");
  245. if($params["status"]==4){
  246. if($pay['inv_tag']==1)return error('存在回票标签未解除');
  247. if($pay['pay_tag']==1)return error('存在付款标签未解除');
  248. if($pay->pay_status!=1)return error('对账单存在未解除的付款金额');
  249. if($pay->inv_status!=1) return error('对账单存在未解除的开票金额');
  250. if($pay->pay_fee!=0 || $pay->apay_fee!=0)return error("对账单存在未解除的付款金额");
  251. if($pay->inv_fee!=0 || $pay->ainv_fee!=0) return error("对账单存在未解除的开票金额");
  252. if($pay->is_comon==1){
  253. $invoceAr=InvoicePay::where(['payNo'=>$params['payNo']])->column('invNo');
  254. if(!empty($invoceAr)){
  255. $ist= InvoicePool::where([['invNo','in',$invoceAr],['status','in',[0,1,2,3,4]]])->select()
  256. ->isEmpty();
  257. if($ist==false)return error('通用订单存在开票申请未解除');
  258. }
  259. }
  260. }
  261. $this->model->startTrans();
  262. try{
  263. $pay->status=$params["status"];
  264. $pay->remark=$params["remark"];
  265. $pay->updatetime=date("Y-m-d H:i:s");
  266. $paySave=$pay->save();
  267. if($paySave==false) throw new \Exception("对账单状态修改失败");
  268. if($params["status"]==4||$params["status"]==3){
  269. $cgdList= PayInfo::where(['payNo'=>$params['payNo'],'is_del'=>0,"status"=>1])->select();
  270. if(!$cgdList->isEmpty()){
  271. $cgdNo = $cgdList->column('cgdNo');
  272. if($pay["pay_type"]==1){
  273. $up = CgdInfo::where([['sequenceNo','in',$cgdNo],['status','=',1]])
  274. ->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  275. if($up==false) throw new \Exception("采购单状态修改失败");
  276. }
  277. else {
  278. $up = Track::where([['TrackCode','in',$cgdNo],['status','=',1]])->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  279. if($up==false) throw new \Exception('物流单状态修改失败');
  280. }
  281. }
  282. $payRemove = PayInfo::where(['payNo'=>$params['payNo'],'status'=>1,'is_del'=>0])->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  283. if($payRemove==false) throw new \Exception("对账单明细删除失败");
  284. }
  285. $this->model->commit();
  286. event('report_code',['type'=>'sub','key'=>'payNo','value'=>$params['payNo']]);
  287. if(($params['status']==3 || $params['status']==4)&&$pay['is_comon']==1){
  288. event('comonOrder',['payNo'=>$params['payNo'],'type'=>'check']);
  289. }
  290. }catch (\Exception $exception){
  291. $this->model->rollback();
  292. return error($exception->getMessage());
  293. }
  294. return success('保存成功');
  295. }
  296. public function delete(){
  297. $params = $this->request->param(["payNo"=>""],"post","trim");
  298. $valid = Validate::rule(["payNo|对账单编号"=>"require|max:255"]);
  299. if(!$valid->check($params)) return error($valid->getError());
  300. $pay = $this->model->where(['payNo'=>$params['payNo'],"is_del"=>0])->findOrEmpty();
  301. if($pay->isEmpty()) return error("对账单不存在");
  302. if($pay->status!=1)return error('对账单当前状态不可删除');
  303. if($this->level==2){
  304. $isBool = AccountCompany::SupplierHasAcount($pay->supplierNo);
  305. if ($isBool) return error('该供应商已经开通账号,不允许当前账号操作');
  306. }
  307. $payinfo = PayInfo::where(['payNo'=>$params['payNo'],"status"=>1,'is_del'=>0])->select();
  308. if($payinfo->isEmpty()) return error('该对账单没有明细');
  309. $this->model->startTrans();
  310. try{
  311. $pay->is_del=1;
  312. $pay->updatetime=date("Y-m-d H:i:s");
  313. $paySave=$pay->save();
  314. if($paySave==false) throw new \Exception("对账单删除失败");
  315. $payRemove = PayInfo::where([['payNo'=>$params['payNo'],"status"=>1,'is_del'=>0]])->save(["is_del"=>1, 'updatetime'=>date('Y-m-d H:i:s')]);
  316. if($payRemove==false) throw new \Exception("对账单明细删除失败");
  317. if ($pay->pay_type==1){
  318. $cgdNo=$payinfo->column('cgdNo');
  319. if(!empty($cgdNo)){
  320. $up = CgdInfo::where([['sequenceNo','in',$cgdNo],['status','=',1]])->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  321. if($up==false) throw new \Exception( "采购单状态修改失败");
  322. }else{
  323. $up = Track::where([['TrackCode','in',$cgdNo],['status','=',1]])->save(['status'=>0, 'updatetime'=>date('Y-m-d H:i:s')]);
  324. if($up==false) throw new \Exception('物流单状态修改失败');
  325. }
  326. }
  327. $this->model->commit();
  328. event('report_code',['type'=>'sub','key'=>'payNo','value'=>$params['payNo']]);
  329. }catch (\Exception $exception){
  330. $this->model->rollback();
  331. return error($exception->getMessage());
  332. }
  333. return success('删除成功');
  334. }
  335. public function info(){
  336. $params = $this->request->param(["payNo"=>""],"post","trim");
  337. $valid = Validate::rule(["payNo|对账单编号"=>"require|max:255"]);
  338. if(!$valid->check($params)) return error($valid->getError());
  339. $pay = $this->model->where(['payNo'=>$params['payNo'],"is_del"=>0])->findOrEmpty();
  340. if($pay->isEmpty()) return error("对账单不存在");
  341. $payinfo= PayInfo::where(['payNo'=>$params['payNo'],"is_del"=>0])->select();
  342. if($payinfo->isEmpty()) return error("对账单明细不存在");
  343. $cgdNo = $payinfo->column('cgdNo');
  344. $pay['cgd_inv_tag_total']=0;
  345. $pay['cgd_pay_tag_total'] = 0;
  346. if($pay->pay_type==1){
  347. $cgdInfo = CgdInfo::where(['sequenceNo'=>$cgdNo,'is_del'=>0,'status'=>1])->select();
  348. if(!$cgdInfo->isEmpty()){
  349. $pay['cgd_inv_tag_total'] =array_sum($cgdInfo->column('inv_tag_fee')) ;
  350. $pay['cgd_pay_tag_total'] = array_sum($cgdInfo->column('pay_tag_fee'));
  351. $cgdInfo = $cgdInfo->toArray();
  352. foreach ($cgdInfo as $key=>&$value){
  353. $value['inv_fee'] = $value['totalPrice']-$value['ainv_fee']-$value['winv_fee']-$value['inv_tag_fee'];
  354. $value['pay_fee'] = $value['totalPrice']-$value['apay_fee']-$value['wpay_fee']-$value['pay_tag_fee'];
  355. $value['orderTax'] = OrderCategory::where(['code'=>$value['sequenceNo'],'spuCode'=>$value['goodNo']])
  356. ->field(['cat_code', 'cat_name', 'merge_code', 'short_name', 'tax', 'inv_good_name'])->findOrEmpty();
  357. $value['catInfo'] = json_decode($value['catInfo'],true);
  358. $value['goodNum'] =$value['goodNum']- $value['thNum'];
  359. $value['sendNum'] =$value['sendNum']- $value['thNum'];
  360. if($pay['is_comon']==1){
  361. $value['qrdCode'] = (new \app\cxinv\model\ComonOrder())->where(['cgdNo'=>$value['sequenceNo']])->value('orderCode','');
  362. }
  363. }
  364. }
  365. }else{
  366. $cgdInfo = Track::where(['TrackCode'=>$cgdNo,'is_del'=>0])->select();
  367. if(!$cgdInfo->isEmpty()){
  368. $fhds = FhdChild::where(['outChildCode'=>$cgdInfo->column("outChildCode")])->column("outCode,good_name,spuCode,post_name,post_code","outChildCode");
  369. $cgdInfo = $cgdInfo->toArray();
  370. foreach ($cgdInfo as $key=>&$value){
  371. if(!isset($fhds[$value['outChildCode']]))$fhds[$value['outChildCode']]=["outCode"=>"","good_name"=>"","spuCode"=>"","post_name"=>"","post_code"=>""];
  372. $value = array_merge($value,$fhds[$value['outChildCode']]);
  373. }
  374. }
  375. }
  376. $pay['pay_type']=Supplier::where(['code'=>$pay['supplierNo']])->value("pay_type",'');
  377. $pay['inv_tag_name']='';
  378. $pay['pay_tag_name']='';
  379. $pay['pay_tag_img']='';
  380. $pay['inv_tag_id']='0';
  381. $pay['pay_tag_id']='0';
  382. $pay['pay_tag_remark']='';
  383. $pay['inv_tag_img']='';
  384. $pay['inv_tag_remark']='';
  385. if($pay['inv_tag']==1 || $pay['pay_tag']==1){
  386. $tag = TagLog::alias('a')
  387. ->leftJoin('order_tag b', 'a.tag_id=b.id')
  388. ->where(['code'=>$pay['payNo'],'a.status'=>[1,2]])
  389. ->order('a.id desc')
  390. ->column('a.id,b.tag_name,a.tag_img,a.tag_remark','b.type');
  391. if($pay['inv_tag']==1){
  392. $pay['inv_tag_name']=$tag['2']['tag_name']??'';
  393. $pay['inv_tag_img']=$tag['2']['tag_img']??'';
  394. $pay['inv_tag_remark']=$tag['2']['tag_remark']??'';
  395. $pay['inv_tag_id']=$tag['2']['id']??'';
  396. }
  397. if($pay['pay_tag']==1){
  398. $pay['pay_tag_name']=$tag['1']['tag_name']??'';
  399. $pay['pay_tag_img']=$tag['1']['tag_img']??'';
  400. $pay['pay_tag_remark']=$tag['1']['tag_remark']??'';
  401. $pay['pay_tag_id']=$tag['1']['id']??'';
  402. }
  403. }
  404. $pay['cgdlist']= $cgdInfo;
  405. return success("获取成功",$pay);
  406. }
  407. }