ContractTaskUtil.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package restcontroller.webmanage.sale.contracttask;
  2. import com.alibaba.fastjson2.JSONObject;
  3. import common.Controller;
  4. import common.YosException;
  5. import common.data.Row;
  6. import common.data.Rows;
  7. import org.apache.commons.lang.StringUtils;
  8. import java.math.BigDecimal;
  9. public class ContractTaskUtil {
  10. public static void check(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow) throws YosException {
  11. JSONObject content = controller.content;
  12. verifyValue(content.getStringValue("license_name"), "营业执照名称");
  13. verifyValue(content.getStringValue("legal_rep"), "法人");
  14. verifyValue(content.getStringValue("mobile"), "电话");
  15. verifyValue(content.getStringValue("phonenumber"), "手机号");
  16. verifyValue(content.getStringValue("taxno"), "税号");
  17. verifyValue(content.getStringValue("license_address"), "营业执照地址");
  18. verifyValue(content.getStringValue("presalesphonenumber"), "售前电话");
  19. verifyValue(content.getStringValue("aftersalesphonenumber"), "售后电话");
  20. verifyValue(content.getStringValue("paymans"), "备案汇款人");
  21. verifyValue(content.getStringValue("idcard"), "身份证");
  22. verifyValue(enterpriseRow.getString("province"), "省");
  23. verifyValue(enterpriseRow.getString("city"), "市");
  24. verifyValue(enterpriseRow.getString("county"), "县");
  25. verifyValue(agentRow.getString("salearea"), "营销区域");
  26. verifyValue(agentRow.getString("agentnum"), "经销商编码");
  27. verifyValue(taskmxRow.getString("begindate"), "开始期限");
  28. verifyValue(taskmxRow.getString("enddate"), "结束期限");
  29. }
  30. public static CompanyInfo getCompanyInfo(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow, Long year, BigDecimal securitydeposit) throws YosException {
  31. JSONObject content = controller.content;
  32. CompanyInfo companyInfo = new CompanyInfo();
  33. companyInfo.setBillno(year + agentRow.getString("agentnum"));
  34. companyInfo.setLicensename(content.getStringValue("license_name"));
  35. companyInfo.setTaxno(content.getStringValue("taxno"));
  36. companyInfo.setLicenseaddress(content.getStringValue("license_address"));
  37. companyInfo.setLegalrep(content.getStringValue("legal_rep"));
  38. companyInfo.setMobile(content.getStringValue("mobile"));
  39. companyInfo.setPhonenumber(content.getStringValue("phonenumber"));
  40. companyInfo.setPresalesphonenumber(content.getStringValue("presalesphonenumber"));
  41. companyInfo.setAftersalesphonenumber(content.getStringValue("aftersalesphonenumber"));
  42. companyInfo.setPaymans(content.getStringValue("paymans"));
  43. companyInfo.setIdcard(content.getStringValue("idcard"));
  44. companyInfo.setProvince(enterpriseRow.getString("province"));
  45. companyInfo.setCity(enterpriseRow.getString("city"));
  46. companyInfo.setCounty(enterpriseRow.getString("county"));
  47. companyInfo.setBegindate(taskmxRow.getString("begindate"));
  48. companyInfo.setEnddate(taskmxRow.getString("enddate"));
  49. companyInfo.setAreaname(agentRow.getString("salearea"));
  50. companyInfo.setSecuritydeposit(securitydeposit.toPlainString());
  51. companyInfo.setTaskmoney(getTaskMoney(taskmxRow).toPlainString());
  52. return companyInfo;
  53. }
  54. public static void verifyValue(String value, String info) throws YosException {
  55. if (StringUtils.isBlank(value)) {
  56. throw new YosException(false, info + "不能为空");
  57. }
  58. }
  59. public static Row getEnterpriseRow(Controller controller, Long sys_enterpriseid) throws YosException {
  60. Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sys_enterprise WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid='" + controller.siteid + "'");
  61. if (rows.isEmpty()) {
  62. throw new YosException(false, "企业不存在");
  63. }
  64. return rows.getRow(0);
  65. }
  66. public static Row getAgentRow(Controller controller, Long sa_agentsid) throws YosException {
  67. Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sa_agents WHERE sa_agentsid =" + sa_agentsid + " and siteid='" + controller.siteid + "'");
  68. if (rows.isEmpty()) {
  69. throw new YosException(false, "经销商不存在");
  70. }
  71. return rows.getRow(0);
  72. }
  73. //查询保证金
  74. public static BigDecimal getSecurityDeposit(Controller controller, Long sys_enterpriseid) throws YosException {
  75. Rows rows = controller.dbConnect.runSqlQuery("select t1.balance from sa_accountbalance t1 " +
  76. "INNER JOIN sa_accountclass t2 ON t2.sa_accountclassid=t1.sa_accountclassid " +
  77. "WHERE t2.accountno='02' and t1.sys_enterpriseid=" + sys_enterpriseid);
  78. if (rows.isEmpty()) {
  79. throw new YosException(false, "保证金不存在");
  80. }
  81. return rows.getRow(0).getBigDecimal("balance");
  82. }
  83. public static BigDecimal getTaskMoney(Row taskmxRow) throws YosException {
  84. BigDecimal y1 = taskmxRow.getBigDecimal("y1");
  85. if (y1.compareTo(BigDecimal.ZERO) == 0) {
  86. throw new YosException(false, "请设置季度任务金额");
  87. }
  88. return y1;
  89. }
  90. }