|
|
@@ -0,0 +1,203 @@
|
|
|
+package com.goafanti.admin.controller;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.AFTConstants;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.enums.AttachmentType;
|
|
|
+import com.goafanti.common.enums.IdentityAuditStatus;
|
|
|
+import com.goafanti.common.enums.IdentityProcess;
|
|
|
+import com.goafanti.common.enums.OrganizationIdentityFields;
|
|
|
+import com.goafanti.common.enums.UserIdentityFields;
|
|
|
+import com.goafanti.common.model.OrganizationIdentity;
|
|
|
+import com.goafanti.common.model.UserIdentity;
|
|
|
+import com.goafanti.common.utils.DateUtils;
|
|
|
+import com.goafanti.user.bo.InputOrganizationIdentity;
|
|
|
+import com.goafanti.user.bo.InputUserIdentity;
|
|
|
+import com.goafanti.user.service.OrganizationIdentityService;
|
|
|
+import com.goafanti.user.service.UserIdentityService;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/api/admin/userCertify")
|
|
|
+public class AdminUserCertifyApiController extends CertifyApiController {
|
|
|
+ @Resource
|
|
|
+ private UserIdentityService userIdentityService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OrganizationIdentityService organizationIdentityService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传认证资料(营业执照图片、组织机构代码证图片、上年度纳税申报表)
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @param sign
|
|
|
+ * @param uid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/upload", method = RequestMethod.POST)
|
|
|
+ public Result uploadCertify(HttpServletRequest req, String sign, String uid) {
|
|
|
+ Result res = new Result();
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ AttachmentType attachmentType = AttachmentType.getField(sign);
|
|
|
+ if (attachmentType == AttachmentType.ORGCODE || attachmentType == AttachmentType.LICENCE) {
|
|
|
+ res.setData(handleFiles(res, "/identity/", true, req, sign, uid));
|
|
|
+ } else if (attachmentType == AttachmentType.RATEPAY) {
|
|
|
+ sign = sign + "_" + (Calendar.getInstance().get(Calendar.YEAR)-1);
|
|
|
+ res.setData(handleFiles(res, "/cognizance/", true, req, sign, uid));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核员审核个人用户信息
|
|
|
+ * @param userIdentity
|
|
|
+ * @param bindingResult
|
|
|
+ * @param paymentDateFormattedDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/user", method = RequestMethod.POST)
|
|
|
+ public Result disposeCertify(@Valid InputUserIdentity userIdentity, BindingResult bindingResult,
|
|
|
+ String paymentDateFormattedDate, String aid, String mid){
|
|
|
+ Result res = new Result();
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == userIdentity.getUid()) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isBlank(paymentDateFormattedDate)) {
|
|
|
+ try {
|
|
|
+ userIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UserIdentity ui = new UserIdentity();
|
|
|
+ BeanUtils.copyProperties(userIdentity, ui);
|
|
|
+ if (StringUtils.isBlank(ui.getId())) {
|
|
|
+ ui.setId(UUID.randomUUID().toString());
|
|
|
+ ui.setAuditStatus(null == ui.getAuditStatus() ? 0 : ui.getAuditStatus());
|
|
|
+ if (IdentityAuditStatus.UNCOMMITTED.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.UNCOMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.COMMITTED.getCode() == ui.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.UNPAID.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.COMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.PAID.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.FILLIN.getCode());
|
|
|
+ } else if (IdentityAuditStatus.NOTPASSED.getCode() == ui.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.PASSED.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.RESULTS.getCode());
|
|
|
+ }
|
|
|
+ res.setData(userIdentityService.insert(ui));
|
|
|
+ } else {
|
|
|
+ ui.setAuditStatus(null == ui.getAuditStatus() ? 0 : ui.getAuditStatus());
|
|
|
+ if (IdentityAuditStatus.UNCOMMITTED.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.UNCOMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.COMMITTED.getCode() == ui.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.UNPAID.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.COMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.PAID.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.FILLIN.getCode());
|
|
|
+ } else if (IdentityAuditStatus.NOTPASSED.getCode() == ui.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.PASSED.getCode() == ui.getAuditStatus()) {
|
|
|
+ ui.setProcess(IdentityProcess.RESULTS.getCode());
|
|
|
+ }
|
|
|
+ res.setData(userIdentityService.updateUserDetail(ui, aid, mid));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核员审核团体用户信息
|
|
|
+ * @param orgIdentity
|
|
|
+ * @param bindingResult
|
|
|
+ * @param paymentDateFormattedDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/org", method = RequestMethod.POST)
|
|
|
+ public Result updateOrgDetail(@Valid InputOrganizationIdentity orgIdentity, BindingResult bindingResult,
|
|
|
+ String paymentDateFormattedDate) {
|
|
|
+ Result res = new Result();
|
|
|
+
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ OrganizationIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == orgIdentity.getUid()) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (!StringUtils.isBlank(paymentDateFormattedDate)) {
|
|
|
+ try {
|
|
|
+ orgIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ OrganizationIdentity oi = new OrganizationIdentity();
|
|
|
+ BeanUtils.copyProperties(orgIdentity, oi);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(oi.getId())) {
|
|
|
+ oi.setId(UUID.randomUUID().toString());
|
|
|
+ oi.setIdentityType(null == oi.getIdentityType() ? 0 : oi.getIdentityType());
|
|
|
+ oi.setAuditStatus(null == oi.getAuditStatus() ? 0 : oi.getAuditStatus());
|
|
|
+ if (IdentityAuditStatus.UNCOMMITTED.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.UNCOMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.COMMITTED.getCode() == oi.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.UNPAID.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.COMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.PAID.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.FILLIN.getCode());
|
|
|
+ } else if (IdentityAuditStatus.NOTPASSED.getCode() == oi.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.PASSED.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.RESULTS.getCode());
|
|
|
+ }
|
|
|
+ oi.setListed(null == oi.getListed() ? 0 : oi.getListed());
|
|
|
+ oi.setListedType(null == oi.getListedType() ? 0 : oi.getListedType());
|
|
|
+ res.setData(organizationIdentityService.insert(oi));
|
|
|
+ } else {
|
|
|
+ oi.setAuditStatus(null == oi.getAuditStatus() ? 0 : oi.getAuditStatus());
|
|
|
+ if (IdentityAuditStatus.UNCOMMITTED.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.UNCOMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.COMMITTED.getCode() == oi.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.UNPAID.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.COMMITTED.getCode());
|
|
|
+ } else if (IdentityAuditStatus.PAID.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.FILLIN.getCode());
|
|
|
+ } else if (IdentityAuditStatus.NOTPASSED.getCode() == oi.getAuditStatus()
|
|
|
+ || IdentityAuditStatus.PASSED.getCode() == oi.getAuditStatus()) {
|
|
|
+ oi.setProcess(IdentityProcess.RESULTS.getCode());
|
|
|
+ }
|
|
|
+ res.setData(organizationIdentityService.updateOrgDetail(oi));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+}
|