增加了套餐包类目区分

This commit is contained in:
1215525055@qq.com 2025-08-27 09:38:26 +08:00
parent 633c21bff8
commit f1ffb08941
14 changed files with 216 additions and 60 deletions

View File

@ -5,6 +5,7 @@ import cn.com.tenlion.operator.pojo.vos.packageorder.PackageOrderWriteoffVO;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.common.component.SecurityComponent;
import ink.wgink.exceptions.SaveException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
@ -42,7 +43,7 @@ public class PackageOrderController extends DefaultBaseController {
@ApiOperation(value = "购买套餐包-订单", notes = "购买套餐包-订单接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("buy/{infoId}")
public SuccessResultData<String> save(@PathVariable String infoId) {
public SuccessResultData<String> save(@PathVariable String infoId) throws Exception {
try{
PackageOrderAppVO vo = new PackageOrderAppVO();
vo.setUserId(securityComponent.getCurrentUser().getUserId());

View File

@ -21,6 +21,8 @@ public class PackageInfoAppDTO {
private String packageName;
@ApiModelProperty(name = "packageType", value = "类型 MATERIAL 写材料 . ALL 全托管")
private String packageType;
@ApiModelProperty(name = "packageCatalog", value = "类目")
private String packageCatalog;
@ApiModelProperty(name = "packageMode", value = "可购买次数 single(每个用户可购买1次), all(不限)")
private String packageMode;
@ApiModelProperty(name = "packageOriginalPrice", value = "原价/单位分")
@ -40,6 +42,14 @@ public class PackageInfoAppDTO {
@ApiModelProperty(name = "createTime", value = "")
private String createTime;
public String getPackageCatalog() {
return packageCatalog == null ? "" : packageCatalog.trim();
}
public void setPackageCatalog(String packageCatalog) {
this.packageCatalog = packageCatalog;
}
public String getPackageExpire() {
return packageExpire == null ? "" : packageExpire.trim();
}

View File

@ -29,6 +29,8 @@ public class PackageInfoDTO {
private String packageType;
@ApiModelProperty(name = "packageMode", value = "可购买次数 single(每个用户可购买1次), infinite(不限)")
private String packageMode;
@ApiModelProperty(name = "packageCatalog", value = "类目")
private String packageCatalog;
@ApiModelProperty(name = "packageOriginalPrice", value = "原价/单位分")
private Integer packageOriginalPrice;
@ApiModelProperty(name = "packageMoney", value = "套餐价/单位分")
@ -70,6 +72,14 @@ public class PackageInfoDTO {
@ApiModelProperty(name = "userList", value = "")
List<RelatedUserDTO> userList = new ArrayList<>();
public String getPackageCatalog() {
return packageCatalog == null ? "" : packageCatalog.trim();
}
public void setPackageCatalog(String packageCatalog) {
this.packageCatalog = packageCatalog;
}
public String getPackageExpire() {
return packageExpire == null ? "" : packageExpire.trim();
}

View File

@ -29,6 +29,8 @@ public class PackageInfoVO {
@ApiModelProperty(name = "packageType", value = "类型写材料 . 全托管等的枚举名")
@CheckEmptyAnnotation(name = "类型")
private String packageType;
@ApiModelProperty(name = "packageCatalog", value = "类目")
private String packageCatalog;
@ApiModelProperty(name = "packageMode", value = "可购买次数 single(每个用户可购买1次), infinite(不限)")
@CheckEmptyAnnotation(name = "限制")
private String packageMode;
@ -69,6 +71,14 @@ public class PackageInfoVO {
@ApiModelProperty(name = "userList", value = "")
List<RelatedUserVO> userList = new ArrayList<>();
public String getPackageCatalog() {
return packageCatalog == null ? "" : packageCatalog.trim();
}
public void setPackageCatalog(String packageCatalog) {
this.packageCatalog = packageCatalog;
}
public Integer getPackageExpire() {
return packageExpire == null ? 0 : packageExpire;
}

View File

@ -180,7 +180,7 @@ public interface IPackageOrderService {
*/
SuccessResultList<List<PackageOrderDTO>> listPage(ListPage page);
List<PackageOrderDTO> listByUserAndInfo(String packageInfoId, String userId);
List<PackageOrderDTO> listByUserAndInfo(String packageCatalog, String packageInfoId, String userId);
/**
* 套餐包-订单统计

View File

@ -182,9 +182,11 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack
}
@Override
public List<PackageOrderDTO> listByUserAndInfo(String packageInfoId, String userId) {
public List<PackageOrderDTO> listByUserAndInfo(String packageCatalog, String packageInfoId, String userId) {
Map<String, Object> params = super.getHashMap(2);
params.put("packageInfoId", packageInfoId);
if(!StringUtils.isEmpty(packageCatalog))
params.put("packageCatalog", packageCatalog);
params.put("notCheckStatus", "不校验删除状态");
params.put("userId", userId);
return packageOrderDao.list(params);
@ -205,19 +207,10 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack
return false;
}
PackageInfoAppDTO infoAppDTO = orderDTO.getPackageInfoAppDTO();
// 仅限购买1次的
if(infoAppDTO.getPackageMode().equals("single")) {
List<PackageOrderDTO> list = listByUserAndInfo(orderDTO.getPackageInfoId(), orderDTO.getCreator());
Boolean exists = false;
for(PackageOrderDTO dto : list) {
if(dto.getPackagePayStatus().equals("1")) {
exists = true;
}
}
if (exists) {
return false;
}
}
// 校验是否可以购买
checkPay(infoAppDTO, orderDTO);
/**
* 1. 更改到账时间 , 状态
*/
@ -241,19 +234,10 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack
throw new SaveException("该套餐订单已购买");
}
PackageInfoAppDTO infoAppDTO = orderDTO.getPackageInfoAppDTO();
// 仅限购买1次的
if(infoAppDTO.getPackageMode().equals("single")) {
List<PackageOrderDTO> list = listByUserAndInfo(orderDTO.getPackageInfoId(), orderDTO.getCreator());
Boolean exists = false;
for(PackageOrderDTO dto : list) {
if(dto.getPackagePayStatus().equals("1")) {
exists = true;
}
}
if (exists) {
throw new SaveException("该套餐只允许购买一次");
}
}
// 校验是否可以购买
checkPay(infoAppDTO, orderDTO);
/**
* 1. 更改到账时间 , 状态
*/
@ -366,6 +350,36 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack
}
return accessToken;
}
private void checkPay(PackageInfoAppDTO infoAppDTO, PackageOrderDTO orderDTO) {
// 仅限购买1次的
if(infoAppDTO.getPackageMode().equals("single")) {
List<PackageOrderDTO> list = listByUserAndInfo("", orderDTO.getPackageInfoId(), orderDTO.getCreator());
Boolean exists = false;
for(PackageOrderDTO dto : list) {
if(dto.getPackagePayStatus().equals("1")) {
exists = true;
}
}
if (exists) {
throw new SaveException("该套餐只允许购买一次");
}
}
// 仅限同類目购买1次的
if(infoAppDTO.getPackageMode().equals("catalog_single")) {
List<PackageOrderDTO> list = listByUserAndInfo(infoAppDTO.getPackageCatalog(), orderDTO.getPackageInfoId(), orderDTO.getCreator());
Boolean exists = false;
for(PackageOrderDTO dto : list) {
if(dto.getPackagePayStatus().equals("1")) {
exists = true;
}
}
if (exists) {
throw new SaveException("该类套餐只允许购买一次");
}
}
}
@Autowired
private SystemApiPathProperties apiPathProperties;
@Override
@ -383,19 +397,9 @@ public class PackageOrderServiceImpl extends DefaultBaseService implements IPack
throw new SaveException("该套餐订单已购买");
}
PackageInfoAppDTO infoAppDTO = orderDTO.getPackageInfoAppDTO();
// 仅限购买1次的
if(infoAppDTO.getPackageMode().equals("single")) {
List<PackageOrderDTO> list = listByUserAndInfo(orderDTO.getPackageInfoId(), orderDTO.getCreator());
Boolean exists = false;
for(PackageOrderDTO dto : list) {
if(dto.getPackagePayStatus().equals("1")) {
exists = true;
}
}
if (exists) {
throw new SaveException("该套餐只允许购买一次");
}
}
// 校验是否可以购买
checkPay(infoAppDTO, orderDTO);
/**
* 扣钱

View File

@ -529,6 +529,14 @@
t1.recharge_remark
FROM
operator_account_recharge t1
LEFT JOIN
sys_user t2
ON
t1.account_id = t2.user_id
LEFT JOIN
user_info t3
ON
t2.user_id = t3.user_id
WHERE
t1.is_delete = 0
<if test="accountId != null and accountId != ''">
@ -552,6 +560,12 @@
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t2.user_name LIKE CONCAT('%', #{keywords}, '%')
OR
t2.user_username LIKE CONCAT('%', #{keywords}, '%')
OR
t3.user_info_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.recharge_check_remark LIKE CONCAT('%', #{keywords}, '%')
)
</if>
@ -589,6 +603,14 @@
SUM(recharge_money)
FROM
operator_account_recharge t1
LEFT JOIN
sys_user t2
ON
t1.account_id = t2.user_id
LEFT JOIN
user_info t3
ON
t2.user_id = t3.user_id
WHERE
t1.is_delete = 0
<if test="accountId != null and accountId != ''">
@ -611,8 +633,14 @@
</if>
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.recharge_check_remark LIKE CONCAT('%', #{keywords}, '%')
<!-- 这里添加其他条件 -->
t2.user_name LIKE CONCAT('%', #{keywords}, '%')
OR
t2.user_username LIKE CONCAT('%', #{keywords}, '%')
OR
t3.user_info_name LIKE CONCAT('%', #{keywords}, '%')
OR
t1.recharge_check_remark LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">

View File

@ -34,10 +34,10 @@
t3.account_money
FROM
sys_user t2
LEFT JOIN
LEFT JOIN
operator_account t3
ON
t2.user_id = t3.user_id
ON
t2.user_id = t3.user_id
WHERE
t2.is_delete = 0 AND t2.user_id = #{userId}
</select>

View File

@ -7,6 +7,7 @@
<result column="package_name" property="packageName"/>
<result column="package_expire" property="packageExpire"/>
<result column="package_type" property="packageType"/>
<result column="package_catalog" property="packageCatalog"/>
<result column="package_mode" property="packageMode"/>
<result column="package_original_price" property="packageOriginalPrice"/>
<result column="package_money" property="packageMoney"/>
@ -23,6 +24,7 @@
<result column="package_name" property="packageName"/>
<result column="package_expire" property="packageExpire"/>
<result column="package_type" property="packageType"/>
<result column="package_catalog" property="packageCatalog"/>
<result column="package_mode" property="packageMode"/>
<result column="package_original_price" property="packageOriginalPrice"/>
<result column="package_money" property="packageMoney"/>
@ -104,6 +106,7 @@
package_name,
package_expire,
package_type,
package_catalog,
package_mode,
package_original_price,
package_money,
@ -129,6 +132,7 @@
#{packageName},
#{packageExpire},
#{packageType},
#{packageCatalog},
#{packageMode},
#{packageOriginalPrice},
#{packageMoney},
@ -246,6 +250,7 @@
<if test="packageOrder != null">
package_order = #{packageOrder},
</if>
package_catalog = #{packageCatalog},
package_description = #{packageDescription},
gmt_modified = #{gmtModified},
modifier = #{modifier},
@ -261,6 +266,7 @@
t1.package_expire,
t1.package_type,
t1.package_mode,
t1.package_catalog,
t1.package_original_price,
t1.package_money,
t1.package_count,
@ -366,6 +372,7 @@
t1.package_expire,
t1.package_name,
t1.package_type,
t1.package_catalog,
t1.package_mode,
t1.package_original_price,
t1.package_money,
@ -401,12 +408,20 @@
)
OR
(
t1.package_mode = 'single' AND t1.package_limit_users != '' AND t1.package_limit_users LIKE CONCAT('%', #{userId} ,'%') AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 WHERE t1.package_info_id = t2.package_info_id AND t2.package_pay_status = '1' AND t2.creator = #{userId})
t1.package_mode = 'single' AND t1.package_limit_users != '' AND t1.package_limit_users LIKE CONCAT('%', #{userId} ,'%') AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 WHERE t1.package_info_id = t2.package_info_id AND t2.package_pay_status = '1' AND t2.creator = #{userId})
)
OR
(
t1.package_mode = 'single' AND t1.package_limit_users = '' AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 WHERE t1.package_info_id = t2.package_info_id AND t2.package_pay_status = '1' AND t2.creator = #{userId})
)
t1.package_mode = 'single' AND t1.package_limit_users = '' AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 WHERE t1.package_info_id = t2.package_info_id AND t2.package_pay_status = '1' AND t2.creator = #{userId})
)
OR
(
t1.package_mode = 'catalog_single' AND t1.package_limit_users != '' AND t1.package_limit_users LIKE CONCAT('%', #{userId} ,'%') AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 LEFT JOIN operator_package_info t3 ON t2.package_info_id = t3.package_info_id WHERE t3.package_catalog = t1.package_catalog AND t2.package_pay_status = '1' AND t2.creator = #{userId})
)
OR
(
t1.package_mode = 'catalog_single' AND t1.package_limit_users = '' AND 1 > (SELECT COUNT(1) FROM operator_package_order t2 LEFT JOIN operator_package_info t3 ON t2.package_info_id = t3.package_info_id WHERE t1.package_catalog = t3.package_catalog AND t2.package_pay_status = '1' AND t2.creator = #{userId})
)
)
ORDER BY t1.package_order , t1.package_onlien_time DESC
</select>
@ -417,6 +432,7 @@
t1.package_expire,
t1.package_name,
t1.package_type,
t1.package_catalog,
t1.package_mode,
t1.package_original_price,
t1.package_money,
@ -496,7 +512,7 @@
#{packageInfoIds[${index}]}
</foreach>
</if>
ORDER BY t1.package_order , t1.create_time DESC
ORDER BY t1.package_status DESC, t1.package_order , t1.create_time DESC
</select>
<!-- 套餐包列表 -->

View File

@ -345,7 +345,13 @@
AND t1.package_pay_status = #{packagePayStatus}
</if>
<if test="packageInfoId != null and packageInfoId != ''">
AND t1.package_info_id = #{packageInfoId}
AND
(
t1.package_info_id = #{packageInfoId}
<if test="packageCatalog != null and packageCatalog != ''">
OR t4.package_catalog = #{packageCatalog}
</if>
)
</if>
<if test="packageType != null and packageType != ''">
AND t4.package_type = #{packageType}

View File

@ -21,6 +21,9 @@
<div class="layui-card-body">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<div class="layui-inline">
<input type="text" style="cursor: pointer" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
</div>
@ -204,6 +207,7 @@
// 修复:使用正确的选择器获取单选按钮的值
var orderMode = $('input[name="orderMode"]:checked').val();
var data = {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
orderMode: orderMode,
endTime: $('#endTime').val(),

View File

@ -126,12 +126,15 @@
return rowData;
}
},
{field: 'packageMode', width: 180, title: '限制', align:'center',
{field: 'packageMode', width: 200, title: '限制', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
if(rowData == 'catalog_single') {
return '<b>同类目每个用户可购买1次</b>';
}
if(rowData == 'single') {
return '<b>每个用户可购买1次</b>';
}

View File

@ -56,8 +56,9 @@
</div>
<div class="layui-col-xs6">
<div class="layui-form-item" pane="">
<label class="layui-form-label">限制<span style="color: red">*</span></label>
<label class="layui-form-label">购买限制<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="radio" name="packageMode" value="catalog_single" title="同类目下每个用户可购买1次" >
<input type="radio" name="packageMode" value="single" title="每个用户可购买1次" >
<input type="radio" name="packageMode" value="all" title="不限制" >
</div>
@ -98,7 +99,7 @@
</div>
</div>
</div>-->
<div class="layui-col-xs6">
<div class="layui-col-xs3">
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
@ -106,6 +107,20 @@
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-form-item" >
<label class="layui-form-label">类目</label>
<div class="layui-input-block layui-form" id="packageCatalogSelectTemplateBox" lay-filter="packageCatalogSelectTemplateBox"></div>
<script id="packageCatalogSelectTemplate" type="text/html">
<select id="packageCatalog" name="packageCatalog">
<option value="">请选择</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label"><button type="button" class="layui-btn layui-btn-sm selectUserAPI" style="margin-top: -5px;margin-left: -12px;" >选择套餐定向用户群</button></label>
@ -167,6 +182,23 @@
var wangEditorObj = {};
var viewerObj = {};
function initPackageTypSelect(value) {
top.restAjax.get(top.restAjax.path('app/data/listbyparentidrelease/74533f1f-96c9-48c2-9e79-73c5194224c7', []), {}, null, function(code, data, args) {
console.log(data);
laytpl(document.getElementById('packageCatalogSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('packageCatalogSelectTemplateBox').innerHTML = html;
});
form.render('select', 'packageCatalogSelectTemplateBox');
var selectObj = {};
selectObj['packageCatalog'] = value;
form.val('dataForm', selectObj);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
initPackageTypSelect("");
var selectedUsers = [];
var selectedUserIds = "";
$(document).on("click", ".selectUserAPI", function(data) {
@ -174,7 +206,7 @@
top.dialog.dialogData.selectedUsers = selectedUsers;
top.layer.open({
type: 2,
title: "选择优惠券发放用户",
title: "选择套餐包定向用户",
closeBtn: 1,
area: ['90%', '90%'],
shadeClose: false,

View File

@ -55,8 +55,9 @@
</div>
<div class="layui-col-xs6">
<div class="layui-form-item" pane="">
<label class="layui-form-label">限制<span style="color: red">*</span></label>
<label class="layui-form-label">购买限制<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="radio" name="packageMode" value="catalog_single" title="同类目下每个用户可购买1次" >
<input type="radio" name="packageMode" value="single" title="每个用户可购买1次" >
<input type="radio" name="packageMode" value="all" title="不限制" >
</div>
@ -97,7 +98,7 @@
</div>
</div>
</div>-->
<div class="layui-col-xs6">
<div class="layui-col-xs3">
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
@ -105,6 +106,20 @@
</div>
</div>
</div>
<div class="layui-col-xs3">
<div class="layui-form-item">
<label class="layui-form-label">类目</label>
<div class="layui-input-block layui-form" id="packageCatalogSelectTemplateBox" lay-filter="packageCatalogSelectTemplateBox"></div>
<script id="packageCatalogSelectTemplate" type="text/html">
<select id="packageCatalog" name="packageCatalog">
<option value="">请选择</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label"><button type="button" class="layui-btn layui-btn-sm selectUserAPI" style="margin-top: -5px;margin-left: -12px;" >选择套餐定向用户群</button></label>
@ -167,6 +182,23 @@
var viewerObj = {};
var packageInfoId = top.restAjax.params(window.location.href).packageInfoId;
function initPackageTypSelect(value) {
top.restAjax.get(top.restAjax.path('app/data/listbyparentidrelease/74533f1f-96c9-48c2-9e79-73c5194224c7', []), {}, null, function(code, data, args) {
console.log(data);
laytpl(document.getElementById('packageCatalogSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('packageCatalogSelectTemplateBox').innerHTML = html;
});
form.render('select', 'packageCatalogSelectTemplateBox');
var selectObj = {};
selectObj['packageCatalog'] = value;
form.val('dataForm', selectObj);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
var selectedUsers = [];
var selectedUserIds = "";
$(document).on("click", ".selectUserAPI", function(data) {
@ -174,7 +206,7 @@
top.dialog.dialogData.selectedUsers = selectedUsers;
top.layer.open({
type: 2,
title: "选择优惠券发放用户",
title: "选择套餐包定向用户",
closeBtn: 1,
area: ['90%', '90%'],
shadeClose: false,
@ -217,7 +249,7 @@
for(var i in data) {
dataFormData[i] = data[i] +'';
}
initPackageTypSelect(data.packageCatalog);
selectedUsers = data.userList;
var phones = "";
$("#phone").val(phones);