Commit c85790ec by 程裕兵

feat:page apply[

parent 0d09a590
...@@ -64,7 +64,7 @@ public class StudioMerchantController implements StudioMerchantApi { ...@@ -64,7 +64,7 @@ public class StudioMerchantController implements StudioMerchantApi {
@PostMapping(value = "/private/studioMerchant/bind") @PostMapping(value = "/private/studioMerchant/bind")
@Override @Override
public JsonResult<Void> bind(@RequestBody @Valid BindStudioMerchantRequest request) { public JsonResult<Void> bind(@RequestBody @Valid BindStudioMerchantRequest request) {
studioMerchantService.bind(request.getStudioId(), request.getMerchantId()); studioMerchantService.bind(request.getStudioId(), request.getMerchantId(), true);
return JsonResult.success(); return JsonResult.success();
} }
......
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
select * select *
from studio_merchant_apply from studio_merchant_apply
where merchant_id = #{merchantId} where merchant_id = #{merchantId}
and open_state = 'S' and open_state = 'SUCCESS'
and apply_type in ('OPEN', 'RE_OPEN')
order by id desc order by id desc
limit 1 limit 1
</select> </select>
...@@ -35,7 +36,8 @@ ...@@ -35,7 +36,8 @@
select * select *
from studio_merchant_apply from studio_merchant_apply
where studio_id = #{studioId} where studio_id = #{studioId}
and open_state = 'S' and open_state = 'SUCCESS'
and apply_type in ('OPEN', 'RE_OPEN')
order by id desc order by id desc
limit 1 limit 1
</select> </select>
......
...@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.jiejing.common.utils.collection.CollectionUtil; import com.jiejing.common.utils.collection.CollectionUtil;
import com.jiejing.common.utils.text.StringUtil; import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.enums.finance.ApplyTypeEnum;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper; import com.jiejing.fitness.finance.repository.mapper.StudioMerchantApplyMapper;
import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery; import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
...@@ -95,7 +96,9 @@ public class StudioMerchantApplyRpService extends ...@@ -95,7 +96,9 @@ public class StudioMerchantApplyRpService extends
QueryWrapper<StudioMerchantApply> wrapper = new QueryWrapper<>(); QueryWrapper<StudioMerchantApply> wrapper = new QueryWrapper<>();
wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId); wrapper.eq(StudioMerchantApply.STUDIO_ID, studioId);
wrapper.in(StudioMerchantApply.OPEN_STATE, wrapper.in(StudioMerchantApply.OPEN_STATE,
Lists.newArrayList(OpenStateEnums.PROCESS, OpenStateEnums.INIT)); Lists.newArrayList(OpenStateEnums.PROCESS.getCode(), OpenStateEnums.INIT.getCode()));
wrapper.in(StudioMerchantApply.APPLY_TYPE,
Lists.newArrayList(ApplyTypeEnum.OPEN.getCode(), ApplyTypeEnum.RE_OPEN.getCode()));
Integer count = this.baseMapper.selectCount(wrapper); Integer count = this.baseMapper.selectCount(wrapper);
return Optional.ofNullable(count).orElse(0); return Optional.ofNullable(count).orElse(0);
} }
......
...@@ -30,8 +30,9 @@ public interface StudioMerchantService { ...@@ -30,8 +30,9 @@ public interface StudioMerchantService {
* *
* @param studioId 场馆ID * @param studioId 场馆ID
* @param merchantId 商户ID * @param merchantId 商户ID
* @param flag 是否添加绑定记录
*/ */
void bind(Long studioId, Long merchantId); void bind(Long studioId, Long merchantId, Boolean flag);
/** /**
* 解绑 * 解绑
......
...@@ -2,6 +2,7 @@ package com.jiejing.fitness.finance.service.merchant.convert; ...@@ -2,6 +2,7 @@ package com.jiejing.fitness.finance.service.merchant.convert;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
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.enums.finance.ApplyTypeEnum; import com.jiejing.fitness.enums.finance.ApplyTypeEnum;
...@@ -559,4 +560,16 @@ public class MerchantConvert { ...@@ -559,4 +560,16 @@ public class MerchantConvert {
return convertBrandMerchant(brandId, studioNames, e, dto); return convertBrandMerchant(brandId, studioNames, e, dto);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
public static StudioMerchantApply convertBindApply(Long studioId, StudioMerchantApply apply) {
StudioMerchantApply toSave = BeanUtil.map(apply, StudioMerchantApply.class);
toSave.setId(IdWorker.getId());
toSave.setApplyNo("-1");
toSave.setApplyType(ApplyTypeEnum.BIND.getCode());
toSave.setStudioId(studioId);
toSave.setCreateTime(new Date());
toSave.setUpdateTime(new Date());
return toSave;
}
} }
...@@ -125,10 +125,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -125,10 +125,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override @Override
public void bind(Long studioId, Long merchantId) { public void bind(Long studioId, Long merchantId, Boolean flag) {
// 解绑后,绑定新商户 PartyToMerchant relation = this.getRelation(studioId);
this.unbindAll(studioId);
PartyToMerchant relation = getRelation(studioId);
StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId); StudioMerchantApply apply = studioMerchantApplyRpService.getLatestOneSuccessByMerchantId(merchantId);
if (null == relation) { if (null == relation) {
partyToMerchantRpService.insert( partyToMerchantRpService.insert(
...@@ -138,6 +136,11 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -138,6 +136,11 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
partyToMerchantRpService.updateById( partyToMerchantRpService.updateById(
MerchantConvert.convertPartyToMerchant(relation.getId(), merchantId, apply.getMerchantNo())); MerchantConvert.convertPartyToMerchant(relation.getId(), merchantId, apply.getMerchantNo()));
} }
// 新增绑定记录
if (flag) {
StudioMerchantApply bindApply = MerchantConvert.convertBindApply(studioId, apply);
studioMerchantApplyRpService.insert(bindApply);
}
} }
@Override @Override
...@@ -257,7 +260,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -257,7 +260,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
PartyToMerchant old = getRelation(apply.getStudioId()); PartyToMerchant old = getRelation(apply.getStudioId());
// 1. 绑定场馆 // 1. 绑定场馆
this.bind(apply.getStudioId(), event.getMerchantId()); this.bind(apply.getStudioId(), event.getMerchantId(), false);
// 2. 绑定品牌 // 2. 绑定品牌
brandMerchantService.bind(apply.getBrandId(), event.getMerchantId()); brandMerchantService.bind(apply.getBrandId(), event.getMerchantId());
......
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