Commit d3cad1db by 邓实川 Committed by chenzg

短信优化,bug修复

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