Commit b0f5dc59 by 程裕兵

feat:brand -> studio

parent 6388820c
...@@ -6,21 +6,19 @@ import lombok.AllArgsConstructor; ...@@ -6,21 +6,19 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* 商户类型 * @author chengyubing
* * @since 2024/3/4 18:22
* @author raccoon
* @since 2020-11-06 16:44
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum MerchantTypeEnums { public enum PartyTypeEnums {
/** /**
* 未知 * 业务方类型
*/ */
UNKNOWN("", ""), STUDIO("STUDIO", "场馆"),
BRAND("BRAND", "品牌"), BRAND("BRAND", "品牌"),
UNKNOWN("UNKNOWN", "未知"),
; ;
@EnumValue @EnumValue
...@@ -28,9 +26,9 @@ public enum MerchantTypeEnums { ...@@ -28,9 +26,9 @@ public enum MerchantTypeEnums {
private final String desc; private final String desc;
public static MerchantTypeEnums getByCode(String code) {
return Arrays.stream(MerchantTypeEnums.values()).filter(e -> e.getCode().equals(code)).findFirst() public static PartyTypeEnums getByCode(String code) {
return Arrays.stream(PartyTypeEnums.values()).filter(e -> e.getCode().equals(code)).findFirst()
.orElse(UNKNOWN); .orElse(UNKNOWN);
} }
} }
package com.jiejing.fitness.finance.api.merchant;
import com.jiejing.common.model.JsonResult;
import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.merchant.request.ApplyBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.AuthBrandMerchantSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantXcxAppIdRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetAuthBrandMerchantSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageBrandMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* 品牌商户API
*
* @author chengyubing
* @since 2024/2/22 11:49
*/
@FeignClient(name = "FINANCE", url = "${rpc.url.fit-finance:http://app-fit-finance:7008}", fallbackFactory = BrandMerchantApiFallback.class)
public interface BrandMerchantApi {
String TAG = "金融-品牌商户管理";
@ApiOperation(value = "品牌入驻商户", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/apply")
JsonResult<Void> apply(ApplyBrandMerchantRequest request);
@ApiOperation(value = "查询品牌当前绑定的商户", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/get")
JsonResult<BrandMerchantVO> get(GetBrandMerchantRequest request);
@ApiOperation(value = "查询品牌进件申请记录", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/getApply")
JsonResult<BrandMerchantApplyVO> getApply(GetBrandMerchantApplyRequest request);
@ApiOperation(value = "分页查询品牌进件申请记录", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/pageApply")
JsonResult<PageVO<BrandMerchantApplyVO>> pageApply(PageBrandMerchantApplyRequest request);
@ApiOperation(value = "绑定微信小程序appId", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/bindXcxAppId")
JsonResult<BrandMerchantBindXcxAppIdVO> bindXcxAppId(BindBrandMerchantXcxAppIdRequest request);
@ApiOperation(value = "授权子渠道", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/authSubChannel")
JsonResult<BrandMerchantAuthSubChannelVO> authSubChannel(AuthBrandMerchantSubChannelRequest request);
@ApiOperation(value = "查询授权子渠道结果", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/listAuthSubChannel")
JsonResult<List<BrandMerchantAuthSubChannelVO>> listAuthSubChannel(
GetAuthBrandMerchantSubChannelRequest request);
@ApiOperation(value = "支付", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/pay")
JsonResult<PayVO> pay(BrandMerchantPayRequest request);
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/refund")
JsonResult<RefundVO> refund(BrandMerchantRefundRequest request);
}
package com.jiejing.fitness.finance.api.merchant;
import com.jiejing.common.model.JsonResult;
import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.merchant.request.ApplyStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.paycenter.api.pay.vo.PayVO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author chengyubing
* @since 2024/3/5 09:41
*/
@FeignClient(name = "FINANCE", url = "${rpc.url.fit-finance:http://app-fit-finance:7008}", fallbackFactory = StudioMerchantApiFallback.class)
public interface StudioMerchantApi {
String TAG = "金融-场馆商户管理";
@ApiOperation(value = "场馆入驻商户", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/getMerchant")
JsonResult<StudioMerchantVO> getMerchant(GetStudioMerchantRequest request);
@ApiOperation(value = "场馆入驻商户", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/apply")
JsonResult<Void> apply(ApplyStudioMerchantRequest request);
@ApiOperation(value = "查询场馆进件申请记录", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/getApply")
JsonResult<StudioMerchantApplyVO> getApply(GetStudioMerchantApplyRequest request);
@ApiOperation(value = "分页查询场馆进件申请记录", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/pageApply")
JsonResult<PageVO<StudioMerchantApplyVO>> pageApply(PageStudioMerchantApplyRequest request);
@ApiOperation(value = "绑定微信小程序appId", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/bindXcxAppId")
JsonResult<StudioMerchantBindXcxAppIdVO> bindXcxAppId(BindStudioMerchantXcxAppIdRequest request);
@ApiOperation(value = "授权子渠道", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/authSubChannel")
JsonResult<StudioMerchantAuthSubChannelVO> authSubChannel(AuthStudioSubChannelRequest request);
@ApiOperation(value = "查询授权子渠道结果", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/listAuthSubChannel")
JsonResult<List<StudioMerchantAuthSubChannelVO>> listAuthSubChannel(GetAuthStudioSubChannelRequest request);
@ApiOperation(value = "支付", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/pay")
JsonResult<PayVO> pay(StudioMerchantPayRequest request);
}
\ No newline at end of file
...@@ -2,79 +2,72 @@ package com.jiejing.fitness.finance.api.merchant; ...@@ -2,79 +2,72 @@ package com.jiejing.fitness.finance.api.merchant;
import com.jiejing.common.model.JsonResult; import com.jiejing.common.model.JsonResult;
import com.jiejing.common.model.PageVO; import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.merchant.request.ApplyBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.ApplyStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.AuthBrandMerchantSubChannelRequest; import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantXcxAppIdRequest; import com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetAuthBrandMerchantSubChannelRequest; import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantRequest; import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageBrandMerchantApplyRequest; import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest; import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* @author chengyubing * @author chengyubing
* @since 2024/2/22 11:49 * @since 2024/3/5 09:41
*/ */
@Component @Component
public class BrandMerchantApiFallback implements FallbackFactory<BrandMerchantApi> { public class StudioMerchantApiFallback implements FallbackFactory<StudioMerchantApi> {
@Override @Override
public BrandMerchantApi create(Throwable throwable) { public StudioMerchantApi create(Throwable throwable) {
return new BrandMerchantApi() { return new StudioMerchantApi() {
@Override @Override
public JsonResult<Void> apply(ApplyBrandMerchantRequest request) { public JsonResult<StudioMerchantVO> getMerchant(GetStudioMerchantRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<BrandMerchantVO> get(GetBrandMerchantRequest request) { public JsonResult<Void> apply(ApplyStudioMerchantRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<BrandMerchantApplyVO> getApply(GetBrandMerchantApplyRequest request) { public JsonResult<StudioMerchantApplyVO> getApply(GetStudioMerchantApplyRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<PageVO<BrandMerchantApplyVO>> pageApply(PageBrandMerchantApplyRequest request) { public JsonResult<PageVO<StudioMerchantApplyVO>> pageApply(PageStudioMerchantApplyRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<BrandMerchantBindXcxAppIdVO> bindXcxAppId(BindBrandMerchantXcxAppIdRequest request) { public JsonResult<StudioMerchantBindXcxAppIdVO> bindXcxAppId(
BindStudioMerchantXcxAppIdRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<BrandMerchantAuthSubChannelVO> authSubChannel( public JsonResult<StudioMerchantAuthSubChannelVO> authSubChannel(AuthStudioSubChannelRequest request) {
AuthBrandMerchantSubChannelRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<List<BrandMerchantAuthSubChannelVO>> listAuthSubChannel( public JsonResult<List<StudioMerchantAuthSubChannelVO>> listAuthSubChannel(
GetAuthBrandMerchantSubChannelRequest request) { GetAuthStudioSubChannelRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
@Override @Override
public JsonResult<PayVO> pay(BrandMerchantPayRequest request) { public JsonResult<PayVO> pay(StudioMerchantPayRequest request) {
return JsonResult.rpcError();
}
@Override
public JsonResult<RefundVO> refund(BrandMerchantRefundRequest request) {
return JsonResult.rpcError(); return JsonResult.rpcError();
} }
}; };
......
...@@ -26,8 +26,8 @@ import lombok.NoArgsConstructor; ...@@ -26,8 +26,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "申请品牌商户请求信息") @ApiModel(description = "申请场馆商户请求信息")
public class ApplyBrandMerchantRequest { public class ApplyStudioMerchantRequest {
@ApiModelProperty(value = "场馆ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空") @NotNull(message = "场馆ID不能为空")
......
...@@ -18,12 +18,12 @@ import lombok.NoArgsConstructor; ...@@ -18,12 +18,12 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户授权子渠道") @ApiModel(description = "场馆商户授权子渠道")
public class AuthBrandMerchantSubChannelRequest { public class AuthStudioSubChannelRequest {
@ApiModelProperty(value = "品牌ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "品牌ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long brandId; private Long studioId;
@ApiModelProperty(value = "子渠道", required = true) @ApiModelProperty(value = "子渠道", required = true)
@NotNull(message = "子渠道不能为空") @NotNull(message = "子渠道不能为空")
......
...@@ -16,12 +16,12 @@ import lombok.NoArgsConstructor; ...@@ -16,12 +16,12 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户绑定小程序appId") @ApiModel(description = "场馆商户绑定小程序appId")
public class BindBrandMerchantXcxAppIdRequest { public class BindStudioMerchantXcxAppIdRequest {
@ApiModelProperty(value = "品牌ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "品牌ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long brandId; private Long studioId;
@ApiModelProperty(value = "小程序appId", required = true) @ApiModelProperty(value = "小程序appId", required = true)
@NotNull(message = "小程序appId不能为空") @NotNull(message = "小程序appId不能为空")
......
package com.jiejing.fitness.finance.api.merchant.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author chengyubing
* @since 2024/2/27 10:54
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "品牌商户退款Request")
public class BrandMerchantRefundRequest {
@ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空")
private Long studioId;
@ApiModelProperty(name = "支付总金额(元)", required = true)
@NotNull(message = "支付总金额不能为空")
private BigDecimal transAmount;
@ApiModelProperty(name = "上层业务退款单号", required = true)
@NotBlank(message = "上层业务退款单号不能为空")
private String orderNo;
@ApiModelProperty(name = "退款请求对应的支付流水号", required = true)
@NotBlank(message = "退款请求对应的支付流水号不能为空")
private String payTransNo;
@ApiModelProperty(name = "退款原因", required = true)
@NotBlank(message = "退款原因不能为空")
private String refundReason;
}
...@@ -16,11 +16,11 @@ import lombok.NoArgsConstructor; ...@@ -16,11 +16,11 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户查看授权子渠道结果") @ApiModel(description = "场馆商户查看授权子渠道结果")
public class GetAuthBrandMerchantSubChannelRequest { public class GetAuthStudioSubChannelRequest {
@ApiModelProperty(value = "品牌ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "品牌ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long brandId; private Long studioId;
} }
...@@ -18,8 +18,8 @@ import lombok.NoArgsConstructor; ...@@ -18,8 +18,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "申请品牌商户记录请求信息") @ApiModel(description = "申请场馆商户记录请求信息")
public class GetBrandMerchantApplyRequest { public class GetStudioMerchantApplyRequest {
@ApiModelProperty(value = "申请ID", required = true) @ApiModelProperty(value = "申请ID", required = true)
@NotNull(message = "申请ID不能为空") @NotNull(message = "申请ID不能为空")
......
...@@ -18,11 +18,11 @@ import lombok.NoArgsConstructor; ...@@ -18,11 +18,11 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "申请品牌商户请求信息") @ApiModel(description = "申请场馆商户请求信息")
public class GetBrandMerchantRequest { public class GetStudioMerchantRequest {
@ApiModelProperty(value = "品牌ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "品牌ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long brandId; private Long studioId;
} }
...@@ -19,8 +19,8 @@ import lombok.NoArgsConstructor; ...@@ -19,8 +19,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "分页查询申请品牌商户请求信息Request") @ApiModel(description = "分页查询申请场馆商户请求信息Request")
public class PageBrandMerchantApplyRequest { public class PageStudioMerchantApplyRequest {
@ApiModelProperty(value = "商户简称") @ApiModelProperty(value = "商户简称")
private String shortName; private String shortName;
......
...@@ -21,12 +21,12 @@ import lombok.NoArgsConstructor; ...@@ -21,12 +21,12 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(description = "品牌商户支付Request") @ApiModel(description = "场馆商户支付Request")
public class BrandMerchantPayRequest { public class StudioMerchantPayRequest {
@ApiModelProperty(value = "品牌ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "品牌ID不能为空") @NotNull(message = "场馆ID不能为空")
private Long brandId; private Long studioId;
@ApiModelProperty(name = "支付总金额(元)", required = true) @ApiModelProperty(name = "支付总金额(元)", required = true)
@NotNull(message = "支付总金额不能为空") @NotNull(message = "支付总金额不能为空")
......
...@@ -23,8 +23,8 @@ import lombok.NoArgsConstructor; ...@@ -23,8 +23,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户申请VO") @ApiModel(description = "场馆商户申请VO")
public class BrandMerchantApplyVO { public class StudioMerchantApplyVO {
@ApiModelProperty("ID") @ApiModelProperty("ID")
private Long id; private Long id;
......
package com.jiejing.fitness.finance.api.merchant.vo; package com.jiejing.fitness.finance.api.merchant.vo;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums; import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.AuthPhaseEnums;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -17,8 +16,8 @@ import lombok.NoArgsConstructor; ...@@ -17,8 +16,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户认证子渠道VO") @ApiModel(description = "场馆商户认证子渠道VO")
public class BrandMerchantAuthSubChannelVO { public class StudioMerchantAuthSubChannelVO {
@ApiModelProperty(value = "申请单") @ApiModelProperty(value = "申请单")
private String applyNo; private String applyNo;
......
...@@ -16,8 +16,8 @@ import lombok.NoArgsConstructor; ...@@ -16,8 +16,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌商户绑定小程序AppIdVO") @ApiModel(description = "场馆商户绑定小程序AppIdVO")
public class BrandMerchantBindXcxAppIdVO { public class StudioMerchantBindXcxAppIdVO {
/** /**
* @see OpenStateEnums * @see OpenStateEnums
......
package com.jiejing.fitness.finance.api.merchant.vo; package com.jiejing.fitness.finance.api.merchant.vo;
import com.jiejing.fitness.finance.api.merchant.request.model.BrandBankCardInfo;
import com.jiejing.fitness.finance.api.merchant.request.model.BrandLegalInfo;
import com.jiejing.fitness.finance.api.merchant.request.model.BrandLicenseInfo;
import com.jiejing.fitness.finance.api.merchant.request.model.BrandResourceInfo;
import com.jiejing.paycenter.api.merchant.vo.SubChannelConfigVO; import com.jiejing.paycenter.api.merchant.vo.SubChannelConfigVO;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums; import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums; import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums;
...@@ -23,11 +19,11 @@ import lombok.NoArgsConstructor; ...@@ -23,11 +19,11 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "品牌当前绑定的商户信息VO") @ApiModel(description = "场馆当前绑定的商户信息VO")
public class BrandMerchantVO { public class StudioMerchantVO {
@ApiModelProperty("品牌ID") @ApiModelProperty("场馆ID")
private Long brandId; private Long studioId;
@ApiModelProperty("渠道号") @ApiModelProperty("渠道号")
private String channelNo; private String channelNo;
......
package com.jiejing.fitness.finance.app.controller.merchant;
import com.jiejing.common.model.JsonResult;
import com.jiejing.common.model.PageVO;
import com.jiejing.common.utils.convert.BeanUtil;
import com.jiejing.fitness.finance.api.merchant.BrandMerchantApi;
import com.jiejing.fitness.finance.api.merchant.request.ApplyBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.AuthBrandMerchantSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.BindBrandMerchantXcxAppIdRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetAuthBrandMerchantSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetBrandMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageBrandMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.request.BrandMerchantRefundRequest;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageBrandMerchantApplyParams;
import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* @author chengyubing
* @since 2024/2/22 11:53
*/
@RestController
public class BrandMerchantController implements BrandMerchantApi {
@Resource
private BrandMerchantService brandMerchantService;
@Resource
private PayService payService;
@ApiOperation(value = "品牌入驻商户", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/apply")
@Override
public JsonResult<Void> apply(@RequestBody @Valid ApplyBrandMerchantRequest request) {
ApplyBrandMerchantParams params = BeanUtil.map(request, ApplyBrandMerchantParams.class);
brandMerchantService.apply(params);
return JsonResult.success();
}
@ApiOperation(value = "查询品牌当前绑定的商户", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/get")
@Override
public JsonResult<BrandMerchantVO> get(@RequestBody @Valid GetBrandMerchantRequest request) {
return JsonResult.success(brandMerchantService.getMerchant(request.getBrandId()));
}
@ApiOperation(value = "查询品牌进件申请记录", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/getApply")
@Override
public JsonResult<BrandMerchantApplyVO> getApply(@RequestBody @Valid GetBrandMerchantApplyRequest request) {
return JsonResult.success(brandMerchantService.getApply(request.getId()));
}
@ApiOperation(value = "分页查询品牌进件申请记录", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/pageApply")
@Override
public JsonResult<PageVO<BrandMerchantApplyVO>> pageApply(
@RequestBody @Valid PageBrandMerchantApplyRequest request) {
PageBrandMerchantApplyParams params = BeanUtil.map(request, PageBrandMerchantApplyParams.class);
return JsonResult.success(brandMerchantService.pageApply(params));
}
@ApiOperation(value = "绑定微信小程序appId", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/bindXcxAppId")
@Override
public JsonResult<BrandMerchantBindXcxAppIdVO> bindXcxAppId(
@RequestBody @Valid BindBrandMerchantXcxAppIdRequest request) {
return JsonResult.success(brandMerchantService.bindXcxAppId(request.getBrandId(), request.getAppId()));
}
@ApiOperation(value = "授权子渠道", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/authSubChannel")
@Override
public JsonResult<BrandMerchantAuthSubChannelVO> authSubChannel(
@RequestBody @Valid AuthBrandMerchantSubChannelRequest request) {
return JsonResult.success(
brandMerchantService.authSubChannel(request.getBrandId(), request.getSubChannel(),
request.getAuthType()));
}
@ApiOperation(value = "查询授权子渠道结果", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/listAuthSubChannel")
@Override
public JsonResult<List<BrandMerchantAuthSubChannelVO>> listAuthSubChannel(
@RequestBody @Valid GetAuthBrandMerchantSubChannelRequest request) {
return JsonResult.success(brandMerchantService.listAuthSubChannel(request.getBrandId()));
}
@ApiOperation(value = "支付", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/pay")
@Override
public JsonResult<PayVO> pay(@RequestBody @Valid BrandMerchantPayRequest request) {
BrandMerchantPayParams params = BeanUtil.map(request, BrandMerchantPayParams.class);
return JsonResult.success(payService.merchantPay(params));
}
@ApiOperation(value = "退款", tags = {TAG})
@PostMapping(value = "/private/brandMerchant/refund")
@Override
public JsonResult<RefundVO> refund(@RequestBody @Valid BrandMerchantRefundRequest request) {
BrandMerchantRefundParams params = BeanUtil.map(request, BrandMerchantRefundParams.class);
return JsonResult.success(payService.merchantRefund(params));
}
}
package com.jiejing.fitness.finance.app.controller.merchant;
import com.jiejing.common.model.JsonResult;
import com.jiejing.common.model.PageVO;
import com.jiejing.common.utils.convert.BeanUtil;
import com.jiejing.fitness.finance.api.merchant.StudioMerchantApi;
import com.jiejing.fitness.finance.api.merchant.request.ApplyStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest;
import com.jiejing.fitness.finance.api.merchant.request.PageStudioMerchantApplyRequest;
import com.jiejing.fitness.finance.api.merchant.request.StudioMerchantPayRequest;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams;
import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.paycenter.api.pay.vo.PayVO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* @author chengyubing
* @since 2024/3/5 09:56
*/
@RestController
public class StudioMerchantController implements StudioMerchantApi {
@Resource
private StudioMerchantService studioMerchantService;
@Resource
private PayService payService;
@ApiOperation(value = "场馆入驻商户", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/getMerchant")
@Override
public JsonResult<StudioMerchantVO> getMerchant(@RequestBody @Valid GetStudioMerchantRequest request) {
return JsonResult.success(studioMerchantService.getMerchant(request.getStudioId()));
}
@ApiOperation(value = "场馆入驻商户", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/apply")
@Override
public JsonResult<Void> apply(@RequestBody @Valid ApplyStudioMerchantRequest request) {
ApplyStudioMerchantParams params = BeanUtil.map(request, ApplyStudioMerchantParams.class);
studioMerchantService.apply(params);
return JsonResult.success();
}
@ApiOperation(value = "查询场馆进件申请记录", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/getApply")
@Override
public JsonResult<StudioMerchantApplyVO> getApply(
@RequestBody @Valid GetStudioMerchantApplyRequest request) {
return JsonResult.success(studioMerchantService.getApply(request.getId()));
}
@ApiOperation(value = "分页查询场馆进件申请记录", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/pageApply")
@Override
public JsonResult<PageVO<StudioMerchantApplyVO>> pageApply(
@RequestBody @Valid PageStudioMerchantApplyRequest request) {
PageStudioMerchantApplyParams params = BeanUtil.map(request, PageStudioMerchantApplyParams.class);
return JsonResult.success(studioMerchantService.pageApply(params));
}
@ApiOperation(value = "绑定微信小程序appId", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/bindXcxAppId")
@Override
public JsonResult<StudioMerchantBindXcxAppIdVO> bindXcxAppId(
@RequestBody @Valid BindStudioMerchantXcxAppIdRequest request) {
return JsonResult.success(studioMerchantService.bindXcxAppId(request.getStudioId(), request.getAppId()));
}
@ApiOperation(value = "授权子渠道", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/authSubChannel")
@Override
public JsonResult<StudioMerchantAuthSubChannelVO> authSubChannel(
@RequestBody @Valid AuthStudioSubChannelRequest request) {
return JsonResult.success(
studioMerchantService.authSubChannel(request.getStudioId(), request.getSubChannel(),
request.getAuthType()));
}
@ApiOperation(value = "查询授权子渠道结果", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/listAuthSubChannel")
@Override
public JsonResult<List<StudioMerchantAuthSubChannelVO>> listAuthSubChannel(
@RequestBody @Valid GetAuthStudioSubChannelRequest request) {
return JsonResult.success(studioMerchantService.listAuthSubChannel(request.getStudioId()));
}
@ApiOperation(value = "支付", tags = {TAG})
@PostMapping(value = "/private/studioMerchant/pay")
@Override
public JsonResult<PayVO> pay(@RequestBody @Valid StudioMerchantPayRequest request) {
StudioMerchantPayParams params = BeanUtil.map(request, StudioMerchantPayParams.class);
return JsonResult.success(payService.merchantPay(params));
}
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
package com.jiejing.fitness.finance.repository.entity; package com.jiejing.fitness.finance.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
...@@ -26,19 +27,19 @@ import lombok.NoArgsConstructor; ...@@ -26,19 +27,19 @@ import lombok.NoArgsConstructor;
/** /**
* <p> * <p>
* 品牌商户关联表(1:1) * 商户关联表
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-04
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Builder(toBuilder = true) @Builder(toBuilder = true)
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class BrandToMerchant implements Serializable { public class PartyToMerchant implements Serializable {
private static final long serialVersionUID = -4973389381018495600L; private static final long serialVersionUID = 128336673584905078L;
/** /**
* 备注: ID 是否允许为null: NO * 备注: ID 是否允许为null: NO
...@@ -47,14 +48,19 @@ public class BrandToMerchant implements Serializable { ...@@ -47,14 +48,19 @@ public class BrandToMerchant implements Serializable {
private Long id; private Long id;
/** /**
* 渠道号 * 备注: 渠道号 是否允许为null: YES
*/ */
private String channelNo; private String channelNo;
/** /**
* 备注: 品牌ID 是否允许为null: YES * 备注: 业务方ID 是否允许为null: YES
*/ */
private Long brandId; private Long partyId;
/**
* 备注: 业务方类型 是否允许为null: YES
*/
private PartyTypeEnums partyType;
/** /**
* 备注: paycenter的商户ID 是否允许为null: YES * 备注: paycenter的商户ID 是否允许为null: YES
...@@ -62,7 +68,7 @@ public class BrandToMerchant implements Serializable { ...@@ -62,7 +68,7 @@ public class BrandToMerchant implements Serializable {
private Long merchantId; private Long merchantId;
/** /**
* 备注: 商户号 是否允许为null: YES * 备注: 商户号(冗余) 是否允许为null: YES
*/ */
private String merchantNo; private String merchantNo;
...@@ -81,7 +87,9 @@ public class BrandToMerchant implements Serializable { ...@@ -81,7 +87,9 @@ public class BrandToMerchant implements Serializable {
public static final String CHANNEL_NO = "channel_no"; public static final String CHANNEL_NO = "channel_no";
public static final String BRAND_ID = "brand_id"; public static final String PARTY_ID = "party_id";
public static final String PARTY_TYPE = "party_type";
public static final String MERCHANT_ID = "merchant_id"; public static final String MERCHANT_ID = "merchant_id";
......
...@@ -29,22 +29,22 @@ import lombok.NoArgsConstructor; ...@@ -29,22 +29,22 @@ import lombok.NoArgsConstructor;
/** /**
* <p> * <p>
* 品牌商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表) * 场馆商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表)
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-05
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Builder(toBuilder = true) @Builder(toBuilder = true)
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class BrandMerchantApply implements Serializable { public class StudioMerchantApply implements Serializable {
private static final long serialVersionUID = -4973389381018495600L; private static final long serialVersionUID = -5392799333879973205L;
/** /**
* ID * 备注: ID 是否允许为null: NO
*/ */
@TableId(value = "id", type = IdType.ID_WORKER) @TableId(value = "id", type = IdType.ID_WORKER)
private Long id; private Long id;
......
...@@ -14,16 +14,16 @@ ...@@ -14,16 +14,16 @@
package com.jiejing.fitness.finance.repository.mapper; package com.jiejing.fitness.finance.repository.mapper;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.mbp.inject.XBaseMapper; import com.jiejing.mbp.inject.XBaseMapper;
/** /**
* <p> * <p>
* 品牌商户关联表(1:1) Mapper 接口 * 商户关联表 Mapper 接口
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-04
*/ */
public interface BrandToMerchantMapper extends XBaseMapper<BrandToMerchant> { public interface PartyToMerchantMapper extends XBaseMapper<PartyToMerchant> {
} }
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
~ 官网: www.xiaomai5.com ~ 官网: www.xiaomai5.com
--> -->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jiejing.fitness.finance.repository.mapper.BrandToMerchantMapper"> <mapper namespace="com.jiejing.fitness.finance.repository.mapper.PartyToMerchantMapper">
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, channel_no, brand_id, merchant_id, merchant_no, create_time, update_time id, channel_no, party_id, party_type, merchant_id, merchant_no, create_time, update_time
</sql> </sql>
</mapper> </mapper>
...@@ -14,19 +14,21 @@ ...@@ -14,19 +14,21 @@
package com.jiejing.fitness.finance.repository.mapper; package com.jiejing.fitness.finance.repository.mapper;
import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.mbp.inject.XBaseMapper; import com.jiejing.mbp.inject.XBaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
* <p> * <p>
* 品牌商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表) Mapper 接口 * 场馆商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表) Mapper 接口
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-05
*/ */
public interface BrandMerchantApplyMapper extends XBaseMapper<BrandMerchantApply> { public interface StudioMerchantApplyMapper extends XBaseMapper<StudioMerchantApply> {
BrandMerchantApply getLatestOneSuccessByBrandId(@Param("brandId") Long brandId); StudioMerchantApply getLatestOneSuccessByMerchantId(@Param("merchantId") Long merchantId);
StudioMerchantApply getLatestOneSuccessByStudioId(@Param("studioId") Long studioId);
} }
...@@ -13,18 +13,28 @@ ...@@ -13,18 +13,28 @@
~ 官网: www.xiaomai5.com ~ 官网: www.xiaomai5.com
--> -->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jiejing.fitness.finance.repository.mapper.BrandMerchantApplyMapper"> <mapper namespace="com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper">
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, brand_id, studio_id, apply_no, apply_type, channel_no, merchant_id, merchant_no, merchant_name, short_name, company_type, open_state, open_fail_message, ali_open_state, ali_auth_state, ali_merchant_no, ali_open_fail_message, wx_offline_open_state, wx_offline_auth_state, wx_offline_merchant_no, wx_offline_open_fail_message, wx_online_open_state, wx_online_auth_state, wx_online_merchant_no, wx_online_open_fail_message, merchant_info, salt, finish_time, create_time, update_time id, brand_id, studio_id, apply_no, apply_type, channel_no, merchant_id, merchant_no, merchant_name, short_name, company_type, open_state, open_fail_message, ali_open_state, ali_auth_state, ali_merchant_no, ali_open_fail_message, wx_offline_open_state, wx_offline_auth_state, wx_offline_merchant_no, wx_offline_open_fail_message, wx_online_open_state, wx_online_auth_state, wx_online_merchant_no, wx_online_open_fail_message, merchant_info, salt, finish_time, create_time, update_time
</sql> </sql>
<select id="getLatestOneSuccessByBrandId" <select id="getLatestOneSuccessByMerchantId"
resultType="com.jiejing.fitness.finance.repository.entity.BrandMerchantApply"> resultType="com.jiejing.fitness.finance.repository.entity.StudioMerchantApply">
select * select *
from brand_merchant_apply from studio_merchant_apply
where brand_id = #{brandId} where merchant_id = #{merchantId}
and open_state = 'S'
order by id desc
limit 1
</select>
<select id="getLatestOneSuccessByStudioId"
resultType="com.jiejing.fitness.finance.repository.entity.StudioMerchantApply">
select *
from studio_merchant_apply
where studio_id = #{studioId}
and open_state = 'S' and open_state = 'S'
order by id desc order by id desc
limit 1 limit 1
......
package com.jiejing.fitness.finance.repository.query;
import com.jiejing.fitness.finance.api.enums.ApplyTypeEnums;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums;
import lombok.Data;
/**
* @author chengyubing
* @since 2024/2/22 18:03
*/
@Data
public class PageStudioMerchantApplyQuery {
/**
* 商户简称
*/
private String shortName;
/**
* 操作类型
*/
private ApplyTypeEnums applyType;
/**
* 场馆ID
*/
private Long studioId;
/**
* 申请类型
*/
private CompanyTypeEnums companyType;
/**
* 商户名称
*/
private String merchantName;
/**
* 申请状态
*/
private OpenStateEnums openState;
/**
* 商户号
*/
private String merchantNo;
/**
* 支付宝商户号
*/
private String aliMerchantNo;
/**
* 微信线上商户号
*/
private String wxOnlineMerchantNo;
/**
* 微信线下商户号
*/
private String wxOfflineMerchantNo;
/**
* 页码:0开始
*/
private Integer current;
/**
* 分页大小
*/
private Integer size;
}
...@@ -15,27 +15,64 @@ ...@@ -15,27 +15,64 @@
package com.jiejing.fitness.finance.repository.service; package com.jiejing.fitness.finance.repository.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.common.utils.collection.CollectionUtil;
import com.jiejing.fitness.finance.repository.mapper.BrandToMerchantMapper; import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.mapper.PartyToMerchantMapper;
import com.jiejing.mbp.MapperRepoService; import com.jiejing.mbp.MapperRepoService;
import java.util.List;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* <p> * <p>
* 品牌商户关联表(1:1) 服务实现类 * 商户关联表 服务实现类
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-04
*/ */
@Service @Service
public class BrandToMerchantRpService extends public class PartyToMerchantRpService extends
MapperRepoService<Long, BrandToMerchant, BrandToMerchantMapper> { MapperRepoService<Long, PartyToMerchant, PartyToMerchantMapper> {
public BrandToMerchant getByBrandId(Long brandId, String channelNo) { public List<PartyToMerchant> listByParty(Long partyId, PartyTypeEnums partyType, String channelNo) {
QueryWrapper<BrandToMerchant> wrapper = new QueryWrapper<>(); QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.eq(BrandToMerchant.BRAND_ID, brandId); wrapper.eq(PartyToMerchant.PARTY_ID, partyId);
wrapper.eq(BrandToMerchant.CHANNEL_NO, channelNo); wrapper.eq(PartyToMerchant.PARTY_TYPE, partyType);
wrapper.eq(PartyToMerchant.CHANNEL_NO, channelNo);
return this.baseMapper.selectList(wrapper);
}
public PartyToMerchant getByStudioId(Long studioId, String channelNo) {
QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.eq(PartyToMerchant.PARTY_ID, studioId);
wrapper.eq(PartyToMerchant.PARTY_TYPE, PartyTypeEnums.STUDIO);
wrapper.eq(PartyToMerchant.CHANNEL_NO, channelNo);
List<PartyToMerchant> list = this.baseMapper.selectList(wrapper);
return CollectionUtil.isEmpty(list) ? null : list.get(0);
}
public PartyToMerchant getOneByPartyAndMerchantId(String channelNo, Long partyId, PartyTypeEnums partyType,
Long merchantId) {
QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.eq(PartyToMerchant.PARTY_ID, partyId);
wrapper.eq(PartyToMerchant.MERCHANT_ID, merchantId);
wrapper.eq(PartyToMerchant.PARTY_TYPE, partyType);
wrapper.eq(PartyToMerchant.CHANNEL_NO, channelNo);
return this.baseMapper.selectOne(wrapper); return this.baseMapper.selectOne(wrapper);
} }
public void deleteByParty(Long partyId, PartyTypeEnums partyType) {
QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.eq(PartyToMerchant.PARTY_ID, partyId);
wrapper.eq(PartyToMerchant.PARTY_TYPE, partyType);
this.baseMapper.delete(wrapper);
}
public void deleteByPartyAndMerchantId(Long partyId, PartyTypeEnums partyType, Long merchantId) {
QueryWrapper<PartyToMerchant> wrapper = new QueryWrapper<>();
wrapper.eq(PartyToMerchant.PARTY_ID, partyId);
wrapper.eq(PartyToMerchant.PARTY_TYPE, partyType);
wrapper.eq(PartyToMerchant.MERCHANT_ID, merchantId);
this.baseMapper.delete(wrapper);
}
} }
...@@ -16,61 +16,69 @@ package com.jiejing.fitness.finance.repository.service; ...@@ -16,61 +16,69 @@ package com.jiejing.fitness.finance.repository.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiejing.common.utils.text.StringUtil; import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.mapper.BrandMerchantApplyMapper; import com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper;
import com.jiejing.fitness.finance.repository.query.PageBrandMerchantApplyQuery; import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
import com.jiejing.mbp.MapperRepoService; import com.jiejing.mbp.MapperRepoService;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
* <p> * <p>
* 品牌商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表) 服务实现类 * 场馆商户申请表(M端以及B端数据回显用,支付以及各状态判断、商户号不使用此表) 服务实现类
* </p> * </p>
* *
* @author chengyubing, created on 2024-02-22 * @author chengyubing, created on 2024-03-05
*/ */
@Service @Service
public class BrandMerchantApplyRpService extends public class StudioMerchantApplyRpService extends
MapperRepoService<Long, BrandMerchantApply, BrandMerchantApplyMapper> { MapperRepoService<Long, StudioMerchantApply, StudioMerchantApplyMapper> {
public BrandMerchantApply getLatestOneSuccessByBrandId(Long brandId) {
return this.baseMapper.getLatestOneSuccessByBrandId(brandId);
}
public Page<BrandMerchantApply> page(PageBrandMerchantApplyQuery params) { public Page<StudioMerchantApply> page(PageStudioMerchantApplyQuery params) {
QueryWrapper<BrandMerchantApply> wrapper = new QueryWrapper<>(); QueryWrapper<StudioMerchantApply> wrapper = new QueryWrapper<>();
if (StringUtil.isNotBlank(params.getShortName())) { if (StringUtil.isNotBlank(params.getShortName())) {
wrapper.like(BrandMerchantApply.SHORT_NAME, params.getShortName()); wrapper.like(StudioMerchantApply.SHORT_NAME, params.getShortName());
} }
if (null != params.getApplyType()) { if (null != params.getApplyType()) {
wrapper.eq(BrandMerchantApply.APPLY_TYPE, params.getApplyType()); wrapper.eq(StudioMerchantApply.APPLY_TYPE, params.getApplyType());
} }
if (null != params.getStudioId()) { if (null != params.getStudioId()) {
wrapper.eq(BrandMerchantApply.STUDIO_ID, params.getStudioId()); wrapper.eq(StudioMerchantApply.STUDIO_ID, params.getStudioId());
} }
if (null != params.getCompanyType()) { if (null != params.getCompanyType()) {
wrapper.eq(BrandMerchantApply.COMPANY_TYPE, params.getCompanyType()); wrapper.eq(StudioMerchantApply.COMPANY_TYPE, params.getCompanyType());
} }
if (StringUtil.isNotBlank(params.getMerchantName())) { if (StringUtil.isNotBlank(params.getMerchantName())) {
wrapper.like(BrandMerchantApply.MERCHANT_NAME, params.getMerchantName()); wrapper.like(StudioMerchantApply.MERCHANT_NAME, params.getMerchantName());
} }
if (null != params.getOpenState()) { if (null != params.getOpenState()) {
wrapper.eq(BrandMerchantApply.OPEN_STATE, params.getOpenState()); wrapper.eq(StudioMerchantApply.OPEN_STATE, params.getOpenState());
} }
if (StringUtil.isNotBlank(params.getMerchantNo())) { if (StringUtil.isNotBlank(params.getMerchantNo())) {
wrapper.eq(BrandMerchantApply.MERCHANT_NO, params.getMerchantNo()); wrapper.eq(StudioMerchantApply.MERCHANT_NO, params.getMerchantNo());
} }
if (StringUtil.isNotBlank(params.getAliMerchantNo())) { if (StringUtil.isNotBlank(params.getAliMerchantNo())) {
wrapper.eq(BrandMerchantApply.ALI_MERCHANT_NO, params.getAliMerchantNo()); wrapper.eq(StudioMerchantApply.ALI_MERCHANT_NO, params.getAliMerchantNo());
} }
if (StringUtil.isNotBlank(params.getWxOnlineMerchantNo())) { if (StringUtil.isNotBlank(params.getWxOnlineMerchantNo())) {
wrapper.eq(BrandMerchantApply.WX_ONLINE_MERCHANT_NO, params.getWxOnlineMerchantNo()); wrapper.eq(StudioMerchantApply.WX_ONLINE_MERCHANT_NO, params.getWxOnlineMerchantNo());
} }
if (StringUtil.isNotBlank(params.getWxOfflineMerchantNo())) { if (StringUtil.isNotBlank(params.getWxOfflineMerchantNo())) {
wrapper.eq(BrandMerchantApply.WX_OFFLINE_MERCHANT_NO, params.getWxOfflineMerchantNo()); wrapper.eq(StudioMerchantApply.WX_OFFLINE_MERCHANT_NO, params.getWxOfflineMerchantNo());
} }
return this.findByWrapperPage(wrapper, params.getCurrent(), params.getSize()); return this.findByWrapperPage(wrapper, params.getCurrent(), params.getSize());
} }
public StudioMerchantApply getLatestOneSuccessByMerchantId(Long merchantId) {
return this.baseMapper.getLatestOneSuccessByMerchantId(merchantId);
}
public StudioMerchantApply getLatestOneSuccessByStudioId(Long studioId) {
QueryWrapper<StudioMerchantApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId);
return this.baseMapper.getLatestOneSuccessByStudioId(studioId);
}
} }
...@@ -52,10 +52,9 @@ public class GeneratorServiceEntity { ...@@ -52,10 +52,9 @@ public class GeneratorServiceEntity {
private String author = "chengyubing"; private String author = "chengyubing";
private String[] tableNames = { private String[] tableNames = {
// "global_config", // "global_config",
// "brand_merchant_apply", // "studio_merchant_apply",
// "brand_to_merchant", // "party_to_merchant",
// "brand_bind_wx_app_id_apply", // "brand_cashier_record"
"brand_cashier_record"
}; };
/** /**
......
...@@ -3,8 +3,8 @@ package com.jiejing.fitness.finance.service.event; ...@@ -3,8 +3,8 @@ package com.jiejing.fitness.finance.service.event;
import static org.springframework.integration.IntegrationMessageHeaderAccessor.DELIVERY_ATTEMPT; import static org.springframework.integration.IntegrationMessageHeaderAccessor.DELIVERY_ATTEMPT;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.jiejing.fitness.finance.api.enums.MerchantTypeEnums; import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.pay.PayService; import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.paycenter.common.event.MerchantEvent; import com.jiejing.paycenter.common.event.MerchantEvent;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
...@@ -28,7 +28,7 @@ public class ListenerService { ...@@ -28,7 +28,7 @@ public class ListenerService {
private static final int MAX_RETRY = 3; private static final int MAX_RETRY = 3;
@Resource @Resource
private BrandMerchantService brandMerchantService; private StudioMerchantService studioMerchantService;
@Resource @Resource
private PayService payService; private PayService payService;
...@@ -42,10 +42,10 @@ public class ListenerService { ...@@ -42,10 +42,10 @@ public class ListenerService {
event.setSubChannels(Optional.ofNullable(event.getSubChannels()).orElse(new ArrayList<>(1))); event.setSubChannels(Optional.ofNullable(event.getSubChannels()).orElse(new ArrayList<>(1)));
event.setSubChannelAuths(Optional.ofNullable(event.getSubChannelAuths()).orElse(new ArrayList<>(1))); event.setSubChannelAuths(Optional.ofNullable(event.getSubChannelAuths()).orElse(new ArrayList<>(1)));
MerchantTypeEnums merchantType = MerchantTypeEnums.getByCode(event.getBizCode()); PartyTypeEnums type = PartyTypeEnums.getByCode(event.getBizCode());
switch (merchantType) { switch (type) {
case BRAND: case STUDIO:
brandMerchantService.callback(event); studioMerchantService.callback(event);
break; break;
default: default:
break; break;
......
package com.jiejing.fitness.finance.service.merchant; package com.jiejing.fitness.finance.service.merchant;
import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageBrandMerchantApplyParams;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.event.MerchantEvent;
import java.util.List;
/** /**
* 品牌商户服务 * 品牌商户服务
* *
...@@ -21,69 +9,19 @@ import java.util.List; ...@@ -21,69 +9,19 @@ import java.util.List;
public interface BrandMerchantService { public interface BrandMerchantService {
/** /**
* 进件申请 * 绑定
*
* @param params 请求参数
*/
void apply(ApplyBrandMerchantParams params);
/**
* 进件申请回调
*
* @param event 事件
*/
void callback(MerchantEvent event);
/**
* 获取品牌当前绑定的商户信息
*
* @param brandId 品牌ID
* @return 商户
*/
BrandMerchantVO getMerchant(Long brandId);
/**
* 获取申请记录详情
*
* @param id ID
* @return 结果
*/
BrandMerchantApplyVO getApply(Long id);
/**
* 分页查询品牌商户申请记录
*
* @param params 请求
* @return 响应
*/
PageVO<BrandMerchantApplyVO> pageApply(PageBrandMerchantApplyParams params);
/**
* 绑定小程序AppId
*
* @param brandId 品牌Id
* @param appId appId
* @return 结果
*/
BrandMerchantBindXcxAppIdVO bindXcxAppId(Long brandId, String appId);
/**
* 授权子渠道
* *
* @param brandId 品牌ID * @param brandId 品牌ID
* @param subChannel 子渠道 * @param merchantId 商户ID
* @param authType 授权类型
* @return 结果
*/ */
BrandMerchantAuthSubChannelVO authSubChannel(Long brandId, SubChannelEnums subChannel, void bind(Long brandId, Long merchantId);
SubChannelAuthTypeEnums authType);
/** /**
* 查询授权子渠道结果 * 解绑
* *
* @param brandId 品牌ID * @param brandId 品牌ID
* @return 结果 * @param merchantId 商户ID
*/ */
List<BrandMerchantAuthSubChannelVO> listAuthSubChannel(Long brandId); void unbind(Long brandId, Long merchantId);
} }
package com.jiejing.fitness.finance.service.merchant;
import com.jiejing.common.model.PageVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.event.MerchantEvent;
import java.util.List;
/**
* @author chengyubing
* @since 2024/3/5 09:58
*/
public interface StudioMerchantService {
/**
* 进件申请
*
* @param params 请求参数
*/
void apply(ApplyStudioMerchantParams params);
/**
* 绑定
*
* @param studioId 场馆ID
* @param merchantId 商户ID
*/
void bind(Long studioId, Long merchantId);
/**
* 解绑
*
* @param studioId 场馆ID
* @param merchantId 商户ID
*/
void unbind(Long studioId, Long merchantId);
/**
* 解绑所有
*
* @param studioId 场馆ID
*/
void unbindAll(Long studioId);
/**
* 进件申请回调
*
* @param event 事件
*/
void callback(MerchantEvent event);
/**
* 获取场馆当前绑定的商户信息
*
* @param studioId 场馆ID
* @return 商户
*/
StudioMerchantVO getMerchant(Long studioId);
/**
* 获取申请记录详情
*
* @param id ID
* @return 结果
*/
StudioMerchantApplyVO getApply(Long id);
/**
* 分页查询场馆商户申请记录
*
* @param params 请求
* @return 响应
*/
PageVO<StudioMerchantApplyVO> pageApply(PageStudioMerchantApplyParams params);
/**
* 绑定小程序AppId
*
* @param studioId 场馆ID
* @param appId appId
* @return 结果
*/
StudioMerchantBindXcxAppIdVO bindXcxAppId(Long studioId, String appId);
/**
* 授权子渠道
*
* @param studioId 场馆ID
* @param subChannel 子渠道
* @param authType 授权类型
* @return 结果
*/
StudioMerchantAuthSubChannelVO authSubChannel(Long studioId, SubChannelEnums subChannel,
SubChannelAuthTypeEnums authType);
/**
* 查询授权子渠道结果
*
* @param studioId 场馆ID
* @return 结果
*/
List<StudioMerchantAuthSubChannelVO> listAuthSubChannel(Long studioId);
}
...@@ -3,22 +3,23 @@ package com.jiejing.fitness.finance.service.merchant.convert; ...@@ -3,22 +3,23 @@ package com.jiejing.fitness.finance.service.merchant.convert;
import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*; import static com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums.*;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jiejing.common.utils.convert.BeanUtil; import com.jiejing.common.utils.convert.BeanUtil;
import com.jiejing.common.utils.crypt.AesUtil; import com.jiejing.common.utils.crypt.AesUtil;
import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO; import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO;
import com.jiejing.fitness.finance.api.enums.ApplyTypeEnums; import com.jiejing.fitness.finance.api.enums.ApplyTypeEnums;
import com.jiejing.fitness.finance.api.enums.MerchantTypeEnums; import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.api.merchant.request.model.AddressInfo; import com.jiejing.fitness.finance.api.merchant.request.model.AddressInfo;
import com.jiejing.fitness.finance.api.merchant.request.model.BrandResourceInfo; import com.jiejing.fitness.finance.api.merchant.request.model.BrandResourceInfo;
import com.jiejing.fitness.finance.api.merchant.vo.BrandBankCardVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandBankCardVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandLegalVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandLegalVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandLicenseVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandLicenseVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandResourceVO; import com.jiejing.fitness.finance.api.merchant.vo.BrandResourceVO;
import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.utils.JsonUtil; import com.jiejing.fitness.finance.service.utils.JsonUtil;
import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest; import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest;
import com.jiejing.paycenter.api.merchant.request.UploadRequest; import com.jiejing.paycenter.api.merchant.request.UploadRequest;
...@@ -59,10 +60,10 @@ import java.util.stream.Collectors; ...@@ -59,10 +60,10 @@ import java.util.stream.Collectors;
public class MerchantConvert { public class MerchantConvert {
public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo, public static ApplyMerchantRequest convertRequest(String channelNo, String applyNo,
ApplyBrandMerchantParams params, Map<ResourceTypeEnums, ResourceInfo> resourceMap, ApplyStudioMerchantParams params, Map<ResourceTypeEnums, ResourceInfo> resourceMap,
ApplyMerchantRequest subChannelInfo) { ApplyMerchantRequest subChannelInfo) {
return ApplyMerchantRequest.builder() return ApplyMerchantRequest.builder()
.bizCode(MerchantTypeEnums.BRAND.getCode()) .bizCode(PartyTypeEnums.STUDIO.getCode())
.applyNo(applyNo) .applyNo(applyNo)
.channelNo(channelNo) .channelNo(channelNo)
.companyType(params.getCompanyType()) .companyType(params.getCompanyType())
...@@ -80,7 +81,7 @@ public class MerchantConvert { ...@@ -80,7 +81,7 @@ public class MerchantConvert {
} }
private static Contact convertContact(ApplyBrandMerchantParams params) { private static Contact convertContact(ApplyStudioMerchantParams params) {
return Contact.builder() return Contact.builder()
.contactName(params.getLegal().getLegalName()) .contactName(params.getLegal().getLegalName())
.contactPhone(params.getLegal().getLegalPhone()) .contactPhone(params.getLegal().getLegalPhone())
...@@ -89,7 +90,7 @@ public class MerchantConvert { ...@@ -89,7 +90,7 @@ public class MerchantConvert {
.build(); .build();
} }
private static BusinessInfo convertBusiness(ApplyBrandMerchantParams params) { private static BusinessInfo convertBusiness(ApplyStudioMerchantParams params) {
AddressInfo address = params.getLicense().getLicenseAddress(); AddressInfo address = params.getLicense().getLicenseAddress();
return BusinessInfo.builder() return BusinessInfo.builder()
.mcc(MccEnums.MCC_7941) .mcc(MccEnums.MCC_7941)
...@@ -104,7 +105,7 @@ public class MerchantConvert { ...@@ -104,7 +105,7 @@ public class MerchantConvert {
.build(); .build();
} }
private static License convertLicense(ApplyBrandMerchantParams params) { private static License convertLicense(ApplyStudioMerchantParams params) {
AddressInfo address = params.getLicense().getLicenseAddress(); AddressInfo address = params.getLicense().getLicenseAddress();
return License.builder() return License.builder()
.licenseType(LicenseTypeEnums.NATIONAL_LEGAL_MERGE) .licenseType(LicenseTypeEnums.NATIONAL_LEGAL_MERGE)
...@@ -124,7 +125,7 @@ public class MerchantConvert { ...@@ -124,7 +125,7 @@ public class MerchantConvert {
.build(); .build();
} }
private static BankCard convertBankCard(ApplyBrandMerchantParams params) { private static BankCard convertBankCard(ApplyStudioMerchantParams params) {
AddressInfo address = params.getBankCard().getCardAddress(); AddressInfo address = params.getBankCard().getCardAddress();
return BankCard.builder() return BankCard.builder()
.cardType(params.getBankCard().getCardType()) .cardType(params.getBankCard().getCardType())
...@@ -150,7 +151,7 @@ public class MerchantConvert { ...@@ -150,7 +151,7 @@ public class MerchantConvert {
.build(); .build();
} }
private static Legal convertLegal(ApplyBrandMerchantParams params) { private static Legal convertLegal(ApplyStudioMerchantParams params) {
AddressInfo address = params.getLegal().getLegalAddress(); AddressInfo address = params.getLegal().getLegalAddress();
return Legal.builder() return Legal.builder()
.legalName(params.getLegal().getLegalName()) .legalName(params.getLegal().getLegalName())
...@@ -169,11 +170,11 @@ public class MerchantConvert { ...@@ -169,11 +170,11 @@ public class MerchantConvert {
.build(); .build();
} }
public static BrandMerchantApply convertApply(Long id, ApplyBrandMerchantParams params, StudioVO studio, public static StudioMerchantApply convertApply(Long id, ApplyStudioMerchantParams params, StudioVO studio,
BrandMerchantApply exist, String channel) { StudioMerchantApply exist, String channel) {
String salt = AesUtil.getSalt(8); String salt = AesUtil.getSalt(8);
ApplyBrandMerchantParams encrypt = params.encrypt(salt); ApplyStudioMerchantParams encrypt = params.encrypt(salt);
return BrandMerchantApply.builder() return StudioMerchantApply.builder()
.id(id) .id(id)
.applyNo(Long.toString(id)) .applyNo(Long.toString(id))
.brandId(studio.getBrandId()) .brandId(studio.getBrandId())
...@@ -191,8 +192,8 @@ public class MerchantConvert { ...@@ -191,8 +192,8 @@ public class MerchantConvert {
.build(); .build();
} }
private static String convertMerchantInfo(ApplyBrandMerchantParams encrypt) { private static String convertMerchantInfo(ApplyStudioMerchantParams encrypt) {
return JSON.toJSONString(ApplyBrandMerchantParams.builder() return JSON.toJSONString(ApplyStudioMerchantParams.builder()
.legal(encrypt.getLegal()) .legal(encrypt.getLegal())
.license(encrypt.getLicense()) .license(encrypt.getLicense())
.bankCard(encrypt.getBankCard()) .bankCard(encrypt.getBankCard())
...@@ -211,7 +212,7 @@ public class MerchantConvert { ...@@ -211,7 +212,7 @@ public class MerchantConvert {
.build(); .build();
} }
public static BrandMerchantApply convertApply(BrandMerchantApply apply, MerchantEvent event, public static StudioMerchantApply convertApply(StudioMerchantApply apply, MerchantEvent event,
List<SubChannelInfo> defaultSubChannels) { List<SubChannelInfo> defaultSubChannels) {
// 品牌商户规则:微信线下公众号、微信线下小程序、支付宝线下通道全部开通成功才算成功 // 品牌商户规则:微信线下公众号、微信线下小程序、支付宝线下通道全部开通成功才算成功
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(event.getSubChannels(), Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(event.getSubChannels(),
...@@ -222,7 +223,7 @@ public class MerchantConvert { ...@@ -222,7 +223,7 @@ public class MerchantConvert {
SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE); SubChannelInfo wxGzhOffline = channelMap.get(SubChannelOpenTypeEnums.WX_GZH_OFFLINE);
OpenStateEnums wxOfflineState = convertWxOfflineState(channelMap); OpenStateEnums wxOfflineState = convertWxOfflineState(channelMap);
String wxOfflineFailMessage = convertWxOfflineFailMessage(channelMap); String wxOfflineFailMessage = convertWxOfflineFailMessage(channelMap);
return BrandMerchantApply.builder() return StudioMerchantApply.builder()
.id(apply.getId()) .id(apply.getId())
.brandId(apply.getBrandId()) .brandId(apply.getBrandId())
.studioId(apply.getStudioId()) .studioId(apply.getStudioId())
...@@ -379,14 +380,6 @@ public class MerchantConvert { ...@@ -379,14 +380,6 @@ public class MerchantConvert {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public static BrandToMerchant convertMerchant(BrandMerchantApply apply) {
BrandToMerchant merchant = BeanUtil.map(apply, BrandToMerchant.class);
merchant.setId(apply.getBrandId());
merchant.setCreateTime(new Date());
merchant.setUpdateTime(new Date());
return merchant;
}
public static Map<ResourceTypeEnums, ResourceInfo> convertResourceMap(BrandResourceInfo resource) { public static Map<ResourceTypeEnums, ResourceInfo> convertResourceMap(BrandResourceInfo resource) {
Map<ResourceTypeEnums, ResourceInfo> map = new HashMap<>(1); Map<ResourceTypeEnums, ResourceInfo> map = new HashMap<>(1);
if (null != resource.getLicensePicId()) { if (null != resource.getLicensePicId()) {
...@@ -426,7 +419,7 @@ public class MerchantConvert { ...@@ -426,7 +419,7 @@ public class MerchantConvert {
return ResourceInfo.builder().resourceId(id).type(type).build(); return ResourceInfo.builder().resourceId(id).type(type).build();
} }
public static BrandMerchantVO convertBrandMerchant(BrandToMerchant relation, MerchantVO merchant, public static StudioMerchantVO convertStuidoMerchant(PartyToMerchant relation, MerchantVO merchant,
List<SubChannelInfo> defaultSubChannels) { List<SubChannelInfo> defaultSubChannels) {
Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap( Map<SubChannelOpenTypeEnums, SubChannelInfo> channelMap = convertSubChannelMap(
JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), defaultSubChannels); JsonUtil.convertList(merchant.getSubChannels(), SubChannelInfo.class), defaultSubChannels);
...@@ -438,8 +431,8 @@ public class MerchantConvert { ...@@ -438,8 +431,8 @@ public class MerchantConvert {
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class)); JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState( OpenStateEnums wxOfflineAuthState = convertWxOfflineAuthState(
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class)); JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
return BrandMerchantVO.builder() return StudioMerchantVO.builder()
.brandId(relation.getBrandId()) .studioId(relation.getPartyId())
.channelNo(merchant.getChannelNo()) .channelNo(merchant.getChannelNo())
.merchantId(merchant.getId()) .merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo()) .merchantNo(merchant.getMerchantNo())
...@@ -462,10 +455,10 @@ public class MerchantConvert { ...@@ -462,10 +455,10 @@ public class MerchantConvert {
.build(); .build();
} }
public static BrandMerchantApplyVO convertApply(BrandMerchantApply apply) { public static StudioMerchantApplyVO convertApply(StudioMerchantApply apply) {
ApplyBrandMerchantParams info = JSON.parseObject(apply.getMerchantInfo(), ApplyStudioMerchantParams info = JSON.parseObject(apply.getMerchantInfo(),
ApplyBrandMerchantParams.class).decrypt(apply.getSalt()); ApplyStudioMerchantParams.class).decrypt(apply.getSalt());
BrandMerchantApplyVO vo = BeanUtil.map(apply, BrandMerchantApplyVO.class); StudioMerchantApplyVO vo = BeanUtil.map(apply, StudioMerchantApplyVO.class);
vo.setLegal(info.getLegal()); vo.setLegal(info.getLegal());
vo.setResource(info.getResource()); vo.setResource(info.getResource());
vo.setLicense(info.getLicense()); vo.setLicense(info.getLicense());
...@@ -473,7 +466,7 @@ public class MerchantConvert { ...@@ -473,7 +466,7 @@ public class MerchantConvert {
return vo; return vo;
} }
public static List<BrandMerchantApplyVO> convertApplyList(List<BrandMerchantApply> applies) { public static List<StudioMerchantApplyVO> convertApplyList(List<StudioMerchantApply> applies) {
return Optional.ofNullable(applies) return Optional.ofNullable(applies)
.orElse(new ArrayList<>()) .orElse(new ArrayList<>())
.stream() .stream()
...@@ -481,4 +474,27 @@ public class MerchantConvert { ...@@ -481,4 +474,27 @@ public class MerchantConvert {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public static PartyToMerchant convertPartyToMerchant(String channelNo, Long partyId, PartyTypeEnums type,
Long merchantId, String merchantNo) {
PartyToMerchant merchant = new PartyToMerchant();
merchant.setId(IdWorker.getId());
merchant.setChannelNo(channelNo);
merchant.setMerchantId(merchantId);
merchant.setMerchantNo(merchantNo);
merchant.setPartyId(partyId);
merchant.setPartyType(type);
merchant.setCreateTime(new Date());
merchant.setUpdateTime(new Date());
return merchant;
}
public static PartyToMerchant convertPartyToMerchant(Long id, Long merchantId, String merchantNo) {
PartyToMerchant merchant = new PartyToMerchant();
merchant.setId(id);
merchant.setMerchantId(merchantId);
merchant.setMerchantNo(merchantNo);
merchant.setUpdateTime(new Date());
return merchant;
}
} }
package com.jiejing.fitness.finance.service.merchant.impl; package com.jiejing.fitness.finance.service.merchant.impl;
import com.alibaba.fastjson.JSON; import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.common.exception.BizException; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.common.model.PageVO; import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.common.utils.convert.BeanUtil; import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO;
import com.jiejing.fitness.finance.repository.entity.BrandMerchantApply;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.query.PageBrandMerchantApplyQuery;
import com.jiejing.fitness.finance.repository.service.BrandMerchantApplyRpService;
import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert; import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageBrandMerchantApplyParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.ResourceRpcService;
import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest;
import com.jiejing.paycenter.api.merchant.vo.AuthSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.ConfigSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import com.jiejing.paycenter.api.merchant.vo.SubChannelAuthVO;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.event.MerchantEvent;
import com.jiejing.paycenter.common.model.ResourceInfo;
import com.jiejing.paycenter.common.model.SubChannelAuthInfo;
import com.jiejing.studio.api.studio.vo.StudioVO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 品牌商户服务 * 品牌商户服务
...@@ -68,188 +26,28 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -68,188 +26,28 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
private String channel; private String channel;
@Resource @Resource
private StudioRpcService studioRpcService; private StudioMerchantApplyRpService studioMerchantApplyRpService;
@Resource @Resource
private MerchantRpcService merchantRpcService; private PartyToMerchantRpService partyToMerchantRpService;
@Resource
private ResourceRpcService resourceRpcService;
@Resource
private BrandMerchantApplyRpService brandMerchantApplyRpService;
@Resource
private BrandToMerchantRpService brandToMerchantRpService;
@Resource
private GlobalConfigRpService globalConfigRpService;
@Async(value = "financeThreadPool")
@Override @Override
public void apply(ApplyBrandMerchantParams params) { public void bind(Long brandId, Long merchantId) {
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId,
Long id = IdWorker.getId(); PartyTypeEnums.BRAND, merchantId);
StudioVO studio = studioRpcService.getStudio(params.getStudioId()); if (null != exist) {
BrandMerchantApply exist = brandMerchantApplyRpService.getLatestOneSuccessByBrandId(studio.getBrandId());
BrandMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel);
brandMerchantApplyRpService.insert(apply);
try {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params);
ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params,
resourceMap, getDefaultBrandSubChannelInfo());
merchantRpcService.apply(request);
} catch (Exception e) {
log.error("apply brand merchant fail {}, brand id = {}, studio id = {}", id, studio.getBrandId(),
params.getStudioId(), e);
this.doOpenMerchantFail(id, e.getMessage());
return; return;
} }
this.doOpenMerchantProcess(id); StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId);
partyToMerchantRpService.insert(
} MerchantConvert.convertPartyToMerchant(apply.getChannelNo(), brandId, PartyTypeEnums.BRAND,
apply.getMerchantId(), apply.getMerchantNo()));
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override
public void callback(MerchantEvent event) {
switch (event.getState()) {
case PROCESS:
this.doOpenMerchantProcess(Long.parseLong(event.getApplyNo()));
break;
case FAIL:
this.doOpenMerchantFail(Long.parseLong(event.getApplyNo()), event.getFailMessage());
break;
case SUCCESS:
this.doOpenMerchantSuccess(event);
break;
default:
break;
}
}
@Override
public BrandMerchantVO getMerchant(Long brandId) {
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(brandId, channel);
if (null == relation) {
return null;
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
return MerchantConvert.convertBrandMerchant(relation, merchant,
getDefaultBrandSubChannelInfo().getSubChannels());
}
@Override
public BrandMerchantApplyVO getApply(Long id) {
BrandMerchantApply apply = brandMerchantApplyRpService.getById(id)
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return MerchantConvert.convertApply(apply);
}
@Override
public PageVO<BrandMerchantApplyVO> pageApply(PageBrandMerchantApplyParams params) {
Page<BrandMerchantApply> page = brandMerchantApplyRpService.page(BeanUtil.map(params,
PageBrandMerchantApplyQuery.class));
return PageVO.convert(page, MerchantConvert.convertApplyList(page.getContent()));
} }
@Override @Override
public BrandMerchantBindXcxAppIdVO bindXcxAppId(Long brandId, String appId) { public void unbind(Long brandId, Long merchantId) {
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(brandId, channel); partyToMerchantRpService.deleteByPartyAndMerchantId(brandId, PartyTypeEnums.BRAND, merchantId);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(channel, IdWorker.getIdStr(),
relation.getMerchantId(), appId);
return BrandMerchantBindXcxAppIdVO.builder().state(vo.getState()).failMessage(vo.getFailMessage())
.build();
}
@Override
public BrandMerchantAuthSubChannelVO authSubChannel(Long brandId, SubChannelEnums subChannel,
SubChannelAuthTypeEnums authType) {
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(brandId, channel);
AuthSubChannelVO vo = merchantRpcService.authSubChannel(channel, relation.getMerchantId(), subChannel,
authType);
return BeanUtil.map(vo, BrandMerchantAuthSubChannelVO.class);
}
@Override
public List<BrandMerchantAuthSubChannelVO> listAuthSubChannel(Long brandId) {
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(brandId, channel);
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
List<SubChannelAuthVO> auths = merchant.getSubChannelAuths();
return Optional.ofNullable(auths).orElse(new ArrayList<>(1)).stream()
.map(e -> BeanUtil.map(e, BrandMerchantAuthSubChannelVO.class)).collect(Collectors.toList());
}
private void doOpenMerchantSuccess(MerchantEvent event) {
BrandMerchantApply apply = brandMerchantApplyRpService.getByIdForUpdate(
Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
BrandMerchantApply applyToModify = MerchantConvert.convertApply(apply, event,
getDefaultBrandSubChannelInfo().getSubChannels());
if (OpenStateEnums.SUCCESS == applyToModify.getOpenState()) {
// 所有子通道全部开通成功
BrandToMerchant exist = brandToMerchantRpService.getByBrandId(apply.getBrandId(), channel);
if (null == exist) {
brandToMerchantRpService.insert(MerchantConvert.convertMerchant(apply));
} else {
brandToMerchantRpService.updateById(MerchantConvert.convertMerchant(apply));
}
}
brandMerchantApplyRpService.updateById(applyToModify);
}
private Map<ResourceTypeEnums, ResourceInfo> upload(ApplyBrandMerchantParams params) {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = MerchantConvert.convertResourceMap(
params.getResource());
Map<Long, ResourceInfoVO> resourceIdUrlMap = resourceRpcService.getResourceMap(params.getStudioId(),
getResourceIds(resourceMap));
resourceMap.keySet().forEach(type -> {
ResourceInfo info = resourceMap.get(type);
ResourceInfoVO vo = resourceIdUrlMap.get(info.getResourceId());
String thirdId = merchantRpcService.upload(MerchantConvert.convertUploadRequest(channel, type, vo));
info.setThirdId(thirdId);
});
return resourceMap;
}
private List<Long> getResourceIds(Map<ResourceTypeEnums, ResourceInfo> resourceMap) {
return resourceMap.values().stream()
.map(ResourceInfo::getResourceId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
}
private void doOpenMerchantFail(Long id, String failMessage) {
brandMerchantApplyRpService.updateById(
BrandMerchantApply.builder().id(id).openState(OpenStateEnums.FAIL)
.openFailMessage(failMessage).build());
}
private void doOpenMerchantProcess(Long id) {
brandMerchantApplyRpService.updateById(
BrandMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build());
}
private ApplyMerchantRequest getDefaultBrandSubChannelInfo() {
GlobalConfig config = globalConfigRpService.getById(
GlobalConfigEnums.BRAND_MERCHANT_SUB_CHANNELS.getCode())
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return JSON.parseObject(config.getConfigValue(), ApplyMerchantRequest.class);
} }
} }
package com.jiejing.fitness.finance.service.merchant.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jiejing.common.exception.BizException;
import com.jiejing.common.model.PageVO;
import com.jiejing.common.utils.collection.CollectionUtil;
import com.jiejing.common.utils.convert.BeanUtil;
import com.jiejing.filecenter.api.resource.vo.ResourceInfoVO;
import com.jiejing.fitness.finance.api.enums.PartyTypeEnums;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantApplyVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantAuthSubChannelVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantBindXcxAppIdVO;
import com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO;
import com.jiejing.fitness.finance.repository.entity.GlobalConfig;
import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
import com.jiejing.fitness.finance.repository.service.GlobalConfigRpService;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
import com.jiejing.fitness.finance.service.merchant.params.ApplyStudioMerchantParams;
import com.jiejing.fitness.finance.service.merchant.params.PageStudioMerchantApplyParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.ResourceRpcService;
import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
import com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest;
import com.jiejing.paycenter.api.merchant.vo.AuthSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.ConfigSubChannelVO;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
import com.jiejing.paycenter.api.merchant.vo.SubChannelAuthVO;
import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import com.jiejing.paycenter.common.enums.merchant.SubChannelEnums;
import com.jiejing.paycenter.common.event.MerchantEvent;
import com.jiejing.paycenter.common.model.ResourceInfo;
import com.jiejing.studio.api.studio.vo.StudioVO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @author chengyubing
* @since 2024/3/5 09:58
*/
@Slf4j
@Service
public class StudioMerchantServiceImpl implements StudioMerchantService {
@Value("${finance.brand.merchant.channel}")
private String channel;
@Resource
private StudioRpcService studioRpcService;
@Resource
private MerchantRpcService merchantRpcService;
@Resource
private ResourceRpcService resourceRpcService;
@Resource
private StudioMerchantApplyRpService studioMerchantApplyRpService;
@Resource
private PartyToMerchantRpService partyToMerchantRpService;
@Resource
private GlobalConfigRpService globalConfigRpService;
@Resource
private BrandMerchantService brandMerchantService;
@Async(value = "financeThreadPool")
@Override
public void apply(ApplyStudioMerchantParams params) {
Long id = IdWorker.getId();
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByStudioId(studio.getId());
StudioMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel);
studioMerchantApplyRpService.insert(apply);
try {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = this.upload(params);
ApplyMerchantRequest request = MerchantConvert.convertRequest(channel, apply.getApplyNo(), params,
resourceMap, getDefaultBrandSubChannelInfo());
merchantRpcService.apply(request);
} catch (Exception e) {
log.error("apply brand merchant fail {}, brand id = {}, studio id = {}", id, studio.getBrandId(),
params.getStudioId(), e);
this.doOpenMerchantFail(id, e.getMessage());
return;
}
this.doOpenMerchantProcess(id);
}
@Override
public void bind(Long studioId, Long merchantId) {
PartyToMerchant relation = getRelation(studioId);
StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId);
if (null == relation) {
partyToMerchantRpService.insert(
MerchantConvert.convertPartyToMerchant(apply.getChannelNo(), studioId, PartyTypeEnums.STUDIO,
apply.getMerchantId(), apply.getMerchantNo()));
} else {
partyToMerchantRpService.updateById(
MerchantConvert.convertPartyToMerchant(relation.getId(), merchantId, apply.getMerchantNo()));
}
}
@Override
public void unbind(Long studioId, Long merchantId) {
partyToMerchantRpService.deleteByPartyAndMerchantId(studioId, PartyTypeEnums.STUDIO, merchantId);
}
@Override
public void unbindAll(Long studioId) {
partyToMerchantRpService.deleteByParty(studioId, PartyTypeEnums.STUDIO);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override
public void callback(MerchantEvent event) {
switch (event.getState()) {
case PROCESS:
this.doOpenMerchantProcess(Long.parseLong(event.getApplyNo()));
break;
case FAIL:
this.doOpenMerchantFail(Long.parseLong(event.getApplyNo()), event.getFailMessage());
break;
case SUCCESS:
this.doOpenMerchantSuccess(event);
break;
default:
break;
}
}
@Override
public StudioMerchantVO getMerchant(Long studioId) {
PartyToMerchant relation = getRelation(studioId);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
return MerchantConvert.convertStuidoMerchant(relation, merchant,
getDefaultBrandSubChannelInfo().getSubChannels());
}
@Override
public StudioMerchantApplyVO getApply(Long id) {
StudioMerchantApply apply = studioMerchantApplyRpService.getById(id)
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return MerchantConvert.convertApply(apply);
}
@Override
public PageVO<StudioMerchantApplyVO> pageApply(PageStudioMerchantApplyParams params) {
Page<StudioMerchantApply> page = studioMerchantApplyRpService.page(BeanUtil.map(params,
PageStudioMerchantApplyQuery.class));
return PageVO.convert(page, MerchantConvert.convertApplyList(page.getContent()));
}
@Override
public StudioMerchantBindXcxAppIdVO bindXcxAppId(Long studioId, String appId) {
PartyToMerchant relation = getRelation(studioId);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(channel, IdWorker.getIdStr(),
relation.getMerchantId(), appId);
return StudioMerchantBindXcxAppIdVO.builder().state(vo.getState()).failMessage(vo.getFailMessage())
.build();
}
private PartyToMerchant getRelation(Long studioId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(studioId, PartyTypeEnums.STUDIO,
channel);
if (CollectionUtil.isEmpty(relations)) {
return null;
}
return relations.get(0);
}
@Override
public StudioMerchantAuthSubChannelVO authSubChannel(Long studioId, SubChannelEnums subChannel,
SubChannelAuthTypeEnums authType) {
PartyToMerchant relation = getRelation(studioId);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
AuthSubChannelVO vo = merchantRpcService.authSubChannel(channel, relation.getMerchantId(), subChannel,
authType);
return BeanUtil.map(vo, StudioMerchantAuthSubChannelVO.class);
}
@Override
public List<StudioMerchantAuthSubChannelVO> listAuthSubChannel(Long studioId) {
PartyToMerchant relation = getRelation(studioId);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
List<SubChannelAuthVO> auths = merchant.getSubChannelAuths();
return Optional.ofNullable(auths).orElse(new ArrayList<>(1)).stream()
.map(e -> BeanUtil.map(e, StudioMerchantAuthSubChannelVO.class)).collect(Collectors.toList());
}
private void doOpenMerchantSuccess(MerchantEvent event) {
StudioMerchantApply apply = studioMerchantApplyRpService.getByIdForUpdate(
Long.parseLong(event.getApplyNo())).orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
StudioMerchantApply applyToModify = MerchantConvert.convertApply(apply, event,
getDefaultBrandSubChannelInfo().getSubChannels());
studioMerchantApplyRpService.updateById(applyToModify);
if (OpenStateEnums.SUCCESS == applyToModify.getOpenState()) {
// 所有子通道全部开通成功
// 1. 绑定场馆
this.bind(apply.getStudioId(), event.getMerchantId());
// 2. 绑定品牌
brandMerchantService.bind(apply.getBrandId(), event.getMerchantId());
}
}
private Map<ResourceTypeEnums, ResourceInfo> upload(ApplyStudioMerchantParams params) {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = MerchantConvert.convertResourceMap(
params.getResource());
Map<Long, ResourceInfoVO> resourceIdUrlMap = resourceRpcService.getResourceMap(params.getStudioId(),
getResourceIds(resourceMap));
resourceMap.keySet().forEach(type -> {
ResourceInfo info = resourceMap.get(type);
ResourceInfoVO vo = resourceIdUrlMap.get(info.getResourceId());
String thirdId = merchantRpcService.upload(MerchantConvert.convertUploadRequest(channel, type, vo));
info.setThirdId(thirdId);
});
return resourceMap;
}
private List<Long> getResourceIds(Map<ResourceTypeEnums, ResourceInfo> resourceMap) {
return resourceMap.values().stream()
.map(ResourceInfo::getResourceId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
}
private void doOpenMerchantFail(Long id, String failMessage) {
studioMerchantApplyRpService.updateById(
StudioMerchantApply.builder().id(id).openState(OpenStateEnums.FAIL)
.openFailMessage(failMessage).build());
}
private void doOpenMerchantProcess(Long id) {
studioMerchantApplyRpService.updateById(
StudioMerchantApply.builder().id(id).openState(OpenStateEnums.PROCESS).build());
}
private ApplyMerchantRequest getDefaultBrandSubChannelInfo() {
GlobalConfig config = globalConfigRpService.getById(
GlobalConfigEnums.BRAND_MERCHANT_SUB_CHANNELS.getCode())
.orElseThrow(() -> new BizException(FinanceErrorEnums.NOT_EXIST));
return JSON.parseObject(config.getConfigValue(), ApplyMerchantRequest.class);
}
}
...@@ -28,8 +28,8 @@ import lombok.NoArgsConstructor; ...@@ -28,8 +28,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "申请品牌商户请求信息") @ApiModel(description = "申请场馆商户请求信息")
public class ApplyBrandMerchantParams { public class ApplyStudioMerchantParams {
@ApiModelProperty(value = "场馆ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空") @NotNull(message = "场馆ID不能为空")
...@@ -69,8 +69,8 @@ public class ApplyBrandMerchantParams { ...@@ -69,8 +69,8 @@ public class ApplyBrandMerchantParams {
@Valid @Valid
private BrandResourceInfo resource; private BrandResourceInfo resource;
public ApplyBrandMerchantParams encrypt(String salt) { public ApplyStudioMerchantParams encrypt(String salt) {
ApplyBrandMerchantParams copy = JSON.parseObject(JSON.toJSONString(this), ApplyBrandMerchantParams.class); ApplyStudioMerchantParams copy = JSON.parseObject(JSON.toJSONString(this), ApplyStudioMerchantParams.class);
if (null != copy.getBankCard()) { if (null != copy.getBankCard()) {
copy.getBankCard().setCardNo(AesUtil.encrypt(salt, copy.getBankCard().getCardNo())); copy.getBankCard().setCardNo(AesUtil.encrypt(salt, copy.getBankCard().getCardNo()));
copy.getBankCard().setCertNo(AesUtil.encrypt(salt, copy.getBankCard().getCertNo())); copy.getBankCard().setCertNo(AesUtil.encrypt(salt, copy.getBankCard().getCertNo()));
...@@ -85,8 +85,8 @@ public class ApplyBrandMerchantParams { ...@@ -85,8 +85,8 @@ public class ApplyBrandMerchantParams {
return copy; return copy;
} }
public ApplyBrandMerchantParams decrypt(String salt) { public ApplyStudioMerchantParams decrypt(String salt) {
ApplyBrandMerchantParams copy = JSON.parseObject(JSON.toJSONString(this), ApplyBrandMerchantParams.class); ApplyStudioMerchantParams copy = JSON.parseObject(JSON.toJSONString(this), ApplyStudioMerchantParams.class);
if (null != copy.getBankCard()) { if (null != copy.getBankCard()) {
copy.getBankCard().setCardNo(AesUtil.decrypt(salt, copy.getBankCard().getCardNo())); copy.getBankCard().setCardNo(AesUtil.decrypt(salt, copy.getBankCard().getCardNo()));
copy.getBankCard().setCertNo(AesUtil.decrypt(salt, copy.getBankCard().getCertNo())); copy.getBankCard().setCertNo(AesUtil.decrypt(salt, copy.getBankCard().getCertNo()));
......
...@@ -5,7 +5,6 @@ import com.jiejing.paycenter.common.enums.common.OpenStateEnums; ...@@ -5,7 +5,6 @@ import com.jiejing.paycenter.common.enums.common.OpenStateEnums;
import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums; import com.jiejing.paycenter.common.enums.merchant.CompanyTypeEnums;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -20,8 +19,8 @@ import lombok.NoArgsConstructor; ...@@ -20,8 +19,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ApiModel(description = "申请品牌商户请求信息") @ApiModel(description = "申请场馆商户请求信息")
public class PageBrandMerchantApplyParams { public class PageStudioMerchantApplyParams {
@ApiModelProperty(value = "商户简称") @ApiModelProperty(value = "商户简称")
private String shortName; private String shortName;
......
package com.jiejing.fitness.finance.service.pay; package com.jiejing.fitness.finance.service.pay;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams; import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO; import com.jiejing.paycenter.api.pay.vo.RefundVO;
...@@ -19,7 +19,7 @@ public interface PayService { ...@@ -19,7 +19,7 @@ public interface PayService {
* @param params 请求参数 * @param params 请求参数
* @return 结果 * @return 结果
*/ */
PayVO merchantPay(BrandMerchantPayParams params); PayVO merchantPay(StudioMerchantPayParams params);
/** /**
* 支付回调 * 支付回调
......
...@@ -9,10 +9,9 @@ import com.jiejing.common.utils.text.StringUtil; ...@@ -9,10 +9,9 @@ import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.finance.api.enums.BrandCashierTransStateEnums; import com.jiejing.fitness.finance.api.enums.BrandCashierTransStateEnums;
import com.jiejing.fitness.finance.api.enums.BrandCashierTransTypeEnums; import com.jiejing.fitness.finance.api.enums.BrandCashierTransTypeEnums;
import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord; import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.utils.FeeUtil; import com.jiejing.fitness.finance.service.utils.FeeUtil;
import com.jiejing.fitness.finance.service.utils.MoneyUtil; import com.jiejing.fitness.finance.service.utils.MoneyUtil;
import com.jiejing.paycenter.api.merchant.vo.MerchantVO; import com.jiejing.paycenter.api.merchant.vo.MerchantVO;
...@@ -27,7 +26,7 @@ import com.jiejing.paycenter.common.enums.pay.PayStateEnums; ...@@ -27,7 +26,7 @@ import com.jiejing.paycenter.common.enums.pay.PayStateEnums;
import com.jiejing.paycenter.common.enums.pay.PayTypeEnums; import com.jiejing.paycenter.common.enums.pay.PayTypeEnums;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
import com.jiejing.paycenter.common.event.RefundEvent; import com.jiejing.paycenter.common.event.RefundEvent;
import com.jiejing.paycenter.common.model.SubChannelInfo; import com.jiejing.studio.api.studio.vo.StudioVO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Date; import java.util.Date;
...@@ -46,7 +45,7 @@ public class PayConvert { ...@@ -46,7 +45,7 @@ public class PayConvert {
private static final List<String> WX_AUTH_CODE_PREFIX = Lists.newArrayList("10", "11", "12", "13", "14", private static final List<String> WX_AUTH_CODE_PREFIX = Lists.newArrayList("10", "11", "12", "13", "14",
"15"); "15");
public static PayRequest convert(BrandMerchantPayParams params, BrandCashierRecord record) { public static PayRequest convert(StudioMerchantPayParams params, BrandCashierRecord record) {
PayRequest request = BeanUtil.map(params, PayRequest.class); PayRequest request = BeanUtil.map(params, PayRequest.class);
request.setTransNo(record.getTransNo()); request.setTransNo(record.getTransNo());
request.setMerchantId(record.getMerchantId()); request.setMerchantId(record.getMerchantId());
...@@ -60,7 +59,7 @@ public class PayConvert { ...@@ -60,7 +59,7 @@ public class PayConvert {
return request; return request;
} }
public static BrandCashierRecord convertPayInit(BrandMerchantPayParams params, BrandToMerchant relation, public static BrandCashierRecord convertPayInit(StudioMerchantPayParams params, StudioVO studio,
MerchantVO merchant) { MerchantVO merchant) {
setSubChannel(params); setSubChannel(params);
Long id = IdWorker.getId(); Long id = IdWorker.getId();
...@@ -72,7 +71,7 @@ public class PayConvert { ...@@ -72,7 +71,7 @@ public class PayConvert {
.orderNo(params.getOrderNo()) .orderNo(params.getOrderNo())
.orderType(params.getOrderType()) .orderType(params.getOrderType())
.transType(BrandCashierTransTypeEnums.PAY) .transType(BrandCashierTransTypeEnums.PAY)
.brandId(relation.getBrandId()) .brandId(studio.getBrandId())
.studioId(params.getStudioId()) .studioId(params.getStudioId())
.merchantId(merchant.getId()) .merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo()) .merchantNo(merchant.getMerchantNo())
...@@ -94,7 +93,7 @@ public class PayConvert { ...@@ -94,7 +93,7 @@ public class PayConvert {
.build(); .build();
} }
private static void setSubChannel(BrandMerchantPayParams params) { private static void setSubChannel(StudioMerchantPayParams params) {
if (PayTypeEnums.BARCODE != params.getPayType() || StringUtil.isBlank(params.getAuthCode())) { if (PayTypeEnums.BARCODE != params.getPayType() || StringUtil.isBlank(params.getAuthCode())) {
// 未设置子渠道,不是付款码支付或付款码为空,直接返回 // 未设置子渠道,不是付款码支付或付款码为空,直接返回
return; return;
...@@ -111,7 +110,7 @@ public class PayConvert { ...@@ -111,7 +110,7 @@ public class PayConvert {
} }
} }
private static BigDecimal getFeeRate(BrandMerchantPayParams params, MerchantVO merchant) { private static BigDecimal getFeeRate(StudioMerchantPayParams params, MerchantVO merchant) {
SubChannelOpenTypeEnums scene; SubChannelOpenTypeEnums scene;
switch (params.getPayType()) { switch (params.getPayType()) {
case MINI: case MINI:
......
...@@ -2,14 +2,14 @@ package com.jiejing.fitness.finance.service.pay.impl; ...@@ -2,14 +2,14 @@ package com.jiejing.fitness.finance.service.pay.impl;
import com.jiejing.common.exception.BizException; import com.jiejing.common.exception.BizException;
import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord; import com.jiejing.fitness.finance.repository.entity.BrandCashierRecord;
import com.jiejing.fitness.finance.repository.entity.BrandToMerchant; import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.service.BrandCashierRecordRpService; import com.jiejing.fitness.finance.repository.service.BrandCashierRecordRpService;
import com.jiejing.fitness.finance.repository.service.BrandToMerchantRpService; import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.pay.PayService; import com.jiejing.fitness.finance.service.pay.PayService;
import com.jiejing.fitness.finance.service.pay.convert.PayConvert; import com.jiejing.fitness.finance.service.pay.convert.PayConvert;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantPayParams;
import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams; import com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams;
import com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams;
import com.jiejing.fitness.finance.service.rpc.MerchantRpcService; import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import com.jiejing.fitness.finance.service.rpc.PayRpcService; import com.jiejing.fitness.finance.service.rpc.PayRpcService;
import com.jiejing.fitness.finance.service.rpc.StudioRpcService; import com.jiejing.fitness.finance.service.rpc.StudioRpcService;
...@@ -18,12 +18,10 @@ import com.jiejing.paycenter.api.pay.request.PayRequest; ...@@ -18,12 +18,10 @@ import com.jiejing.paycenter.api.pay.request.PayRequest;
import com.jiejing.paycenter.api.pay.request.RefundPayRequest; import com.jiejing.paycenter.api.pay.request.RefundPayRequest;
import com.jiejing.paycenter.api.pay.vo.PayVO; import com.jiejing.paycenter.api.pay.vo.PayVO;
import com.jiejing.paycenter.api.pay.vo.RefundVO; import com.jiejing.paycenter.api.pay.vo.RefundVO;
import com.jiejing.paycenter.common.enums.pay.PayStateEnums;
import com.jiejing.paycenter.common.event.PayEvent; import com.jiejing.paycenter.common.event.PayEvent;
import com.jiejing.paycenter.common.event.RefundEvent; import com.jiejing.paycenter.common.event.RefundEvent;
import com.jiejing.studio.api.studio.vo.StudioVO; import com.jiejing.studio.api.studio.vo.StudioVO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -41,7 +39,7 @@ public class PayServiceImpl implements PayService { ...@@ -41,7 +39,7 @@ public class PayServiceImpl implements PayService {
private String channel; private String channel;
@Resource @Resource
private BrandToMerchantRpService brandToMerchantRpService; private PartyToMerchantRpService partyToMerchantRpService;
@Resource @Resource
private PayRpcService payRpcService; private PayRpcService payRpcService;
...@@ -56,13 +54,16 @@ public class PayServiceImpl implements PayService { ...@@ -56,13 +54,16 @@ public class PayServiceImpl implements PayService {
private MerchantRpcService merchantRpcService; private MerchantRpcService merchantRpcService;
@Override @Override
public PayVO merchantPay(BrandMerchantPayParams params) { public PayVO merchantPay(StudioMerchantPayParams params) {
StudioVO studio = studioRpcService.getStudio(params.getStudioId()); StudioVO studio = studioRpcService.getStudio(params.getStudioId());
BrandToMerchant relation = brandToMerchantRpService.getByBrandId(studio.getBrandId(), channel); PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), channel);
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId()); MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId());
BrandCashierRecord record = PayConvert.convertPayInit(params, relation, merchant); BrandCashierRecord record = PayConvert.convertPayInit(params, studio, merchant);
brandCashierRecordRpService.insert(record); brandCashierRecordRpService.insert(record);
PayRequest request = PayConvert.convert(params, record); PayRequest request = PayConvert.convert(params, record);
......
...@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor; ...@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(description = "品牌商户支付Params") @ApiModel(description = "场馆商户支付Params")
public class BrandMerchantPayParams { public class StudioMerchantPayParams {
@ApiModelProperty(value = "场馆ID", required = true) @ApiModelProperty(value = "场馆ID", required = true)
@NotNull(message = "场馆ID不能为空") @NotNull(message = "场馆ID不能为空")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment