master
eason.qian 7 years ago
parent 92a9fb7482
commit 93b4ac57b2

@ -4,4 +4,10 @@ import com.alibaba.fastjson.JSONObject;
public interface ActMonDelaySettleService {
JSONObject getActNotice(JSONObject device);
JSONObject getActDetail(JSONObject device);
void actApply(JSONObject device);
void cancelAct(JSONObject device);
}

@ -6,6 +6,9 @@ import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleRedPackMapper
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
@ -14,6 +17,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@Service
@ -27,18 +32,14 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
@Resource
private ClientAccountMapper clientAccountMapper;
private final static LocalDate endDate = LocalDate.of(2018,07,01);
@Override
public JSONObject getActNotice(JSONObject device){
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_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");
// }
// device.put("account_name",account.getString("display_name"));
// device.put("create_time",new Date());
// device.put("rate",new BigDecimal(12));
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
JSONObject res = new JSONObject();
res.put("total_redpack",total_redpack);
@ -47,6 +48,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
return res;
}
@Override
public JSONObject getActDetail(JSONObject device){
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
@ -58,11 +60,46 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
apply = true;
}
BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id);
PageList<JSONObject> list = actMonDelaySettleRedPackMapper.listRedpacks(client_id,new PageBounds(Order.formString("send_time")));
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){
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){
throw new BadRequestException("您已经参与过活动,无需重复报名");
}
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");
}
device.put("account_name",account.getString("display_name"));
device.put("create_time",new Date());
device.put("rate",new BigDecimal(12));
device.put("expire_time",endDate);
actMonDelaySettleMapper.save(device);
}
@Override
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){
throw new BadRequestException("您未参加活动,不可取消");
}
JSONObject clientLog = clientLogs.get(0);
clientLog.put("is_valid",0);
clientLog.put("expire_time",new Date());
actMonDelaySettleMapper.update(clientLog);
}
}

@ -12,7 +12,10 @@ import java.util.List;
@AutoMapper(tablename = "act_mon_delay_settle", pkName = "id")
public interface ActMonDelaySettleMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject dietOrderInfo);
void save(JSONObject clientlog);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject clientlog);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")

Loading…
Cancel
Save