代码优化

master
yixian 7 years ago
parent 1c3ace6ffd
commit 28933de278

@ -17,11 +17,9 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -65,7 +63,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id); List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
Boolean apply = false; Boolean apply = false;
if (!clientLogs.isEmpty() && clientLogs.size() > 0) { if (!clientLogs.isEmpty()) {
apply = true; apply = true;
} }
if (new Date().compareTo(act.getDate("active_date")) < 0) { if (new Date().compareTo(act.getDate("active_date")) < 0) {
@ -90,7 +88,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
@Override @Override
public void actApply(JSONObject device) { public void actApply(JSONObject device) {
JSONObject act = actAppMapper.getActDetail("1"); JSONObject act = actAppMapper.getActDetail("1");
Assert.notNull(act,"The activity is not valid"); Assert.notNull(act, "The activity is not valid");
if (!act.getBoolean("is_valid")) { if (!act.getBoolean("is_valid")) {
throw new BadRequestException("The activity is not valid"); throw new BadRequestException("The activity is not valid");
} }
@ -104,7 +102,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
deviceSupport.findRegister(clientType); deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id"); int client_id = device.getIntValue("client_id");
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id); List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
if (!clientLogs.isEmpty() && clientLogs.size() > 0) { if (!clientLogs.isEmpty()) {
throw new BadRequestException("您已经参与过活动,无需重复报名"); throw new BadRequestException("您已经参与过活动,无需重复报名");
} }
JSONObject account = clientAccountMapper.findById(device.getString("account_id")); JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
@ -125,7 +123,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
deviceSupport.findRegister(clientType); deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id"); int client_id = device.getIntValue("client_id");
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id); List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
if (clientLogs.isEmpty() || clientLogs.size() == 0) { if (clientLogs.isEmpty()) {
throw new BadRequestException("您未参加活动,不可取消"); throw new BadRequestException("您未参加活动,不可取消");
} }
JSONObject clientLog = clientLogs.get(0); JSONObject clientLog = clientLogs.get(0);

@ -4,7 +4,7 @@
<select id="listAttendClients" resultType="com.alibaba.fastjson.JSONObject"> <select id="listAttendClients" resultType="com.alibaba.fastjson.JSONObject">
select act.account_name,act.create_time,act.client_id,c.client_moniker select act.account_name,act.create_time,act.client_id,c.client_moniker
FROM act_mon_delay_settle act FROM act_mon_delay_settle act
LEFT JOIN sys_clients c ON act.client_id = c.client_id INNER JOIN sys_clients c ON act.client_id = c.client_id
<where> <where>
act.is_valid = 1 and c.is_valid = 1 act.is_valid = 1 and c.is_valid = 1
<if test="client_moniker!=null">and c.client_moniker = #{client_moniker}</if> <if test="client_moniker!=null">and c.client_moniker = #{client_moniker}</if>

Loading…
Cancel
Save