feat:商户规则绑定
This commit is contained in:
1 parent
b88ec9812b
commit
ca1295434f
23 files changed
+275
-32
No files matched your search
+4
@@ -54,6 +54,10 @@ public interface RemoteDeptService {
|
||||
@PostMapping("/dept/inner-all-dept")
|
||||
R<List<SysDept>> getInnerAllDept(@RequestBody DeptAllListDto dto);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/dept/inner-dept")
|
||||
R<List<SysDept>> getInnerDept(@RequestBody DeptAllListDto dto);
|
||||
|
||||
/**
|
||||
* 通过部门ID获取负责人列表
|
||||
*
|
||||
|
||||
+8
@@ -225,4 +225,12 @@ public class SysDeptController {
|
||||
public R<List<SysDept>> getInnerAllDept(@RequestBody DeptAllListDto dto) {
|
||||
return R.ok(sysDeptMapper.allList(dto));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@PostMapping("/inner-dept")
|
||||
public R<List<SysDept>> getInnerDept(@RequestBody DeptAllListDto dto) {
|
||||
return R.ok(sysDeptService.getInnerDept(dto));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+3
@@ -21,6 +21,7 @@ package com.bsd.pjcloud.admin.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.admin.api.dto.DeptAllListDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.vo.DeptExcelVO;
|
||||
import com.bsd.pjcloud.admin.api.vo.OrgTreeVO;
|
||||
@@ -127,4 +128,6 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
*/
|
||||
List<SysDept> selectByNames(List<String> names);
|
||||
|
||||
|
||||
List<SysDept> getInnerDept(DeptAllListDto dto);
|
||||
}
|
||||
+10
@@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.constant.OrgTypeEnum;
|
||||
import com.bsd.pjcloud.admin.api.constant.PostCodeEnum;
|
||||
import com.bsd.pjcloud.admin.api.dto.DeptAllListDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.*;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.admin.api.vo.DeptExcelVO;
|
||||
@@ -413,6 +414,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDept> getInnerDept(DeptAllListDto dto) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), SysDept::getDeptId, dto.getDeptId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getIsSyncZy()), SysDept::getIsSyncZy, dto.getIsSyncZy())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), SysDept::getDeptId, dto.getDeptIds())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询所有子节点。
|
||||
*
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.Arrays;
|
||||
public enum WalletMchSupType {
|
||||
|
||||
BRAND("10", "品牌"),
|
||||
MCH("20", "商家"),
|
||||
MCH("20", "商户"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class MchRuleJoinDtoEntity extends Model<MchRuleJoinDtoEntity> {
|
||||
/**
|
||||
* 目标部门id
|
||||
*/
|
||||
private Long tragetDeptId;
|
||||
private Long targetDeptId;
|
||||
|
||||
/**
|
||||
* 规则配置id
|
||||
|
||||
+10
@@ -26,4 +26,14 @@ public class MchRuleJoinDtoVo extends MchRuleJoinDtoEntity {
|
||||
*/
|
||||
private Long multiple;
|
||||
|
||||
/**
|
||||
* 源商户名
|
||||
*/
|
||||
private String sourceMchName;
|
||||
|
||||
/**
|
||||
* 目标商户名
|
||||
*/
|
||||
private String targetMchName;
|
||||
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class MchDeptController {
|
||||
@Operation(summary = "同步全部", description = "分页查询")
|
||||
@GetMapping("/sync-all")
|
||||
public R syncAll() {
|
||||
mchDeptUserService.syncAll();
|
||||
mchDeptUserService.syncAll(List.of());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -101,6 +101,16 @@ public class MchManageController {
|
||||
return R.ok(mchManageService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "app查询合作商家的分店", description = "app查询合作商家的分店")
|
||||
@GetMapping("/app/children-page-join")
|
||||
@Inner(value = false)
|
||||
public R<Page<MchManageVo>> appParentPageJoin(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
|
||||
dto.setVisibleMobile(YesNoEnum.YES.getCode());
|
||||
dto.setTypes(MerchantTypeEnum.SUPERMARKET.getType());
|
||||
dto.setParentIsNull(false);
|
||||
return R.ok(mchManageService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "app查询店铺详情", description = "app查询店铺详情")
|
||||
@GetMapping("/app/detail")
|
||||
public R<MchManageVo> appPageJoin(@RequestParam Long id) {
|
||||
|
||||
+14
-6
@@ -55,28 +55,36 @@ public class MchRuleJoinController {
|
||||
return R.ok(mchRuleJoinControllerService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("join-detail/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_view')")
|
||||
public R joinDetail(@PathVariable("id") Long id) {
|
||||
return R.ok(mchRuleJoinControllerService.joinDetail(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增商户规格配置表", description = "新增商户规格配置表")
|
||||
@SysLog("新增商户规格配置表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_add')")
|
||||
public R save(@RequestBody MchRuleJoinDtoEntity walletRuleMchConfig) {
|
||||
return R.ok(mchRuleJoinControllerService.save(walletRuleMchConfig));
|
||||
public R save(@RequestBody MchRuleJoinDtoEntity dto) {
|
||||
return R.ok(mchRuleJoinControllerService.create(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改商户规格配置表", description = "修改商户规格配置表")
|
||||
@SysLog("修改商户规格配置表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_edit')")
|
||||
public R updateById(@RequestBody MchRuleJoinDtoEntity walletRuleMchConfig) {
|
||||
return R.ok(mchRuleJoinControllerService.updateById(walletRuleMchConfig));
|
||||
public R updateById(@RequestBody MchRuleJoinDtoEntity dto) {
|
||||
return R.ok(mchRuleJoinControllerService.edit(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除商户规格配置表", description = "通过id删除商户规格配置表")
|
||||
@SysLog("通过id删除商户规格配置表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_del')")
|
||||
public R removeById(@RequestBody Long ids) {
|
||||
return R.ok(mchRuleJoinControllerService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
mchRuleJoinControllerService.delByIds(CollUtil.toList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
|
||||
+12
-2
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRulePriceConfigDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRulePriceConfigEntity;
|
||||
@@ -24,8 +25,8 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/wallet-rule-price-config")
|
||||
@Tag(description = "wallet-rule-price-config", name = "钱包规则管理")
|
||||
@RequestMapping("/mch-rule-price-config")
|
||||
@Tag(description = "mch-rule-price-config", name = "钱包规则管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class MchRulePriceConfigController {
|
||||
|
||||
@@ -39,9 +40,18 @@ public class MchRulePriceConfigController {
|
||||
return R.ok(walletRulePriceConfigService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页下拉查询", description = "分页下拉查询")
|
||||
@GetMapping("/page-select")
|
||||
public R pageSelect(@ParameterObject Page page, @ParameterObject MchRulePriceConfigDto dto) {
|
||||
DataScope dataScope = null;
|
||||
return R.ok(walletRulePriceConfigService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRulePriceConfig_view')")
|
||||
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(walletRulePriceConfigService.getById(id));
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
|
||||
MPJLambdaQueryWrapper<MchManageEntity> wrapper = new MPJLambdaQueryWrapper<MchManageEntity>()
|
||||
.selectAll(MchManageEntity.class)
|
||||
.eqIfExists(MchManageEntity::getVisibleMobile, dto.getVisibleMobile())
|
||||
.eqIfExists(MchManageEntity::getParentId, dto.getParentId())
|
||||
.likeIfExists(MchManageEntity::getName, dto.getName())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds())
|
||||
.apply(ObjectUtil.isNotEmpty(dto.getType()), "FIND_IN_SET({0}, types)", dto.getType())
|
||||
@@ -65,9 +66,9 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), MchManageEntity::getDeptId, dto.getDeptId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getSupType()), MchManageEntity::getSupType, dto.getSupType())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getParentId()), MchManageEntity::getParentId, dto.getParentId())
|
||||
.eq(dto.getParentIsNull(), MchManageEntity::getParentId, -1L)
|
||||
.like(ObjectUtil.isNotEmpty(dto.getName()), MchManageEntity::getName, dto.getName())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds())
|
||||
.isNull(dto.getParentIsNull(), MchManageEntity::getParentId)
|
||||
.in(ObjectUtil.isNotEmpty(dto.getIds()), MchManageEntity::getId, dto.getIds())
|
||||
.orderByDesc(MchManageEntity::getSort)
|
||||
.orderByDesc(MchManageEntity::getDeptId)
|
||||
|
||||
+4
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRuleJoinDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRuleJoinDtoEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -14,4 +17,5 @@ public interface WalletRuleMchConfigMapper extends PjcloudBaseMapper<MchRuleJoin
|
||||
|
||||
Page<MchRuleJoinDtoVo> pageScopeList(Page page, @Param("dto") MchRuleJoinDto dto, DataScope dataScope);
|
||||
|
||||
MchRuleJoinDtoVo joinDetail(@Param("id") Long id);
|
||||
}
|
||||
+15
@@ -1,11 +1,26 @@
|
||||
package com.bsd.pjcloud.wallet.mapper.rule;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRulePriceConfigDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRulePriceConfigEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRulePriceConfigVo;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface WalletRulePriceConfigMapper extends PjcloudBaseMapper<MchRulePriceConfigEntity> {
|
||||
|
||||
default Page<MchRulePriceConfigVo> scopePageList(Page page, MchRulePriceConfigDto dto, DataScope dataScope) {
|
||||
LambdaQueryWrapper<MchRulePriceConfigEntity> wrapper = new LambdaQueryWrapper<MchRulePriceConfigEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getId()), MchRulePriceConfigEntity::getId, dto.getId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getRulePriceType()), MchRulePriceConfigEntity::getRulePriceType, dto.getRulePriceType())
|
||||
.orderByDesc(MchRulePriceConfigEntity::getCreateTime)
|
||||
.orderByDesc(MchRulePriceConfigEntity::getRulePriceType);
|
||||
return selectPageByScope(page, wrapper, dataScope);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ public interface MchDeptService extends IService<MchDeptEntity> {
|
||||
/**
|
||||
* 同步全部
|
||||
*/
|
||||
void syncAll();
|
||||
void syncAll(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 分页复杂查询
|
||||
|
||||
+21
@@ -7,6 +7,8 @@ import com.bsd.pjcloud.wallet.api.dto.mch.MchRuleJoinDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRuleJoinDtoEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface MchRuleJoinControllerService extends IService<MchRuleJoinDtoEntity> {
|
||||
|
||||
/**
|
||||
@@ -14,4 +16,23 @@ public interface MchRuleJoinControllerService extends IService<MchRuleJoinDtoEnt
|
||||
*/
|
||||
Page<MchRuleJoinDtoVo> pageScopeList(Page page, MchRuleJoinDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
Long create(MchRuleJoinDtoEntity dto);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
Long edit(MchRuleJoinDtoEntity dto);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
void delByIds(ArrayList<Long> list);
|
||||
|
||||
/**
|
||||
* 复杂详情
|
||||
*/
|
||||
MchRuleJoinDtoVo joinDetail(Long id);
|
||||
}
|
||||
+8
@@ -1,8 +1,11 @@
|
||||
package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRulePriceConfigDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRulePriceConfigEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRulePriceConfigVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -21,4 +24,9 @@ public interface WalletRulePriceConfigService extends IService<MchRulePriceConfi
|
||||
* 删除
|
||||
*/
|
||||
void delByIds(ArrayList<Long> list);
|
||||
|
||||
/**
|
||||
* 权限分页查询
|
||||
*/
|
||||
Page<MchRulePriceConfigVo> scopePageList(Page page, MchRulePriceConfigDto dto, DataScope dataScope);
|
||||
}
|
||||
+6
-3
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.DeptAllListDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
@@ -43,9 +44,11 @@ public class MchDeptServiceImpl extends ServiceImpl<MchDeptUserMapper, MchDeptEn
|
||||
* 同步全部
|
||||
*/
|
||||
@Override
|
||||
public void syncAll() {
|
||||
DataScope dataScope = DataScope.of();
|
||||
List<SysDept> dpetList = remoteDeptService.getAllDept(null).getData();
|
||||
public void syncAll(List<Long> deptIds) {
|
||||
DataScope dataScope = null;
|
||||
DeptAllListDto deptDto = new DeptAllListDto();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) deptDto.setDeptIds(deptIds);
|
||||
List<SysDept> dpetList = remoteDeptService.getInnerDept(deptDto).getData();
|
||||
if (ObjectUtil.isEmpty(dpetList)) return;
|
||||
// 插入部门
|
||||
List<MchDeptEntity> saveUserList = new ArrayList<>();
|
||||
|
||||
+26
-11
@@ -21,6 +21,7 @@ import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.utils.Drawing2D;
|
||||
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
|
||||
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchManageEntity;
|
||||
@@ -85,6 +86,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(MchManageEntity dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getParentId())) dto.setParentId(-1L);
|
||||
if (existName(dto.getName(), dto.getTypes(), null)) {
|
||||
throw new RuntimeException("商户名不能重复");
|
||||
}
|
||||
@@ -92,7 +94,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
throw new RuntimeException("该部门已经绑定过商户");
|
||||
}
|
||||
if (!ObjectUtil.equals(dto.getTypes(), MerchantTypeEnum.SUPERMARKET.getType())) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getParentId())) {
|
||||
if (ObjectUtil.notEqual(dto.getParentId(), -1L)) {
|
||||
throw new RuntimeException("改类型不能选择品牌");
|
||||
}
|
||||
}
|
||||
@@ -101,7 +103,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
}
|
||||
baseMapper.insert(dto);
|
||||
getSelf().refreshQrcode(dto.getId());
|
||||
updateMchCount(dto);
|
||||
updateMchCount(dto.getParentId());
|
||||
// walletThirdZyService.syncAllMch(dto.getId(), Boolean.FALSE);
|
||||
return dto.getId();
|
||||
}
|
||||
@@ -116,21 +118,34 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
throw new RuntimeException("该部门已经绑定过商户");
|
||||
}
|
||||
if (!ObjectUtil.equals(dto.getTypes(), MerchantTypeEnum.SUPERMARKET.getType())) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getParentId())) {
|
||||
throw new RuntimeException("改类型不能选择品牌");
|
||||
if (ObjectUtil.notEqual(dto.getParentId(), -1L)) {
|
||||
throw new RuntimeException("该类型不能选择品牌");
|
||||
}
|
||||
}
|
||||
MchManageEntity mchManage = getSelf().getById(dto.getId());
|
||||
Long orgParentId = mchManage.getParentId();
|
||||
if (ObjectUtil.isEmpty(mchManage.getParentId())) {
|
||||
mchManage.setParentId(-1L);
|
||||
dto.setParentId(-1L);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(mchManage)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
if (ObjectUtil.equals(mchManage.getTypes(), MerchantTypeEnum.SUPERMARKET.getType())) {
|
||||
if (ObjectUtil.isNotEmpty(mchManage.getMchCount()) && mchManage.getMchCount() > 0) {
|
||||
throw new RuntimeException("该" + MerchantTypeEnum.SUPERMARKET.getName() + "下面有子店铺,不能修改类型");
|
||||
if (!ObjectUtil.equals(mchManage.getTypes(), dto.getTypes())) {
|
||||
throw new RuntimeException("该" + MerchantTypeEnum.SUPERMARKET.getName() + "下面有子店铺,不能修改类型");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果有parentId就不能换types
|
||||
if (ObjectUtil.notEqual(mchManage.getParentId(), -1L)) {
|
||||
if (!ObjectUtil.equals(mchManage.getTypes(), dto.getTypes())) {
|
||||
throw new RuntimeException("该" + MerchantTypeEnum.SUPERMARKET.getName() + "下的" + WalletMchSupType.MCH.getDesc() + ",不能修改类型");
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(dto);
|
||||
updateMchCount(dto);
|
||||
updateMchCount(orgParentId);
|
||||
// walletThirdZyService.syncAllMch(dto.getId(), Boolean.FALSE);
|
||||
}
|
||||
|
||||
@@ -172,7 +187,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
MchManageDto childrenDto = new MchManageDto();
|
||||
childrenDto.setParentId(v.getId());
|
||||
List<MchManageVo> list = list(childrenDto);
|
||||
if (ObjectUtil.isEmpty(list)) break;
|
||||
if (ObjectUtil.isEmpty(list)) continue;
|
||||
v.setChildren(list);
|
||||
}
|
||||
return pageList;
|
||||
@@ -289,14 +304,14 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
/**
|
||||
* 更新分店数量
|
||||
*/
|
||||
private void updateMchCount(MchManageEntity dto) {
|
||||
if (ObjectUtil.isEmpty(dto) || ObjectUtil.isEmpty(dto.getParentId())) return;
|
||||
private void updateMchCount(Long orgParentId) {
|
||||
if (ObjectUtil.equals(orgParentId, -1L)) return;
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
|
||||
.eq(MchManageEntity::getParentId, dto.getParentId())
|
||||
.eq(MchManageEntity::getParentId, orgParentId)
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(count)) {
|
||||
MchManageEntity updateEntity = new MchManageEntity();
|
||||
updateEntity.setId(dto.getParentId());
|
||||
updateEntity.setId(orgParentId);
|
||||
updateEntity.setMchCount(count);
|
||||
updateById(updateEntity);
|
||||
}
|
||||
|
||||
+79
@@ -1,18 +1,24 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.mch;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRuleJoinDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRuleJoinDtoEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleMchConfigMapper;
|
||||
import com.bsd.pjcloud.wallet.service.MchManageService;
|
||||
import com.bsd.pjcloud.wallet.service.MchRuleJoinControllerService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@@ -20,6 +26,53 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Service
|
||||
public class MchRuleJoinControllerServiceImpl extends ServiceImpl<WalletRuleMchConfigMapper, MchRuleJoinDtoEntity> implements MchRuleJoinControllerService {
|
||||
|
||||
private final MchManageService mchManageService;
|
||||
|
||||
@Override
|
||||
public Long create(MchRuleJoinDtoEntity dto) {
|
||||
if (existMchRuleJoin(dto)) {
|
||||
throw new RuntimeException("绑定的规则类型不能重复");
|
||||
}
|
||||
if (areMchIdsDistinct(dto)) {
|
||||
throw new RuntimeException("源商户与目标商户不能重复");
|
||||
}
|
||||
MchManageEntity targetMch = mchManageService.getById(dto.getTargetMchId());
|
||||
if (ObjectUtil.isEmpty(targetMch)) {
|
||||
throw new RuntimeException("目标商户不存在");
|
||||
}
|
||||
dto.setTargetDeptId(targetMch.getDeptId());
|
||||
baseMapper.insert(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long edit(MchRuleJoinDtoEntity dto) {
|
||||
if (existMchRuleJoin(dto)) {
|
||||
throw new RuntimeException("绑定的规则类型不能重复");
|
||||
}
|
||||
if (areMchIdsDistinct(dto)) {
|
||||
throw new RuntimeException("源商户与目标商户不能重复");
|
||||
}
|
||||
MchManageEntity targetMch = mchManageService.getById(dto.getTargetMchId());
|
||||
if (ObjectUtil.isEmpty(targetMch)) {
|
||||
throw new RuntimeException("目标商户不存在");
|
||||
}
|
||||
dto.setTargetDeptId(targetMch.getDeptId());
|
||||
baseMapper.updateById(dto);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delByIds(ArrayList<Long> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
baseMapper.deleteByIds(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MchRuleJoinDtoVo joinDetail(Long id) {
|
||||
return baseMapper.joinDetail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限分页查询
|
||||
*/
|
||||
@@ -27,4 +80,30 @@ public class MchRuleJoinControllerServiceImpl extends ServiceImpl<WalletRuleMchC
|
||||
public Page<MchRuleJoinDtoVo> pageScopeList(Page page, MchRuleJoinDto dto, DataScope dataScope) {
|
||||
return baseMapper.pageScopeList(page, dto, dataScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否重复
|
||||
*/
|
||||
private boolean existMchRuleJoin(MchRuleJoinDtoEntity dto) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchRuleJoinDtoEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getSourceMchId()), MchRuleJoinDtoEntity::getSourceMchId, dto.getSourceMchId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getTargetMchId()), MchRuleJoinDtoEntity::getTargetMchId, dto.getTargetMchId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getRulePriceConfigId()), MchRuleJoinDtoEntity::getRulePriceConfigId, dto.getRulePriceConfigId())
|
||||
.ne(ObjectUtil.isNotEmpty(dto.getId()), MchRuleJoinDtoEntity::getId, dto.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
return count >= 1;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sourceMchId和targetMchId是否重复
|
||||
*/
|
||||
private boolean areMchIdsDistinct(MchRuleJoinDtoEntity dto) {
|
||||
if (!ObjectUtil.isAllNotEmpty(dto.getSourceMchId(), dto.getTargetMchId())) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtil.equals(dto.getSourceMchId(), dto.getTargetMchId());
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -3,10 +3,13 @@ package com.bsd.pjcloud.wallet.service.impl.mch;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.dto.mch.MchRulePriceConfigDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.mch.MchRulePriceConfigEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.mch.MchRulePriceConfigVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.rule.WalletRulePriceConfigMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRulePriceConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -71,11 +74,18 @@ public class MchRulePriceConfigServiceImpl extends ServiceImpl<WalletRulePriceCo
|
||||
// 删除缓存
|
||||
list.forEach(v -> {
|
||||
redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_RULE_PRICE_CONFIG_DETAIL + v);
|
||||
// walletThirdZyService.syncAllMch(v, Boolean.TRUE);
|
||||
});
|
||||
baseMapper.deleteByIds(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限分页查询
|
||||
*/
|
||||
@Override
|
||||
public Page<MchRulePriceConfigVo> scopePageList(Page page, MchRulePriceConfigDto dto, DataScope dataScope) {
|
||||
return baseMapper.scopePageList(page, dto, dataScope);
|
||||
}
|
||||
|
||||
private boolean existRulePriceType(String rulePriceConfigType, Long id) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchRulePriceConfigEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(rulePriceConfigType), MchRulePriceConfigEntity::getRulePriceType, rulePriceConfigType)
|
||||
|
||||
+26
-4
@@ -6,7 +6,7 @@
|
||||
<result property="id" column="id"/>
|
||||
<result property="sourceMchId" column="source_mch_id"/>
|
||||
<result property="targetMchId" column="target_mch_id"/>
|
||||
<result property="tragetDeptId" column="traget_dept_id"/>
|
||||
<result property="targetDeptId" column="target_dept_id"/>
|
||||
<result property="rulePriceConfigId" column="rule_price_config_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
@@ -47,12 +47,34 @@
|
||||
p.id as rulePirceConfigId,
|
||||
p.rule_price_type,
|
||||
p.base_price,
|
||||
p.multiple
|
||||
from wallet_rule_mch_config a
|
||||
left join wallet_rule_price_config p on a.rule_price_config_id = p.id
|
||||
p.multiple,
|
||||
source.name as sourceMchName,
|
||||
target.name as targetMchName
|
||||
from mch_rule_join a
|
||||
left join mch_rule_price_config p on a.rule_price_config_id = p.id
|
||||
left join mch_manage source on source.id = a.source_mch_id
|
||||
left join mch_manage target on target.id = a.target_mch_id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
order by a.create_time desc , a.id desc
|
||||
</select>
|
||||
|
||||
<select id="joinDetail" resultType="com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo">
|
||||
<include refid="selectA"/>
|
||||
p.id as rulePirceConfigId,
|
||||
p.rule_price_type as rulePriceType,
|
||||
p.base_price as basePrice,
|
||||
p.multiple as multiple,
|
||||
source.name as sourceMchName,
|
||||
target.name as targetMchName
|
||||
from mch_rule_join a
|
||||
left join mch_rule_price_config p on a.rule_price_config_id = p.id
|
||||
left join mch_manage source on source.id = a.source_mch_id
|
||||
left join mch_manage target on target.id = a.target_mch_id
|
||||
<where>
|
||||
a.id = #{id}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+2
@@ -15,4 +15,6 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user