1、优化发布java代码流程,开源不易,开源统计请大家配合,谢谢。
2、修复bug 3、优化sql文件 4、短信回执
This commit is contained in:
@@ -31,12 +31,16 @@ public class SmsConstants {
|
||||
public static final String SMS_API_TEMP_LIST_URI = "sms/template";
|
||||
// 发送短信
|
||||
public static final String SMS_API_SEND_URI = "sms/send";
|
||||
// 获取发送状态
|
||||
public static final String SMS_API_SEND_STATUS = "sms/status";
|
||||
|
||||
//接口异常错误码
|
||||
public static final Integer SMS_ERROR_CODE = 400;
|
||||
|
||||
//短信发送队列key
|
||||
public static final String SMS_SEND_KEY = "sms_send_list";
|
||||
// 发送短信后状态同步key
|
||||
public static final String SMS_SEND_RESULT_KEY = "sms_send_result_list";
|
||||
|
||||
// 短信模版配置开关常量
|
||||
public static final String SMS_CONFIG_VERIFICATION_CODE = "verificationCode";// 验证码
|
||||
|
||||
@@ -12,11 +12,9 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.security.Security;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -539,47 +537,48 @@ public class CrmebUtil {
|
||||
|
||||
/**
|
||||
* 同比率计算 //同比增长率= ((当前周期 - 上一个周期) ÷ 上一个周期 ) *100%
|
||||
* @param now 当前周期
|
||||
* @param last 上一个周期
|
||||
* @param i1 当前周期
|
||||
* @param i2 上一个周期
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-06
|
||||
* @
|
||||
*/
|
||||
public static String getRate(Integer now, Integer last){
|
||||
int diff = now - last;
|
||||
if(diff == 0){
|
||||
return "0%";
|
||||
}
|
||||
|
||||
return (((now - last) / last) * 100) + "%";
|
||||
public static int getRate(Integer i1, Integer i2){
|
||||
BigDecimal b1 = new BigDecimal(i1);
|
||||
BigDecimal b2 = new BigDecimal(i2);
|
||||
return getRate(b1, b2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同比率计算 //同比增长率= ((当前周期 - 上一个周期) ÷ 上一个周期 ) *100%
|
||||
* @param now 当前周期
|
||||
* @param last 上一个周期
|
||||
* @param b1 当前周期
|
||||
* @param b2 上一个周期
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-05-06
|
||||
* @
|
||||
*/
|
||||
public static String getRate(BigDecimal now, BigDecimal last){
|
||||
public static int getRate(BigDecimal b1, BigDecimal b2){
|
||||
//计算差值
|
||||
BigDecimal subtract = now.subtract(now);
|
||||
BigDecimal zero = new BigDecimal(BigInteger.ZERO);
|
||||
if(subtract.equals(zero)){
|
||||
|
||||
if(b2.equals(b1)){
|
||||
//数值一样,说明没有增长
|
||||
return "0%";
|
||||
return Constants.NUM_ZERO;
|
||||
}
|
||||
|
||||
if(b2.equals(BigDecimal.ZERO)){
|
||||
//b2是0
|
||||
return Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
|
||||
return (b1.subtract(b2)).divide(b2, 2, BigDecimal.ROUND_UP).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue();
|
||||
|
||||
|
||||
// BigDecimal.setScale();//用于格式化小数点
|
||||
// setScale(1);//表示保留以为小数,默认用四舍五入方式
|
||||
// setScale(1,BigDecimal.ROUND_DOWN);//直接删除多余的小数位,如2.35会变成2.3
|
||||
// setScale(1,BigDecimal.ROUND_UP);//进位处理,2.35变成2.4
|
||||
// setScale(1,BigDecimal.ROUND_HALF_UP);//四舍五入,2.35变成2.4
|
||||
// setScaler(1,BigDecimal.ROUND_HALF_DOWN);//四舍五入,2.35变成2.3,如果是5则向下舍
|
||||
|
||||
|
||||
return subtract.divide(last, 0, BigDecimal.ROUND_UP).multiply(new BigDecimal(100)) + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
package com.zbkj.crmeb.express.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递公司表
|
||||
* </p>
|
||||
*
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_express")
|
||||
@ApiModel(value="Express对象", description="快递公司表")
|
||||
public class Express implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "快递公司id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "快递公司简称")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "快递公司全称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示")
|
||||
private Boolean isShow;
|
||||
|
||||
|
||||
}
|
||||
package com.zbkj.crmeb.express.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递公司表
|
||||
* </p>
|
||||
*
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("eb_express")
|
||||
@ApiModel(value="Express对象", description="快递公司表")
|
||||
public class Express implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "快递公司id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "快递公司简称")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "快递公司全称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示")
|
||||
private Integer isShow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public class ExpressRequest implements Serializable {
|
||||
@NotNull(message = "排序数字必须填写")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "是否显示", required = true)
|
||||
@ApiModelProperty(value = "是否显示 0=否 1=是", required = true)
|
||||
@NotNull(message = "请选择是否弃用")
|
||||
private Boolean isShow;
|
||||
private Integer isShow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ public class ExpressSearchRequest implements Serializable {
|
||||
@ApiModelProperty(value = "搜索关键字", required = true)
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "是否显示", required = true)
|
||||
private Boolean isShow = null;
|
||||
@ApiModelProperty(value = "是否显示 0=否 1=是", required = true)
|
||||
private Integer isShow;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ExpressController {
|
||||
pageParamRequest.setLimit(Constants.EXPORT_MAX_LIMIT);
|
||||
|
||||
ExpressSearchRequest expressSearchRequest = new ExpressSearchRequest();
|
||||
expressSearchRequest.setIsShow(true);
|
||||
expressSearchRequest.setIsShow(1);
|
||||
return CommonResult.success(CommonPage.restPage(expressService.getList(expressSearchRequest, pageParamRequest)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +92,6 @@ public class SmsRecordController {
|
||||
@RequestMapping(value = "/record/list", method = RequestMethod.GET)
|
||||
public CommonResult<CommonPage<SmsRecord>> getList(@ModelAttribute SmsRecordRequest smsRecordRequest,
|
||||
@ModelAttribute PageParamRequest pageParamRequest){
|
||||
SmsRecord smsRecord = new SmsRecord();
|
||||
BeanUtils.copyProperties(smsRecordRequest, smsRecord);
|
||||
CommonPage<SmsRecord> smsRecordCommonPage =
|
||||
CommonPage.restPage(smsRecordService.getList(smsRecordRequest, pageParamRequest));
|
||||
return CommonResult.success(smsRecordCommonPage);
|
||||
|
||||
@@ -22,4 +22,6 @@ public class SendSmsVo {
|
||||
// 发送参数
|
||||
private String param;
|
||||
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,12 @@ public interface SmsRecordService extends IService<SmsRecord> {
|
||||
* @return 保存结果
|
||||
*/
|
||||
boolean save(SmsRecord smsRecord);
|
||||
|
||||
|
||||
// 短信状态同步
|
||||
void consumeSmsStatus();
|
||||
|
||||
// 更新短信实际发送状态嘛
|
||||
void updateSmsStatus(List<Integer> recordIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.zbkj.crmeb.sms.request.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mr.Zhang
|
||||
@@ -44,6 +45,11 @@ public interface SmsService{
|
||||
boolean pushCodeToList(String phone, Integer tag,HashMap<String, Object> pram);
|
||||
|
||||
void push(String phone,String tempKey,Integer msgTempId,boolean valid, HashMap<String,Object> mapPram);
|
||||
/**
|
||||
* 根据发送id同步发送短信结果
|
||||
* @param recordIds 短信发送id
|
||||
*/
|
||||
void pushByAsyncStatus(List<Integer> recordIds);
|
||||
|
||||
void consume();
|
||||
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
package com.zbkj.crmeb.sms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.common.PageParamRequest;
|
||||
import com.constants.SmsConstants;
|
||||
import com.exception.CrmebException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RestTemplateUtil;
|
||||
import com.zbkj.crmeb.sms.model.SmsRecord;
|
||||
import com.zbkj.crmeb.sms.dao.SmsRecordDao;
|
||||
import com.zbkj.crmeb.sms.request.SmsRecordRequest;
|
||||
import com.zbkj.crmeb.sms.service.SmsRecordService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,8 +35,13 @@ public class SmsRecordServiceImpl extends ServiceImpl<SmsRecordDao, SmsRecord> i
|
||||
|
||||
@Resource
|
||||
private SmsRecordDao dao;
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SmsRecordServiceImpl.class);
|
||||
/**
|
||||
* 短信发送记录
|
||||
* @param request 请求参数
|
||||
@@ -51,5 +68,85 @@ public class SmsRecordServiceImpl extends ServiceImpl<SmsRecordDao, SmsRecord> i
|
||||
public boolean save(SmsRecord smsRecord) {
|
||||
return dao.insert(smsRecord) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新短信记录实际发送状态嘛
|
||||
* @param recordIds 待更新短信发送id
|
||||
*/
|
||||
@Override
|
||||
public void updateSmsStatus(List<Integer> recordIds) {
|
||||
HashMap<String, List<Integer>> pram = new HashMap<>();
|
||||
pram.put("record_id", recordIds);
|
||||
String result = restTemplateUtil.postJsonData(
|
||||
SmsConstants.SMS_API_URL + SmsConstants.SMS_API_SEND_STATUS,
|
||||
JSONObject.parseObject(JSONObject.toJSONString(pram)));
|
||||
|
||||
JSONObject joResult;
|
||||
try{
|
||||
joResult = checkResult(result);
|
||||
}catch (Exception e1){
|
||||
joResult = JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
int resultCode = joResult.getInteger("status");
|
||||
String message = joResult.getString("msg");
|
||||
JSONObject data = joResult.getJSONObject("data");
|
||||
String smsRecodeId = (data.containsKey("id") ? data.getString("id") : "0");
|
||||
|
||||
}
|
||||
|
||||
// 短信发送状态同步队列消费者
|
||||
@Async
|
||||
public void consumeSmsStatus() {
|
||||
Long size = redisUtil.getListSize(SmsConstants.SMS_SEND_RESULT_KEY);
|
||||
logger.info("SmsServiceImpl.consumeSmsStatus | size:" + size);
|
||||
if(size > 0){
|
||||
for (int i = 0; i < size; i++) {
|
||||
//如果10秒钟拿不到一个数据,那么退出循环
|
||||
Object data = redisUtil.getRightPop(SmsConstants.SMS_SEND_RESULT_KEY, 10L);
|
||||
if(null == data){
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
List<Integer> recordIds = (List<Integer>) JSONObject.parseObject(data.toString());
|
||||
updateSmsStatus(recordIds);
|
||||
}catch (Exception e){
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_RESULT_KEY, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测结构请求返回的数据
|
||||
* @param result 接口返回的结果
|
||||
* @author Mr.Zhang
|
||||
* @since 2020-04-16
|
||||
* @return JSONObject
|
||||
*/
|
||||
private JSONObject checkResult(String result){
|
||||
if(StringUtils.isBlank(result)){
|
||||
throw new CrmebException("短信平台接口异常,没任何数据返回!");
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if(SmsConstants.SMS_ERROR_CODE.equals(jsonObject.getInteger("status"))){
|
||||
throw new CrmebException("短信平台接口" + jsonObject.getString("msg"));
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private JSONObject checkResult(JSONObject result){
|
||||
if(null == result){
|
||||
throw new CrmebException("短信平台接口异常,没任何数据返回!");
|
||||
}
|
||||
if(SmsConstants.SMS_ERROR_CODE.equals(result.getInteger("status"))){
|
||||
throw new CrmebException("短信平台接口" + result.getString("msg"));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -438,12 +440,22 @@ public class SmsServiceImpl implements SmsService {
|
||||
JSONObject data = joResult.getJSONObject("data");
|
||||
String smsRecodeId = (data.containsKey("id") ? data.getString("id") : "0");
|
||||
|
||||
SmsRecord smsRecord = new SmsRecord(0,sendSmsVo.getUid(), sendSmsVo.getMobile(),sendSmsVo.getParam(), "", sendSmsVo.getTemplate().toString() ,resultCode,Integer.parseInt(smsRecodeId), message);
|
||||
// 注意这里的状态仅仅是调用是否成功的状态 需要等待5分钟一周另外一个任务去查询发送状态后再更新status数据
|
||||
SmsRecord smsRecord = new SmsRecord(0,sendSmsVo.getUid(), sendSmsVo.getMobile(),sendSmsVo.getContent(),
|
||||
"", sendSmsVo.getTemplate().toString(),
|
||||
resultCode,Integer.parseInt(smsRecodeId), message);
|
||||
smsRecordService.save(smsRecord);
|
||||
|
||||
// 添加到短信实际发送状态队列
|
||||
if(smsRecodeId.length() > 0){
|
||||
List<Integer> recordsIds = new ArrayList<>();
|
||||
recordsIds.add(Integer.parseInt(smsRecodeId));
|
||||
pushByAsyncStatus(recordsIds);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 短信队列消费者
|
||||
*/
|
||||
@@ -536,6 +548,16 @@ public class SmsServiceImpl implements SmsService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加短信发送状态同步队列
|
||||
* @param recordIds 短信发送id
|
||||
*/
|
||||
@Override
|
||||
public void pushByAsyncStatus(List<Integer> recordIds) {
|
||||
if(null == recordIds) return;
|
||||
redisUtil.lPush(SmsConstants.SMS_SEND_RESULT_KEY, JSONObject.toJSONString(recordIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册手机号码
|
||||
* @param phone 手机号码
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.statistics.service.impl;
|
||||
|
||||
import com.constants.Constants;
|
||||
import com.utils.CrmebUtil;
|
||||
import com.utils.DateUtil;
|
||||
import com.zbkj.crmeb.statistics.response.HomeRateResponse;
|
||||
import com.zbkj.crmeb.statistics.service.HomeService;
|
||||
@@ -57,22 +58,11 @@ public class HomeServiceImpl implements HomeService {
|
||||
|
||||
|
||||
//日同比
|
||||
int dayRate = Constants.NUM_ZERO;
|
||||
if(!today.equals(BigDecimal.ZERO)){
|
||||
dayRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(!yesterday.equals(BigDecimal.ZERO)){
|
||||
dayRate = today.subtract(yesterday).divide(yesterday).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue();
|
||||
}
|
||||
int dayRate = CrmebUtil.getRate(today, yesterday);
|
||||
|
||||
//周同比
|
||||
int weekRate = Constants.NUM_ZERO;
|
||||
if(!week.equals(BigDecimal.ZERO)){
|
||||
weekRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(!preWeek.equals(BigDecimal.ZERO)){
|
||||
weekRate = week.subtract(preWeek).divide(preWeek).multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue();
|
||||
}
|
||||
int weekRate = CrmebUtil.getRate(week, preWeek);
|
||||
|
||||
|
||||
return new HomeRateResponse(yesterday, dayRate, weekRate, all);
|
||||
}
|
||||
@@ -104,22 +94,11 @@ public class HomeServiceImpl implements HomeService {
|
||||
|
||||
|
||||
//日同比
|
||||
int dayRate = Constants.NUM_ZERO;
|
||||
if(today != Constants.NUM_ZERO){
|
||||
dayRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(yesterday != Constants.NUM_ZERO){
|
||||
dayRate = ((today - yesterday) / yesterday) * Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
int dayRate = CrmebUtil.getRate(today, yesterday);
|
||||
|
||||
//周同比
|
||||
int weekRate = Constants.NUM_ZERO;
|
||||
if(week != Constants.NUM_ZERO){
|
||||
weekRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(preWeek != Constants.NUM_ZERO){
|
||||
weekRate = ((weekRate - preWeek) / preWeek) * Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
int weekRate = CrmebUtil.getRate(week, preWeek);
|
||||
|
||||
|
||||
return new HomeRateResponse(yesterday, dayRate, weekRate, all);
|
||||
}
|
||||
@@ -151,22 +130,11 @@ public class HomeServiceImpl implements HomeService {
|
||||
|
||||
|
||||
//日同比
|
||||
int dayRate = Constants.NUM_ZERO;
|
||||
if(today != Constants.NUM_ZERO){
|
||||
dayRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(yesterday != Constants.NUM_ZERO){
|
||||
dayRate = ((today - yesterday) / yesterday) * Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
int dayRate = CrmebUtil.getRate(today, yesterday);
|
||||
|
||||
//周同比
|
||||
int weekRate = Constants.NUM_ZERO;
|
||||
if(week != Constants.NUM_ZERO){
|
||||
weekRate = Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
if(preWeek != Constants.NUM_ZERO){
|
||||
weekRate = ((weekRate - preWeek) / preWeek) * Constants.NUM_ONE_HUNDRED;
|
||||
}
|
||||
int weekRate = CrmebUtil.getRate(week, preWeek);
|
||||
|
||||
|
||||
return new HomeRateResponse(yesterday, dayRate, weekRate, all);
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderDao, StoreOrder
|
||||
QueryWrapper<StoreOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("sum(pay_price) as pay_price").
|
||||
eq("paid", 1).
|
||||
eq("is_del", 1);
|
||||
eq("is_del", 0);
|
||||
if(null != userId){
|
||||
queryWrapper.eq("uid", userId);
|
||||
}
|
||||
@@ -659,7 +659,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderDao, StoreOrder
|
||||
public int getOrderCount(Integer userId, String date) {
|
||||
LambdaQueryWrapper<StoreOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(StoreOrder::getPaid,1)
|
||||
.eq(StoreOrder::getIsDel, 1);
|
||||
.eq(StoreOrder::getIsDel, 0);
|
||||
|
||||
if(null != userId){
|
||||
lambdaQueryWrapper.eq(StoreOrder::getUid, userId);
|
||||
|
||||
@@ -55,10 +55,10 @@ public class SystemAdminController {
|
||||
@ApiOperation(value = "分页列表")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<CommonPage<SystemAdmin>> getList(@Validated SystemAdminRequest systemAdminRequest, PageParamRequest pageParamRequest){
|
||||
public CommonResult<CommonPage<SystemAdminResponse>> getList(@Validated SystemAdminRequest systemAdminRequest, PageParamRequest pageParamRequest){
|
||||
SystemAdmin systemAdmin = new SystemAdmin();
|
||||
BeanUtils.copyProperties(systemAdminRequest, systemAdmin);
|
||||
CommonPage<SystemAdmin> systemAdminCommonPage = CommonPage.restPage(systemAdminService.getList(systemAdminRequest, pageParamRequest));
|
||||
CommonPage<SystemAdminResponse> systemAdminCommonPage = CommonPage.restPage(systemAdminService.getList(systemAdminRequest, pageParamRequest));
|
||||
return CommonResult.success(systemAdminCommonPage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zbkj.crmeb.system.response;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -25,6 +26,8 @@ public class SystemAdminResponse implements Serializable {
|
||||
|
||||
private String roles;
|
||||
|
||||
private String roleNames;
|
||||
|
||||
private String lastIp;
|
||||
|
||||
private Integer lastTime;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @since 2020-04-13
|
||||
*/
|
||||
public interface SystemAdminService extends IService<SystemAdmin> {
|
||||
List<SystemAdmin> getList(SystemAdminRequest request, PageParamRequest pageParamRequest);
|
||||
List<SystemAdminResponse> getList(SystemAdminRequest request, PageParamRequest pageParamRequest);
|
||||
|
||||
SystemAdminResponse getInfo(SystemAdminRequest request) throws Exception;
|
||||
|
||||
|
||||
@@ -11,16 +11,23 @@ import com.zbkj.crmeb.authorization.manager.TokenManager;
|
||||
import com.zbkj.crmeb.authorization.model.TokenModel;
|
||||
import com.zbkj.crmeb.system.dao.SystemAdminDao;
|
||||
import com.zbkj.crmeb.system.model.SystemAdmin;
|
||||
import com.zbkj.crmeb.system.model.SystemRole;
|
||||
import com.zbkj.crmeb.system.request.SystemAdminAddRequest;
|
||||
import com.zbkj.crmeb.system.request.SystemAdminRequest;
|
||||
import com.zbkj.crmeb.system.request.SystemRoleSearchRequest;
|
||||
import com.zbkj.crmeb.system.response.SystemAdminResponse;
|
||||
import com.zbkj.crmeb.system.service.SystemAdminService;
|
||||
import com.zbkj.crmeb.system.service.SystemRoleService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Mr.Zhang
|
||||
@@ -33,12 +40,15 @@ public class SystemAdminServiceImpl extends ServiceImpl<SystemAdminDao, SystemAd
|
||||
@Resource
|
||||
private SystemAdminDao dao;
|
||||
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
|
||||
@Resource
|
||||
private TokenManager tokenManager;
|
||||
|
||||
|
||||
@Override
|
||||
public List<SystemAdmin> getList(SystemAdminRequest request, PageParamRequest pageParamRequest){
|
||||
public List<SystemAdminResponse> getList(SystemAdminRequest request, PageParamRequest pageParamRequest){
|
||||
PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
|
||||
|
||||
//带SystemAdminRequest类的多条件查询
|
||||
@@ -76,7 +86,29 @@ public class SystemAdminServiceImpl extends ServiceImpl<SystemAdminDao, SystemAd
|
||||
if(null != systemAdmin.getStatus()){
|
||||
lambdaQueryWrapper.eq(SystemAdmin::getStatus, systemAdmin.getStatus());
|
||||
}
|
||||
return dao.selectList(lambdaQueryWrapper);
|
||||
List<SystemAdmin> systemAdmins = dao.selectList(lambdaQueryWrapper);
|
||||
List<SystemAdminResponse> systemAdminResponses = new ArrayList<>();
|
||||
PageParamRequest pageRole = new PageParamRequest();
|
||||
pageRole.setLimit(999);
|
||||
List<SystemRole> roleList = systemRoleService.getList(new SystemRoleSearchRequest(), pageRole);
|
||||
// for (SystemRole systemRole : roleList) {
|
||||
for (SystemAdmin admin : systemAdmins) {
|
||||
SystemAdminResponse sar = new SystemAdminResponse();
|
||||
BeanUtils.copyProperties(admin, sar);
|
||||
if(StringUtils.isBlank(admin.getRoles())) break;
|
||||
List<Integer> roleIds = CrmebUtil.stringToArrayInt(admin.getRoles());
|
||||
List<String> roleNames = new ArrayList<>();
|
||||
for (Integer roleId : roleIds) {
|
||||
List<SystemRole> hasRoles = roleList.stream().filter(e -> e.getId() == roleId).collect(Collectors.toList());
|
||||
if(hasRoles.size()> 0){
|
||||
roleNames.add(hasRoles.stream().map(SystemRole::getRoleName).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
sar.setRoleNames(StringUtils.join(roleNames,","));
|
||||
systemAdminResponses.add(sar);
|
||||
}
|
||||
// }
|
||||
return systemAdminResponses;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,16 +188,17 @@ public class SystemAdminServiceImpl extends ServiceImpl<SystemAdminDao, SystemAd
|
||||
throw new CrmebException("管理员已存在");
|
||||
}
|
||||
|
||||
SystemAdminRequest systemAdminRequest = new SystemAdminRequest();
|
||||
BeanUtils.copyProperties(systemAdminAddRequest, systemAdminRequest);
|
||||
|
||||
// 执行新增管理员操作
|
||||
String pwd = CrmebUtil.encryptPassword(systemAdminAddRequest.getPwd(), systemAdminAddRequest.getAccount());
|
||||
systemAdminAddRequest.setPwd(pwd);
|
||||
SystemAdmin systemAdmin = new SystemAdmin();
|
||||
BeanUtils.copyProperties(systemAdminAddRequest, systemAdmin);
|
||||
|
||||
// 执行新增管理员操作
|
||||
String pwd = CrmebUtil.encryptPassword(systemAdmin.getPwd(), systemAdmin.getAccount());
|
||||
systemAdminAddRequest.setPwd(pwd); // 设置为加密后的密码
|
||||
SystemAdminResponse systemAdminResponse = new SystemAdminResponse();
|
||||
BeanUtils.copyProperties(systemAdminAddRequest, systemAdminResponse);
|
||||
if(dao.insert(systemAdmin) <= 0){
|
||||
throw new CrmebException("新增管理员失败");
|
||||
}
|
||||
return systemAdminResponse;
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -88,7 +88,6 @@ public interface UserService extends IService<User> {
|
||||
|
||||
Map<Object, Object> getAddUserCountGroupDate(String date);
|
||||
|
||||
|
||||
boolean bind(UserBindingRequest request);
|
||||
|
||||
UserCenterResponse getUserCenter();
|
||||
|
||||
@@ -638,14 +638,14 @@ public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserS
|
||||
dateLimitUtilVo dateLimit = DateUtil.getDateLimit(date);
|
||||
queryWrapper.between("create_time", dateLimit.getStartTime(), dateLimit.getEndTime());
|
||||
}
|
||||
queryWrapper.groupBy("create_time").orderByAsc("create_time");
|
||||
queryWrapper.groupBy("left(create_time, 10)").orderByAsc("create_time");
|
||||
List<User> list = userDao.selectList(queryWrapper);
|
||||
if(list.size() < 1){
|
||||
return map;
|
||||
}
|
||||
|
||||
for (User user : list) {
|
||||
map.put(user.getCreateTime(), user.getUid());
|
||||
map.put(DateUtil.dateToStr(user.getCreateTime(), Constants.DATE_FORMAT_DATE), user.getUid());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user