记得上下班打卡 | git大法好,push需谨慎

Commit a7e03161 authored by 姜秀龙's avatar 姜秀龙

自测完善

parent 6d70c683
......@@ -8,13 +8,21 @@ CREATE TABLE IF NOT EXISTS `kylin_order_refund_reasons` (
`placeholder` varchar(200) NOT NULL DEFAULT '' COMMENT '二级输入placeholder',
`is_applied` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已应用 0未应用 1应用中',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,越大越靠前',
`is_deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除',
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`mid`),
UNIQUE KEY `uk_reason_id` (`reason_id`),
KEY `idx_is_applied_sort` (`is_applied`, `sort`)
KEY `idx_is_applied_sort` (`is_applied`, `sort`),
KEY `idx_is_deleted` (`is_deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='演出票退款原因配置';
-- 已建表环境补逻辑删除字段(若已存在可忽略报错)
ALTER TABLE `kylin_order_refund_reasons`
ADD COLUMN `is_deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除 0未删除 1已删除' AFTER `sort`;
ALTER TABLE `kylin_order_refund_reasons`
ADD KEY `idx_is_deleted` (`is_deleted`);
ALTER TABLE `kylin_order_refunds`
ADD COLUMN `reason_id` varchar(32) DEFAULT NULL COMMENT '退款原因配置ID' AFTER `reason`,
ADD COLUMN `reason_detail` varchar(200) DEFAULT NULL COMMENT '退款原因二级补充说明' AFTER `reason_id`;
-- 演出票退款原因管理 - 菜单与权限
-- 挂载在「正在映画」顶级菜单下
-- 挂载在:正在映画 → 退款管理 下面(与「订单退款列表」「演出退款管理」同级)
SET @zhengzaiRootId = (
SELECT menu_id
FROM sys_menu
WHERE menu_name = '正在映画'
AND parent_id = 0
AND menu_type = 'M'
LIMIT 1
);
SET @refundParentId = (
SET @refundManageId = (
SELECT menu_id
FROM sys_menu
WHERE menu_name LIKE '%退款%'
WHERE menu_name = '退款管理'
AND parent_id = @zhengzaiRootId
AND menu_type = 'M'
LIMIT 1
);
-- 若无退款父菜单则挂到正在映画根下
SET @parentId = IFNULL(@refundParentId, @zhengzaiRootId);
INSERT INTO sys_menu (menu_name, parent_id, order_num, url, target, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
VALUES ('退款原因管理', @parentId, 20, '/kylin/refundReasons', 'menuItem', 'C', '0', 'kylin:refundReasons:list', 'fa fa-list', 'admin', NOW(), '', NULL, '演出票退款原因配置');
VALUES ('退款原因管理', @refundManageId, 2, '/kylin/refundReasons', 'menuItem', 'C', '0', 'kylin:refundReasons:list', '#', 'admin', NOW(), '', NULL, '演出票退款原因配置');
SET @menuId = LAST_INSERT_ID();
......
......@@ -55,6 +55,9 @@ public class OrderRefundReasonParam {
if (entity.getIsApplied() == null) {
entity.setIsApplied(0);
}
if (entity.getIsDeleted() == null) {
entity.setIsDeleted(0);
}
if (entity.getSort() == null) {
entity.setSort(0);
}
......
......@@ -86,7 +86,7 @@ public class KylinOrderRefundReasonsAdminController extends BaseController {
public AjaxResult delete(OrderRefundReasonParam param) {
List<String> ids = param.getIds();
Boolean result = refundReasonAdminService.delete(ids);
return result ? success("删除成功") : error("删除失败(应用中的原因需先取消应用)");
return result ? success("删除成功") : error("删除失败(应用中的原因需先取消应用,或数据不存在)");
}
@Log(title = "应用/取消应用退款原因", businessType = BusinessType.UPDATE)
......@@ -107,6 +107,6 @@ public class KylinOrderRefundReasonsAdminController extends BaseController {
@ResponseBody
public AjaxResult appliedList() {
List<OrderRefundReasonVo> list = refundReasonAdminService.listApplied();
return success(list);
return AjaxResult.success(list);
}
}
......@@ -29,10 +29,10 @@
</div>
</div>
<div class="form-group" id="placeholderGroup" style="display:none;">
<label class="col-sm-3 control-label">补充输入提示</label>
<label class="col-sm-3 control-label is-required">二级输入 placeholder</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="placeholder" id="placeholder"
maxlength="200" placeholder="二级输入框 placeholder">
maxlength="200" placeholder="请输入补充说明的提示文案">
</div>
</div>
<div class="form-group">
......@@ -48,12 +48,26 @@
<script type="text/javascript">
var prefix = ctx + "kylin/refundReasons";
function togglePlaceholderGroup() {
if ($('input[name="needDetail"]:checked').val() == '1') {
$('#placeholderGroup').show();
} else {
$('#placeholderGroup').hide();
$('#placeholder').val('');
}
}
function submitHandler() {
var name = $('#name').val().trim();
if (!name) {
$.modal.alertWarning("请填写退款理由名称");
return false;
}
var needDetail = $('input[name="needDetail"]:checked').val();
if (needDetail == '1' && !$('#placeholder').val().trim()) {
$.modal.alertWarning("请填写二级输入 placeholder");
return false;
}
if ($.validate.form()) {
var data = $('#form-reason-add').serializeArray();
$.operate.save(prefix + "/create", data);
......@@ -61,14 +75,9 @@
}
$(function () {
$('input[name="needDetail"]').on('change', function () {
if ($(this).val() == '1') {
$('#placeholderGroup').show();
} else {
$('#placeholderGroup').hide();
$('#placeholder').val('');
}
});
// 本页 radio 走 iCheck,必须用 ifChecked,否则选「是」不会展示 placeholder
$('input[name="needDetail"]').on('ifChecked change', togglePlaceholderGroup);
togglePlaceholderGroup();
});
</script>
</body>
......
......@@ -78,7 +78,7 @@
},
{
field: 'placeholder',
title: '补充提示文案'
title: '二级输入placeholder'
},
{
field: 'isApplied',
......
......@@ -35,10 +35,10 @@
</div>
<div class="form-group" id="placeholderGroup"
th:style="${RefundReasonVo.needDetail == 1} ? '' : 'display:none;'">
<label class="col-sm-3 control-label">补充输入提示</label>
<label class="col-sm-3 control-label is-required">二级输入 placeholder</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="placeholder" id="placeholder"
maxlength="200" placeholder="二级输入框 placeholder"
maxlength="200" placeholder="请输入补充说明的提示文案"
th:value="${RefundReasonVo.placeholder}">
</div>
</div>
......@@ -56,6 +56,15 @@
<script type="text/javascript">
var prefix = ctx + "kylin/refundReasons";
function togglePlaceholderGroup() {
if ($('input[name="needDetail"]:checked').val() == '1') {
$('#placeholderGroup').show();
} else {
$('#placeholderGroup').hide();
$('#placeholder').val('');
}
}
function submitHandler() {
if ($('#form-reason-edit').length === 0) {
$.modal.alertWarning("应用中的退款原因不可编辑");
......@@ -66,6 +75,11 @@
$.modal.alertWarning("请填写退款理由名称");
return false;
}
var needDetail = $('input[name="needDetail"]:checked').val();
if (needDetail == '1' && !$('#placeholder').val().trim()) {
$.modal.alertWarning("请填写二级输入 placeholder");
return false;
}
if ($.validate.form()) {
var data = $('#form-reason-edit').serializeArray();
$.operate.save(prefix + "/update", data);
......@@ -73,14 +87,9 @@
}
$(function () {
$('input[name="needDetail"]').on('change', function () {
if ($(this).val() == '1') {
$('#placeholderGroup').show();
} else {
$('#placeholderGroup').hide();
$('#placeholder').val('');
}
});
// 本页 radio 走 iCheck,必须用 ifChecked,否则选「是」不会展示 placeholder
$('input[name="needDetail"]').on('ifChecked change', togglePlaceholderGroup);
togglePlaceholderGroup();
});
</script>
</body>
......
......@@ -50,8 +50,9 @@ public class KylinOrderRefundReasonAdminServiceImpl
String reasonId = IDGenerator.nextSnowId();
LocalDateTime now = LocalDateTime.now();
KylinOrderRefundReasons entity = param.getFields(reasonId, now);
// 新建默认未应用
// 新建默认未应用、未删除
entity.setIsApplied(0);
entity.setIsDeleted(0);
reasonsMapper.insert(entity);
refreshAppliedCache();
return true;
......@@ -68,7 +69,9 @@ public class KylinOrderRefundReasonAdminServiceImpl
return false;
}
KylinOrderRefundReasons existing = reasonsMapper.selectOne(
new QueryWrapper<KylinOrderRefundReasons>().eq("reason_id", param.getReasonId())
new QueryWrapper<KylinOrderRefundReasons>()
.eq("reason_id", param.getReasonId())
.eq("is_deleted", 0)
);
if (existing == null) {
return false;
......@@ -78,13 +81,15 @@ public class KylinOrderRefundReasonAdminServiceImpl
return false;
}
KylinOrderRefundReasons entity = param.getFields(null, null);
// 不允许通过 update 直接改应用态
// 不允许通过 update 直接改应用态/删除态
entity.setIsApplied(null);
entity.setIsDeleted(null);
entity.setReasonId(null);
entity.setCreatedAt(null);
entity.setUpdatedAt(LocalDateTime.now());
reasonsMapper.update(entity, new UpdateWrapper<KylinOrderRefundReasons>()
.eq("reason_id", param.getReasonId()));
.eq("reason_id", param.getReasonId())
.eq("is_deleted", 0));
refreshAppliedCache();
return true;
} catch (Exception e) {
......@@ -96,7 +101,9 @@ public class KylinOrderRefundReasonAdminServiceImpl
@Override
public OrderRefundReasonVo detail(String reasonId) {
KylinOrderRefundReasons data = reasonsMapper.selectOne(
new QueryWrapper<KylinOrderRefundReasons>().eq("reason_id", reasonId)
new QueryWrapper<KylinOrderRefundReasons>()
.eq("reason_id", reasonId)
.eq("is_deleted", 0)
);
if (data == null) {
return null;
......@@ -109,6 +116,12 @@ public class KylinOrderRefundReasonAdminServiceImpl
try {
PageHelper.startPage(param.getPageNum(), param.getPageSize());
Map<String, Object> paramMap = BeanUtil.convertBeanToMap(param);
// convertBeanToMap(isAll) 会把 null 变成 "",isApplied=0 需保留为整型
if (param.getIsApplied() != null) {
paramMap.put("isApplied", param.getIsApplied());
} else {
paramMap.remove("isApplied");
}
List<KylinOrderRefundReasons> list = reasonsMapper.searchList(paramMap);
if (list != null) {
for (KylinOrderRefundReasons item : list) {
......@@ -129,14 +142,25 @@ public class KylinOrderRefundReasonAdminServiceImpl
return false;
}
List<KylinOrderRefundReasons> list = reasonsMapper.selectList(
new QueryWrapper<KylinOrderRefundReasons>().in("reason_id", reasonIds)
new QueryWrapper<KylinOrderRefundReasons>()
.in("reason_id", reasonIds)
.eq("is_deleted", 0)
);
if (list == null || list.isEmpty()) {
return false;
}
for (KylinOrderRefundReasons item : list) {
if (item.getIsApplied() != null && item.getIsApplied() == 1) {
return false;
}
}
reasonsMapper.delete(new QueryWrapper<KylinOrderRefundReasons>().in("reason_id", reasonIds));
// 逻辑删除,保留 reason_id 供历史退款单关联
KylinOrderRefundReasons update = new KylinOrderRefundReasons();
update.setIsDeleted(1);
update.setUpdatedAt(LocalDateTime.now());
reasonsMapper.update(update, new UpdateWrapper<KylinOrderRefundReasons>()
.in("reason_id", reasonIds)
.eq("is_deleted", 0));
refreshAppliedCache();
return true;
} catch (Exception e) {
......@@ -152,7 +176,9 @@ public class KylinOrderRefundReasonAdminServiceImpl
return false;
}
KylinOrderRefundReasons existing = reasonsMapper.selectOne(
new QueryWrapper<KylinOrderRefundReasons>().eq("reason_id", reasonId)
new QueryWrapper<KylinOrderRefundReasons>()
.eq("reason_id", reasonId)
.eq("is_deleted", 0)
);
if (existing == null) {
return false;
......@@ -160,7 +186,9 @@ public class KylinOrderRefundReasonAdminServiceImpl
KylinOrderRefundReasons update = new KylinOrderRefundReasons();
update.setIsApplied(isApplied);
update.setUpdatedAt(LocalDateTime.now());
reasonsMapper.update(update, new UpdateWrapper<KylinOrderRefundReasons>().eq("reason_id", reasonId));
reasonsMapper.update(update, new UpdateWrapper<KylinOrderRefundReasons>()
.eq("reason_id", reasonId)
.eq("is_deleted", 0));
refreshAppliedCache();
return true;
} catch (Exception e) {
......
......@@ -46,6 +46,11 @@ public class KylinOrderRefundReasons implements Serializable, Cloneable {
*/
private Integer isApplied;
/**
* 是否删除 0未删除 1已删除
*/
private Integer isDeleted;
/**
* 排序,越大越靠前
*/
......
......@@ -11,14 +11,17 @@
placeholder,
is_applied,
sort,
is_deleted,
created_at,
updated_at
FROM kylin_order_refund_reasons
<where>
AND is_deleted = 0
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="isApplied != null and isApplied != ''">
<!-- isApplied=0 时不能写 != '',OGNL 会把 0 当成空 -->
<if test="isApplied != null">
AND is_applied = #{isApplied}
</if>
</where>
......@@ -34,10 +37,12 @@
placeholder,
is_applied,
sort,
is_deleted,
created_at,
updated_at
FROM kylin_order_refund_reasons
WHERE is_applied = 1
AND is_deleted = 0
ORDER BY sort DESC, mid DESC
</select>
......
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