|
|
|
@ -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.PageList;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -24,7 +25,7 @@ import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
|
|
|
|
|
public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ActMonDelaySettleRedPackMapper actMonDelaySettleRedPackMapper;
|
|
|
|
|
@Resource
|
|
|
|
@ -38,23 +39,23 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getActNotice(JSONObject device){
|
|
|
|
|
public JSONObject getActNotice(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
int client_id = device.getIntValue("client_id");
|
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
res.put("total_redpack",total_redpack);
|
|
|
|
|
res.put("desc","你有一份奖励待领取");
|
|
|
|
|
res.put("total_redpack", total_redpack);
|
|
|
|
|
res.put("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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getActDetail(JSONObject device){
|
|
|
|
|
public JSONObject getActDetail(JSONObject device) {
|
|
|
|
|
JSONObject act = actAppMapper.getActDetail("1");
|
|
|
|
|
if (!act.getBoolean("is_valid")){
|
|
|
|
|
if (!act.getBoolean("is_valid")) {
|
|
|
|
|
throw new BadRequestException("Activity is not valid");
|
|
|
|
|
}
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
@ -63,70 +64,72 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
|
|
|
|
|
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
Boolean apply = false;
|
|
|
|
|
if (!clientLogs.isEmpty() && clientLogs.size()>0){
|
|
|
|
|
if (!clientLogs.isEmpty() && clientLogs.size() > 0) {
|
|
|
|
|
apply = true;
|
|
|
|
|
}
|
|
|
|
|
if (new Date().compareTo(act.getDate("active_date"))<0){
|
|
|
|
|
res.put("active",false);
|
|
|
|
|
res.put("active_date",act.getDate("active_date"));
|
|
|
|
|
res.put("expire",false);
|
|
|
|
|
}else if (new Date().compareTo(act.getDate("expire_date"))>0){
|
|
|
|
|
res.put("active",false);
|
|
|
|
|
res.put("expire",true);
|
|
|
|
|
}else {
|
|
|
|
|
res.put("active",true);
|
|
|
|
|
res.put("expire",false);
|
|
|
|
|
if (new Date().compareTo(act.getDate("active_date")) < 0) {
|
|
|
|
|
res.put("active", false);
|
|
|
|
|
res.put("active_date", act.getDate("active_date"));
|
|
|
|
|
res.put("expire", false);
|
|
|
|
|
} else if (new Date().compareTo(act.getDate("expire_date")) > 0) {
|
|
|
|
|
res.put("active", false);
|
|
|
|
|
res.put("expire", true);
|
|
|
|
|
} else {
|
|
|
|
|
res.put("active", true);
|
|
|
|
|
res.put("expire", false);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
|
|
|
|
|
PageList<JSONObject> list = actMonDelaySettleRedPackMapper.listRedpacks(client_id,new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
|
res.put("apply",apply);
|
|
|
|
|
res.put("total_redpack",total_redpack);
|
|
|
|
|
res.put("list",list);
|
|
|
|
|
PageList<JSONObject> list = actMonDelaySettleRedPackMapper.listRedpacks(client_id, new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
|
res.put("apply", apply);
|
|
|
|
|
res.put("total_redpack", total_redpack);
|
|
|
|
|
res.put("list", list);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actApply(JSONObject device){
|
|
|
|
|
public void actApply(JSONObject device) {
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
int client_id = device.getIntValue("client_id");
|
|
|
|
|
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
|
|
|
|
|
if (!clientLogs.isEmpty() && clientLogs.size()>0){
|
|
|
|
|
if (!clientLogs.isEmpty() && clientLogs.size() > 0) {
|
|
|
|
|
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) {
|
|
|
|
|
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("create_time",new Date());
|
|
|
|
|
device.put("rate",new BigDecimal(12));
|
|
|
|
|
device.put("expire_time",act.getDate("expire_date"));
|
|
|
|
|
device.put("account_name", account.getString("display_name"));
|
|
|
|
|
device.put("create_time", new Date());
|
|
|
|
|
JSONObject params = act.getJSONObject("params_json");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void cancelAct(JSONObject device){
|
|
|
|
|
public void cancelAct(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|
int client_id = device.getIntValue("client_id");
|
|
|
|
|
List<JSONObject> clientLogs = actMonDelaySettleMapper.clientLog(client_id);
|
|
|
|
|
if (clientLogs.isEmpty() || clientLogs.size()==0){
|
|
|
|
|
if (clientLogs.isEmpty() || clientLogs.size() == 0) {
|
|
|
|
|
throw new BadRequestException("您未参加活动,不可取消");
|
|
|
|
|
}
|
|
|
|
|
JSONObject clientLog = clientLogs.get(0);
|
|
|
|
|
clientLog.put("is_valid",0);
|
|
|
|
|
clientLog.put("expire_time",new Date());
|
|
|
|
|
clientLog.put("is_valid", 0);
|
|
|
|
|
clientLog.put("expire_time", new Date());
|
|
|
|
|
actMonDelaySettleMapper.update(clientLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|