Commit 9b9683d9 by 程裕兵

feat:bind

parent 97ff19cc
...@@ -9,8 +9,10 @@ import com.jiejing.filecenter.api.common.enums.AccessTypeEnum; ...@@ -9,8 +9,10 @@ import com.jiejing.filecenter.api.common.enums.AccessTypeEnum;
import com.jiejing.filecenter.api.common.util.UploadUtil; import com.jiejing.filecenter.api.common.util.UploadUtil;
import com.jiejing.filecenter.api.resource.ResourceApi; import com.jiejing.filecenter.api.resource.ResourceApi;
import com.jiejing.fitness.finance.repository.service.StudioCashierRecordRpService; import com.jiejing.fitness.finance.repository.service.StudioCashierRecordRpService;
import com.jiejing.fitness.finance.service.merchant.StudioMerchantService;
import com.jiejing.fitness.finance.service.utils.FileUtils; import com.jiejing.fitness.finance.service.utils.FileUtils;
import com.jiejing.paycenter.api.merchant.MerchantQueryApi; import com.jiejing.paycenter.api.merchant.MerchantQueryApi;
import com.jiejing.paycenter.common.event.MerchantEvent;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
...@@ -19,6 +21,7 @@ import java.util.Map; ...@@ -19,6 +21,7 @@ import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -60,11 +63,14 @@ public class TestController { ...@@ -60,11 +63,14 @@ public class TestController {
@Resource @Resource
private StudioCashierRecordRpService studioCashierRecordRpService; private StudioCashierRecordRpService studioCashierRecordRpService;
@PostMapping(value = "/private/test/sumMerchantPaySuccessGroupByStudioId") @Resource
public JsonResult<Map<Long, BigDecimal>> sumMerchantPaySuccessGroupByStudioId(@RequestParam Long startDate, @RequestParam Long endDate, private StudioMerchantService studioMerchantService;
@RequestParam Long merchantId) {
return JsonResult.success(studioCashierRecordRpService.sumMerchantPaySuccessGroupByStudioId(
merchantId, new Date(startDate), new Date(endDate))); @PostMapping(value = "/private/test/merchantCallback")
public JsonResult<Map<Long, BigDecimal>> merchantCallback(@RequestBody MerchantEvent event) {
studioMerchantService.callback(event);
return JsonResult.success();
} }
......
...@@ -37,8 +37,7 @@ public class ListenerService { ...@@ -37,8 +37,7 @@ public class ListenerService {
@EventHandler(value = MerchantEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY) @EventHandler(value = MerchantEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY)
public void handleMerchantEvent(MerchantEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) { public void handleMerchantEvent(MerchantEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) {
try { try {
log.info("start process merchant event {}, {}, {}", event.getApplyNo(), event.getMerchantId(), log.info("start process merchant event {}", JSON.toJSONString(event));
event.getMerchantNo());
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)));
...@@ -59,7 +58,7 @@ public class ListenerService { ...@@ -59,7 +58,7 @@ public class ListenerService {
@EventHandler(value = PayEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY) @EventHandler(value = PayEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY)
public void payEventCallback(PayEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) { public void payEventCallback(PayEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) {
try { try {
log.info("start process pay event {}", event.getTransNo()); log.info("start process pay event {}", JSON.toJSONString(event));
payService.payCallback(event); payService.payCallback(event);
} catch (Exception e) { } catch (Exception e) {
log.info("process pay event fail {}", event.getTransNo(), e); log.info("process pay event fail {}", event.getTransNo(), e);
...@@ -69,7 +68,7 @@ public class ListenerService { ...@@ -69,7 +68,7 @@ public class ListenerService {
@EventHandler(value = RefundEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY) @EventHandler(value = RefundEvent.class, binder = "biz-kafka", maxAttempts = MAX_RETRY)
public void refundEventCallback(RefundEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) { public void refundEventCallback(RefundEvent event, @Header(DELIVERY_ATTEMPT) int retryNum) {
try { try {
log.info("start process refund event {}", event.getTransNo()); log.info("start process refund event {}", JSON.toJSONString(event));
payService.refundCallback(event); payService.refundCallback(event);
} catch (Exception e) { } catch (Exception e) {
log.info("process refund event fail {}", event.getTransNo(), e); log.info("process refund event fail {}", event.getTransNo(), e);
......
...@@ -67,6 +67,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -67,6 +67,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Override @Override
public void unbind(Long brandId, Long merchantId) { public void unbind(Long brandId, Long merchantId) {
log.info("unbind brand merchant {}, {}", brandId, merchantId);
partyToMerchantRpService.deleteByPartyAndMerchantId(brandId, PartyTypeEnum.BRAND, merchantId); partyToMerchantRpService.deleteByPartyAndMerchantId(brandId, PartyTypeEnum.BRAND, merchantId);
} }
......
...@@ -160,6 +160,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -160,6 +160,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Override @Override
public void unbindAll(Long merchantId) { public void unbindAll(Long merchantId) {
log.info("unbind all studio of merchant {}", merchantId);
partyToMerchantRpService.deleteByMerchantId(merchantId, PartyTypeEnum.STUDIO); partyToMerchantRpService.deleteByMerchantId(merchantId, PartyTypeEnum.STUDIO);
} }
...@@ -365,8 +366,12 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -365,8 +366,12 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
Long oldMerchantId = old.getMerchantId(); Long oldMerchantId = old.getMerchantId();
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(oldMerchantId); StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(oldMerchantId);
log.info("current bound merchant of studio : {}, and the merchant is from studio : {}",
JSON.toJSONString(old), exist.getStudioId());
if (!exist.getStudioId().equals(apply.getStudioId())) { if (!exist.getStudioId().equals(apply.getStudioId())) {
// 之前绑定的商户不是自己的商户,不需要解绑 // 之前绑定的商户不是自己的商户,不需要解绑
log.info("exist merchant no is not studio self {}, {}, {}", oldMerchantId, apply.getStudioId(),
exist.getStudioId());
return oldMerchantId; return oldMerchantId;
} }
......
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