Commit d3cad1db by 邓实川 Committed by chenzg

短信优化,bug修复

parent f2a88eeb
......@@ -38,6 +38,9 @@ public class QyzxSms extends Model<QyzxSms> {
@ApiModelProperty(value="主键",example="101")
private Integer id;
@ApiModelProperty(value="使用记录表id",example="101")
private Integer useId;
@ApiModelProperty(value="组织机构代码 组织机构代码",example="101")
private Integer orgCode;
......
......@@ -138,19 +138,21 @@ public class LoginController {
public Result<String> sendCode(@RequestBody EntRegisterDto entRegisterDto) {
String phone = entRegisterDto.getPhone();
Integer orgCode = QyzxEmpLogin.builder().build()
Integer orgCode = null;
if (entRegisterDto.getTc() != 4) { // 如果不是注册,则判断
orgCode = QyzxEmpLogin.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpLogin>().eq(QyzxEmpLogin::getPhone, phone)).getOrgId();
QyzxRemainingQuantity quantity = QyzxRemainingQuantity.builder().build().selectOne(
new LambdaQueryWrapper<QyzxRemainingQuantity>().eq(QyzxRemainingQuantity::getOrgCode, orgCode)
.eq(QyzxRemainingQuantity::getPmid, 1).gt(QyzxRemainingQuantity::getRemainder, 0));
QyzxRemainingQuantity quantity = QyzxRemainingQuantity.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxRemainingQuantity>()
.eq(QyzxRemainingQuantity::getOrgCode, orgCode).eq(QyzxRemainingQuantity::getPmid, 1)
.gt(QyzxRemainingQuantity::getRemainder, 0));
Date date = null;
Integer remainder = null;
if (quantity != null) {
remainder = quantity.getRemainder();
date = quantity.getExpireDate();
}
if (entRegisterDto.getTc() != 4) { //如果不是注册,则判断套餐余额
if (quantity == null || remainder == null || remainder <= 0) { // 判断充了钱没
return ResultUtil.error("请充值后使用短信功能!");
}
......@@ -168,8 +170,9 @@ public class LoginController {
phone = entRegisterDto.getUsername();
entRegisterDto.setPhone(phone);
}
JSONObject j = aliyunSMS.authCode(entRegisterDto, entRegisterDto.getTc(), code);
List<Object> list = aliyunSMS.authCode(entRegisterDto, entRegisterDto.getTc(), code);
Integer useId = (Integer) list.get(0);
JSONObject j = (JSONObject) list.get(1);
// 获取当前日期的字符串格式
String today = DateUtil.today();
// yyyy-MM-dd
......@@ -191,6 +194,7 @@ public class LoginController {
qyzxSms.setMessageType(entRegisterDto.getTc());
qyzxSms.setPhone(phoneNum);
qyzxSms.setOrgCode(orgCode);
qyzxSms.setUseId(useId);
qyzxSms.insert();
String message = j.getString("Message");
......
package cn.timer.api.utils.aliyun;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -64,21 +66,26 @@ public class AliyunSMS {
* 5."修改密码验证码" 6."信息变更验证码"
*/
@SuppressWarnings("deprecation")
public JSONObject authCode(EntRegisterDto entRegisterDto,
public List<Object> authCode(EntRegisterDto entRegisterDto,
@RequestParam(required = false, defaultValue = "1") Integer templateCode, Integer code) {
String phone = entRegisterDto.getPhone();
Integer orgCode = QyzxEmpLogin.builder().build()
QyzxRemainingQuantity quantity = null;
Integer remainder = null;
String orderNo = null;
Integer orgCode = null;
if (templateCode != 4) {
orgCode = QyzxEmpLogin.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpLogin>().eq(QyzxEmpLogin::getPhone, phone)).getOrgId();
QyzxRemainingQuantity quantity = QyzxRemainingQuantity.builder().build().selectOne(
new LambdaQueryWrapper<QyzxRemainingQuantity>().eq(QyzxRemainingQuantity::getOrgCode, orgCode)
.eq(QyzxRemainingQuantity::getPmid, 1).gt(QyzxRemainingQuantity::getRemainder, 0));
Integer remainder = quantity.getRemainder();
quantity = QyzxRemainingQuantity.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxRemainingQuantity>()
.eq(QyzxRemainingQuantity::getOrgCode, orgCode).eq(QyzxRemainingQuantity::getPmid, 1)
.gt(QyzxRemainingQuantity::getRemainder, 0));
remainder = quantity.getRemainder();
Date date = quantity.getExpireDate();
String orderNo = quantity.getOrderNo();
orderNo = quantity.getOrderNo();
if (templateCode != 4) {
if (quantity == null || remainder == null || remainder <= 0) {
System.err.println("企业 " + orgCode + " :套餐余额不足,请充钱");
return null;
......@@ -145,8 +152,9 @@ public class AliyunSMS {
} catch (ClientException e) {
e.printStackTrace();
}
Integer id = null;
if (a != null && a.contains("OK")) {
if (templateCode != 4) {
qyzxUseRecord.setOriginalTotalNum(remainder); // 原数量
qyzxUseRecord.setNowTotalNum(--remainder);
qyzxUseRecord.setUserPhone(phone);
......@@ -156,10 +164,18 @@ public class AliyunSMS {
qyzxUseRecord.setCreateUser("System");
qyzxUseRecord.insert();
id = qyzxUseRecord.getId();
quantity.setRemainder(remainder);
quantity.update(new LambdaUpdateWrapper<QyzxRemainingQuantity>()
.eq(QyzxRemainingQuantity::getOrgCode, orgCode).eq(QyzxRemainingQuantity::getOrderNo, orderNo));
return JSONObject.parseObject(response.getData());// 代表请求成功
}
List<Object> list = new ArrayList<Object>();
list.add(id);
list.add(JSONObject.parseObject(response.getData()));
return list;// 代表请求成功
}
return null;
......
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