diff --git a/src/db/20201028/loans_apply.sql b/src/db/20201028/loans_apply.sql new file mode 100644 index 000000000..f7e90ca01 --- /dev/null +++ b/src/db/20201028/loans_apply.sql @@ -0,0 +1,22 @@ +ALTER TABLE `sys_clients_apply` +ADD COLUMN `type` smallint(1) NULL DEFAULT 0 COMMENT '0:PC 1:PC-卡支付'; + + +CREATE TABLE `sys_clients_loans_apply` ( + `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键id', + `create_time` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '创建时间', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', + `modifiy_time` timestamp(0) NULL DEFAULT NULL COMMENT '修改时间', + `modifier` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改者', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人姓名', + `phone` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系人手机', + `email` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联系邮箱', + `business_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商业名称', + `industry` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '行业', + `status` int(1) NULL DEFAULT 0 COMMENT '贷款申请状态 0:待处理、1:处理中、2:已处理', + `source` int(1) NULL DEFAULT 0 COMMENT '申请来源: 0 : PC,1:公众号菜单,2:公众号推送,3:小程序申请,4:App申请', + `client_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户id', + `client_moniker` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户的parterCode', + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注信息', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '贷款申请表' ROW_FORMAT = Dynamic; diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/descriptor/LoanApplicationDescriptor.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/descriptor/LoanApplicationDescriptor.java new file mode 100644 index 000000000..f1c072c6f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/descriptor/LoanApplicationDescriptor.java @@ -0,0 +1,54 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.sql.Timestamp; + +/** + * 贷款申请信息描述 + */ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class LoanApplicationDescriptor { + + private String id; + + private Timestamp createTime; + + private String clientId; + + private String name; + + private String phone; + + private String email; + + private String businessName; + + private String industry; + + /** + * 处理状态 + */ + private String status; + + /** + * 处理状态值 + */ + private String statusDescription; + + /** + * 备注信息 + */ + private String remark; + + /** + * 申请来源 + */ + private Integer source; +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplication.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplication.java new file mode 100644 index 000000000..b9117657f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplication.java @@ -0,0 +1,83 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.entity; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor.LoanApplicationDescriptor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.sql.Timestamp; + +/** + * 贷款申请信息 + */ +@Data +@Accessors(chain = true) +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class LoanApplication { + + private String id; + + private Timestamp createTime; + + private Timestamp modifyTime; + + private String creator; + + private String modifier; + + private String clientId; + + /** + * 联系人姓名 + */ + private String name; + /** + * 联系人手机 + */ + private String phone; + /** + * 联系人邮箱 + */ + private String email; + /** + * 商业名称 + */ + private String businessName; + /** + * 行业 + */ + private String industry; + + /** + * 处理状态 + */ + private LoanApplicationStatus status; + + /** + * 备注信息 + */ + private String remark; + + /** + * 申请来源 + */ + private Integer source; + + public LoanApplicationDescriptor describe() { + return new LoanApplicationDescriptor() + .setId(this.id) + .setClientId(this.clientId) + .setCreateTime(this.createTime) + .setName(this.name) + .setPhone(this.phone) + .setEmail(this.email) + .setBusinessName(this.businessName) + .setIndustry(this.industry) + .setStatus(this.status.value()) + .setStatusDescription(this.status.description()) + .setRemark(this.remark) + .setSource(this.source); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplicationStatus.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplicationStatus.java new file mode 100644 index 000000000..1177745a1 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/LoanApplicationStatus.java @@ -0,0 +1,90 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.entity; + +/** + * 贷款申请状态 0:待处理、1:处理中、2:已处理 + */ +public enum LoanApplicationStatus { + + /** + * 待处理 + */ + READY { + @Override + public int code() { + return 0; + } + + @Override + public String value() { + return "READY"; + } + + @Override + public String description() { + return "待处理"; + } + }, + /** + * 处理中 + */ + PROCESSING { + @Override + public int code() { + return 1; + } + + @Override + public String value() { + return "PROCESSING"; + } + + @Override + public String description() { + return "处理中"; + } + }, + /** + * 已处理 + */ + COMPLETED { + @Override + public int code() { + return 2; + } + + @Override + public String value() { + return "COMPLETED"; + } + + @Override + public String description() { + return "已处理"; + } + }; + + /** + * 获取代码。 + * + * @return 代码 + */ + public abstract int code(); + + /** + * 获取代码对应的值。 + * + * @return 代码值 + */ + public abstract String value(); + + public abstract String description(); + + public static LoanApplicationStatus codeOf(int code) { + for (LoanApplicationStatus status : LoanApplicationStatus.values()) { + if (status.code() == code) { + return status; + } + } + return LoanApplicationStatus.READY; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/request/ModifyLoanApplicationRequest.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/request/ModifyLoanApplicationRequest.java new file mode 100644 index 000000000..1ca7c3a17 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/entity/request/ModifyLoanApplicationRequest.java @@ -0,0 +1,34 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.request; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplicationStatus; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class ModifyLoanApplicationRequest { + + private String id; + + /** + * 状态信息 + */ + private Integer status; + + /** + * 备注信息 + */ + private String remark; + + public ModifyLoanApplicationRequest build(String id, String status, String remark) { + return new ModifyLoanApplicationRequest() + .setId(id) + .setStatus(LoanApplicationStatus.valueOf(status).code()) + .setRemark(remark); + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/repository/LoanApplicationRepository.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/repository/LoanApplicationRepository.java new file mode 100644 index 000000000..ce8303faf --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/repository/LoanApplicationRepository.java @@ -0,0 +1,17 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.repository; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplication; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.request.ModifyLoanApplicationRequest; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; + +import java.util.Map; + +public interface LoanApplicationRepository { + + PageList listPagedLoanApplication(Map params, PageBounds pageBounds); + + LoanApplication getById(String id); + + void changeLoanApplication(ModifyLoanApplicationRequest request); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/service/LoanApplicationService.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/service/LoanApplicationService.java new file mode 100644 index 000000000..983705096 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/service/LoanApplicationService.java @@ -0,0 +1,18 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.service; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor.LoanApplicationDescriptor; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.web.command.ModifyLoanApplicationCommand; +import au.com.royalpay.payment.manage.support.representation.PageListRepresentation; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; + +import java.util.Map; + +public interface LoanApplicationService { + + PageListRepresentation listPagedLoanApplication(Map params, PageBounds pageBounds); + + LoanApplicationDescriptor getById(String id); + + void changeLoanApplication(String id, ModifyLoanApplicationCommand command); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationController.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationController.java new file mode 100644 index 000000000..9786e57f4 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationController.java @@ -0,0 +1,43 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.web; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor.LoanApplicationDescriptor; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.service.LoanApplicationService; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.web.command.ModifyLoanApplicationCommand; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 贷款申请资源 + */ +@RestController +@RequestMapping(value = "/partners") +public class RestLoanApplicationController { + + @Resource + private LoanApplicationService applicationService; + + /** + * 获取贷款申请详情 + * + * @param id 编号 + * @return + */ + @RequestMapping(value = "/loanApplications/{id}", method = RequestMethod.GET) + public LoanApplicationDescriptor getLoanApplication(@PathVariable("id") String id) { + return applicationService.getById(id); + } + + /** + * 更新贷款申请信息 + * + * @param id 编号 + * @param command 入参 + */ + @RequestMapping(value = "/loanApplications/{id}", method = RequestMethod.PUT) + public void changeLoanApplication(@PathVariable("id") String id, + @RequestBody ModifyLoanApplicationCommand command) { + applicationService.changeLoanApplication(id, command); + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationsController.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationsController.java new file mode 100644 index 000000000..bc35affac --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/RestLoanApplicationsController.java @@ -0,0 +1,44 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.web; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor.LoanApplicationDescriptor; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.service.LoanApplicationService; +import au.com.royalpay.payment.manage.support.representation.PageListRepresentation; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.constraints.Min; +import java.util.Map; + +/** + * 贷款申请列表资源 + */ +@RestController +@RequestMapping(value = "/partners") +public class RestLoanApplicationsController { + + @Resource + private LoanApplicationService applicationService; + + /** + * 贷款申请分页列表 + * + * @param params + * @param page + * @param pageSize + * @return + */ + @RequestMapping(value = "/loanApplications", method = RequestMethod.GET) + public Object listPagedLoanApplication(@RequestParam Map params, + @Min(1) @RequestParam(value = "page", required = false, defaultValue = "1") int page, + @Min(1) @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) { + PageBounds pageBounds = new PageBounds(page, pageSize, Order.formString("create_time.desc")); + PageListRepresentation result = applicationService.listPagedLoanApplication(params, pageBounds); + return result; + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/command/ModifyLoanApplicationCommand.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/command/ModifyLoanApplicationCommand.java new file mode 100644 index 000000000..716111cfd --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/domain/web/command/ModifyLoanApplicationCommand.java @@ -0,0 +1,23 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.domain.web.command; + + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; + +@Data +@Accessors(chain = true) +@NoArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class ModifyLoanApplicationCommand { + + @NotBlank(message = "error.payment.valid.param_missing") + private String remark; + + @NotBlank(message = "error.payment.valid.param_missing") + private String status; + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/repository/LoanApplicationRepositoryImpl.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/repository/LoanApplicationRepositoryImpl.java new file mode 100644 index 000000000..91120ce89 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/repository/LoanApplicationRepositoryImpl.java @@ -0,0 +1,35 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.infrastructure.repository; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplication; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.request.ModifyLoanApplicationRequest; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.repository.LoanApplicationRepository; +import au.com.royalpay.payment.manage.mappers.loanapplication.LoanApplicationMapper; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.springframework.stereotype.Repository; + +import javax.annotation.Resource; +import java.util.Map; + +@Repository +public class LoanApplicationRepositoryImpl implements LoanApplicationRepository { + + @Resource + private LoanApplicationMapper mapper; + + @Override + public PageList listPagedLoanApplication(Map params, PageBounds pageBounds) { + return mapper.listPagedLoanApplication(params, pageBounds); + } + + @Override + public LoanApplication getById(String id) { + return mapper.findById(id); + } + + @Override + public void changeLoanApplication(ModifyLoanApplicationRequest request) { + mapper.updateLoanApplication(request); + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/service/LoanApplicationServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/service/LoanApplicationServiceImpl.java new file mode 100644 index 000000000..79606ba95 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/loanapplicaiton/infrastructure/service/LoanApplicationServiceImpl.java @@ -0,0 +1,54 @@ +package au.com.royalpay.payment.manage.loanapplicaiton.infrastructure.service; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.descriptor.LoanApplicationDescriptor; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplication; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.request.ModifyLoanApplicationRequest; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.repository.LoanApplicationRepository; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.service.LoanApplicationService; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.web.command.ModifyLoanApplicationCommand; +import au.com.royalpay.payment.manage.support.representation.PageListRepresentation; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Map; + +@Service +public class LoanApplicationServiceImpl implements LoanApplicationService { + + @Resource + private LoanApplicationRepository repository; + + @Override + public PageListRepresentation listPagedLoanApplication(Map params, PageBounds pageBounds) { + PageList loanApplications = repository.listPagedLoanApplication(params, pageBounds); + PageList loanApplicationDescriptors = new PageList<>(loanApplications.getPaginator()); + loanApplications.forEach(item -> { + loanApplicationDescriptors.add(item.describe()); + }); + return new PageListRepresentation<>(loanApplicationDescriptors); + } + + @Override + public LoanApplicationDescriptor getById(String id) { + LoanApplication application = this.getLoanApplication(id); + return application.describe(); + } + + @Override + public void changeLoanApplication(String id, ModifyLoanApplicationCommand command) { + LoanApplication application = this.getLoanApplication(id); + repository.changeLoanApplication(new ModifyLoanApplicationRequest().build(application.getId(), command.getStatus(), command.getRemark())); + } + + private LoanApplication getLoanApplication(String id) { + LoanApplication application = repository.getById(id); + if (application == null) { + throw new BadRequestException("Loan is not exist"); + } + return application; + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.java new file mode 100644 index 000000000..3e171fb34 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.java @@ -0,0 +1,31 @@ +package au.com.royalpay.payment.manage.mappers.loanapplication; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplication; +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.request.ModifyLoanApplicationRequest; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; +import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; +import com.yixsoft.support.mybatis.autosql.annotations.SqlType; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +@AutoMapper(tablename = "sys_clients_loans_apply", pkName = "id") +public interface LoanApplicationMapper { + + PageList listPagedLoanApplication(Map params, PageBounds pageBounds); + + @AutoSql(SqlType.INSERT) + void save(JSONObject request); + + LoanApplication findById(@Param("id") String id); + + @AutoSql(SqlType.UPDATE) + void updateLoanApplication(ModifyLoanApplicationRequest request); + + @AutoSql(SqlType.DELETE) + void deleteLoanApplication(@Param("id") String id); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/events/listeners/SendingApplyToWechatMessageListener.java b/src/main/java/au/com/royalpay/payment/manage/merchants/events/listeners/SendingApplyToWechatMessageListener.java index f39a72ace..9725e960c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/events/listeners/SendingApplyToWechatMessageListener.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/events/listeners/SendingApplyToWechatMessageListener.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.merchants.events.listeners; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; import au.com.royalpay.payment.manage.merchants.events.ClientApplyEvent; +import au.com.royalpay.payment.manage.officialwebsit.domain.entity.PartnerApplyType; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; @@ -9,7 +10,6 @@ import au.com.royalpay.payment.tools.env.PlatformEnvironment; import org.apache.commons.lang3.time.DateFormatUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Service; @@ -31,7 +31,7 @@ public class SendingApplyToWechatMessageListener implements ApplicationListener< public void onApplicationEvent(ClientApplyEvent event) { List managerOpenIds = managerMapper.listOpenIdsOfCompliances(); String uri = "/partners/application/partner_apply_info/" + event.getApplyInfo().getString("client_apply_id"); - String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat")+"?target="+uri; + String loginUrl = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/manager_signin_wechat") + "?target=" + uri; logger.info("sending new client request to wechat binded compliances"); for (String wxOpenid : managerOpenIds) { try { @@ -45,7 +45,17 @@ public class SendingApplyToWechatMessageListener implements ApplicationListener< private TemplateMessage initTemplate(ClientApplyEvent event, String loginUrl, String wxOpenid, String templateId) { TemplateMessage msg = new TemplateMessage(wxOpenid, templateId, loginUrl); - msg.put("first", "有新商户提交了开通申请,请审核", "#ff0000"); + if (event.getApplyInfo().containsKey("type")) { + String type = event.getApplyInfo().getString("type"); + if (PartnerApplyType.typeOf(type).isCard()) { + msg.put("first", "有新商户提交了卡支付开通申请,请审核", "#ff0000"); + } + if (PartnerApplyType.typeOf(type).isLoans()) { + msg.put("first", "有新商户提交了贷款开通申请,请审核", "#ff0000"); + } + } else { + msg.put("first", "有新商户提交了开通申请,请审核", "#ff0000"); + } msg.put("keyword1", "商户开通申请", "#0000ff"); msg.put("keyword2", event.getApplyInfo().getString("company_name"), "#000000"); msg.put("keyword3", DateFormatUtils.format(event.getTimestamp(), "yyyy-MM-dd HH:mm:ss,z"), "#000000"); diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/entity/PartnerApplyType.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/entity/PartnerApplyType.java new file mode 100644 index 000000000..604c61fa8 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/entity/PartnerApplyType.java @@ -0,0 +1,104 @@ +package au.com.royalpay.payment.manage.officialwebsit.domain.entity; + +/** + * 申请类型:0,CARD 卡支付;1,LOANS 贷款申请 + */ +public enum PartnerApplyType { + + /** + * 卡支付 + */ + CARD { + @Override + public int code() { + return 0; + } + + @Override + public String value() { + return "CARD"; + } + + @Override + public String description() { + return "卡支付"; + } + + @Override + public boolean isCard() { + return true; + } + + @Override + public boolean isLoans() { + return false; + } + }, + /** + * 贷款申请 + */ + LOANS { + @Override + public int code() { + return 1; + } + + @Override + public String value() { + return "LOANS"; + } + + @Override + public String description() { + return "贷款申请"; + } + + @Override + public boolean isCard() { + return false; + } + + @Override + public boolean isLoans() { + return true; + } + }; + + /** + * 获取代码。 + * + * @return 代码 + */ + public abstract int code(); + + /** + * 获取代码对应的值。 + * + * @return 代码值 + */ + public abstract String value(); + + public abstract String description(); + + public static PartnerApplyType codeOf(int code) { + for (PartnerApplyType status : PartnerApplyType.values()) { + if (status.code() == code) { + return status; + } + } + return PartnerApplyType.CARD; + } + + public static PartnerApplyType typeOf(String type) { + for (PartnerApplyType status : PartnerApplyType.values()) { + if (status.value().equalsIgnoreCase(type)) { + return status; + } + } + return PartnerApplyType.CARD; + } + + public abstract boolean isCard(); + + public abstract boolean isLoans(); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/repository/PartnerApplyRepository.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/repository/PartnerApplyRepository.java new file mode 100644 index 000000000..742d71afe --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/repository/PartnerApplyRepository.java @@ -0,0 +1,7 @@ +package au.com.royalpay.payment.manage.officialwebsit.domain.repository; + +import com.alibaba.fastjson.JSONObject; + +public interface PartnerApplyRepository { + void save(JSONObject applyInfo); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/service/PartnerApplyService.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/service/PartnerApplyService.java new file mode 100644 index 000000000..517571e68 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/service/PartnerApplyService.java @@ -0,0 +1,7 @@ +package au.com.royalpay.payment.manage.officialwebsit.domain.service; + +import au.com.royalpay.payment.manage.officialwebsit.domain.web.command.PartnerApplyInfo; + +public interface PartnerApplyService { + void applyPartner(PartnerApplyInfo apply); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/RestPartnerApplyController.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/RestPartnerApplyController.java new file mode 100644 index 000000000..5147109a3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/RestPartnerApplyController.java @@ -0,0 +1,46 @@ +package au.com.royalpay.payment.manage.officialwebsit.domain.web; + +import au.com.royalpay.payment.manage.officialwebsit.domain.service.PartnerApplyService; +import au.com.royalpay.payment.manage.officialwebsit.domain.web.command.PartnerApplyInfo; +import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.http.HttpUtils; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +/** + * 卡支付/贷款申请资源 + */ +@RestController +@RequestMapping("/partners") +public class RestPartnerApplyController { + + @Resource + private PartnerApplyService applyService; + + + /** + * 卡支付/贷款申请入口 + * + * @param apply + * @param errors + * @param response + * @throws Exception + */ + @RequestMapping(value = "/website/application", method = RequestMethod.POST) + public void applyPartner(@RequestBody @Valid PartnerApplyInfo apply, + Errors errors, HttpServletResponse response) throws Exception { + if (!PlatformEnvironment.getEnv().enablePartnerApply()) { + throw new BadRequestException("商户自主申请暂时关闭. Merchant Apply disabled at the moment."); + } + HttpUtils.handleValidErrors(errors); + applyService.applyPartner(apply); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/command/PartnerApplyInfo.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/command/PartnerApplyInfo.java new file mode 100644 index 000000000..baa320260 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/domain/web/command/PartnerApplyInfo.java @@ -0,0 +1,104 @@ +package au.com.royalpay.payment.manage.officialwebsit.domain.web.command; + +/** + * 卡支付/贷款申请信息请求入参 + */ +public class PartnerApplyInfo { + /** + * 前缀name + */ + private String firstName; + /** + * 后缀name + */ + private String surname; + /** + * 手机号 + */ + private String phoneNumber; + /** + * email + */ + private String emailAddress; + /** + * 公司名称 + */ + private String businessName; + /** + *行业 + */ + private String industry; + /** + * 申请类型:0,CARD 卡支付;1,LOANS 贷款申请 + */ + private String type; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public String getIndustry() { + return industry; + } + + public void setIndustry(String industry) { + this.industry = industry; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "PartnerApplyInfo{" + + "firstName='" + firstName + '\'' + + ", Surname='" + surname + '\'' + + ", phoneNumber='" + phoneNumber + '\'' + + ", emailAddress='" + emailAddress + '\'' + + ", businessName='" + businessName + '\'' + + ", industry='" + industry + '\'' + + ", type='" + type + '\'' + + '}'; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/repository/PartnerApplyRepositoryImpl.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/repository/PartnerApplyRepositoryImpl.java new file mode 100644 index 000000000..ff39a81a9 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/repository/PartnerApplyRepositoryImpl.java @@ -0,0 +1,20 @@ +package au.com.royalpay.payment.manage.officialwebsit.infrastructure.repository; + +import au.com.royalpay.payment.manage.mappers.loanapplication.LoanApplicationMapper; +import au.com.royalpay.payment.manage.officialwebsit.domain.repository.PartnerApplyRepository; +import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Repository; + +import javax.annotation.Resource; + +@Repository +public class PartnerApplyRepositoryImpl implements PartnerApplyRepository { + + @Resource + private LoanApplicationMapper mapper; + + @Override + public void save(JSONObject applyInfo) { + mapper.save(applyInfo); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/service/PartnerApplyServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/service/PartnerApplyServiceImpl.java new file mode 100644 index 000000000..534129e57 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/officialwebsit/infrastructure/service/PartnerApplyServiceImpl.java @@ -0,0 +1,81 @@ +package au.com.royalpay.payment.manage.officialwebsit.infrastructure.service; + +import au.com.royalpay.payment.manage.loanapplicaiton.domain.entity.LoanApplicationStatus; +import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; +import au.com.royalpay.payment.manage.merchants.events.ClientApplyEvent; +import au.com.royalpay.payment.manage.officialwebsit.domain.entity.PartnerApplyType; +import au.com.royalpay.payment.manage.officialwebsit.domain.repository.PartnerApplyRepository; +import au.com.royalpay.payment.manage.officialwebsit.domain.service.PartnerApplyService; +import au.com.royalpay.payment.manage.officialwebsit.domain.web.command.PartnerApplyInfo; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.ApplicationEventPublisherAware; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.UUID; + +@Slf4j +@Service +public class PartnerApplyServiceImpl implements PartnerApplyService, ApplicationEventPublisherAware { + + @Resource + private ClientApplyMapper clientApplyMapper; + + @Resource + private PartnerApplyRepository applyRepository; + + @Resource + private ApplicationEventPublisher publisher; + + @Override + public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { + this.publisher = applicationEventPublisher; + } + + @Override + public void applyPartner(PartnerApplyInfo apply) { + PartnerApplyType applyType = PartnerApplyType.typeOf(apply.getType()); + if (applyType.isCard()) { + JSONObject applyInfo = this.buildCardPaymentApplyInfo(apply); + clientApplyMapper.save(applyInfo); + publisher.publishEvent(new ClientApplyEvent(this, applyInfo)); + } + if (applyType.isLoans()) { + JSONObject applyInfo = this.buildLoansApplyInfo(apply); + applyRepository.save(applyInfo); + publisher.publishEvent(new ClientApplyEvent(this, applyInfo)); + } + + } + + private JSONObject buildLoansApplyInfo(PartnerApplyInfo apply) { + JSONObject result = new JSONObject(); + String name = apply.getFirstName() + " " + apply.getSurname(); + result.put("id", UUID.randomUUID().toString()); + result.put("name", name); + result.put("phone", apply.getPhoneNumber()); + result.put("email", apply.getEmailAddress()); + result.put("industry", apply.getIndustry()); + result.put("business_name", apply.getBusinessName()); + result.put("status", LoanApplicationStatus.READY.code()); + result.put("source", 0); + return result; + } + + private JSONObject buildCardPaymentApplyInfo(PartnerApplyInfo apply) { + JSONObject result = new JSONObject(); + String name = apply.getFirstName() + " " + apply.getSurname(); + result.put("client_apply_id", UUID.randomUUID().toString()); + result.put("contact_person", name); + result.put("contact_phone", apply.getPhoneNumber()); + result.put("contact_email", apply.getEmailAddress()); + result.put("company_name", apply.getBusinessName()); + result.put("short_name", apply.getBusinessName()); + result.put("industry", apply.getIndustry()); + result.put("type", 1); + return result; + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/support/representation/PageListRepresentation.java b/src/main/java/au/com/royalpay/payment/manage/support/representation/PageListRepresentation.java new file mode 100644 index 000000000..910e10da0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/support/representation/PageListRepresentation.java @@ -0,0 +1,33 @@ +package au.com.royalpay.payment.manage.support.representation; + +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import com.github.miemiedev.mybatis.paginator.domain.Paginator; + +public class PageListRepresentation { + + private PageList data; + + private Paginator pagination; + + public PageListRepresentation(PageList pageList) { + this.data = pageList; + this.pagination = pageList.getPaginator(); + + } + + public PageList getData() { + return data; + } + + public void setData(PageList data) { + this.data = data; + } + + public Paginator getPagination() { + return pagination; + } + + public void setPagination(Paginator pagination) { + this.pagination = pagination; + } +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.xml new file mode 100644 index 000000000..e00f94c5e --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/loanapplication/LoanApplicationMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/ui/static/payment/partner/partner-apply.js b/src/main/ui/static/payment/partner/partner-apply.js index cc1e1c034..31fc03ec5 100644 --- a/src/main/ui/static/payment/partner/partner-apply.js +++ b/src/main/ui/static/payment/partner/partner-apply.js @@ -19,15 +19,28 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS return $http.get('/partners/application/' + $stateParams.client_apply_id); }] } + }).state('partner_apply.loans_application', { + url: '/loans/application', + templateUrl: '/static/payment/partner/templates/partner_loans_application.html', + controller: 'partnerLoansApplicationListCtrl' + }).state('partner_apply.loans_application_detail', { + url: '/loans/application/{id}', + templateUrl: '/static/payment/partner/templates/partner_loans_application_detail.html', + controller: 'partnerLoansApplicationDetailCtrl', + resolve: { + partner: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/partners/loanApplications/' + $stateParams.id); + }] + } }) }]); - app.controller('partnerApplyCtrl', ['$rootScope','$state', function ($rootScope,$state) { - if ($state.is('partner_apply')){ + app.controller('partnerApplyCtrl', ['$rootScope', '$state', function ($rootScope, $state) { + if ($state.is('partner_apply')) { $state.go('.partner_application'); } }]); - app.controller('partnerApplicationListCtrl', ['$scope', '$state', '$http', '$uibModal', 'commonDialog', 'industryMap', 'stateMap','countryMap', - function ($scope, $state, $http, $uibModal, commonDialog, industryMap, stateMap,countryMap) { + app.controller('partnerApplicationListCtrl', ['$scope', '$state', '$http', '$uibModal', 'commonDialog', 'industryMap', 'stateMap', 'countryMap', + function ($scope, $state, $http, $uibModal, commonDialog, industryMap, stateMap, countryMap) { $scope.pagination = {}; $scope.industries = industryMap.configs() $scope.states = stateMap.configs(); @@ -206,6 +219,67 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }]); + app.controller('partnerLoansApplicationListCtrl', ['$scope', '$state', '$http', '$uibModal', 'commonDialog', 'industryMap', 'stateMap', 'countryMap', + function ($scope, $state, $http, $uibModal, commonDialog, industryMap, stateMap, countryMap) { + $scope.pagination = {}; + $scope.industries = industryMap.configs() + $scope.states = stateMap.configs(); + $scope.countries = countryMap.configs(); + $scope.params = {}; + + $scope.loadPartners = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/partners/loanApplications', {params: params}).then(function (resp) { + $scope.partners = resp.data.data; + $scope.pagination = resp.data.pagination; + }); + }; + $scope.loadPartners(1); + + $scope.handleButton = function (obj) { + var partner = angular.copy(obj); + partner.link = true; + $uibModal.open({ + templateUrl: '/static/payment/partner/templates/partner_loans_application_edit.html', + controller: 'partnerApplicationEditCtrl', + resolve: { + partner: partner + } + }).result.then(function () { + commonDialog.alert({title: 'Success', content: '修改成功!', type: 'success'}); + $state.reload(); + // $state.go('partner_application.detail', {client_apply_id: obj.client_apply_id}, {reload: true}); + }) + }; + + + }]); + + + app.controller('partnerApplicationEditCtrl', ['$scope', '$http', '$state', 'partner', function ($scope, $http, $state, partner) { + $scope.partner = angular.copy(partner); + $scope.submit = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') <= 0) { + item.$dirty = true; + } + }); + return; + } + + $scope.errmsg = null; + $http.put('/partners/loanApplications/' + partner.id, $scope.partner).then(function (resp) { + $scope.$close(); + + }, function (resp) { + $scope.errmsg = resp.data.message; + }); + }; + + }]); + app.filter('cut', function () { return function (value, wordwise, max, tail) { if (!value) return ''; diff --git a/src/main/ui/static/payment/partner/templates/partner_application.html b/src/main/ui/static/payment/partner/templates/partner_application.html index 63ac128bd..2de6c8ed1 100644 --- a/src/main/ui/static/payment/partner/templates/partner_application.html +++ b/src/main/ui/static/payment/partner/templates/partner_application.html @@ -53,7 +53,7 @@ - PC + PC(卡支付) 公众号菜单 公众号推送 小程序申请 @@ -108,4 +108,4 @@ - \ No newline at end of file + diff --git a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html index 3e0e75539..edc8f9da8 100644 --- a/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html +++ b/src/main/ui/static/payment/partner/templates/partner_bankaccounts.html @@ -320,7 +320,7 @@ - (Promotional Offer) +
+
+
+
+
+
+
+ + +
+
+ +
+
+
+ +
+
+
+

Application List

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Application TimeCompany NameSourceApprove StatusRemarkOperation
+ PC + 公众号菜单 + 公众号推送 + 小程序申请 + App申请 + + {{partner.statusDescription}} + + + handle + +
+ +
+ +
+ + +
+ +
+
+ + diff --git a/src/main/ui/static/payment/partner/templates/partner_loans_application_edit.html b/src/main/ui/static/payment/partner/templates/partner_loans_application_edit.html new file mode 100644 index 000000000..8185fe753 --- /dev/null +++ b/src/main/ui/static/payment/partner/templates/partner_loans_application_edit.html @@ -0,0 +1,33 @@ + + diff --git a/src/main/ui/static/payment/partner/templates/partners_apply.html b/src/main/ui/static/payment/partner/templates/partners_apply.html index e05375a16..49839bc6c 100644 --- a/src/main/ui/static/payment/partner/templates/partners_apply.html +++ b/src/main/ui/static/payment/partner/templates/partners_apply.html @@ -19,9 +19,9 @@
  • Application & Open
  • - +
  • + Loans Application +