Commit 649b60c7 by guojuxing

Merge remote-tracking branch 'origin/developer' into developer

parents 952f5021 00061a07
......@@ -9,41 +9,40 @@ import org.apache.commons.lang3.StringUtils;
*/
public enum SmsAppEnum {
MEMBER_OPEN_CARD("MEMBER_OPEN_CARD", "会员开卡"),
GIC_MALL("GIC_MALL", "微商城"),
GIC_INTEGRAL("GIC_INTEGRAL", "积分商城"),
SMS("sms", "短信营销"),
ECM("ecm", "触点营销"),
ECM_TIMER("ecm-timer", "定时营销"),
GAME_DZP("dzp", "大转盘"),
GAME_GGK("ggk", "刮刮卡"),
GAME_KLFL("klfl", "口令福利"),
GAME_PTYX("ptyx", "拼图游戏"),
OTHER("other", "其他"),
MEMBER_OPEN_CARD("MEMBER_OPEN_CARD", "会员开卡", false),
GIC_MALL("GIC_MALL", "微商城", true),
GIC_INTEGRAL("GIC_INTEGRAL", "积分商城", true),
SMS("sms", "短信营销", true),
ECM("ecm", "触点营销", true),
ECM_TIMER("ecm-timer", "定时营销", true),
GAME_DZP("dzp", "大转盘", true),
GAME_GGK("ggk", "刮刮卡", true),
GAME_KLFL("klfl", "口令福利", true),
GAME_PTYX("ptyx", "拼图游戏", true),
OTHER("other", "其他", false),
;
private String code;
private String name;
// 需要权限控制
private boolean isCtrl;
SmsAppEnum(String code, String name) {
SmsAppEnum(String code, String name, boolean isCtrl) {
this.code = code;
this.name = name;
this.isCtrl = isCtrl;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
public boolean isCtrl() {
return isCtrl;
}
public static String getNameByCode(String code) {
......
package com.gic.enterprise.qo;
import java.util.List;
/**
*
* @Description:
......@@ -42,6 +44,8 @@ public class RecordQO extends PageQO {
private Integer payType;
private List<String> appCodeList;
public String getStartTime() {
return startTime;
}
......@@ -113,4 +117,12 @@ public class RecordQO extends PageQO {
public void setPayType(Integer payType) {
this.payType = payType;
}
public List<String> getAppCodeList() {
return appCodeList;
}
public void setAppCodeList(List<String> appCodeList) {
this.appCodeList = appCodeList;
}
}
......@@ -467,6 +467,12 @@
<if test="appCode != null ">
and app_code = #{appCode}
</if>
<if test="null != appCodeList and appCodeList.size > 0">
and app_code in
<foreach collection="appCodeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="smsContent != null and smsContent != '' ">
and ( sms_content like concat('%', #{smsContent}, '%') or receive_phone like concat('%', #{smsContent}, '%') )
</if>
......
......@@ -477,6 +477,12 @@
<if test="appCode != null and appCode != '' ">
and app_code = #{appCode}
</if>
<if test="null != appCodeList and appCodeList.size > 0">
and app_code in
<foreach collection="appCodeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="smsContent != null and smsContent != '' ">
and (sms_content like concat('%', #{smsContent}, '%') or receive_phone like concat('%', #{smsContent}, '%') )
</if>
......
......@@ -251,7 +251,7 @@
and (update_time &gt;= #{startTime} or push_time &gt;= #{startTime})
</if>
<if test="endTime != null">
and (update_time &lt;= #{endTime} or update_time &lt;= #{endTime})
and (update_time &lt;= #{endTime} or push_time &lt;= #{endTime})
</if>
<if test="pushClassifyId != null">
and push_classify_id = #{pushClassifyId}
......@@ -264,7 +264,7 @@
where t1.user_id=#{userId}
and (t1.status = 1 or t1.status = 2) and t1.message_id=t3.message_id
<if test="search != null and search != ''">
and (title like concat('%', #{search}, '%') or content like concat('%', #{search}, '%'))
and (t1.title like concat('%', #{search}, '%') or t1.content like concat('%', #{search}, '%'))
</if>
<if test="status != null">
and t1.status = #{status}
......
......@@ -2,25 +2,35 @@ package com.gic.enterprise.web.controller;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.service.MenuApiService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.constant.SmsAppEnum;
import com.gic.enterprise.dto.*;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.qo.RecordQO;
import com.gic.enterprise.service.BillingRecordApiService;
import com.gic.enterprise.service.DictApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.enterprise.web.vo.*;
import com.gic.open.api.dto.ApplicationDTO;
import com.gic.open.api.service.ApplicationApiService;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
*
......@@ -31,10 +41,32 @@ import java.util.Map;
@RestController
public class BillingRecordController {
private Logger logger = LogManager.getLogger(BillingRecordController.class);
@Autowired
private BillingRecordApiService billingRecordApiService;
@Autowired
private DictApiService dictApiService;
@Autowired
ApplicationApiService applicationApiService;
@Autowired
MenuApiService menuApiService;
LoadingCache<String, Long> appCache = CacheBuilder.newBuilder()
.maximumSize(20)
.expireAfterWrite(1L, TimeUnit.HOURS)
.build(new CacheLoader<String, Long>() {
@Override
public Long load(String s) throws Exception {
ApplicationDTO applicationDTO = applicationApiService.getApplicationByModule(s).getResult();
if (applicationDTO != null) {
return applicationDTO.getApplicationId();
} else {
return null;
}
}
});
@RequestMapping("/list-account-balance")
public RestResponse listAccountBalanceRecord(RecordQO recordQO) {
......@@ -101,10 +133,23 @@ public class BillingRecordController {
if (StringUtils.isNotBlank(recordQO.getEndTime())) {
recordQO.setEndTime(recordQO.getEndTime() + " 23:59:59");
}
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() == 0 && StringUtils.isBlank(recordQO.getAppCode())) {
Set<String> appIdList = menuApiService.getAppIdSetByUserId(UserDetailUtils.getUserDetail().getUserId()).getResult();
if (CollectionUtils.isEmpty(appIdList)) {
return RestResponse.success(new Page<>());
}
List<ApplicationDTO> applicationList = applicationApiService.listApplicationByIdIn(appIdList.stream().map(Long::valueOf).collect(Collectors.toList())).getResult();
if (CollectionUtils.isEmpty(applicationList)) {
return RestResponse.success(new Page<>());
}
List<String> appCodeList = applicationList.stream().map(ApplicationDTO::getModuleCode).collect(Collectors.toList());
recordQO.setAppCodeList(appCodeList);
}
ServiceResponse<Page<SmsRecordDTO>> serviceResponse = billingRecordApiService.listSmsRecord(recordQO);
if (serviceResponse.isSuccess()) {
Page page = new Page(serviceResponse.getResult().getCurrentPage(), serviceResponse.getResult().getPageSize(), serviceResponse.getResult().getTotalPage(), serviceResponse.getResult().getTotalCount());
Page page = new Page(serviceResponse.getResult().getCurrentPage(), serviceResponse.getResult().getPageSize(),
serviceResponse.getResult().getTotalPage(), serviceResponse.getResult().getTotalCount());
List<SmsRecordVO> list = EntityUtil.changeEntityListByJSON(SmsRecordVO.class, serviceResponse.getResult().getResult());
page.setResult(list);
return RestResponse.success(page);
......@@ -116,6 +161,24 @@ public class BillingRecordController {
@RequestMapping("/list-international-sms")
public RestResponse listInternationalSmsRecord(RecordQO recordQO) {
recordQO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
if (StringUtils.isNotBlank(recordQO.getStartTime())) {
recordQO.setStartTime(recordQO.getStartTime() + " 00:00:00");
}
if (StringUtils.isNotBlank(recordQO.getEndTime())) {
recordQO.setEndTime(recordQO.getEndTime() + " 23:59:59");
}
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() == 0 && StringUtils.isBlank(recordQO.getAppCode())) {
Set<String> appIdList = menuApiService.getAppIdSetByUserId(UserDetailUtils.getUserDetail().getUserId()).getResult();
if (CollectionUtils.isEmpty(appIdList)) {
return RestResponse.success(new Page<>());
}
List<ApplicationDTO> applicationList = applicationApiService.listApplicationByIdIn(appIdList.stream().map(Long::valueOf).collect(Collectors.toList())).getResult();
if (CollectionUtils.isEmpty(applicationList)) {
return RestResponse.success(new Page<>());
}
List<String> appCodeList = applicationList.stream().map(ApplicationDTO::getModuleCode).collect(Collectors.toList());
recordQO.setAppCodeList(appCodeList);
}
ServiceResponse<Page<InternationalSmsRecordDTO>> serviceResponse = billingRecordApiService.listInternationalSmsRecord(recordQO);
if (serviceResponse.isSuccess()) {
Page page = new Page(serviceResponse.getResult().getCurrentPage(), serviceResponse.getResult().getPageSize(), serviceResponse.getResult().getTotalPage(), serviceResponse.getResult().getTotalCount());
......@@ -149,14 +212,31 @@ public class BillingRecordController {
@RequestMapping("/list-sms-app-type")
public RestResponse listSmsAppType() {
List<Map<String, String>> list = new ArrayList<>();
for (SmsAppEnum app : SmsAppEnum.values()) {
HashMap<String, String> map = new HashMap<>();
map.put("key", app.getName());
map.put("value", app.getCode());
list.add(map);
Set<String> appIdSet;
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() == 0) {
appIdSet = menuApiService.getAppIdSetByUserId(UserDetailUtils.getUserDetail().getUserId()).getResult();
} else {
appIdSet = new HashSet<>();
}
try {
List<Map<String, String>> list = new ArrayList<>();
for (SmsAppEnum app : SmsAppEnum.values()) {
HashMap<String, String> map = new HashMap<>();
if (app.isCtrl() && UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin() == 0) {
Long appId = appCache.get(app.getCode());
if (!appIdSet.contains(appId.toString())) {
continue;
}
}
map.put("key", app.getName());
map.put("value", app.getCode());
list.add(map);
}
return RestResponse.success(list);
} catch (ExecutionException e) {
logger.info("获取缓存失败", e);
}
return RestResponse.success(list);
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), ErrorCode.SYSTEM_ERROR.getMsg());
}
......
......@@ -115,4 +115,5 @@
<dubbo:reference interface="com.gic.marketing.api.service.coupon.CouponShelfApiService" id="couponShelfApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.open.api.service.AppTokenApiService" id="appTokenApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.open.api.service.ApplicationApiService" id="applicationApiService" timeout="6000"/>
</beans>
......@@ -79,11 +79,11 @@ public class PushMessageController {
@RequestMapping("page-push-message")
public RestResponse pagePushMessage(String search, Integer pushStatus, Integer classifyId, String startTime, String endTime, PageQO pageQO){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ServiceResponse<Page<PushMessageDTO>> response = null;
try {
response = this.pushMessageApiService.pagePushMessage(search, pushStatus,
StringUtils.isBlank(startTime) ? null : simpleDateFormat.parse(startTime), StringUtils.isBlank(endTime) ? null : simpleDateFormat.parse(endTime), pageQO.getCurrentPage(), pageQO.getPageSize(), classifyId);
StringUtils.isBlank(startTime) ? null : simpleDateFormat.parse(startTime+" 00:00:00"), StringUtils.isBlank(endTime) ? null : simpleDateFormat.parse(endTime+" 23:59:59"), pageQO.getCurrentPage(), pageQO.getPageSize(), classifyId);
} catch (ParseException e) {
e.printStackTrace();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment