From c22480729cfe7633c439dcf1887df99dbc81e0cd Mon Sep 17 00:00:00 2001 From: qiaowei Date: Thu, 5 Dec 2019 11:28:20 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E7=BA=A6=E3=80=81=E8=A7=A3=E7=BB=91?= =?utf8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../com/supwisdom/dlpay/mobile/MobileApi.kt | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/MobileApi.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/MobileApi.kt index da662719..0f6f5d65 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/MobileApi.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/MobileApi.kt @@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestHeader import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.multipart.MultipartFile import java.time.Duration import java.util.* @@ -400,7 +401,7 @@ class ApiV1 { } val exsitUser = mobileApiService.findUserById(card.userid) if (exsitUser != null) { - return JsonResult.error("该银行卡号已被绑定,如有疑问,请联系客服") + return JsonResult.error("该银行卡号已被绑定,若您本人绑定,请先解除绑定,若非本人,请联系客服") } //call api var resp = citizencardPayService.bindCard(cardno, name, idtype, idno, phone) @@ -766,4 +767,89 @@ class ApiV1 { JsonResult.error(resp.retmsg) } } + + /** + * + * 解除银行协议 + * */ + @RequestMapping("/unsignbxy") + fun unSignbxy(): JsonResult { + val p = SecurityContextHolder.getContext().authentication + val user = mobileApiService.findUserById(p.name) + ?: return JsonResult.error("用户不存在,请注册") + var signed: String + if (!user.userid.isNullOrEmpty()) { + var card = mobileApiService.findCardByUserid(user.userid!!) + ?: return JsonResult.error("银行卡不存在,不能解除代扣协议") + //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_UNSIGNCARD) + if (resp.code != "0000") { + return JsonResult.error(resp.message) + } + card.signed = false + mobileApiService.saveCard(card) + signed = TradeDict.STATUS_NO + } else { + return JsonResult.error("未绑定银行卡,不能解除代扣协议") + } + return JsonResult.ok("ok") + .put("signed", signed)!! + } + + /** + * 解除绑定 + * */ + @RequestMapping("/unbindcard") + fun unbindcard(paypwd: String): JsonResult { + val p = SecurityContextHolder.getContext().authentication + val user = mobileApiService.findUserById(p.name) + ?: return JsonResult.error("用户不存在,请注册") + if(user.paypwd.isNullOrEmpty()){ + return JsonResult.error("支付密码未设置,请先设置") + } + val paypwdtimes = user.checkPaypwdtime() + if (paypwdtimes == -1) { + return JsonResult.error("支付密码错误次数过多,请30分钟后再试") + } else if (paypwdtimes == 1) { + mobileApiService.saveUser(user) + } + val encoder = BCryptPasswordEncoder() + if (!encoder.matches(paypwd, user.paypwd)) { + user.updatePaypwderror(false).also { + if (it) mobileApiService.saveUser(user) + } + return JsonResult.error("支付密码错误") + } else { + user.updatePaypwderror(true).also { + if (it) mobileApiService.saveUser(user) + } + } + var card = mobileApiService.findCardByUserid(user.userid!!) + ?: return JsonResult.error(-1, "银行卡未绑定,无需解绑") + card.signed = false + user.userid = null + mobileApiService.saveCard(card) + mobileApiService.saveUser(user) + return JsonResult.ok("OK") + ?.put("signed", TradeDict.STATUS_NO)!! + } + + /** + * 上传头像 + * */ + @RequestMapping("/uploadphoto") + fun uploadPhoto(file: MultipartFile): JsonResult { + val p = SecurityContextHolder.getContext().authentication + val user = mobileApiService.findUserById(p.name) + ?: return JsonResult.error("用户不存在,请注册") + /** + * TODO + * 1.已有头像更新 + * 2.没有头像上传 + * 3.返回图片ID + * + */ + return JsonResult.ok("OK") + } } \ No newline at end of file -- 2.17.1