SalorderTfDataWebApiPlugin.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package scmc.sm.webapi;
  2. import kd.bos.openapi.api.plugin.ApiSavePlugin;
  3. import java.math.BigDecimal;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. public class SalorderTfDataWebApiPlugin implements ApiSavePlugin {
  9. @Override
  10. public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
  11. for (Map<String, Object> map : reqData) {
  12. if(map.get("billentry")!=null) {
  13. List<Map> entryList = (ArrayList) map.get("billentry");
  14. for(Map entryObj : entryList){
  15. //含税单价
  16. BigDecimal priceandtax = new BigDecimal(0);
  17. if (entryObj.get("priceandtax") != null || !"".equals(map.get("priceandtax"))) {
  18. priceandtax = new BigDecimal(entryObj.get("priceandtax").toString());
  19. }
  20. //折后含税单价
  21. BigDecimal pznm_discpriceandtax = new BigDecimal(0);
  22. if (entryObj.get("pznm_discpriceandtax") != null || !"".equals(map.get("pznm_discpriceandtax"))) {
  23. pznm_discpriceandtax = new BigDecimal(entryObj.get("pznm_discpriceandtax").toString());
  24. }
  25. BigDecimal cal = priceandtax.subtract(pznm_discpriceandtax);
  26. if (cal.compareTo(BigDecimal.ZERO) != 0) {
  27. entryObj.put("discounttype", "C");//折扣方式
  28. entryObj.put("discountamount", cal);//折扣额
  29. } else {
  30. entryObj.put("discounttype", "NULL");//折扣方式
  31. }
  32. }
  33. }
  34. }
  35. return reqData;
  36. }
  37. }