解约、解绑接口
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 da66271..0f6f5d6 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.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 @@
         }
         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 @@
             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