feat:店铺折扣
This commit is contained in:
1 parent
aa3897a651
commit
8e5c8ea24c
6 files changed
+34
-3
No files matched your search
@@ -0,0 +1,4 @@
|
||||
-- 商户表新增优惠折扣字段:取值 1-99,写 10 表示 1 折(值越小折扣越大),为空表示无折扣。
|
||||
-- app 端商户列表(/wallet/mch-manage/app/page-join)按"有折扣优先、折扣大(值小)优先"排序。
|
||||
ALTER TABLE mch_manage
|
||||
ADD COLUMN discounts_rate int DEFAULT NULL COMMENT '优惠折扣(1-99,10=1折)' AFTER discounts_price;
|
||||
@@ -107,6 +107,7 @@ CREATE TABLE mch_manage
|
||||
address_des varchar(256) DEFAULT NULL COMMENT '商户地址',
|
||||
sort int NOT NULL COMMENT '排序',
|
||||
discounts_price varchar(256) NOT NULL COMMENT '优惠价格(没实际作用)',
|
||||
discounts_rate int DEFAULT NULL COMMENT '优惠折扣(1-99,10=1折)',
|
||||
cooperation_status varchar(64) NOT NULL COMMENT '合作状态',
|
||||
mch_count int NOT NULL COMMENT '分店数量',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
|
||||
+6
@@ -147,6 +147,12 @@ public class MchManageEntity extends Model<MchManageEntity> {
|
||||
@Schema(description = "优惠价格(没实际作用)")
|
||||
private String discountsPrice;
|
||||
|
||||
/**
|
||||
* 优惠折扣(1-99,10=1折,空为无折扣)
|
||||
*/
|
||||
@Schema(description = "优惠折扣(1-99,10=1折,空为无折扣)")
|
||||
private Integer discountsRate;
|
||||
|
||||
/**
|
||||
* 合作状态
|
||||
*/
|
||||
|
||||
+2
-3
@@ -30,9 +30,8 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
|
||||
.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())
|
||||
.orderByDesc(MchManageEntity::getSort)
|
||||
.orderByDesc(MchManageEntity::getCreateTime)
|
||||
.orderByDesc(MchManageEntity::getId);
|
||||
// 优惠折扣(1-99,10=1折)越小折扣越大:有折扣的排在无折扣(ifnull补100)前面,1折排在2折前面
|
||||
.last("order by ifnull(discounts_rate, 100) asc, sort desc, create_time desc, id desc");
|
||||
return selectJoinPage(page, MchManageVo.class, wrapper);
|
||||
}
|
||||
|
||||
|
||||
+19
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
@@ -107,6 +108,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(MchManageEntity dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getParentId())) dto.setParentId(-1L);
|
||||
checkDiscountsRate(dto.getDiscountsRate());
|
||||
if (existName(dto.getName(), dto.getTypes(), null)) {
|
||||
throw new RuntimeException("商户名不能重复");
|
||||
}
|
||||
@@ -137,6 +139,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
beforeInvocation = true
|
||||
)
|
||||
public void edit(MchManageEntity dto) {
|
||||
checkDiscountsRate(dto.getDiscountsRate());
|
||||
if (existName(dto.getName(), dto.getTypes(), dto.getId())) {
|
||||
throw new RuntimeException("商户名不能重复");
|
||||
}
|
||||
@@ -171,6 +174,12 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(dto);
|
||||
// 全局 update-strategy=not_null 会跳过 null 字段,优惠折扣在表单清空保存时需显式置空
|
||||
if (dto.getDiscountsRate() == null) {
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<MchManageEntity>()
|
||||
.set(MchManageEntity::getDiscountsRate, null)
|
||||
.eq(MchManageEntity::getId, dto.getId()));
|
||||
}
|
||||
updateMchCount(orgParentId);
|
||||
// walletThirdZyService.syncAllMch(dto.getId(), Boolean.FALSE);
|
||||
}
|
||||
@@ -214,6 +223,16 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠折扣取值 1-99(10=1折),为空表示无折扣
|
||||
*/
|
||||
private void checkDiscountsRate(Integer discountsRate) {
|
||||
if (ObjectUtil.isEmpty(discountsRate)) return;
|
||||
if (discountsRate < 1 || discountsRate > 99) {
|
||||
throw new RuntimeException("优惠折扣范围为1-99(10表示1折)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 parent_id 实时统计各主店可见分店数(visible_mobile=1,逻辑删除自动过滤),
|
||||
* 覆盖 mch_manage.mch_count 冗余计数,避免分店增删/隐藏后计数与实际不一致
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<result property="addressDes" column="address_des"/>
|
||||
<result property="supType" column="sup_type"/>
|
||||
<result property="discountsPrice" column="discounts_price"/>
|
||||
<result property="discountsRate" column="discounts_rate"/>
|
||||
<result property="cooperationStatus" column="cooperation_status"/>
|
||||
<result property="mchCount" column="mch_count"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
@@ -47,6 +48,7 @@
|
||||
a.sort,
|
||||
a.sup_type,
|
||||
a.discounts_price,
|
||||
a.discounts_rate,
|
||||
a.cooperation_status,
|
||||
a.mch_count,
|
||||
a.platform_ranke,
|
||||
|
||||
Reference in new issue
Block a user