完善合约状态字典,调整新增合约、修改合约、审核合约(包括会员的自动添加),未处理合约模块的权限。
This commit is contained in:
@ -15,6 +15,13 @@
|
||||
<description>私家农场(社区支持农业)管理系统</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
@ -39,4 +46,25 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -2,16 +2,12 @@ package com.jlt.csa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
@ -77,6 +73,8 @@ public class FarmerContractController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody FarmerContract farmerContract)
|
||||
{
|
||||
farmerContract.countDays();
|
||||
farmerContract.setStatus(DictUtils.getDictValue("csa_contract_status", "待定"));
|
||||
farmerContract.setCreateBy(getUsername());
|
||||
return toAjax(farmerContractService.insertFarmerContract(farmerContract));
|
||||
}
|
||||
@ -89,6 +87,9 @@ public class FarmerContractController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody FarmerContract farmerContract)
|
||||
{
|
||||
logger.error("--==> AAA");
|
||||
farmerContract.countDays();
|
||||
farmerContract.setStatus(null);
|
||||
farmerContract.setUpdateBy(getUsername());
|
||||
return toAjax(farmerContractService.updateFarmerContract(farmerContract));
|
||||
}
|
||||
@ -101,6 +102,21 @@ public class FarmerContractController extends BaseController
|
||||
@DeleteMapping("/{contractIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] contractIds)
|
||||
{
|
||||
return toAjax(farmerContractService.deleteFarmerContractByContractIds(contractIds));
|
||||
if (contractIds.length == 1) {
|
||||
return toAjax(farmerContractService.deleteFarmerContractByContractId(contractIds[0]));
|
||||
} else {
|
||||
return toAjax(farmerContractService.deleteFarmerContractByContractIds(contractIds));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核会员合约
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('csa:contract:edit')")
|
||||
@Log(title = "会员签约", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/audit/{contractId}")
|
||||
public AjaxResult audit(@PathVariable Long contractId)
|
||||
{
|
||||
return toAjax(farmerContractService.auditContract(contractId));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,11 @@
|
||||
package com.jlt.csa.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@ -34,9 +30,9 @@ public class FarmerContract extends BaseEntity
|
||||
@Excel(name = "会员id")
|
||||
private Long farmerId;
|
||||
|
||||
/** 会员姓名 */
|
||||
@Excel(name = "会员姓名")
|
||||
private String memberName;
|
||||
/** 签约人 */
|
||||
@Excel(name = "签约人")
|
||||
private String contractor;
|
||||
|
||||
/** 合约金币 */
|
||||
@Excel(name = "合约金币")
|
||||
@ -124,14 +120,14 @@ public class FarmerContract extends BaseEntity
|
||||
{
|
||||
return farmerId;
|
||||
}
|
||||
public void setMemberName(String memberName)
|
||||
public void setContractor(String contractor)
|
||||
{
|
||||
this.memberName = memberName;
|
||||
this.contractor = contractor;
|
||||
}
|
||||
|
||||
public String getMemberName()
|
||||
public String getContractor()
|
||||
{
|
||||
return memberName;
|
||||
return contractor;
|
||||
}
|
||||
public void setCoins(BigDecimal coins)
|
||||
{
|
||||
@ -237,7 +233,7 @@ public class FarmerContract extends BaseEntity
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("contractId", getContractId())
|
||||
.append("farmerId", getFarmerId())
|
||||
.append("memberName", getMemberName())
|
||||
.append("memberName", getContractor())
|
||||
.append("coins", getCoins())
|
||||
.append("balance", getBalance())
|
||||
.append("weight", getWeight())
|
||||
|
@ -2,6 +2,7 @@ package com.jlt.csa.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.jlt.csa.domain.FarmerContract;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 会员签约Mapper接口
|
||||
@ -49,7 +50,7 @@ public interface FarmerContractMapper
|
||||
* @param contractId 会员签约主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteFarmerContractByContractId(Long contractId);
|
||||
public int deleteFarmerContractByContractId(@Param("contractId") Long contractId, @Param("status") String status);
|
||||
|
||||
/**
|
||||
* 批量删除会员签约
|
||||
@ -57,5 +58,5 @@ public interface FarmerContractMapper
|
||||
* @param contractIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteFarmerContractByContractIds(Long[] contractIds);
|
||||
public int deleteFarmerContractByContractIds(@Param("contractIds") Long[] contractIds, @Param("status") String status);
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package com.jlt.csa.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.jlt.csa.domain.FarmerContract;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* 会员签约Service接口
|
||||
@ -58,4 +61,11 @@ public interface IFarmerContractService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteFarmerContractByContractId(Long contractId);
|
||||
|
||||
/**
|
||||
* 审核会员签约信息
|
||||
* @param contractId 合约id
|
||||
* @return 受影响的记录数
|
||||
*/
|
||||
public int auditContract(@PathVariable Long contractId);
|
||||
}
|
||||
|
@ -1,12 +1,22 @@
|
||||
package com.jlt.csa.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.jlt.csa.domain.Farmer;
|
||||
import com.jlt.csa.service.IFarmerService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.ExceptionUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.jlt.csa.mapper.FarmerContractMapper;
|
||||
import com.jlt.csa.domain.FarmerContract;
|
||||
import com.jlt.csa.service.IFarmerContractService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
|
||||
|
||||
/**
|
||||
* 会员签约Service业务层处理
|
||||
@ -17,8 +27,83 @@ import com.jlt.csa.service.IFarmerContractService;
|
||||
@Service
|
||||
public class FarmerContractServiceImpl implements IFarmerContractService
|
||||
{
|
||||
@Autowired
|
||||
private FarmerContractMapper farmerContractMapper;
|
||||
private IFarmerService farmerService;
|
||||
|
||||
@Autowired
|
||||
public void setFarmerContractMapper(FarmerContractMapper farmerContractMapper) {
|
||||
this.farmerContractMapper = farmerContractMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setFarmerService(IFarmerService farmerService) {
|
||||
this.farmerService = farmerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核会员签约信息
|
||||
* @param contractId 合约id
|
||||
* @return 受影响的记录数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int auditContract(Long contractId) {
|
||||
// 载入合约
|
||||
FarmerContract contract = selectFarmerContractByContractId(contractId);
|
||||
|
||||
// 检查合约是否存在,
|
||||
if (contract == null) {
|
||||
throw new RuntimeException("合约不存在,无法审核!");
|
||||
}
|
||||
|
||||
// 合约不符合审核条件,返回错误提示
|
||||
if (!contract.getStatus().equals(DictUtils.getDictValue("csa_contract_status", "待定"))) {
|
||||
throw new RuntimeException("该合约不符合审核条件!");
|
||||
}
|
||||
|
||||
Farmer farmer = null;
|
||||
|
||||
if (contract.getFarmerId() == null) {
|
||||
// 如果是新签,新建地主信息
|
||||
farmer = new Farmer();
|
||||
farmer.setName("待绑定");
|
||||
farmer.setCoins(new BigDecimal(0));
|
||||
farmer.setBalance(new BigDecimal(0));
|
||||
farmer.setWeight(new BigDecimal(0));
|
||||
farmer.setArchedYears(0L);
|
||||
farmer.setJoinDate(contract.getJoinDate());
|
||||
farmer.setIsExpire("N");
|
||||
} else {
|
||||
// 老地主,载入地主信息
|
||||
farmer = farmerService.selectFarmerByFarmerId(contract.getFarmerId());
|
||||
|
||||
if (farmer == null)
|
||||
throw new RuntimeException("该合约指向了不存在的会员信息,无法审核!");
|
||||
}
|
||||
|
||||
// 累计合约信息至地主,菜地有效期需要在绑定地块时处理
|
||||
farmer.setCoins(farmer.getCoins().add(contract.getCoins()));
|
||||
farmer.setBalance(farmer.getBalance().add(contract.getBalance()));
|
||||
farmer.setWeight(farmer.getWeight().add(contract.getWeight()));
|
||||
farmer.setArchedYears(farmer.getArchedYears() + contract.getArchedYears());
|
||||
|
||||
// 构建合约更新字段
|
||||
contract = new FarmerContract();
|
||||
contract.setContractId(contractId);
|
||||
contract.setStatus("0");
|
||||
contract.setUpdateBy(getUsername());
|
||||
|
||||
if (contract.getFarmerId() == null) {
|
||||
// 新地主新签
|
||||
farmerService.insertFarmer(farmer);
|
||||
contract.setFarmerId(farmer.getFarmerId());
|
||||
} else {
|
||||
// 老地主续签
|
||||
farmerService.updateFarmer(farmer);
|
||||
}
|
||||
|
||||
return updateFarmerContract(contract);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员签约
|
||||
@ -53,7 +138,6 @@ public class FarmerContractServiceImpl implements IFarmerContractService
|
||||
@Override
|
||||
public int insertFarmerContract(FarmerContract farmerContract)
|
||||
{
|
||||
farmerContract.countDays();
|
||||
farmerContract.setCreateTime(DateUtils.getNowDate());
|
||||
return farmerContractMapper.insertFarmerContract(farmerContract);
|
||||
}
|
||||
@ -67,13 +151,13 @@ public class FarmerContractServiceImpl implements IFarmerContractService
|
||||
@Override
|
||||
public int updateFarmerContract(FarmerContract farmerContract)
|
||||
{
|
||||
farmerContract.countDays();
|
||||
System.out.println("----------------=====> 111");
|
||||
farmerContract.setUpdateTime(DateUtils.getNowDate());
|
||||
return farmerContractMapper.updateFarmerContract(farmerContract);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除会员签约
|
||||
* 批量逻辑删除会员签约
|
||||
*
|
||||
* @param contractIds 需要删除的会员签约主键
|
||||
* @return 结果
|
||||
@ -81,7 +165,7 @@ public class FarmerContractServiceImpl implements IFarmerContractService
|
||||
@Override
|
||||
public int deleteFarmerContractByContractIds(Long[] contractIds)
|
||||
{
|
||||
return farmerContractMapper.deleteFarmerContractByContractIds(contractIds);
|
||||
return farmerContractMapper.deleteFarmerContractByContractIds(contractIds, "1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,6 +177,6 @@ public class FarmerContractServiceImpl implements IFarmerContractService
|
||||
@Override
|
||||
public int deleteFarmerContractByContractId(Long contractId)
|
||||
{
|
||||
return farmerContractMapper.deleteFarmerContractByContractId(contractId);
|
||||
return farmerContractMapper.deleteFarmerContractByContractId(contractId, "1");
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="FarmerContract" id="FarmerContractResult">
|
||||
<result property="contractId" column="contract_id" />
|
||||
<result property="farmerId" column="farmer_id" />
|
||||
<result property="memberName" column="member_name" />
|
||||
<result property="contractor" column="contractor" />
|
||||
<result property="coins" column="coins" />
|
||||
<result property="balance" column="balance" />
|
||||
<result property="weight" column="weight" />
|
||||
@ -27,16 +27,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFarmerContractVo">
|
||||
select contract_id, farmer_id, member_name, coins, balance, weight, arched_years, activate_way, join_credential_no, join_date, due_date, days, status, del_flag, create_by, create_time, update_by, update_time, remark from csa_farmer_contract
|
||||
select contract_id, farmer_id, contractor, coins, balance, weight, arched_years, activate_way, join_credential_no, join_date, due_date, days, status, del_flag, create_by, create_time, update_by, update_time, remark from csa_farmer_contract
|
||||
</sql>
|
||||
|
||||
<select id="selectFarmerContractList" parameterType="FarmerContract" resultMap="FarmerContractResult">
|
||||
<include refid="selectFarmerContractVo"/>
|
||||
<where>
|
||||
<if test="memberName != null and memberName != ''"> and member_name like concat('%', #{memberName}, '%')</if>
|
||||
<if test="contractor != null and contractor != ''"> and contractor like concat('%', #{contractor}, '%')</if>
|
||||
<if test="joinDate != null "> and join_date = #{joinDate}</if>
|
||||
<if test="dueDate != null "> and due_date = #{dueDate}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="delFlag == null or delFlag == ''"> and del_flag = '0'</if>
|
||||
<if test="delFlag != null and delFlag != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -49,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into csa_farmer_contract
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="farmerId != null">farmer_id,</if>
|
||||
<if test="memberName != null and memberName != ''">member_name,</if>
|
||||
<if test="contractor != null and contractor != ''">contractor,</if>
|
||||
<if test="coins != null">coins,</if>
|
||||
<if test="balance != null">balance,</if>
|
||||
<if test="weight != null">weight,</if>
|
||||
@ -69,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="farmerId != null">#{farmerId},</if>
|
||||
<if test="memberName != null and memberName != ''">#{memberName},</if>
|
||||
<if test="contractor != null and contractor != ''">#{contractor},</if>
|
||||
<if test="coins != null">#{coins},</if>
|
||||
<if test="balance != null">#{balance},</if>
|
||||
<if test="weight != null">#{weight},</if>
|
||||
@ -93,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update csa_farmer_contract
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="farmerId != null">farmer_id = #{farmerId},</if>
|
||||
<if test="memberName != null and memberName != ''">member_name = #{memberName},</if>
|
||||
<if test="contractor != null and contractor != ''">contractor = #{contractor},</if>
|
||||
<if test="coins != null">coins = #{coins},</if>
|
||||
<if test="balance != null">balance = #{balance},</if>
|
||||
<if test="weight != null">weight = #{weight},</if>
|
||||
@ -114,14 +116,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where contract_id = #{contractId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteFarmerContractByContractId" parameterType="Long">
|
||||
delete from csa_farmer_contract where contract_id = #{contractId}
|
||||
<delete id="deleteFarmerContractByContractId">
|
||||
update csa_farmer_contract set del_flag = '2' where contract_id = #{contractId}
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteFarmerContractByContractIds" parameterType="String">
|
||||
delete from csa_farmer_contract where contract_id in
|
||||
<foreach item="contractId" collection="array" open="(" separator="," close=")">
|
||||
<delete id="deleteFarmerContractByContractIds">
|
||||
update csa_farmer_contract set del_flag = '2' where contract_id in
|
||||
<foreach item="contractId" collection="contractIds" open="(" separator="," close=")">
|
||||
#{contractId}
|
||||
</foreach>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</delete>
|
||||
</mapper>
|
Reference in New Issue
Block a user