3
0
Fork 0

## Opt - 商品自定义排序

This commit is contained in:
sangelxiu1 2025-07-21 09:27:12 +08:00
parent 1e0d0989c7
commit 18def4fffc
4 changed files with 23 additions and 4 deletions

View File

@ -327,7 +327,7 @@ public class BdWaresController extends BaseController {
if (!isPutOn) {
return AjaxResult.error("产品规格至少有一个上架");
}
wares.setSort(0);
// wares.setSort(0);
waresService.saveWares(wares, userTokenService.getLoginUser());
return AjaxResult.success(wares.getWaresCode());
}
@ -458,7 +458,7 @@ public class BdWaresController extends BaseController {
}
}
waresParams.setSort(0);
// waresParams.setSort(0);
waresService.updateWares(waresParams, userTokenService.getLoginUser());
return AjaxResult.success(waresParams.getWaresCode());
}
@ -825,6 +825,10 @@ public class BdWaresController extends BaseController {
String waresCode = CreateNormsCodeUtils.createWaresCode(waresService.getLastWaresCode());
return AjaxResult.success(waresCode);
}
@GetMapping("/getMaxSortNum")
public AjaxResult getMaxSortNum() {
return AjaxResult.success("请求成功!", iBdWaresService.getMaxSortNum());
}
/**
* 商品序号创建

View File

@ -23,6 +23,11 @@ import java.util.Map;
*/
public interface IBdWaresService extends IService<BdWares> {
/**
* 获取最大排序值
* @return
*/
int getMaxSortNum();
/**
* 新增商品基础信息
*

View File

@ -1,6 +1,7 @@
package com.hzs.sale.wares.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -95,6 +96,15 @@ public class BdWaresServiceImpl extends ServiceImpl<BdWaresMapper, BdWares> impl
@DubboReference
ITransactionServiceApi transactionServiceApi;
@Override
public int getMaxSortNum() {
Integer maxSort = this.getMaxSort(SecurityUtils.getPkCountry());
if(ObjectUtil.isNotEmpty(maxSort)){
return maxSort + 1;
}
return 1;
}
@Override
@Transactional(rollbackFor = Exception.class)
public BdWares saveWares(WaresParams waresParams, LoginUser user) {

View File

@ -228,7 +228,7 @@
<if test="waresStatus != null">
and bw.WARES_STATUS &lt;= #{waresStatus}
</if>
order by bw.SORT_STATUS desc , bw.WARES_PRICE ,bw.CREATION_TIME desc
order by bw.sort desc, bw.CREATION_TIME desc
</select>
<select id="selectByMoveUpSort" resultType="integer">
@ -437,7 +437,7 @@
<if test="param.systemType">
and bw.system_type = #{param.systemType}
</if>
order by bw.SORT_STATUS desc , bw.WARES_PRICE ,bw.CREATION_TIME desc
order by bw.SORT desc, bw.CREATION_TIME desc
</select>
<!-- 查询盒数商品对应产品列表 -->