import com.supwisdom.dlpay.mobile.service.MobileApiService
import com.supwisdom.dlpay.system.service.DictionaryProxy
import com.supwisdom.dlpay.util.ConstantUtil
+import com.supwisdom.dlpay.util.YnrccUtil
import org.apache.commons.lang.StringUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.redis.core.RedisTemplate
import org.bouncycastle.cms.RecipientId.password
-
-
@RestController
@RequestMapping("/mobileapi/i")
class ApiInit {
if (card.userid.isNullOrEmpty() || card.status != TradeDict.STATUS_NORMAL) {
return JsonResult.error("银行卡号信息有误")
}
+ val person = userService.findOnePersonByUserid(card.userid)
+ if (person.name != name) {
+ return JsonResult.error("绑定信息有误[姓名]")
+ }
+ if (person.idtype != idtype || person.idno != idno) {
+ return JsonResult.error("绑定信息有误[证件类型/证件号]")
+ }
val exsitUser = mobileApiService.findUserById(card.userid)
if (exsitUser != null) {
return JsonResult.error("该银行卡号已被绑定,如有疑问,请联系客服")
}
- //TODO call api
- //user.bindtime = DateUtil.getNow()
- //user.userid = card.userid
- //mobileApiService.saveUser(user)
- var resp = citizencardPayService.bindCard(cardno,name,idtype,idno,phone);
- if(resp.code!="0000"){
+ //call api
+ var resp = citizencardPayService.bindCard(cardno, name, idtype, idno, phone);
+ if (resp.code != "0000") {
return JsonResult.error(resp.message)
}
- val code = RandomUtils.randomNumber(6)
+ var signed = ""
+ if (resp.sinstatus == "1") {
+ signed = TradeDict.STATUS_YES
+ card.signed = true
+ user.signedtime = DateUtil.getNow();
+ mobileApiService.saveCard(card)
+ mobileApiService.saveUser(user)
+ }
+ System.out.println(resp.captcha)
+ var code = if (resp.captcha.isNullOrEmpty()) {
+ RandomUtils.randomNumber(6)
+ } else {
+ resp.captcha
+ }
System.out.println(code)
- redisTemplate.opsForValue().set(user.phone, code, Duration.ofMinutes(5))
+ redisTemplate.opsForValue().set(user.phone, code, Duration.ofMinutes(10))
var payseted = false
if (!user.paypwd.isNullOrEmpty()) {
payseted = true
}
- var signed = ""
- if (card.signed) {
- signed = TradeDict.STATUS_YES
- }
+
return JsonResult.ok("OK").put("personid", card.userid)
?.put("paypwdset", payseted)
?.put("phonex", StringUtil.phoneReplace(phone))
val p = SecurityContextHolder.getContext().authentication
val user = mobileApiService.findUserById(p.name)
?: return JsonResult.error("用户不存在,请注册")
- user.issigned = TradeDict.STATUS_YES
- user.signedtime = DateUtil.getNow()
var signed: String
if (!user.userid.isNullOrEmpty()) {
var card = mobileApiService.findCardByUserid(user.userid!!) ?: return JsonResult.error("卡片不存在,请重新绑定")
if (card.signed) {
signed = TradeDict.STATUS_YES
- }else{
- //TODO call sign api
+ } else {
+ //call sign api
+ val person = userService.findOnePersonByUserid(card.userid)
+ var resp = citizencardPayService.signCard(card.cardno, person.name, person.idtype, person.idno, user.phone, YnrccUtil.TRANSTYPE_SIGNCARD)
+ if (resp.code != "0000") {
+ return JsonResult.error(resp.message)
+ }
card.signed = true
+ user.signedtime = DateUtil.getNow();
mobileApiService.saveCard(card)
+ mobileApiService.saveUser(user)
signed = TradeDict.STATUS_YES
}
- }else{
+ } else {
return JsonResult.error("请先绑定银行卡")
}
- mobileApiService.saveUser(user)
return JsonResult.ok("ok")
.put("signed", signed)!!
}
mobileApiService.findUserById(p.name)
?: return JsonResult.error("用户不存在,请注册")
//TODO cardlost
- return JsonResult.ok("ok")
+ return JsonResult.ok("ok").put("qrcode",p.name)!!
}