ZyDepositFileService.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. package thyyxxk.webserver.service.zygl;
  2. import cn.hutool.core.convert.Convert;
  3. import cn.hutool.core.date.DateUtil;
  4. import cn.hutool.core.util.IdUtil;
  5. import cn.hutool.core.util.ReflectUtil;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.stereotype.Service;
  8. import org.springframework.transaction.annotation.Isolation;
  9. import org.springframework.transaction.annotation.Propagation;
  10. import org.springframework.transaction.annotation.Transactional;
  11. import thyyxxk.webserver.config.exception.BizException;
  12. import thyyxxk.webserver.config.exception.ExceptionEnum;
  13. import thyyxxk.webserver.constants.Constants;
  14. import thyyxxk.webserver.constants.SettleTypeEnum;
  15. import thyyxxk.webserver.constants.YesOrNo;
  16. import thyyxxk.webserver.constants.ZyDepositFileStatusEnum;
  17. import thyyxxk.webserver.dao.his.datamodify.ZyDetailChargeDao;
  18. import thyyxxk.webserver.dao.his.zygl.ZyActpatientDao;
  19. import thyyxxk.webserver.dao.his.zygl.ZyDepositFileDao;
  20. import thyyxxk.webserver.dao.his.zygl.ZyLedgerFileDao;
  21. import thyyxxk.webserver.dao.his.zygl.ZyReceiptDao;
  22. import thyyxxk.webserver.entity.executeItem.ZyLedgerFile;
  23. import thyyxxk.webserver.entity.inpatient.ZyActpatient;
  24. import thyyxxk.webserver.entity.inpatient.charge.ZyDepositFile;
  25. import thyyxxk.webserver.entity.inpatient.charge.ZyReceipt;
  26. import thyyxxk.webserver.utils.AssertUtil;
  27. import thyyxxk.webserver.utils.CloneUtil;
  28. import thyyxxk.webserver.utils.TokenUtil;
  29. import javax.annotation.Resource;
  30. import java.math.BigDecimal;
  31. import java.util.Arrays;
  32. import java.util.Date;
  33. import java.util.List;
  34. /**
  35. * @Description:
  36. * @Author:lihong
  37. * @Date: 2025/5/8
  38. */
  39. @Service
  40. @Slf4j
  41. public class ZyDepositFileService {
  42. @Resource
  43. private ZyDepositFileDao zyDepositFileMapper;
  44. @Resource
  45. private ZyActpatientDao zyActpatientMapper;
  46. @Resource
  47. private ZyLedgerFileDao zyLedgerFileMapper;
  48. @Resource
  49. private ZyReceiptDao zyReceiptMapper;
  50. @Resource
  51. private ZyDetailChargeDao zyDetailChargeMapper;
  52. public List<ZyDepositFile> queryZyDepositFileByInpatientNoAndTimes(ZyDepositFile zyDepositFile) {
  53. return zyDepositFileMapper.selectZyDepositFileByInpatientNoAndTimes(zyDepositFile);
  54. }
  55. @Transactional(rollbackFor = Exception.class)
  56. public int saveZyDepositFile(ZyDepositFile zyDepositFile) {
  57. AssertUtil.isnotBlank(zyDepositFile.getInpatientNo(),"住院号不能为空");
  58. AssertUtil.isnotBlank(zyDepositFile.getStatus(),"事务类型不能为空");
  59. if(!ZyDepositFileStatusEnum.PREPAY.code.equals(zyDepositFile.getStatus()) && !ZyDepositFileStatusEnum.STRAIGHT_BACK.code.equals(zyDepositFile.getStatus())){
  60. throw new BizException(ExceptionEnum.LOGICAL_ERROR,"事务类型的值不符合规范,只能缴费或直退");
  61. }
  62. ZyActpatient zyActpatient = zyActpatientMapper.selectByInpatientNo(ZyActpatient.ZY_ACTPATIENT, zyDepositFile.getInpatientNo(), null);
  63. AssertUtil.isnotBlank(zyActpatient,"住院号没有查询到对应的住院记录");
  64. zyDepositFile.setAdmissTimes(zyActpatient.getAdmissTimes());
  65. Integer depoTimes = zyDepositFileMapper.selectMaxDepoTimes(zyDepositFile);
  66. if (depoTimes == null) {
  67. depoTimes = 0;
  68. }
  69. depoTimes++;
  70. zyDepositFile.setDepoTimes(depoTimes);
  71. zyDepositFile.setDepoDate(new Date());
  72. zyDepositFile.setWindowNo(ZyDepositFile.IN_HOSPITAL);
  73. zyDepositFile.setDeleted(YesOrNo.NO.getCode().toString());
  74. //此时账页信息为空,是收费
  75. if (zyDepositFile.getLedgerSn() == null) {
  76. Integer currentLedgerSn = zyLedgerFileMapper.selectCurrentLedgerSn(zyDepositFile.getInpatientNo(), zyActpatient.getAdmissTimes());
  77. if (currentLedgerSn == null) {
  78. Integer maxLedgerSn = zyLedgerFileMapper.selectMaxLedgerSn(zyDepositFile.getInpatientNo(), zyActpatient.getAdmissTimes());
  79. if (maxLedgerSn == null) {
  80. maxLedgerSn = 0;
  81. }
  82. currentLedgerSn = maxLedgerSn++;
  83. }
  84. zyDepositFile.setLedgerSn(currentLedgerSn);
  85. }
  86. //查询账页信息
  87. ZyLedgerFile zyLedgerFile = zyLedgerFileMapper.selectZyLedgerFileByInpatientNoAndTimesAndLedgerSn(zyDepositFile.getInpatientNo(), zyActpatient.getAdmissTimes(), zyDepositFile.getLedgerSn());
  88. AssertUtil.isnotBlank(zyLedgerFile,"没有找到当前病人本次住院的账页信息");
  89. //缴费
  90. if (ZyDepositFileStatusEnum.PREPAY.code.equals(zyDepositFile.getStatus())) {
  91. AssertUtil.isnotBlank(zyDepositFile.getDepoAmount(),"缴费金额不能为空");
  92. //非自助或者非聚合支付与银联卡的需要传缴费流水号
  93. if (YesOrNo.YES.getCode().equals(zyDepositFile.getAutoFlag()) && Arrays.asList(Constants.ZZWX, Constants.ZZZFB, Constants.JHZF, Constants.YLK).contains(zyDepositFile.getDepoType())) {
  94. AssertUtil.isnotBlank(zyDepositFile.getReceiptNo(),"his缴费订单号不能为空");
  95. AssertUtil.isnotBlank(zyDepositFile.getAgtordnum(),"流水号不能为空");
  96. AssertUtil.isnotBlank(zyDepositFile.getPsordnum(),"订单号不能为空");
  97. }else {
  98. zyDepositFile.setReceiptNo(IdUtil.getSnowflake().nextIdStr());
  99. }
  100. zyDepositFile.setPrinted(0);
  101. }
  102. else{
  103. AssertUtil.isnotBlank(zyDepositFile.getReceiptNo(),"退费,收据号不能为空");
  104. AssertUtil.isnotBlank(zyDepositFile.getDepoType(),"退费,支付方式不能为空");
  105. ZyDepositFile tempZyDepositFile = queryZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo());
  106. AssertUtil.isnotBlank(tempZyDepositFile, "当前退费的收据号不存在");
  107. if(YesOrNo.YES.getCode().equals(zyDepositFile.getRefundType())){
  108. if(!Constants.JHZF.equals(zyDepositFile.getDepoType()) && !Constants.YLK.equals(zyDepositFile.getDepoType())){
  109. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "原路退费只能选择聚合支付或银联卡");
  110. }
  111. AssertUtil.isnotBlank(tempZyDepositFile.getAgtordnum(),"原缴费记录流水号为空,不能原路退费,请选择普通退费");
  112. AssertUtil.isnotBlank(tempZyDepositFile.getPsordnum(),"原缴费记录订单号为空,不能原路退费,请选择普通退费");
  113. zyDepositFile.setPsordnum(tempZyDepositFile.getPsordnum());
  114. zyDepositFile.setAgtordnum(tempZyDepositFile.getAgtordnum());
  115. zyDepositFile.setTraceNo(tempZyDepositFile.getTraceNo());
  116. zyDepositFile.setParChannel(tempZyDepositFile.getParChannel());
  117. }
  118. BigDecimal sum = querySumDepoAmountByReceiptNo(zyDepositFile.getReceiptNo());
  119. if(BigDecimal.ZERO.compareTo(sum) == 0){
  120. modifyReportFlag(zyDepositFile.getReceiptNo());
  121. AssertUtil.isnotBlank(tempZyDepositFile, "当前操作的费用已经退过费,请勿重复操作。");
  122. }
  123. zyDepositFile.setDepoAmount(BigDecimal.ZERO.subtract(tempZyDepositFile.getDepoAmount()));
  124. zyDepositFile.setAdmissTimes(tempZyDepositFile.getAdmissTimes());
  125. zyDepositFile.setLedgerSn(tempZyDepositFile.getLedgerSn());
  126. zyDepositFile.setPrinted(tempZyDepositFile.getPrinted());
  127. zyDepositFile.setReportFlag(YesOrNo.YES.getCode().toString());
  128. zyDepositFile.setReportFlag(YesOrNo.YES.getCode().toString());
  129. zyDepositFile.setDepoType(zyDepositFile.getDepoType());
  130. zyDepositFileMapper.updateReportFlag(zyDepositFile.getReceiptNo());
  131. }
  132. zyDepositFile.setOpIdCode(TokenUtil.getInstance().getTokenUserId());
  133. int num = zyDepositFileMapper.insetZyDepositFile(zyDepositFile);
  134. //设置账页信息
  135. zyLedgerFile.setDeposit(zyLedgerFile.getDeposit().add(zyDepositFile.getDepoAmount()));
  136. zyLedgerFile.setBalance(zyLedgerFile.getBalance().add(zyDepositFile.getDepoAmount()));
  137. zyLedgerFileMapper.updateZyLedgerFile(zyLedgerFile);
  138. //设置住院表的余额
  139. zyActpatient.setBalance(zyActpatient.getBalance().add(zyDepositFile.getDepoAmount()));
  140. zyActpatient.setTableName(ZyActpatient.ZY_ACTPATIENT);
  141. zyActpatientMapper.updateBalance(zyActpatient);
  142. return num;
  143. }
  144. public BigDecimal querySumDepoAmountByReceiptNo(String receiptNo) {
  145. return zyDepositFileMapper.selectSumDepoAmountByReceiptNo(receiptNo);
  146. }
  147. /**
  148. * @param
  149. * @description: 按照住院号查询该收据号的总费用 ==0 说明已经退了费 >0 说明未退费
  150. * @author: lihong
  151. * @date: 2023/11/15 14:42
  152. * @param: receiptNo
  153. * @return: java.math.BigDecimal
  154. */
  155. public BigDecimal querySumDepoAmountByInpatientNo(String inpatientNo,Integer admissTimes) {
  156. return zyDepositFileMapper.selectSumDepoAmountByInpatientNo(inpatientNo,admissTimes);
  157. }
  158. public int modifyReportFlag(String receiptNo) {
  159. return zyDepositFileMapper.updateReportFlag(receiptNo);
  160. }
  161. public ZyDepositFile queryZyDepositFileByReceiptNo(String receiptNo) {
  162. return zyDepositFileMapper.selectZyDepositFileByReceiptNo(receiptNo);
  163. }
  164. public int modifyPrinted(String receiptNo) {
  165. return zyDepositFileMapper.updatePrinted(receiptNo);
  166. }
  167. public ZyDepositFile queryZyDepositFileByAgtordnum(String psordnum, String agtordnum, String tableName) {
  168. if (tableName == null) {
  169. tableName = "zy_deposit_file";
  170. }
  171. return zyDepositFileMapper.selectZyDepositFileByAgtordnum(psordnum, agtordnum, tableName);
  172. }
  173. @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
  174. public int cancelCashi(String opId, String inpatientNo, Integer admissTimes) {
  175. ZyLedgerFile zyLedgerFile = zyLedgerFileMapper.selectLastLedgerSn(inpatientNo, admissTimes);
  176. if (zyLedgerFile == null) {
  177. throw new BizException(ExceptionEnum.LOGICAL_ERROR,"账页信息不存在");
  178. }
  179. if (!SettleTypeEnum.TELLER.code.equals(zyLedgerFile.getSettleType())) {
  180. throw new BizException(ExceptionEnum.LOGICAL_ERROR,"当前病人的结算状态非【已出纳】,无法进行费用冲销操作!");
  181. }
  182. Integer minLedgerSn = zyLedgerFileMapper.selectMinLedgerSn(inpatientNo, admissTimes);
  183. Date now = new Date();
  184. //将原账页信息修改保存
  185. ZyLedgerFile oriZyLedgerFile = CloneUtil.clone(zyLedgerFile);
  186. oriZyLedgerFile.setLedgerSn(minLedgerSn - 1);
  187. oriZyLedgerFile.setTfFlag(YesOrNo.YES.getCode().toString());
  188. zyLedgerFileMapper.insetZyLedgerFile(oriZyLedgerFile);
  189. //退费后的冲抵记录
  190. ZyLedgerFile newZyLedgerFile = getZyLedgerFile(opId, zyLedgerFile, minLedgerSn, now);
  191. zyLedgerFileMapper.insetZyLedgerFile(newZyLedgerFile);
  192. //更新源账页数据
  193. zyLedgerFileMapper.updateZyLedgerFileForCancelCashi(inpatientNo, admissTimes, zyLedgerFile.getLedgerSn());
  194. ZyDepositFile zyDepositFile = zyDepositFileMapper.selectLastZyDepositFile(inpatientNo, Double.valueOf(admissTimes));
  195. if (zyDepositFile == null) {
  196. throw new BizException(ExceptionEnum.LOGICAL_ERROR,"收据信息不存在");
  197. }
  198. ZyDepositFile updateZyDepositFile = new ZyDepositFile();
  199. updateZyDepositFile.setInpatientNo(inpatientNo);
  200. updateZyDepositFile.setAdmissTimes(zyDepositFile.getAdmissTimes());
  201. updateZyDepositFile.setDepoTimes(zyDepositFile.getDepoTimes());
  202. updateZyDepositFile.setLedgerSn(oriZyLedgerFile.getLedgerSn());
  203. updateZyDepositFile.setDeleted(YesOrNo.YES.getCode().toString());
  204. zyDepositFileMapper.updateZyDepositFileCommon(updateZyDepositFile);
  205. zyDepositFile.setDepoDate(now);
  206. zyDepositFile.setOpIdCode(opId);
  207. zyDepositFile.setDepoAmount(BigDecimal.ZERO.subtract(zyDepositFile.getDepoAmount()));
  208. zyDepositFile.setLedgerSn(newZyLedgerFile.getLedgerSn());
  209. zyDepositFile.setDeleted(YesOrNo.YES.getCode().toString());
  210. zyDepositFileMapper.insetZyDepositFile(zyDepositFile);
  211. ZyReceipt zyReceipt = zyReceiptMapper.selectLastZyReceipt(inpatientNo, admissTimes);
  212. if (zyReceipt == null) {
  213. throw new BizException(ExceptionEnum.LOGICAL_ERROR,"发票信息不存在");
  214. }
  215. //将原账页信息修改保存
  216. ZyReceipt oriZyReceipt = CloneUtil.clone(zyReceipt);
  217. oriZyReceipt.setLedgerSn(oriZyLedgerFile.getLedgerSn());
  218. zyReceiptMapper.insertZyReceipt(oriZyReceipt);
  219. //退费后的冲抵记录
  220. ZyReceipt newZyReceipt = getZyReceipt(opId, now, newZyLedgerFile, zyReceipt);
  221. zyReceiptMapper.insertZyReceipt(newZyReceipt);
  222. //设置新的发票信息
  223. ZyReceipt updateZyReceipt = new ZyReceipt();
  224. updateZyReceipt.setInpatientNo(inpatientNo);
  225. updateZyReceipt.setAdmissTimes(zyReceipt.getAdmissTimes());
  226. updateZyReceipt.setLedgerSn(zyReceipt.getLedgerSn());
  227. updateZyReceipt.setReceiptNo("00000000");
  228. updateZyReceipt.setOpIdCode("");
  229. updateZyReceipt.setPrintDate(DateUtil.parse("1970-01-01", "yyyy-MM-dd"));
  230. zyReceiptMapper.clearZyReceipt(updateZyReceipt);
  231. zyDetailChargeMapper.insertForCancelCashi(inpatientNo, admissTimes, 1, 1, now, oriZyLedgerFile.getLedgerSn());
  232. return zyDetailChargeMapper.insertForCancelCashi(inpatientNo, admissTimes, 1, -1, now, newZyLedgerFile.getLedgerSn());
  233. }
  234. //@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
  235. //public List<ZyDepositFile> teller(String opId, ZyDepositFileVo zyDepositFileVo) {
  236. // if (zyDepositFileVo == null) {
  237. // throw new MzException("费用参数不能为空!");
  238. // }
  239. // if (zyDepositFileVo.getZyDepositFiles() == null || zyDepositFileVo.getZyDepositFiles().size() == 0) {
  240. // throw new MzException("结算补交或者结算退费支付方式不能为空!");
  241. // }
  242. // String inpatientNo = null;
  243. // Double admissTimes = null;
  244. // Integer maxDepoTimes = null;
  245. // Integer maxLedgerSn = null;
  246. // List<ZyDepositFile> refundPosList = null;
  247. // Date now = new Date();
  248. // for (ZyDepositFile zyDepositFile : zyDepositFileVo.getZyDepositFiles()) {
  249. // if (StringUtils.isBlank(zyDepositFile.getInpatientNo())) {
  250. // throw new MzException("患者住院号不能为空!");
  251. // }
  252. // if (zyDepositFile.getAdmissTimes() == null) {
  253. // throw new MzException("患者住院次数不能为空!");
  254. // }
  255. // if (zyDepositFile.getDepoAmount() == null) {
  256. // throw new MzException("支付金额不能为空!");
  257. // }
  258. // if (StringUtils.isBlank(zyDepositFile.getDepoType())) {
  259. // throw new MzException("支付方式不能为空!");
  260. // }
  261. // if (StringUtils.isBlank(zyDepositFile.getStatus())) {
  262. // throw new MzException("事务类型不能为空!");
  263. // }
  264. // if (maxDepoTimes == null) {
  265. // maxDepoTimes = zyDepositFileMapper.selectMaxDepoTimes(zyDepositFile);
  266. // if (maxDepoTimes == null) {
  267. // maxDepoTimes = 0;
  268. // }
  269. // }
  270. // if (maxLedgerSn == null) {
  271. // inpatientNo = zyDepositFile.getInpatientNo();
  272. // admissTimes = zyDepositFile.getAdmissTimes();
  273. // maxLedgerSn = zyLedgerFileMapper.selectMaxLedgerSn(zyDepositFile.getInpatientNo(), zyDepositFile.getAdmissTimes().intValue());
  274. // }
  275. // if (zyDepositFileVo.getRefundType() != null) {
  276. // if (YesNoEnum.NO.code.equals(zyDepositFileVo.getRefundType())) {
  277. // zyDepositFile.setDepoType(Constants.CASH);
  278. // } else if (YesNoEnum.YES.code.equals(zyDepositFileVo.getRefundType())) {
  279. // if (refundPosList == null) {
  280. // refundPosList = new ArrayList<>();
  281. // }
  282. // if (Constants.YLK.equals(zyDepositFile.getDepoType()) || Constants.JHZF.equals(zyDepositFile.getDepoType())) {
  283. // ZyDepositFile dbZyDepositFile=zyDepositFileMapper.selectZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo());
  284. // if(dbZyDepositFile==null){
  285. // throw new MzException("根据收据号未查询到对应的未退费预交金记录!");
  286. // }
  287. // zyDepositFile.setParChannel(dbZyDepositFile.getParChannel());
  288. // zyDepositFile.setPsordnum(dbZyDepositFile.getPsordnum());
  289. // zyDepositFile.setAgtordnum(dbZyDepositFile.getAgtordnum());
  290. // zyDepositFile.setTransDate(dbZyDepositFile.getTransDate());
  291. // zyDepositFile.setTraceNo(dbZyDepositFile.getTraceNo());
  292. // refundPosList.add(zyDepositFile);
  293. // }
  294. // }
  295. // }
  296. // zyDepositFile.setDepoTimes(Double.valueOf(++maxDepoTimes));
  297. // zyDepositFile.setDepoDate(now);
  298. // zyDepositFile.setOpIdCode(opId);
  299. // if(zyDepositFile.getReceiptNo()==null){
  300. // zyDepositFile.setReceiptNo("");
  301. // }
  302. // zyDepositFile.setPrinted(0D);
  303. // zyDepositFile.setLedgerSn(Double.valueOf(maxLedgerSn));
  304. // zyDepositFile.setWindowNo(ZyDepositFile.NEW_VALUATION);
  305. // zyDepositFile.setDeleted(YesNoEnum.NO.code.toString());
  306. // zyDepositFileMapper.insetZyDepositFile(zyDepositFile);
  307. // }
  308. // zyDepositFileMapper.updateHsrAndHsTime(inpatientNo, admissTimes, opId, now);
  309. // ZyLedgerFile updateZyLedgerFile = new ZyLedgerFile();
  310. // updateZyLedgerFile.setInpatientNo(inpatientNo);
  311. // updateZyLedgerFile.setAdmissTimes(admissTimes.intValue());
  312. // updateZyLedgerFile.setLedgerSn(maxLedgerSn);
  313. // updateZyLedgerFile.setCashId(opId);
  314. // updateZyLedgerFile.setCashDate(now);
  315. // updateZyLedgerFile.setSettleType(SettleTypeEnum.TELLER.code);
  316. // updateZyLedgerFile.setBalance(BigDecimal.ZERO);
  317. // zyLedgerFileMapper.updateZyLedgerFileCommon(updateZyLedgerFile);
  318. // ZyActpatient updateZyActpatient = new ZyActpatient();
  319. // updateZyActpatient.setInpatientNo(inpatientNo);
  320. // updateZyActpatient.setAdmissTimes(admissTimes.intValue());
  321. // updateZyActpatient.setBalance(BigDecimal.ZERO);
  322. // updateZyActpatient.setTableName("zy_inactpatient");
  323. // zyActpatientMapper.updateBalance(updateZyActpatient);
  324. // return refundPosList;
  325. //}
  326. private ZyReceipt getZyReceipt(String opId, Date now, ZyLedgerFile newZyLedgerFile, ZyReceipt zyReceipt) {
  327. ZyReceipt newZyReceipt = CloneUtil.clone(zyReceipt);
  328. newZyReceipt.setLedgerSn(newZyLedgerFile.getLedgerSn());
  329. newZyReceipt.setTotalCharge(BigDecimal.ZERO.subtract(newZyReceipt.getTotalCharge()));
  330. newZyReceipt.setAccountDate(now);
  331. newZyReceipt.setPrintDate(DateUtil.parse("1900-01-01 00:00:00.000", "yyyy-MM-dd HH:mm:ss"));
  332. newZyReceipt.setOpIdCode(opId);
  333. for (int i = 1; i <= 30 ; i++) {
  334. String fieldName = "charge"+i;
  335. BigDecimal charge = Convert.toBigDecimal(ReflectUtil.getFieldValue(newZyReceipt, fieldName),BigDecimal.ZERO);
  336. ReflectUtil.setFieldValue(newZyReceipt,fieldName,BigDecimal.ZERO.subtract(charge));
  337. }
  338. return newZyReceipt;
  339. }
  340. private ZyLedgerFile getZyLedgerFile(String opId, ZyLedgerFile zyLedgerFile, Integer minLedgerSn, Date now) {
  341. ZyLedgerFile newZyLedgerFile = CloneUtil.clone(zyLedgerFile);
  342. newZyLedgerFile.setLedgerSn(minLedgerSn - 2);
  343. newZyLedgerFile.setAccountDate(now);
  344. newZyLedgerFile.setOpIdCode(opId);
  345. newZyLedgerFile.setDeposit(BigDecimal.ZERO.subtract(newZyLedgerFile.getDeposit()));
  346. newZyLedgerFile.setBalance(BigDecimal.ZERO.subtract(newZyLedgerFile.getBalance()));
  347. newZyLedgerFile.setTotalCharge(BigDecimal.ZERO.subtract(newZyLedgerFile.getTotalCharge()));
  348. newZyLedgerFile.setCharge1(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge1()));
  349. newZyLedgerFile.setCharge2(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge2()));
  350. newZyLedgerFile.setCharge3(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge3()));
  351. newZyLedgerFile.setCharge4(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge4()));
  352. newZyLedgerFile.setCharge5(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge5()));
  353. newZyLedgerFile.setCharge6(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge6()));
  354. newZyLedgerFile.setCharge7(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge7()));
  355. newZyLedgerFile.setCharge8(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge8()));
  356. newZyLedgerFile.setCharge9(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge9()));
  357. newZyLedgerFile.setCharge10(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge10()));
  358. newZyLedgerFile.setCharge11(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge11()));
  359. newZyLedgerFile.setCharge12(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge12()));
  360. newZyLedgerFile.setCharge13(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge13()));
  361. newZyLedgerFile.setCharge14(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge14()));
  362. newZyLedgerFile.setCharge15(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge15()));
  363. newZyLedgerFile.setCharge16(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge16()));
  364. newZyLedgerFile.setCharge17(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge17()));
  365. newZyLedgerFile.setCharge18(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge18()));
  366. newZyLedgerFile.setCharge19(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge19()));
  367. newZyLedgerFile.setCharge20(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge20()));
  368. newZyLedgerFile.setCharge21(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge21()));
  369. newZyLedgerFile.setCharge22(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge22()));
  370. newZyLedgerFile.setCharge23(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge23()));
  371. newZyLedgerFile.setCharge24(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge24()));
  372. newZyLedgerFile.setCharge25(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge25()));
  373. newZyLedgerFile.setCharge26(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge26()));
  374. newZyLedgerFile.setCharge27(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge27()));
  375. newZyLedgerFile.setCharge28(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge28()));
  376. newZyLedgerFile.setCharge29(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge29()));
  377. newZyLedgerFile.setCharge30(BigDecimal.ZERO.subtract(newZyLedgerFile.getCharge30()));
  378. newZyLedgerFile.setLastBalance(BigDecimal.ZERO.subtract(newZyLedgerFile.getLastBalance()));
  379. newZyLedgerFile.setSettle(BigDecimal.ZERO.subtract(newZyLedgerFile.getSettle()));
  380. newZyLedgerFile.setCashDate(now);
  381. newZyLedgerFile.setCashId(opId);
  382. newZyLedgerFile.setDcountNo(YesOrNo.NO.getCode().toString());
  383. newZyLedgerFile.setDcountDate(null);
  384. newZyLedgerFile.setTfFlag(YesOrNo.YES.getCode().toString());
  385. return newZyLedgerFile;
  386. }
  387. }