diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 8d2931204..a66815511 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -156,6 +156,21 @@ public class WxRentContract implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "租期(月)", name = "lease") private Integer lease; + @io.swagger.annotations.ApiModelProperty(value = "类型", name = "type") + private Integer type; + + @io.swagger.annotations.ApiModelProperty(value = "调整比例", name = "adjustRatio") + private Integer adjustRatio; + + @io.swagger.annotations.ApiModelProperty(value = "调整周期", name = "adjustPeriod") + private Integer adjustPeriod; + + @io.swagger.annotations.ApiModelProperty(value = "支付比例", name = "payRatio") + private Integer payRatio; + + @io.swagger.annotations.ApiModelProperty(value = "营业额", name = "revenue") + private Integer revenue; + public Long getMerchantId() { return merchantId; @@ -365,6 +380,46 @@ public class WxRentContract implements Serializable { this.lease = lease; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getAdjustRatio() { + return adjustRatio; + } + + public void setAdjustRatio(Integer adjustRatio) { + this.adjustRatio = adjustRatio; + } + + public Integer getAdjustPeriod() { + return adjustPeriod; + } + + public void setAdjustPeriod(Integer adjustPeriod) { + this.adjustPeriod = adjustPeriod; + } + + public Integer getPayRatio() { + return payRatio; + } + + public void setPayRatio(Integer payRatio) { + this.payRatio = payRatio; + } + + public Integer getRevenue() { + return revenue; + } + + public void setRevenue(Integer revenue) { + this.revenue = revenue; + } + public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), MerchantId_ASC("`merchant_id` ASC"), MerchantId_DESC("`merchant_id` DESC"), Price_ASC("`price` ASC"), Price_DESC("`price` DESC"), RentalStartDate_ASC("`rental_start_date` ASC"), RentalStartDate_DESC("`rental_start_date` DESC"), RentalEndDate_ASC("`rental_end_date` ASC"), RentalEndDate_DESC("`rental_end_date` DESC"), SignDate_ASC("`sign_date` ASC"), SignDate_DESC("`sign_date` DESC"), ReceivePeriod_ASC("`receive_period` ASC"), ReceivePeriod_DESC("`receive_period` DESC"), TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), Filepath_ASC("`filepath` ASC"), Filepath_DESC("`filepath` DESC"), Status_ASC("`status` ASC"), Status_DESC("`status` DESC"), ContractNumber_ASC("`contract_number` ASC"), ContractNumber_DESC("`contract_number` DESC"), Deposit_ASC("`deposit` ASC"), Deposit_DESC("`deposit` DESC"), PayDate_ASC("`pay_date` ASC"), PayDate_DESC("`pay_date` DESC"), IsDel_ASC("`is_del` ASC"), IsDel_DESC("`is_del` DESC"), MerchantName_ASC("`merchant_name` ASC"), MerchantName_DESC("`merchant_name` DESC"), Brand_ASC("`brand` ASC"), Brand_DESC("`brand` DESC"), BusinessId_ASC("`business_id` ASC"), BusinessId_DESC("`business_id` DESC"), ShopType_ASC("`shop_type` ASC"), ShopType_DESC("`shop_type` DESC"), ShopId_ASC("`shop_id` ASC"), ShopId_DESC("`shop_id` DESC"), Updatetime_ASC("`updatetime` ASC"), Updatetime_DESC("`updatetime` DESC"), Createtime_ASC("`createtime` ASC"), Createtime_DESC("`createtime` DESC"); private String value; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumRentContractType.java b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractType.java new file mode 100644 index 000000000..f83d37d81 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ + +public enum EnumRentContractType { + + RENT_BY_AREA(1, "面积"), + RENT_BY_JOINT(2, "联营扣点") + ; + + public static EnumRentContractType getEnum(Integer code) { + for (EnumRentContractType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumRentContractType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 8bf390867..28b3e32d0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -23,6 +23,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; import java.util.*; @@ -142,12 +144,29 @@ public class WxRentContractServiceImpl implements WxRentContractService { instance.add(Calendar.MONTH, record.getLease()); instance.add(Calendar.DAY_OF_MONTH, -1); record.setRentalEndDate(instance.getTime()); - record.setPrice(record.getPrice() != null ? record.getPrice() : 0); - record.setDeposit(record.getDeposit() != null ? record.getDeposit() : 0); - record.setUpdatetime(new Date()); - if (record.getPrice() == 0 || record.getDeposit() == 0) { - record.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); + + if(record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())){ + if(record.getRevenue()==null || record.getRevenue().intValue()==0){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"营业额不能为空且大于0"); + } + if(record.getPayRatio()==null || record.getPayRatio().intValue()==0){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"支付比例不能为空且大于0"); + } + BigDecimal hundred = new BigDecimal(100); + BigDecimal oneThousand = new BigDecimal(10000); + BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(hundred); + BigDecimal payRatio = new BigDecimal(record.getPayRatio()).divide(oneThousand); + BigDecimal price = revenue.multiply(payRatio).setScale(2,RoundingMode.HALF_EVEN); + record.setPrice(price.multiply(hundred).intValue()); } + if(record.getPrice()==null || record.getPrice().intValue()==0){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"租金不能为空且大于0"); + } + if(record.getDeposit()==null || record.getDeposit().intValue()==0){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"押金不能为空且大于0"); + } + + record.setUpdatetime(new Date()); try { WxRentContract wxRentContractParams = new WxRentContract(); wxRentContractParams.setTenantId(record.getTenantId()); diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 80c7728a9..d5ae8769f 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -28,11 +28,19 @@ - + + + + + + - `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`,`pay_account`,`filename`,`lease` + `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`, + `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, + `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, + `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio` @@ -63,6 +71,7 @@ and `pay_account` = #{payAccount} and `filename` = #{filename} and `lease` = #{lease} + and `type` = #{type} @@ -84,7 +93,7 @@