PaymentReceiptService.php 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. <?php
  2. namespace App\Service;
  3. use App\Model\BasicType;
  4. use App\Model\Employee;
  5. use App\Model\PaymentReceipt;
  6. use App\Model\PaymentReceiptInfo;
  7. use App\Model\PurchaseOrder;
  8. use App\Model\PurchaseOrderSpecial;
  9. use App\Model\ReturnExchangeOrder;
  10. use App\Model\SalesOrder;
  11. use Carbon\Carbon;
  12. use Illuminate\Support\Facades\DB;
  13. class PaymentReceiptService extends Service
  14. {
  15. public function paymentReceiptGet($data,$user){
  16. $order_number = (new OrderNoService())->createOrderNumber(PaymentReceipt::prefix);
  17. if(! $order_number) return [false,'工单编号生成失败!'];
  18. return [true,['order_number' => $order_number]];
  19. }
  20. public function customerEdit($data,$user){
  21. list($status,$msg) = $this->customerRule($data,$user, false);
  22. if(!$status) return [$status,$msg];
  23. try {
  24. DB::beginTransaction();
  25. $model = PaymentReceipt::where('id',$data['id'])->first();
  26. // $model->data_order_no = $data['data_order_no'];
  27. // $model->data_type = $data['data_type'];
  28. $model->type = $data['type'];
  29. $model->account = $data['account'] ?? 0;
  30. $model->pay_way = $data['pay_way'] ?? 0;
  31. // $model->amount = $data['amount'] ?? 0;
  32. $model->mark = $data['mark'] ?? '';
  33. $model->payment_receipt_date = $data['payment_receipt_date'] ?? 0;
  34. $model->save();
  35. $time = time();
  36. $old = PaymentReceiptInfo::where('del_time',0)
  37. ->where('payment_receipt_id',$data['id'])
  38. ->select('file')
  39. ->get()->toArray();
  40. $old = array_column($old,'file');
  41. PaymentReceiptInfo::where('del_time',0)
  42. ->where('payment_receipt_id',$data['id'])
  43. ->update(['del_time' => $time]);
  44. $new = [];
  45. if(! empty($data['file'])){
  46. $insert = [];
  47. foreach ($data['file'] as $value){
  48. $insert[] = [
  49. 'payment_receipt_id' => $model->id,
  50. 'file' => $value['url'],
  51. 'type' => PaymentReceiptInfo::type_one,
  52. 'name' => $value['name'],
  53. 'crt_time' => $time,
  54. ];
  55. if(in_array($value['url'], $old)) {
  56. foreach ($old as $o_k => $o_v){
  57. if($o_v == $value['url']) unset($old[$o_k]);
  58. }
  59. }else{
  60. $new[] = $value['url'];
  61. }
  62. }
  63. PaymentReceiptInfo::insert($insert);
  64. }
  65. if(! empty($data['employee_one'])){
  66. $insert = [];
  67. foreach ($data['employee_one'] as $value){
  68. $insert[] = [
  69. 'payment_receipt_id' => $model->id,
  70. 'data_id' => $value,
  71. 'type' => PaymentReceiptInfo::type_two,
  72. 'crt_time' => $time,
  73. ];
  74. }
  75. PaymentReceiptInfo::insert($insert);
  76. }
  77. if(! empty($data['amount_list'])){
  78. $insert = [];
  79. foreach ($data['amount_list'] as $value){
  80. $insert[] = [
  81. 'payment_receipt_id' => $model->id,
  82. 'data_type' => $data['type'],
  83. 'data_order_no' => $value['data_order_no'],
  84. 'data_order_type' => $data['data_type'],
  85. 'amount' => $value['amount'],
  86. 'type' => PaymentReceiptInfo::type_three,
  87. 'crt_time' => $time,
  88. ];
  89. }
  90. PaymentReceiptInfo::insert($insert);
  91. }
  92. DB::commit();
  93. }catch (\Exception $exception){
  94. DB::rollBack();
  95. return [false,$exception->getMessage()];
  96. }
  97. if(! empty($data['check'])) {
  98. list($status,$msg) = (new CheckService())->checkAll([
  99. "id" => $data['id'],
  100. "order_number" => $data['order_number'],
  101. "opt_case" => CheckService::ten,
  102. "menu_id" => $data['menu_id']
  103. ],$user);
  104. // if(! $status) return [true, '保存成功,收付款确认失败,异常信息:' . $msg];
  105. }
  106. return [true, ['file' => ['new' => $new, 'old' => $old]]];
  107. }
  108. public function customerAdd($data,$user){
  109. list($status,$msg) = $this->customerRule($data,$user);
  110. if(!$status) return [$status,$msg];
  111. try {
  112. DB::beginTransaction();
  113. $model = new PaymentReceipt();
  114. $model->order_number = $data['order_number'];
  115. // $model->data_order_no = $data['data_order_no'];
  116. $model->data_type = $data['data_type'];
  117. $model->type = $data['type'];
  118. $model->account = $data['account'] ?? 0;
  119. $model->pay_way = $data['pay_way'] ?? 0;
  120. // $model->amount = $data['amount'] ?? 0;
  121. $model->mark = $data['mark'] ?? '';
  122. $model->crt_id = $user['id'];
  123. $model->depart_id = $data['depart_id'];
  124. $model->top_depart_id = $data['top_depart_id'];
  125. $model->payment_receipt_date = $data['payment_receipt_date'] ?? 0;
  126. $model->save();
  127. $time = time();
  128. $new = [];
  129. if(! empty($data['file'])){
  130. $insert = [];
  131. foreach ($data['file'] as $value){
  132. $insert[] = [
  133. 'payment_receipt_id' => $model->id,
  134. 'file' => $value['url'],
  135. 'type' => PaymentReceiptInfo::type_one,
  136. 'name' => $value['name'],
  137. 'crt_time' => $time,
  138. ];
  139. if(! empty($value['url'])) $new[] = $value['url'];
  140. }
  141. PaymentReceiptInfo::insert($insert);
  142. }
  143. if(! empty($data['employee_one'])){
  144. $insert = [];
  145. foreach ($data['employee_one'] as $value){
  146. $insert[] = [
  147. 'payment_receipt_id' => $model->id,
  148. 'data_id' => $value,
  149. 'type' => PaymentReceiptInfo::type_two,
  150. 'crt_time' => $time,
  151. ];
  152. }
  153. PaymentReceiptInfo::insert($insert);
  154. }
  155. if(! empty($data['amount_list'])){
  156. $insert = [];
  157. foreach ($data['amount_list'] as $value){
  158. $insert[] = [
  159. 'payment_receipt_id' => $model->id,
  160. 'data_type' => $data['type'],
  161. 'data_order_no' => $value['data_order_no'],
  162. 'data_order_type' => $data['data_type'],
  163. 'amount' => $value['amount'],
  164. 'type' => PaymentReceiptInfo::type_three,
  165. 'crt_time' => $time,
  166. ];
  167. }
  168. PaymentReceiptInfo::insert($insert);
  169. }
  170. DB::commit();
  171. }catch (\Exception $exception){
  172. DB::rollBack();
  173. if (str_contains($exception->getMessage(), '1062') || str_contains($exception->getMessage(), 'Duplicate entry')) {
  174. return [false, '收付款单编号已存在,请重新获取!'];
  175. }
  176. return [false,$exception->getMessage()];
  177. }
  178. if(! empty($data['check'])) {
  179. list($status,$msg) = (new CheckService())->checkAll([
  180. "id" => $model->id,
  181. "order_number" => $data['order_number'],
  182. "opt_case" => CheckService::ten,
  183. "menu_id" => $data['menu_id']
  184. ],$user);
  185. // if(! $status) return [true, '保存成功,收付款确认失败,异常信息:' . $msg];
  186. }
  187. return [true, ['file' => ['new' => $new]]];
  188. }
  189. public function customerDel($data){
  190. if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
  191. $booking = PaymentReceipt::where('del_time',0)->where('id',$data['id'])->first();
  192. if(empty($booking)) return [false,'收付款单不存在或已被删除'];
  193. $booking = $booking->toArray();
  194. if($booking['state'] > PaymentReceipt::STATE_ZERO) return [false,'请确认收付款单状态,删除失败'];
  195. try {
  196. DB::beginTransaction();
  197. $time = time();
  198. $old = PaymentReceiptInfo::where('del_time',0)
  199. ->where('payment_receipt_id',$data['id'])
  200. ->select('file')
  201. ->get()->toArray();
  202. $old = array_column($old,'file');
  203. PaymentReceipt::where('id',$data['id'])->update([
  204. 'del_time'=> $time
  205. ]);
  206. PaymentReceiptInfo::where('del_time',0)
  207. ->where('payment_receipt_id',$data['id'])
  208. ->update(['del_time' => $time]);
  209. DB::commit();
  210. }catch (\Exception $exception){
  211. DB::rollBack();
  212. return [false,$exception->getMessage()];
  213. }
  214. return [true, ['file' => ['old' => $old]]];
  215. }
  216. public function customerDetail($data){
  217. if(empty($data['id']) && empty($data['order_number'])) return [false,'请选择数据!'];
  218. if(! empty($data['id'])){
  219. $customer = PaymentReceipt::where('del_time',0)
  220. ->where('id',$data['id'])
  221. ->first();
  222. }else{
  223. $customer = PaymentReceipt::where('del_time',0)
  224. ->where('order_number',$data['order_number'])
  225. ->first();
  226. $data['id'] = empty($customer->id) ? 0 : $customer->id;
  227. }
  228. if(empty($customer)) return [false,'收付款记录不存在或已被删除'];
  229. $customer = $customer->toArray();
  230. $array = [
  231. $customer['account'],
  232. $customer['pay_way'],
  233. ];
  234. $basic_map = BasicType::whereIn('id',$array)
  235. ->pluck('title','id')
  236. ->toArray();
  237. $customer['account_title'] = $basic_map[$customer['account']] ?? "";
  238. $customer['pay_way_title'] = $basic_map[$customer['pay_way']] ?? "";
  239. $customer['type_title'] = PaymentReceipt::$model_type[$customer['type']] ?? "";
  240. $customer['data_type_title'] = PaymentReceipt::$data_type[$customer['data_type']] ?? "";
  241. $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
  242. $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
  243. $customer['payment_receipt_date'] = $customer['payment_receipt_date'] ? date("Y-m-d",$customer['payment_receipt_date']): '';
  244. //订单状态数据组织
  245. $state_array = $this->getStateMake([$customer]);
  246. $customer['state_title'] = $this->makeState($customer,$state_array);
  247. $file = PaymentReceiptInfo::where('del_time',0)
  248. ->whereIn('type',[PaymentReceiptInfo::type_one,PaymentReceiptInfo::type_two])
  249. ->where('payment_receipt_id',$data['id'])
  250. ->get()->toArray();
  251. $emp_id = [];
  252. foreach ($file as $value){
  253. if(in_array($value['type'],PaymentReceiptInfo::$man)){
  254. $emp_id[] = $value['data_id'];
  255. }
  256. }
  257. $emp_map = Employee::whereIn('id',array_unique($emp_id))
  258. ->pluck('emp_name','id')
  259. ->toArray();
  260. $customer['file'] = $customer['employee_one'] = [];
  261. $fileUploadService = new FileUploadService();
  262. foreach ($file as $value){
  263. if($value['type'] == PaymentReceiptInfo::type_one){
  264. $tmp = [
  265. 'url' => $value['file'],
  266. 'name' => $value['name'],
  267. 'show_url' => $fileUploadService->getFileShow($value['file']),
  268. ];
  269. $customer['file'][] = $tmp;
  270. }elseif (in_array($value['type'],PaymentReceiptInfo::$man)){
  271. $tt = $emp_map[$value['data_id']] ?? '';
  272. if(! empty($tt)){
  273. $tmp = [
  274. 'id' => $value['data_id'],
  275. 'name' => $emp_map[$value['data_id']] ?? '',
  276. ];
  277. if($value['type'] == PaymentReceiptInfo::type_two){
  278. $customer['employee_one'][] = $tmp;
  279. }
  280. }
  281. }
  282. }
  283. //组织金额
  284. $customer['amount_list'] = $this->makeDetail($customer);
  285. return [true, $customer];
  286. }
  287. public function makeDetail($data){
  288. $return = [];
  289. $info = PaymentReceiptInfo::where('del_time',0)
  290. ->where('type',PaymentReceiptInfo::type_three)
  291. ->where('payment_receipt_id', $data['id'])
  292. ->select('payment_receipt_id','data_order_type','data_type','amount','data_order_no')
  293. ->get()->toArray();
  294. $order_no = array_column($info,'data_order_no');
  295. //退换货金额
  296. if($data['type'] == PaymentReceipt::type_one){
  297. if($data['data_type'] == PaymentReceipt::data_type_one){
  298. $order = SalesOrder::where('del_time',0)
  299. ->whereIn('order_number',$order_no)
  300. ->pluck('contract_fee','order_number')
  301. ->toArray();
  302. $getDifferentAmountALL = (new ReturnExchangeOrderService())->getDifferentAmountALL2(array_keys($order));
  303. }else{
  304. $order = PurchaseOrder::where('del_time',0)
  305. ->whereIn('order_number',$order_no)
  306. ->pluck('purchase_total','order_number')
  307. ->toArray();
  308. $getDifferentAmountALL = (new ReturnExchangeOrderService())->getDifferentAmountALL2(array_keys($order), ReturnExchangeOrder::Order_type2);
  309. }
  310. }
  311. //除自己这个收付款单外 所有订单已填的金额
  312. $infos = PaymentReceiptInfo::where('del_time',0)
  313. ->where('type',PaymentReceiptInfo::type_three)
  314. ->where('data_type',$data['type'])
  315. ->where('payment_receipt_id','<>',$data['id'])
  316. ->whereIn('data_order_no',$order_no)
  317. ->get()->toArray();
  318. $infos_map = [];
  319. foreach ($infos as $value){
  320. if(isset($infos_map[$value['data_order_no']])){
  321. $infos_map[$value['data_order_no']] += $value['amount'];
  322. }else{
  323. $infos_map[$value['data_order_no']] = $value['amount'];
  324. }
  325. }
  326. //收款金额(审核后)
  327. $info_one_array = [];
  328. if($data['type'] == PaymentReceipt::type_three){
  329. $info_one = PaymentReceiptInfo::from('payment_receipt_info as a')
  330. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  331. ->where('b.state',PaymentReceipt::STATE_TWO)
  332. ->where('b.del_time',0)
  333. ->where('a.del_time',0)
  334. ->where('a.type',PaymentReceiptInfo::type_three)
  335. ->where('a.data_order_type',PaymentReceipt::data_type_one)
  336. ->whereIn('a.data_order_no',$order_no)
  337. ->where('a.data_type',PaymentReceipt::type_one)
  338. ->select('a.data_order_no','a.amount')
  339. ->get()->toArray();
  340. $info_one_array = [];
  341. foreach ($info_one as $value){
  342. if(isset($info_one_array[$value['data_order_no']])){
  343. $info_one_array[$value['data_order_no']] += $value['amount'];
  344. }else{
  345. $info_one_array[$value['data_order_no']] = $value['amount'];
  346. }
  347. }
  348. }
  349. foreach ($info as $value){
  350. $total = $tmp_receipt = 0;
  351. if($data['type'] == PaymentReceipt::type_one){
  352. //收款 = 总金额 - 已收 - 退货退款
  353. //总金额
  354. $total_amount = $order[$value['data_order_no']] ?? 0;
  355. //已收
  356. $tmp_receipt = $infos_map[$value['data_order_no']] ?? 0;
  357. //退货退款
  358. $tmp_return = $getDifferentAmountALL[$value['data_order_no']] ?? 0;
  359. //收款
  360. $total = bcsub(bcsub($total_amount, $tmp_receipt,2), $tmp_return, 2);
  361. }elseif($data['type'] == PaymentReceipt::type_three){
  362. //红冲 = 审核后的收款金额 - 已红冲
  363. //总金额 收款金额(审核后)
  364. $total_amount = $info_one_array[$value['data_order_no']] ?? 0;
  365. //已红冲
  366. $tmp_receipt = $infos_map[$value['data_order_no']] ?? 0;
  367. //红冲
  368. $total = bcsub($total_amount, $tmp_receipt, 2);
  369. }
  370. $tmp = [
  371. 'data_order_no' => $value['data_order_no'],
  372. 'total_amount' => $total,//总共能填的金额
  373. 'has_amount' => $tmp_receipt,//已经填的金额
  374. 'amount' => $value['amount'],//本单金额
  375. 'receipt_amount' => $value['amount'],//本单金额
  376. ];
  377. $return[] = $tmp;
  378. }
  379. return $return;
  380. }
  381. public function customerCommon($data,$user,$field = []){
  382. if(empty($field)){
  383. $field = ['type','id','data_type','order_number','data_order_no','amount','account','pay_way','crt_id','crt_time','mark','state','payment_receipt_date'];
  384. }
  385. $model = PaymentReceipt::Clear($user,$data);
  386. $model = $model->where('del_time',0)
  387. ->select($field)
  388. ->orderby('id', 'desc');
  389. if(isset($data['state'])) $model->where('state', $data['state']);
  390. if(! empty($data['data_order_no'])) {
  391. $id = $this->searchForDataOrder($data['data_order_no']);
  392. $model->whereIn('id', $id);
  393. }
  394. if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
  395. if(! empty($data['data_type'])) $model->where('data_type', $data['data_type']);
  396. if(! empty($data['type'])) $model->where('type', $data['type']);
  397. if(! empty($data['account'])) $model->where('account',$data['account']);
  398. if(! empty($data['pay_way'])) $model->where('pay_way',$data['pay_way']);
  399. if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
  400. if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
  401. $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
  402. $model->where('crt_time','>=',$return[0]);
  403. $model->where('crt_time','<=',$return[1]);
  404. }
  405. if(! empty($data['payment_receipt_date'][0]) && ! empty($data['payment_receipt_date'][1])){
  406. $return = $this->changeDateToTimeStampAboutRange($data['payment_receipt_date']);
  407. $model->where('payment_receipt_date','>=',$return[0]);
  408. $model->where('payment_receipt_date','<=',$return[1]);
  409. }
  410. if(! empty($data['belong'])){
  411. $id = (new RangeService())->paymentReceiptSearch($data);
  412. $model->whereIn('id',$id);
  413. }
  414. if(! empty($data['smart_search'])){
  415. $id = $this->searchForDataOrder($data['smart_search']);
  416. $model->where('order_number', 'LIKE', '%'.$data['smart_search'].'%')
  417. ->OrWhereIn('id',$id);
  418. }
  419. if(! empty($data['wx_crt_time'][0]) && ! empty($data['wx_crt_time'][1])) {
  420. $model->where('crt_time','>=',$data['wx_crt_time'][0]);
  421. $model->where('crt_time','<=',$data['wx_crt_time'][1]);
  422. }
  423. return $model;
  424. }
  425. public function searchForDataOrder($message){
  426. $info = PaymentReceiptInfo::where('del_time',0)
  427. ->where('type',PaymentReceiptInfo::type_three)
  428. ->where('data_order_no', 'LIKE', '%'.$message.'%')
  429. ->select('payment_receipt_id')
  430. ->get()->toArray();
  431. return array_unique(array_column($info,'payment_receipt_id'));
  432. }
  433. public function customerList($data,$user){
  434. $model = $this->customerCommon($data, $user);
  435. $list = $this->limit($model,'',$data);
  436. $list = $this->fillData($list, $data);
  437. $count = $this->countData("crt_time", $data, $user);
  438. $list['today'] = $count[0] ?? 0;
  439. $list['yesterday'] = $count[1] ?? 0;
  440. return [true, $list];
  441. }
  442. public function customerRule(&$data, $user, $is_add = true){
  443. if(empty($data['order_number'])) return [false,'收付款单编号不能为空'];
  444. if(empty($data['data_type'])) return [false,'关联单号类型不能为空'];
  445. if(! isset(PaymentReceipt::$data_type[$data['data_type']])) return [false, '关联单号类型不存在'];
  446. if(empty($data['type'])) return [false,'收付款类型不能为空'];
  447. if(! isset(PaymentReceipt::$model_type[$data['type']])) return [false, '收付款类型不存在'];
  448. if(empty($data['amount_list']) || ! is_array($data['amount_list'])) return [false,'关联单号与金额不能为空'];
  449. foreach ($data['amount_list'] as $value){
  450. if(empty($value['data_order_no'])) return [false,'关联单号不能为空'];
  451. if(empty($value['amount'])) return [false,'金额不能为空'];
  452. if(floatval($value['amount']) == 0) return [false, '金额请输入大于0的数值'];
  453. $res = $this->checkNumber($value['amount']);
  454. if(! $res) return [false, '金额请输入不超过两位小数并且大于0的数值'];
  455. }
  456. if(! empty($data['payment_receipt_date'])) $data['payment_receipt_date'] = $this->changeDateToDate($data['payment_receipt_date']);
  457. //所属部门 以及 顶级部门
  458. if(empty($data['depart_id'])) {
  459. $data['depart_id'] = $this->getDepart($user);
  460. $data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
  461. }
  462. if($is_add){
  463. $bool = PaymentReceipt::where('del_time',0)
  464. ->where('order_number',$data['order_number'])
  465. ->exists();
  466. if($bool) return [false,'收付款单编号已存在,请重新获取'];
  467. }else{
  468. if(empty($data['id'])) return [false,'ID不能为空'];
  469. $booking = PaymentReceipt::where('del_time',0)->where('id',$data['id'])->first();
  470. if(empty($booking)) return [false,'收付款单不存在或已被删除'];
  471. $booking = $booking->toArray();
  472. if(! in_array($booking['state'],[PaymentReceipt::STATE_ZERO,PaymentReceipt::State_minus_one])) return [false,'请确认收付款单状态,编辑失败'];
  473. //订单编辑提交限制
  474. $current_top_depart_id = $this->getMyTopDepart($user);
  475. list($status, $msg) = $this->returnOrderEditErrorCommon($current_top_depart_id, $booking['top_depart_id']);
  476. if(! $status) return [false, $msg];
  477. }
  478. list($status,$msg) = $this->checkRule($data);
  479. if(! $status) return [false, $msg];
  480. return [true, ''];
  481. }
  482. public function checkRule($data){
  483. $payment_receipt_id = $data['id'] ?? 0;
  484. $map = [];
  485. foreach ($data['amount_list'] as $value){
  486. $map[$value['data_order_no']] = $value['amount'];
  487. }
  488. $search = array_keys($map);
  489. if($data['data_type'] == PaymentReceipt::data_type_one){ //合同逻辑
  490. //总金额
  491. $result = SalesOrder::where('del_time',0)
  492. ->whereIn('order_number',$search)
  493. ->select('id','order_number','contract_fee as total_amount')
  494. ->get()->toArray();
  495. $result_map = array_column($result,null,'order_number');
  496. if(count($search) != count($result)) {
  497. foreach ($search as $value){
  498. if(! isset($result_map[$value])) return [false, $value . '不存在或已被删除'];
  499. }
  500. }
  501. $result_map = array_column($result,'order_number','id');
  502. //收付款金额
  503. $info = PaymentReceiptInfo::where('del_time',0)
  504. ->where('type',PaymentReceiptInfo::type_three)
  505. ->where('data_order_type',PaymentReceipt::data_type_one)
  506. ->whereIn('data_order_no',$search)
  507. // ->where('data_type',$data['type'])
  508. ->select('payment_receipt_id','data_order_no','amount','data_type')
  509. ->get()->toArray();
  510. $info_array = $red = [];
  511. foreach ($info as $value){
  512. if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
  513. if($value['data_type'] == PaymentReceipt::type_one){
  514. if(isset($info_array[$value['data_order_no']])){
  515. $info_array[$value['data_order_no']] += $value['amount'];
  516. }else{
  517. $info_array[$value['data_order_no']] = $value['amount'];
  518. }
  519. }elseif($value['data_type'] == PaymentReceipt::type_three){
  520. if(isset($red[$value['data_order_no']])){
  521. $red[$value['data_order_no']] += $value['amount'];
  522. }else{
  523. $red[$value['data_order_no']] = $value['amount'];
  524. }
  525. }
  526. }
  527. //退货退款金额
  528. $return_exchange = (new ReturnExchangeOrderService())->getDifferentAmountALL(array_column($result,'id'));
  529. if($data['type'] == PaymentReceipt::type_one){
  530. // order_number => amount
  531. $return_exchange_array = [];
  532. foreach ($result_map as $key => $value){
  533. if(isset($return_exchange[$key])) $return_exchange_array[$value] = $return_exchange[$key];
  534. }
  535. foreach ($result as $value){
  536. //收款 = 总金额 - (已收 - 红冲) - 退货退款
  537. //$max = $value['total_amount'] - $tmp_receipt - $tmp_return;
  538. $tmp_receipt = $info_array[$value['order_number']] ?? 0;
  539. $tmp_red = $red[$value['order_number']] ?? 0;
  540. $tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
  541. $max = bcsub(bcsub($value['total_amount'], bcsub($tmp_receipt,$tmp_red,2),2), $tmp_return, 2);
  542. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  543. }
  544. }elseif($data['type'] == PaymentReceipt::type_three){
  545. //收款金额(审核后)
  546. $info_one = PaymentReceiptInfo::from('payment_receipt_info as a')
  547. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  548. ->where('b.state',PaymentReceipt::STATE_TWO)
  549. ->where('b.del_time',0)
  550. ->where('a.del_time',0)
  551. ->where('a.type',PaymentReceiptInfo::type_three)
  552. ->where('a.data_order_type',PaymentReceipt::data_type_one)
  553. ->whereIn('a.data_order_no',$search)
  554. ->where('a.data_type',PaymentReceipt::type_one)
  555. ->select('a.payment_receipt_id','a.data_order_no','a.amount')
  556. ->get()->toArray();
  557. $info_one_array = [];
  558. foreach ($info_one as $value){
  559. if(isset($info_one_array[$value['data_order_no']])){
  560. $info_one_array[$value['data_order_no']] += $value['amount'];
  561. }else{
  562. $info_one_array[$value['data_order_no']] = $value['amount'];
  563. }
  564. }
  565. foreach ($result as $value){
  566. //红冲 = 审核后的收款单金额 - 已红冲
  567. $tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
  568. $tmp_return = $red[$value['order_number']] ?? 0;
  569. $max = bcsub($tmp_receipt, $tmp_return, 2);
  570. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  571. }
  572. }
  573. }elseif ($data['data_type'] == PaymentReceipt::data_type_two){//采购逻辑
  574. //总金额
  575. $result = PurchaseOrder::where('del_time',0)
  576. ->whereIn('order_number',$search)
  577. ->select('id','order_number','purchase_total as total_amount')
  578. ->get()->toArray();
  579. $result_map = array_column($result,null,'order_number');
  580. if(count($search) != count($result)) {
  581. foreach ($search as $value){
  582. if(! isset($result_map[$value])) return [false, $value . '不存在或已被删除'];
  583. }
  584. }
  585. $result_map = array_column($result,'order_number','id');
  586. //收付款金额
  587. $info = PaymentReceiptInfo::where('del_time',0)
  588. ->where('type',PaymentReceiptInfo::type_three)
  589. ->where('data_order_type',PaymentReceipt::data_type_two)
  590. ->whereIn('data_order_no',$search)
  591. // ->where('data_type',$data['type'])
  592. ->select('payment_receipt_id','data_order_no','amount','data_type')
  593. ->get()->toArray();
  594. $info_array = $red = [];
  595. foreach ($info as $value){
  596. if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
  597. if($value['data_type'] == PaymentReceipt::type_one){
  598. if(isset($info_array[$value['data_order_no']])){
  599. $info_array[$value['data_order_no']] += $value['amount'];
  600. }else{
  601. $info_array[$value['data_order_no']] = $value['amount'];
  602. }
  603. }elseif($value['data_type'] == PaymentReceipt::type_three){
  604. if(isset($red[$value['data_order_no']])){
  605. $red[$value['data_order_no']] += $value['amount'];
  606. }else{
  607. $red[$value['data_order_no']] = $value['amount'];
  608. }
  609. }
  610. }
  611. //退货退款金额
  612. $return_exchange = (new ReturnExchangeOrderService())->getDifferentAmountALL(array_column($result,'id'),1);
  613. if($data['type'] == PaymentReceipt::type_one){
  614. $return_exchange_array = [];
  615. foreach ($result_map as $key => $value){
  616. // order_number => amount
  617. if(isset($return_exchange[$key])) $return_exchange_array[$value] = $return_exchange[$key];
  618. }
  619. foreach ($result as $value){
  620. //收款 = 总金额 - (已收 - 红冲) - 退货退款
  621. //$max = $value['total_amount'] - $tmp_receipt - $tmp_return;
  622. $tmp_receipt = $info_array[$value['order_number']] ?? 0;
  623. $tmp_red = $red[$value['order_number']] ?? 0;
  624. $tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
  625. $max = bcsub(bcsub($value['total_amount'], bcsub($tmp_receipt,$tmp_red,2),2), $tmp_return, 2);
  626. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  627. }
  628. }elseif($data['type'] == PaymentReceipt::type_three){
  629. //收款金额(审核后)
  630. $info_one = PaymentReceiptInfo::from('payment_receipt_info as a')
  631. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  632. ->where('b.state',PaymentReceipt::STATE_TWO)
  633. ->where('b.del_time',0)
  634. ->where('a.del_time',0)
  635. ->where('a.type',PaymentReceiptInfo::type_three)
  636. ->where('a.data_order_type',PaymentReceipt::data_type_one)
  637. ->whereIn('a.data_order_no',$search)
  638. ->where('a.data_type',PaymentReceipt::type_one)
  639. ->select('a.payment_receipt_id','a.data_order_no','a.amount')
  640. ->get()->toArray();
  641. $info_one_array = [];
  642. foreach ($info_one as $value){
  643. if(isset($info_one_array[$value['data_order_no']])){
  644. $info_one_array[$value['data_order_no']] += $value['amount'];
  645. }else{
  646. $info_one_array[$value['data_order_no']] = $value['amount'];
  647. }
  648. }
  649. foreach ($result as $value){
  650. //红冲 = 审核后的收款单金额 - 已红冲
  651. $tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
  652. $tmp_return = $red[$value['order_number']] ?? 0;
  653. $max = bcsub($tmp_receipt, $tmp_return, 2);
  654. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  655. }
  656. }
  657. }elseif ($data['data_type'] == PaymentReceipt::data_type_three){//虚拟采购
  658. //总金额
  659. $result = PurchaseOrderSpecial::where('del_time',0)
  660. ->whereIn('order_number',$search)
  661. ->select('id','order_number','purchase_total as total_amount','other_fee','sales_order_id')
  662. ->get()->toArray();
  663. $result_map = array_column($result,null,'order_number');
  664. if(count($search) != count($result)) {
  665. foreach ($search as $value){
  666. if(! isset($result_map[$value])) return [false, $value . '不存在或已被删除'];
  667. }
  668. }
  669. $result_map = array_column($result,'order_number','sales_order_id');
  670. //收付款金额
  671. $info = PaymentReceiptInfo::where('del_time',0)
  672. ->where('type',PaymentReceiptInfo::type_three)
  673. ->where('data_order_type',PaymentReceipt::data_type_three)
  674. ->whereIn('data_order_no',$search)
  675. // ->where('data_type',$data['type'])
  676. ->select('payment_receipt_id','data_order_no','amount','data_type')
  677. ->get()->toArray();
  678. $info_array = $red = [];
  679. foreach ($info as $value){
  680. if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
  681. if($value['data_type'] == PaymentReceipt::type_one){
  682. if(isset($info_array[$value['data_order_no']])){
  683. $info_array[$value['data_order_no']] += $value['amount'];
  684. }else{
  685. $info_array[$value['data_order_no']] = $value['amount'];
  686. }
  687. }elseif($value['data_type'] == PaymentReceipt::type_three){
  688. if(isset($red[$value['data_order_no']])){
  689. $red[$value['data_order_no']] += $value['amount'];
  690. }else{
  691. $red[$value['data_order_no']] = $value['amount'];
  692. }
  693. }
  694. }
  695. //退货退款金额
  696. $return_exchange = (new ReturnExchangeOrderService())->getDifferentAmountALL(array_column($result,'sales_order_id'));
  697. if($data['type'] == PaymentReceipt::type_one){
  698. // order_number => amount
  699. $return_exchange_array = [];
  700. foreach ($result_map as $key => $value){
  701. if(isset($return_exchange[$key])) $return_exchange_array[$value] = $return_exchange[$key];
  702. }
  703. foreach ($result as $value){
  704. //收款 = 总金额(订单金额 + 其他费用) - (已收 - 红冲) - 退换货
  705. $tmp_receipt = $info_array[$value['order_number']] ?? 0;
  706. $tmp_red = $red[$value['order_number']] ?? 0;
  707. $total = bcadd($value['total_amount'],$value['other_fee'],2);
  708. $tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
  709. $max = bcsub($total, bcsub($tmp_receipt,$tmp_red,2), 2);
  710. $max = bcsub($max, $tmp_return, 2);
  711. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  712. }
  713. }elseif($data['type'] == PaymentReceipt::type_three){
  714. //收款金额(审核后)
  715. $info_one = PaymentReceiptInfo::from('payment_receipt_info as a')
  716. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  717. ->where('b.state',PaymentReceipt::STATE_TWO)
  718. ->where('b.del_time',0)
  719. ->where('a.del_time',0)
  720. ->where('a.type',PaymentReceiptInfo::type_three)
  721. ->where('a.data_order_type',PaymentReceipt::data_type_three)
  722. ->whereIn('a.data_order_no',$search)
  723. ->where('a.data_type',PaymentReceipt::type_one)
  724. ->select('a.payment_receipt_id','a.data_order_no','a.amount')
  725. ->get()->toArray();
  726. $info_one_array = [];
  727. foreach ($info_one as $value){
  728. if(isset($info_one_array[$value['data_order_no']])){
  729. $info_one_array[$value['data_order_no']] += $value['amount'];
  730. }else{
  731. $info_one_array[$value['data_order_no']] = $value['amount'];
  732. }
  733. }
  734. foreach ($result as $value){
  735. //红冲 = 审核后的收款单金额 - 已红冲
  736. $tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
  737. $tmp_return = $red[$value['order_number']] ?? 0;
  738. $max = bcsub($tmp_receipt, $tmp_return, 2);
  739. if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
  740. }
  741. }
  742. }
  743. return [true, ''];
  744. }
  745. public function fillData($data, $ergs){
  746. if(empty($data['data'])) return $data;
  747. $emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
  748. ->pluck('emp_name','id')
  749. ->toArray();
  750. $array = array_unique(array_merge_recursive(array_column($data['data'],'account'),array_column($data['data'],'pay_way')));
  751. $basic_map = BasicType::whereIn('id',$array)
  752. ->pluck('title','id')
  753. ->toArray();
  754. $map = [];
  755. $info = PaymentReceiptInfo::where('del_time',0)
  756. ->where('type',PaymentReceiptInfo::type_three)
  757. ->whereIn('payment_receipt_id', array_unique(array_column($data['data'],'id')))
  758. ->select('payment_receipt_id','data_order_no')
  759. ->get()->toArray();
  760. foreach ($info as $value){
  761. $map[$value['payment_receipt_id']][] = $value['data_order_no'];
  762. }
  763. //订单状态数据组织
  764. $state_array = $this->getStateMake($data['data']);
  765. foreach ($data['data'] as $key => $value){
  766. $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
  767. $data['data'][$key]['payment_receipt_date'] = $value['payment_receipt_date'] ? date('Y-m-d',$value['payment_receipt_date']) : '';
  768. $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
  769. $data['data'][$key]['state_title'] = $this->makeState($data['data'][$key], $state_array);
  770. $data['data'][$key]['type_title'] = PaymentReceipt::$model_type[$value['type']] ?? '';
  771. $data['data'][$key]['data_type_title'] = PaymentReceipt::$data_type[$value['data_type']] ?? '';
  772. $data['data'][$key]['account_title'] = $basic_map[$value['account']] ?? '';
  773. $data['data'][$key]['pay_way_title'] = $basic_map[$value['pay_way']] ?? '';
  774. $data['data'][$key]['data_order_no'] = $map[$value['id']] ?? [];
  775. }
  776. return $data;
  777. }
  778. public function countData($column = "", $data, $user){
  779. if(empty($column) || empty($data['from_wx'])) return [0, 0];
  780. // 获取今天的开始和结束时间戳
  781. $todayStart = Carbon::today()->startOfDay()->timestamp;
  782. $todayEnd = Carbon::today()->endOfDay()->timestamp;
  783. // 获取昨天的开始和结束时间戳
  784. $yesterdayStart = Carbon::yesterday()->startOfDay()->timestamp;
  785. $yesterdayEnd = Carbon::yesterday()->endOfDay()->timestamp;
  786. $data['wx_' . $column] = [$todayStart, $todayEnd];
  787. $model = $this->customerCommon($data, $user);
  788. // 查询今天的数据条数
  789. $todayCount = $model->count();
  790. $data['wx_' . $column] = [$yesterdayStart, $yesterdayEnd];
  791. $model = $this->customerCommon($data, $user);
  792. // 查询昨天的数据条数
  793. $yesterdayCount = $model->count();
  794. return [$todayCount, $yesterdayCount];
  795. }
  796. public function getStateMake($data){
  797. if(empty($data)) return [];
  798. $order_no = [];
  799. foreach ($data as $value){
  800. if(! in_array($value['state'], [PaymentReceipt::State_minus_one,PaymentReceipt::STATE_ONE])) continue;
  801. $order_no[] = $value['order_number'];
  802. }
  803. return (new OaService())->getOaTeamDetailList($order_no);
  804. }
  805. public function makeState($value, $state_array){
  806. if(! empty($state_array[$value['order_number']])){
  807. $return = $state_array[$value['order_number']];
  808. if($value['state'] == PaymentReceipt::State_minus_one){
  809. $state = "驳回:" . $return;
  810. }else{
  811. $state = "待" . $return . "审核";
  812. }
  813. }elseif($value['state'] == PaymentReceipt::STATE_ZERO){
  814. $state = "待" . $value['crt_name'] . "提交";
  815. }else{
  816. $state = PaymentReceipt::$name[$value['state']] ?? '';
  817. }
  818. return $state;
  819. }
  820. //详情里
  821. public function getPaymentReceiptDataList($data,$type){
  822. $data['data_order_no'] = $data['order_number'];
  823. $info_array = PaymentReceiptInfo::from('payment_receipt_info as a')
  824. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  825. ->where('b.del_time',0)
  826. ->where('a.del_time',0)
  827. ->where('a.type',PaymentReceiptInfo::type_three)
  828. ->where('a.data_order_type',$type)
  829. ->where('a.data_order_no',$data['data_order_no'])
  830. ->select('a.payment_receipt_id','a.data_order_no','a.amount','a.data_type','b.state','b.payment_receipt_date','b.crt_time','b.order_number','b.account','b.pay_way')
  831. ->get()->toArray();
  832. $array = array_unique(array_merge_recursive(array_column($info_array,'account'),array_column($info_array,'pay_way')));
  833. $basic_map = BasicType::whereIn('id',$array)
  834. ->pluck('title','id')
  835. ->toArray();
  836. $emp_id = PaymentReceiptInfo::where('del_time',0)
  837. ->whereIn('payment_receipt_id',array_column($info_array,'payment_receipt_id'))
  838. ->where('type',PaymentReceiptInfo::type_two)
  839. ->get()->toArray();
  840. $info = [];
  841. if(! empty($emp_id)){
  842. $emp_map = Employee::whereIn('id',array_unique(array_column($emp_id,'data_id')))
  843. ->pluck('emp_name','id')
  844. ->toArray();
  845. foreach ($emp_id as $value){
  846. $name = $emp_map[$value['data_id']] ?? "";
  847. if(isset($info[$value['payment_receipt_id']])){
  848. $info[$value['payment_receipt_id']] .= ',' . $name;
  849. }else{
  850. $info[$value['payment_receipt_id']] = $name;
  851. }
  852. }
  853. }
  854. //四个金额类型
  855. $one = $two = $three = $four = $not_confirm_receipt_amount = 0;
  856. foreach ($info_array as $key => $value){
  857. //归属人
  858. $info_array[$key]['belong'] = $info[$value['payment_receipt_id']] ?? '';
  859. $info_array[$key]['account'] = $basic_map[$value['account']] ?? '';
  860. $info_array[$key]['pay_way'] = $basic_map[$value['pay_way']] ?? '';
  861. $info_array[$key]['state_title'] = PaymentReceipt::$name[$value['state']] ?? '';
  862. $info_array[$key]['type_title'] = PaymentReceipt::$model_type[$value['data_type']] ?? '';
  863. $info_array[$key]['payment_receipt_date'] = $value['payment_receipt_date'] ? date('Y-m-d',$value['payment_receipt_date']) : '';
  864. if($value['data_type'] == PaymentReceipt::type_one) $not_confirm_receipt_amount += $value['amount'];
  865. if($value['data_type'] == PaymentReceipt::type_one && $value['state'] == PaymentReceipt::STATE_TWO){
  866. $one += $value['amount'];
  867. }elseif ($value['data_type'] == PaymentReceipt::type_three && $value['state'] == PaymentReceipt::STATE_TWO){
  868. $three += $value['amount'];
  869. }
  870. }
  871. $return['receipt_amount'] = bcsub($one, $three, 2); // 已回款金额
  872. $return['not_receipt_amount'] = 0;
  873. $return['red_amount'] = $three;// 已红冲金额
  874. $return['bad_amount'] = $four;
  875. $return['all_count'] = count($info_array);
  876. $return['not_confirm_receipt_amount'] = $not_confirm_receipt_amount;
  877. $return['list'] = $info_array;
  878. return $return;
  879. }
  880. //列表里 默认:(收款)
  881. public function getPaymentReceiptDataCountList($data){
  882. $data_order_no = $data;
  883. if(empty($data_order_no)) return [];
  884. $order = PaymentReceiptInfo::from('payment_receipt_info as a')
  885. ->leftJoin('payment_receipt as b','b.id','a.payment_receipt_id')
  886. ->where('b.del_time',0)
  887. ->where('a.del_time',0)
  888. ->where('a.type',PaymentReceiptInfo::type_three)
  889. ->whereIn('a.data_order_no',$data_order_no)
  890. ->select('a.payment_receipt_id','a.data_order_no','a.amount','a.data_type','b.state','b.payment_receipt_date')
  891. ->get()->toArray();
  892. // $order = PaymentReceiptInfo::where('del_time',0)
  893. // ->where('type',PaymentReceiptInfo::type_three)
  894. // ->whereIn('data_order_no',$data_order_no)
  895. // ->get()->toArray();
  896. // 所有状态都统计 审核成功的统计
  897. $return = $return1 = [];
  898. foreach ($order as $value){
  899. $key = $value['data_order_no'] . $value['data_type'];
  900. if(isset($return[$key])){
  901. $return[$key] += $value['amount'];
  902. }else{
  903. $return[$key] = $value['amount'];
  904. }
  905. if($value['state'] == PaymentReceipt::STATE_TWO){
  906. if(isset($return1[$key])){
  907. $return1[$key] += $value['amount'];
  908. }else{
  909. $return1[$key] = $value['amount'];
  910. }
  911. }
  912. }
  913. return [$return, $return1];
  914. }
  915. public function maked(){
  916. $payment = PaymentReceipt::where('del_time',0)
  917. ->where('data_order_no','LIKE', '%'."T9SO.".'%')
  918. ->where('amount','>',0)
  919. ->get()->toArray();
  920. $insert = [];
  921. foreach ($payment as $value){
  922. $insert[] = [
  923. 'payment_receipt_id' => $value['id'],
  924. 'crt_time' => $value['crt_time'],
  925. 'type' => PaymentReceiptInfo::type_three,
  926. 'data_order_no' => $value['data_order_no'],
  927. 'amount' => $value['amount'],
  928. 'data_order_type' => $value['type'],
  929. 'data_type' => PaymentReceipt::type_one,
  930. ];
  931. }
  932. if(! empty($insert)) PaymentReceiptInfo::insert($insert);
  933. }
  934. public function checkForEdit($data_order_no = ""){
  935. if(empty($data_order_no)) return [false, '校验参数异常'];
  936. $bool = PaymentReceipt::where('data_order_no', $data_order_no)
  937. ->where('del_time',0)
  938. ->exists();
  939. if(! $bool) return [true, ''];
  940. return [false, "单号:" . $data_order_no . "已建收付款单,编辑操作有可能改变单据原始总金额导致收付款金额错乱,请先删除收付款单据!"];
  941. }
  942. }