eason.qian 7 years ago
parent 95c379892f
commit 288f7d5e1f

@ -261,23 +261,23 @@ CREATE TABLE act_mon_delay_settle_redpack
send_time DATETIME COMMENT '奖励发放时间'
);
create table act_app_list
(
act_id varchar(50) not null
primary key,
act_name varchar(100) not null comment '活动名称',
act_url varchar(400) default null comment '活动链接',
is_valid tinyint(1) default '0' not null,
params_json text default null comment '活动参数',
create_time datetime default null,
`desc` varchar(400) default null comment '活动简介',
act_content text default null comment 'html',
show_type smallint(6) default '0' null comment '0:url;1:content',
is_show_window tinyint default '0' null comment 'app是否弹框',
act_img varchar(200) default null comment '广告位图片',
window_img varchar(200) default null comment 'app弹框图片',
update_time datetime default null
)
comment 'app活动' engine=InnoDB
;
CREATE TABLE `act_app_list` (
`act_id` varchar(50) NOT NULL,
`act_name` varchar(100) NOT NULL COMMENT '活动名称',
`act_url` varchar(400) DEFAULT NULL COMMENT '活动链接',
`is_valid` tinyint(1) NOT NULL DEFAULT 0,
`params_json` text DEFAULT NULL COMMENT '活动参数',
`create_time` datetime DEFAULT NULL,
`desc` varchar(400) DEFAULT NULL COMMENT '活动简介',
`act_content` text DEFAULT NULL COMMENT 'html',
`show_type` smallint(6) DEFAULT 0 COMMENT '0:url;1:content',
`is_show_window` tinyint(4) DEFAULT 0 COMMENT 'app是否弹框',
`act_img` varchar(200) DEFAULT NULL COMMENT '广告位图片',
`window_img` varchar(200) DEFAULT NULL COMMENT 'app弹框图片',
`update_time` datetime DEFAULT NULL,
`active_date` date NOT NULL COMMENT '生效日期',
`expire_date` date DEFAULT NULL COMMENT '活动结束日期',
PRIMARY KEY (`act_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='app活动'

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.activities.monsettledelay.core.impls;
import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService;
import au.com.royalpay.payment.manage.mappers.act.ActAppMapper;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleMapper;
import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleRedPackMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
@ -14,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.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
@ -31,8 +33,9 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
private DeviceSupport deviceSupport;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private ActAppMapper actAppMapper;
private final static LocalDate endDate = LocalDate.of(2018,07,01);
@Override
public JSONObject getActNotice(JSONObject device){
@ -50,6 +53,10 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
@Override
public JSONObject getActDetail(JSONObject device){
JSONObject act = actAppMapper.getActDetail("1");
if (!act.getBoolean("is_valid")){
throw new BadRequestException("Activity is not valid");
}
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id");
@ -59,6 +66,17 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
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);
}
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);
@ -69,6 +87,16 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
@Override
public void actApply(JSONObject device){
JSONObject act = actAppMapper.getActDetail("1");
if (!act.getBoolean("is_valid")){
throw new BadRequestException("The activity is not valid");
}
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){
throw new BadRequestException("The activity has expired");
}
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
int client_id = device.getIntValue("client_id");
@ -83,7 +111,7 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService{
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);
device.put("expire_time",act.getDate("expire_date"));
actMonDelaySettleMapper.save(device);
}

Loading…
Cancel
Save