| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package restcontroller.webmanage.sale.contracttask;
- import com.alibaba.fastjson2.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.data.Row;
- import common.data.Rows;
- import org.apache.commons.lang.StringUtils;
- import java.math.BigDecimal;
- public class ContractTaskUtil {
- public static void check(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow) throws YosException {
- JSONObject content = controller.content;
- verifyValue(content.getStringValue("license_name"), "营业执照名称");
- verifyValue(content.getStringValue("legal_rep"), "法人");
- verifyValue(content.getStringValue("mobile"), "电话");
- verifyValue(content.getStringValue("phonenumber"), "手机号");
- verifyValue(content.getStringValue("taxno"), "税号");
- verifyValue(content.getStringValue("license_address"), "营业执照地址");
- verifyValue(content.getStringValue("presalesphonenumber"), "售前电话");
- verifyValue(content.getStringValue("aftersalesphonenumber"), "售后电话");
- verifyValue(content.getStringValue("paymans"), "备案汇款人");
- verifyValue(content.getStringValue("idcard"), "身份证");
- verifyValue(enterpriseRow.getString("province"), "省");
- verifyValue(enterpriseRow.getString("city"), "市");
- verifyValue(enterpriseRow.getString("county"), "县");
- verifyValue(agentRow.getString("salearea"), "营销区域");
- verifyValue(agentRow.getString("agentnum"), "经销商编码");
- verifyValue(taskmxRow.getString("begindate"), "开始期限");
- verifyValue(taskmxRow.getString("enddate"), "结束期限");
- }
- public static CompanyInfo getCompanyInfo(Controller controller, Row enterpriseRow, Row agentRow, Row taskmxRow, Long year, BigDecimal securitydeposit) throws YosException {
- JSONObject content = controller.content;
- CompanyInfo companyInfo = new CompanyInfo();
- companyInfo.setBillno(year + agentRow.getString("agentnum"));
- companyInfo.setLicensename(content.getStringValue("license_name"));
- companyInfo.setTaxno(content.getStringValue("taxno"));
- companyInfo.setLicenseaddress(content.getStringValue("license_address"));
- companyInfo.setLegalrep(content.getStringValue("legal_rep"));
- companyInfo.setMobile(content.getStringValue("mobile"));
- companyInfo.setPhonenumber(content.getStringValue("phonenumber"));
- companyInfo.setPresalesphonenumber(content.getStringValue("presalesphonenumber"));
- companyInfo.setAftersalesphonenumber(content.getStringValue("aftersalesphonenumber"));
- companyInfo.setPaymans(content.getStringValue("paymans"));
- companyInfo.setIdcard(content.getStringValue("idcard"));
- companyInfo.setProvince(enterpriseRow.getString("province"));
- companyInfo.setCity(enterpriseRow.getString("city"));
- companyInfo.setCounty(enterpriseRow.getString("county"));
- companyInfo.setBegindate(taskmxRow.getString("begindate"));
- companyInfo.setEnddate(taskmxRow.getString("enddate"));
- companyInfo.setAreaname(agentRow.getString("salearea"));
- companyInfo.setSecuritydeposit(securitydeposit.toPlainString());
- companyInfo.setTaskmoney(getTaskMoney(taskmxRow).toPlainString());
- return companyInfo;
- }
- public static void verifyValue(String value, String info) throws YosException {
- if (StringUtils.isBlank(value)) {
- throw new YosException(false, info + "不能为空");
- }
- }
- public static Row getEnterpriseRow(Controller controller, Long sys_enterpriseid) throws YosException {
- Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sys_enterprise WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid='" + controller.siteid + "'");
- if (rows.isEmpty()) {
- throw new YosException(false, "企业不存在");
- }
- return rows.getRow(0);
- }
- public static Row getAgentRow(Controller controller, Long sa_agentsid) throws YosException {
- Rows rows = controller.dbConnect.runSqlQuery("SELECT * from sa_agents WHERE sa_agentsid =" + sa_agentsid + " and siteid='" + controller.siteid + "'");
- if (rows.isEmpty()) {
- throw new YosException(false, "经销商不存在");
- }
- return rows.getRow(0);
- }
- //查询保证金
- public static BigDecimal getSecurityDeposit(Controller controller, Long sys_enterpriseid) throws YosException {
- Rows rows = controller.dbConnect.runSqlQuery("select t1.balance from sa_accountbalance t1 " +
- "INNER JOIN sa_accountclass t2 ON t2.sa_accountclassid=t1.sa_accountclassid " +
- "WHERE t2.accountno='02' and t1.sys_enterpriseid=" + sys_enterpriseid);
- if (rows.isEmpty()) {
- throw new YosException(false, "保证金不存在");
- }
- return rows.getRow(0).getBigDecimal("balance");
- }
- public static BigDecimal getTaskMoney(Row taskmxRow) throws YosException {
- BigDecimal y1 = taskmxRow.getBigDecimal("y1");
- if (y1.compareTo(BigDecimal.ZERO) == 0) {
- throw new YosException(false, "请设置季度任务金额");
- }
- return y1;
- }
- }
|