|
|
@ -15,6 +15,7 @@ import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
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.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
@ -24,7 +25,7 @@ import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
|
|
|
|
public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ActMonDelaySettleRedPackMapper actMonDelaySettleRedPackMapper;
|
|
|
|
private ActMonDelaySettleRedPackMapper actMonDelaySettleRedPackMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -38,23 +39,23 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getActNotice(JSONObject device){
|
|
|
|
public JSONObject getActNotice(JSONObject device) {
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
int client_id = device.getIntValue("client_id");
|
|
|
|
int client_id = device.getIntValue("client_id");
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
res.put("total_redpack",total_redpack);
|
|
|
|
res.put("total_redpack", total_redpack);
|
|
|
|
res.put("desc","你有一份奖励待领取");
|
|
|
|
res.put("desc", "你有一份奖励待领取");
|
|
|
|
res.put("url", PlatformEnvironment.getEnv().concatUrl("/api/v1.0/retail/app/act/mondelay/desc"));
|
|
|
|
res.put("url", PlatformEnvironment.getEnv().concatUrl("/api/v1.0/retail/app/act/mondelay/desc"));
|
|
|
|
res.put("show",true);
|
|
|
|
res.put("show", true);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getActDetail(JSONObject device){
|
|
|
|
public JSONObject getActDetail(JSONObject device) {
|
|
|
|
JSONObject act = actAppMapper.getActDetail("1");
|
|
|
|
JSONObject act = actAppMapper.getActDetail("1");
|
|
|
|
if (!act.getBoolean("is_valid")){
|
|
|
|
if (!act.getBoolean("is_valid")) {
|
|
|
|
throw new BadRequestException("Activity is not valid");
|
|
|
|
throw new BadRequestException("Activity is not valid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
@ -63,70 +64,72 @@ 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() && clientLogs.size() > 0) {
|
|
|
|
apply = true;
|
|
|
|
apply = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new Date().compareTo(act.getDate("active_date"))<0){
|
|
|
|
if (new Date().compareTo(act.getDate("active_date")) < 0) {
|
|
|
|
res.put("active",false);
|
|
|
|
res.put("active", false);
|
|
|
|
res.put("active_date",act.getDate("active_date"));
|
|
|
|
res.put("active_date", act.getDate("active_date"));
|
|
|
|
res.put("expire",false);
|
|
|
|
res.put("expire", false);
|
|
|
|
}else if (new Date().compareTo(act.getDate("expire_date"))>0){
|
|
|
|
} else if (new Date().compareTo(act.getDate("expire_date")) > 0) {
|
|
|
|
res.put("active",false);
|
|
|
|
res.put("active", false);
|
|
|
|
res.put("expire",true);
|
|
|
|
res.put("expire", true);
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
res.put("active",true);
|
|
|
|
res.put("active", true);
|
|
|
|
res.put("expire",false);
|
|
|
|
res.put("expire", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
PageList<JSONObject> list = actMonDelaySettleRedPackMapper.listRedpacks(client_id,new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
PageList<JSONObject> list = actMonDelaySettleRedPackMapper.listRedpacks(client_id, new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
res.put("apply",apply);
|
|
|
|
res.put("apply", apply);
|
|
|
|
res.put("total_redpack",total_redpack);
|
|
|
|
res.put("total_redpack", total_redpack);
|
|
|
|
res.put("list",list);
|
|
|
|
res.put("list", list);
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void actApply(JSONObject device){
|
|
|
|
public void actApply(JSONObject device) {
|
|
|
|
JSONObject act = actAppMapper.getActDetail("1");
|
|
|
|
JSONObject act = actAppMapper.getActDetail("1");
|
|
|
|
if (!act.getBoolean("is_valid")){
|
|
|
|
Assert.notNull(act,"The activity is not valid");
|
|
|
|
|
|
|
|
if (!act.getBoolean("is_valid")) {
|
|
|
|
throw new BadRequestException("The activity is not valid");
|
|
|
|
throw new BadRequestException("The activity is not valid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new Date().compareTo(act.getDate("active_date"))<0){
|
|
|
|
if (new Date().compareTo(act.getDate("active_date")) < 0) {
|
|
|
|
throw new BadRequestException("The activity has not yet begin");
|
|
|
|
throw new BadRequestException("The activity has not yet begin");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new Date().compareTo(act.getDate("expire_date"))>0){
|
|
|
|
if (new Date().compareTo(act.getDate("expire_date")) > 0) {
|
|
|
|
throw new BadRequestException("The activity has expired");
|
|
|
|
throw new BadRequestException("The activity has expired");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
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() && clientLogs.size() > 0) {
|
|
|
|
throw new BadRequestException("您已经参与过活动,无需重复报名");
|
|
|
|
throw new BadRequestException("您已经参与过活动,无需重复报名");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
if (device.getIntValue("client_id") != account.getIntValue("client_id") || PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
|
|
|
|
if (device.getIntValue("client_id") != account.getIntValue("client_id") || PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) {
|
|
|
|
throw new ForbiddenException("You have no permission");
|
|
|
|
throw new ForbiddenException("You have no permission.Please login in using the administrator account");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
device.put("account_name",account.getString("display_name"));
|
|
|
|
device.put("account_name", account.getString("display_name"));
|
|
|
|
device.put("create_time",new Date());
|
|
|
|
device.put("create_time", new Date());
|
|
|
|
device.put("rate",new BigDecimal(12));
|
|
|
|
JSONObject params = act.getJSONObject("params_json");
|
|
|
|
device.put("expire_time",act.getDate("expire_date"));
|
|
|
|
device.put("rate", params.getBigDecimal("rate") == null ? new BigDecimal(0.15) : params.getBigDecimal("rate"));
|
|
|
|
|
|
|
|
device.put("expire_time", act.getDate("expire_date"));
|
|
|
|
actMonDelaySettleMapper.save(device);
|
|
|
|
actMonDelaySettleMapper.save(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void cancelAct(JSONObject device){
|
|
|
|
public void cancelAct(JSONObject device) {
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
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() || clientLogs.size() == 0) {
|
|
|
|
throw new BadRequestException("您未参加活动,不可取消");
|
|
|
|
throw new BadRequestException("您未参加活动,不可取消");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject clientLog = clientLogs.get(0);
|
|
|
|
JSONObject clientLog = clientLogs.get(0);
|
|
|
|
clientLog.put("is_valid",0);
|
|
|
|
clientLog.put("is_valid", 0);
|
|
|
|
clientLog.put("expire_time",new Date());
|
|
|
|
clientLog.put("expire_time", new Date());
|
|
|
|
actMonDelaySettleMapper.update(clientLog);
|
|
|
|
actMonDelaySettleMapper.update(clientLog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|