Commit 72b41163 by 东州 翁

Merge branch 'develop' of 120.24.24.239:8timerv2/8timerapiv200 into wdz

parents 82e2df48 e22b2a90
......@@ -3,12 +3,9 @@ package cn.timer.api.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
......@@ -16,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -62,82 +58,58 @@ public class LoginController {
@Value("${config-8timer.register-free-time}")
public Integer offset; // 系统赠送时间
@Value("${config-8timer.Aliyun.PROJECT_NAME}")
private String PROJECT_NAME;
@Value("${config-8timer.Aliyun.REGION_ID}")
private String REGION_ID;
@Value("${config-8timer.Aliyun.ACCESSKEY_ID}")
private String ACCESSKEY_ID;
@Value("${config-8timer.Aliyun.SECRET}")
private String SECRET;
public static String host;
public static String PROJECT_ID;
public static String PROJECT_SECRET;
@Value("${config-8timer.esign.host}")
private String host_s;
@Value("${config-8timer.esign.PROJECT_ID}")
private String PROJECT_ID_s;
@Value("${config-8timer.esign.PROJECT_SECRET}")
private String PROJECT_SECRET_s;
@PostConstruct
public void init() {
host = host_s;
PROJECT_ID = PROJECT_ID_s;
PROJECT_SECRET = PROJECT_SECRET_s;
}
@Value("${config-8timer.Aliyun.PROJECT_NAME}")
private String endpoint;
@Value("${config-8timer.Aliyun.ACCESSKEY_ID}")
private String accessKeyId;
@Value("${config-8timer.Aliyun.SECRET}")
private String accessKeySecret;
@Value("${config-8timer.Aliyun.bucketName}")
private String bucketName;
@Value("${config-8timer.Aliyun.bucketName_pri}")
private String bucketName_pri;
@Value("${config-8timer.Aliyun.project_package}")
private String project_package;
@Value("${config-8timer.Aliyun.expirationTime}")
private String expirationTime;
@Value("${config-8timer.Aliyun.expirationTime_pri}")
private String expirationTime_pri;
@GetMapping(value = "/test")
public Map<String, Object> test() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1", offset);
map.put("2", PROJECT_NAME);
map.put("3", REGION_ID);
map.put("4", ACCESSKEY_ID);
map.put("5", SECRET);
map.put("6", host);
map.put("7", PROJECT_ID);
map.put("8", PROJECT_SECRET);
map.put("9", endpoint);
map.put("10", accessKeyId);
map.put("11", accessKeySecret);
map.put("12", bucketName);
map.put("13", bucketName_pri);
map.put("14", project_package);
map.put("15", expirationTime);
map.put("16", expirationTime_pri);
return map;
}
/*
* @Value("${config-8timer.Aliyun.PROJECT_NAME}") private String PROJECT_NAME;
*
* @Value("${config-8timer.Aliyun.REGION_ID}") private String REGION_ID;
*
* @Value("${config-8timer.Aliyun.ACCESSKEY_ID}") private String ACCESSKEY_ID;
*
* @Value("${config-8timer.Aliyun.SECRET}") private String SECRET;
*
* public static String host; public static String PROJECT_ID; public static
* String PROJECT_SECRET;
*
* @Value("${config-8timer.esign.host}") private String host_s;
*
* @Value("${config-8timer.esign.PROJECT_ID}") private String PROJECT_ID_s;
*
* @Value("${config-8timer.esign.PROJECT_SECRET}") private String
* PROJECT_SECRET_s;
*
* @PostConstruct public void init() { host = host_s; PROJECT_ID = PROJECT_ID_s;
* PROJECT_SECRET = PROJECT_SECRET_s; }
*
* @Value("${config-8timer.Aliyun.PROJECT_NAME}") private String endpoint;
*
* @Value("${config-8timer.Aliyun.ACCESSKEY_ID}") private String accessKeyId;
*
* @Value("${config-8timer.Aliyun.SECRET}") private String accessKeySecret;
*
* @Value("${config-8timer.Aliyun.bucketName}") private String bucketName;
*
* @Value("${config-8timer.Aliyun.bucketName_pri}") private String
* bucketName_pri;
*
* @Value("${config-8timer.Aliyun.project_package}") private String
* project_package;
*
* @Value("${config-8timer.Aliyun.expirationTime}") private String
* expirationTime;
*
* @Value("${config-8timer.Aliyun.expirationTime_pri}") private String
* expirationTime_pri;
*
* @GetMapping(value = "/test") public Map<String, Object> test() { Map<String,
* Object> map = new HashMap<String, Object>(); map.put("1", offset);
* map.put("2", PROJECT_NAME); map.put("3", REGION_ID); map.put("4",
* ACCESSKEY_ID); map.put("5", SECRET); map.put("6", host); map.put("7",
* PROJECT_ID); map.put("8", PROJECT_SECRET); map.put("9", endpoint);
* map.put("10", accessKeyId); map.put("11", accessKeySecret); map.put("12",
* bucketName); map.put("13", bucketName_pri); map.put("14", project_package);
* map.put("15", expirationTime); map.put("16", expirationTime_pri); return map;
* }
*/
@Autowired
private HttpSession session;
......@@ -148,6 +120,9 @@ public class LoginController {
@Autowired
private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper;
@Autowired
private AliyunSMS aliyunSMS;
// @Autowired
// private DataSourceTransactionManager transactionManager;
......@@ -175,6 +150,7 @@ public class LoginController {
remainder = quantity.getRemainder();
date = quantity.getExpireDate();
}
if (entRegisterDto.getTc() != 4) { //如果不是注册,则判断套餐余额
if (quantity == null || remainder == null || remainder <= 0) { // 判断充了钱没
return ResultUtil.error("请充值后使用短信功能!");
}
......@@ -182,13 +158,12 @@ public class LoginController {
System.err.println("企业 " + orgCode + " :短信套餐已过期");
return ResultUtil.error("短信套餐已到期!");
}
}
// 6位随机数验证码
try {
Integer code = (int) ((Math.random() * 9 + 1) * 100000);
AliyunSMS aliyunSMS = new AliyunSMS();
if (phone == null || "".equals(phone)) {
phone = entRegisterDto.getUsername();
entRegisterDto.setPhone(phone);
......@@ -202,13 +177,13 @@ public class LoginController {
Thread.sleep(1000);
JSONObject jsonObject = (JSONObject) JSONObject
.parseObject(new AliyunSMS().QuerySendDetails(phone, today, j.getString("BizId")))
.parseObject(aliyunSMS.QuerySendDetails(phone, today, j.getString("BizId")))
.getJSONObject("SmsSendDetailDTOs").getJSONArray("SmsSendDetailDTO").get(0);
String templateCode = jsonObject.getString("TemplateCode");
String phoneNum = jsonObject.getString("PhoneNum");
String content = jsonObject.getString("Content");
String sendStatus = jsonObject.getString("SendStatus");
String sendDate = jsonObject.getString("SendDate");
// String templateCode = jsonObject.getString("TemplateCode");
// String sendStatus = jsonObject.getString("SendStatus");
// String sendDate = jsonObject.getString("SendDate");
QyzxSms qyzxSms = new QyzxSms();
qyzxSms.setContent(content);
......
package cn.timer.api.controller.dzht;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
......@@ -235,15 +236,14 @@ public class DzhtController {
return ResultUtil.data(list);
}
public static String savePath() {
String savePath = null;
String name = System.getProperty("os.name");
if (name.startsWith("Windows")) {
savePath = "E:\\esignTemplate"; // Windows本地服务器文件保存路径包
}else if(name.startsWith("Linux")){
} else if (name.startsWith("Linux")) {
savePath = "esignTemplate"; // Linux远程服务器文件保存路径包
}else {
} else {
savePath = "esignTemplate"; // 其他服务器文件保存路径包
}
return savePath;
......@@ -335,8 +335,8 @@ public class DzhtController {
public Result<Object> rzUserNow(@CurrentUser UserBean userBean, Integer empNum) {
DzhtAssoGrrz grrz = new DzhtAssoGrrz();
grrz.setType(0);
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().select("phone").eq("org_code", userBean.getOrgCode()).eq("emp_num", empNum));
YgglMainEmp yg = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().select("phone")
.eq("org_code", userBean.getOrgCode()).eq("emp_num", empNum));
grrz.setMobileNo(yg.getPhone());
DzhtAssoGrzc grzc = DzhtAssoGrzc.builder().build().selectOne(new QueryWrapper<DzhtAssoGrzc>()
......@@ -661,12 +661,28 @@ public class DzhtController {
if (code.equals("0") && j.get("errCode").toString().equals("0")) {
htmb.insert();
File file = new File(filePath);
boolean delete = file.delete();
System.err.println(delete);
return ResultUtil.data(a);
} else {
return ResultUtil.data(a, "创建失败");
}
}
// public static void main(String[] args) throws Exception {
// String ossUrl = "https://8time-v2.oss-cn-shenzhen.aliyuncs.com/8timer2.0/117/test/7001.jpg";
// String fileName = System.currentTimeMillis() + UUID.randomUUID().toString()
// + ossUrl.substring(ossUrl.lastIndexOf("."));
// String filePath = FileHelper.downLoadFromUrl(ossUrl, fileName, savePath());
// System.err.println(filePath);
// File file = new File(filePath);
// Thread.sleep(2000);
// System.err.println(file.delete());
// }
// 通过模板创建文件
@PostMapping("/createByTemplate")
@ApiOperation(value = "创建文件", httpMethod = "POST", notes = "接口发布说明")
......@@ -694,7 +710,7 @@ public class DzhtController {
@GetMapping("/queryName")
@ApiOperation(value = "查名字", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getName(@RequestParam(required = false)Integer empNum) {
public Result<Object> getName(@RequestParam(required = false) Integer empNum) {
String name = QueryUtil.queryEmpName(empNum);
Map<String, String> map = QueryUtil.queryVersionName();
return ResultUtil.datas(map, name, "查询成功");
......
......@@ -34,8 +34,6 @@ public class OSSController {
*
* @param userBean
* @param moudle
*
* @param moudle
*/
@PostMapping(value = "/upload")
@ApiOperation(value = "上传普通文件", httpMethod = "POST", notes = "接口发布说明")
......
......@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
......@@ -78,30 +79,21 @@ public class QyzxBusinessController {
.selectList(new LambdaQueryWrapper<QyzxRemainingQuantity>().eq(QyzxRemainingQuantity::getIsDelete, 0)
.eq(QyzxRemainingQuantity::getOrgCode, userBean.getOrgCode())
.eq(QyzxRemainingQuantity::getPmid, 1).select(QyzxRemainingQuantity::getRemainder));
Integer remainder1 = null;
for (QyzxRemainingQuantity qyzxRemainingQuantity : qyzxRemainingQuantitys1) {
remainder1 = qyzxRemainingQuantity.getRemainder();
if (qyzxRemainingQuantitys1.size() > 1) {
remainder1 += remainder1;
}
}
Integer sum1 = qyzxRemainingQuantitys1.stream()
.collect(Collectors.summingInt(QyzxRemainingQuantity::getRemainder));
List<QyzxRemainingQuantity> qyzxRemainingQuantitys2 = QyzxRemainingQuantity.builder().build()
.selectList(new LambdaQueryWrapper<QyzxRemainingQuantity>().eq(QyzxRemainingQuantity::getIsDelete, 0)
.eq(QyzxRemainingQuantity::getOrgCode, userBean.getOrgCode())
.eq(QyzxRemainingQuantity::getPmid, 2).select(QyzxRemainingQuantity::getRemainder));
Integer remainder2 = null;
for (QyzxRemainingQuantity qyzxRemainingQuantity : qyzxRemainingQuantitys2) {
remainder2 = qyzxRemainingQuantity.getRemainder();
if (qyzxRemainingQuantitys2.size() > 1) {
remainder2 += remainder2;
}
}
Integer sum2 = qyzxRemainingQuantitys2.stream()
.collect(Collectors.summingInt(QyzxRemainingQuantity::getRemainder));
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("message", remainder1);
map1.put("message", sum1);
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("contract", remainder2);
map2.put("contract", sum2);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.add(map1);
......@@ -114,8 +106,9 @@ public class QyzxBusinessController {
public Result<List<QyzxPayContent>> getPayListwithContract(@CurrentUser UserBean userBean) {
List<QyzxPayContent> list = QyzxPayContent.builder().build()
.selectList(new LambdaQueryWrapper<QyzxPayContent>().eq(QyzxPayContent::getPmid, 1).select(
QyzxPayContent::getContent, QyzxPayContent::getNowPrice, QyzxPayContent::getOriginalPrice,
QyzxPayContent::getSpecification, QyzxPayContent::getExpiration));
QyzxPayContent::getId, QyzxPayContent::getContent, QyzxPayContent::getNowPrice,
QyzxPayContent::getOriginalPrice, QyzxPayContent::getSpecification,
QyzxPayContent::getExpiration));
return ResultUtil.data(list, "获取成功");
}
......@@ -124,8 +117,9 @@ public class QyzxBusinessController {
public Result<List<QyzxPayContent>> getPayListWithMsg(@CurrentUser UserBean userBean) {
List<QyzxPayContent> list = QyzxPayContent.builder().build()
.selectList(new LambdaQueryWrapper<QyzxPayContent>().eq(QyzxPayContent::getPmid, 2).select(
QyzxPayContent::getContent, QyzxPayContent::getNowPrice, QyzxPayContent::getOriginalPrice,
QyzxPayContent::getSpecification, QyzxPayContent::getExpiration));
QyzxPayContent::getId, QyzxPayContent::getContent, QyzxPayContent::getNowPrice,
QyzxPayContent::getOriginalPrice, QyzxPayContent::getSpecification,
QyzxPayContent::getExpiration));
return ResultUtil.data(list, "获取成功");
}
......@@ -134,8 +128,9 @@ public class QyzxBusinessController {
public Result<List<QyzxPayContent>> getPayListWithSystem(@CurrentUser UserBean userBean) {
List<QyzxPayContent> list = QyzxPayContent.builder().build()
.selectList(new LambdaQueryWrapper<QyzxPayContent>().eq(QyzxPayContent::getPmid, 3).select(
QyzxPayContent::getContent, QyzxPayContent::getNowPrice, QyzxPayContent::getOriginalPrice,
QyzxPayContent::getSpecification, QyzxPayContent::getExpiration));
QyzxPayContent::getId, QyzxPayContent::getContent, QyzxPayContent::getNowPrice,
QyzxPayContent::getOriginalPrice, QyzxPayContent::getSpecification,
QyzxPayContent::getExpiration));
return ResultUtil.data(list, "获取成功");
}
......
......@@ -3,6 +3,7 @@ package cn.timer.api.utils.aliyun;
import java.util.Date;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -32,19 +33,20 @@ import cn.timer.api.dto.qyzx.EntRegisterDto;
*
*/
@Transactional
@Component
public class AliyunSMS {
@Value("${config-8timer.Aliyun.PROJECT_NAME}")
private String PROJECT_NAME;
public String PROJECT_NAME;
@Value("${config-8timer.Aliyun.REGION_ID}")
private String REGION_ID;
public String REGION_ID;
@Value("${config-8timer.Aliyun.ACCESSKEY_ID}")
private String ACCESSKEY_ID;
public String ACCESSKEY_ID;
@Value("${config-8timer.Aliyun.SECRET}")
private String SECRET;
public String SECRET;
final static String CODE_NAME = "TemplateCode";// 短信模板代码参数名
final static String TEMPLATE_PARAM = "TemplateParam";// 自定义参数
......@@ -76,6 +78,7 @@ public class AliyunSMS {
Date date = quantity.getExpireDate();
String orderNo = quantity.getOrderNo();
if (templateCode != 4) {
if (quantity == null || remainder == null || remainder <= 0) {
System.err.println("企业 " + orgCode + " :套餐余额不足,请充钱");
return null;
......@@ -84,6 +87,7 @@ public class AliyunSMS {
System.err.println("企业 " + orgCode + " :短信套餐已过期");
return null;
}
}
QyzxUseRecord qyzxUseRecord = new QyzxUseRecord();
......@@ -143,7 +147,6 @@ public class AliyunSMS {
}
if (a != null && a.contains("OK")) {
qyzxUseRecord.setOriginalTotalNum(remainder); // 原数量
qyzxUseRecord.setNowTotalNum(--remainder);
qyzxUseRecord.setUserPhone(phone);
......@@ -156,7 +159,6 @@ public class AliyunSMS {
quantity.setRemainder(remainder);
quantity.update(new LambdaUpdateWrapper<QyzxRemainingQuantity>()
.eq(QyzxRemainingQuantity::getOrgCode, orgCode).eq(QyzxRemainingQuantity::getOrderNo, orderNo));
return JSONObject.parseObject(response.getData());// 代表请求成功
}
......@@ -191,7 +193,6 @@ public class AliyunSMS {
} catch (Exception e) {
e.printStackTrace();
}
System.err.println(a);
if (a != null && a.contains("OK")) {
return a;// 代表请求成功
}
......@@ -248,7 +249,6 @@ public class AliyunSMS {
String a = null;
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
a = response.getData();
......
......@@ -4,6 +4,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
......@@ -29,6 +31,18 @@ import cn.timer.api.utils.aliyun.AliyunSMS;
@Lazy(false)
public class RemindUtil implements SchedulingConfigurer {
@Autowired
private AliyunSMS sms;
@Value("${config-8timer.remind.one}")
private int one;
@Value("${config-8timer.remind.two}")
private int two;
@Value("${config-8timer.remind.three}")
private int three;
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
static String className = new Exception().getStackTrace()[0].getClassName();
static String methodName = null;
......@@ -57,9 +71,8 @@ public class RemindUtil implements SchedulingConfigurer {
* 每天固定时间提醒
*/
// @Scheduled(cron = "0 0 8 * * ?") // 每天8点扫一下看有没要提醒的,有就发一个
public static String reportCurrentTime() {
public String reportCurrentTime() {
AliyunSMS sms = new AliyunSMS();
List<HtzzAssoHtgx> htgxs = HtzzAssoHtgx.builder().build().selectAll();
for (HtzzAssoHtgx htgx : htgxs) {
QueryWrapper<HtzzAdminZzda> q = new QueryWrapper<HtzzAdminZzda>();
......@@ -78,12 +91,12 @@ public class RemindUtil implements SchedulingConfigurer {
if (sjc > 0) {
if (betweenDay <= 1) {
sms.remind(name, htname, time, phone); // 少于1天短信提醒
} else if (betweenDay == 3) {
sms.remind(name, htname, time, phone); // 少于3天短信提醒
} else if (betweenDay == 7) {
sms.remind(name, htname, time, phone); // 少于7天短信提醒
} else if (betweenDay == 30) {
sms.remind(name, htname, time, phone); // 少于30天短信提醒
} else if (betweenDay == one) {
sms.remind(name, htname, time, phone); // 短信提醒1
} else if (betweenDay == two) {
sms.remind(name, htname, time, phone); // 短信提醒2
} else if (betweenDay == three) {
sms.remind(name, htname, time, phone); // 短信提醒3
}
} else {
zzda.setTxkgType(1); // 关闭提醒
......
......@@ -170,6 +170,10 @@ config-8timer:
# pro: https://openapi.esign.cn
PROJECT_ID: 4438775940
PROJECT_SECRET: 7b100813cca2746081c57837855ac5af
remind: #合同提醒时间 默认小于等于1天会提醒+三个配置项
one: 3
two: 7
three: 30
......
......@@ -142,3 +142,7 @@ config-8timer:
host: https://openapi.esign.cn
PROJECT_ID: 4438775940
PROJECT_SECRET: 7b100813cca2746081c57837855ac5af
remind: #合同提醒时间 默认小于等于1天会提醒+三个配置项
one: 3
two: 7
three: 30
\ No newline at end of file
......@@ -142,3 +142,7 @@ config-8timer:
host: https://smlopenapi.esign.cn
PROJECT_ID: 4438775940
PROJECT_SECRET: 7b100813cca2746081c57837855ac5af
remind: #合同提醒时间 默认小于等于1天会提醒+三个配置项
one: 3
two: 7
three: 30
\ No newline at end of file
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