## Opt - 商品自定义排序

This commit is contained in:
sangelxiu1 2025-07-21 09:26:10 +08:00 committed by cabbage
parent c06b96e98a
commit 5eb2720abc
4 changed files with 23 additions and 4 deletions

View File

@ -297,7 +297,7 @@ public class BdWaresController extends BaseController {
if (!isPutOn) {
return AjaxResult.error("产品规格至少有一个上架");
}
wares.setSort(0);
// wares.setSort(0);
iBdWaresService.saveWares(wares, userTokenService.getLoginUser());
return AjaxResult.success(wares.getWaresCode());
}
@ -429,7 +429,7 @@ public class BdWaresController extends BaseController {
}
}
waresParams.setSort(0);
// waresParams.setSort(0);
iBdWaresService.updateWares(waresParams, userTokenService.getLoginUser());
return AjaxResult.success(waresParams.getWaresCode());
}
@ -794,6 +794,10 @@ public class BdWaresController extends BaseController {
String waresCode = CreateNormsCodeUtils.createWaresCode(iBdWaresService.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;
@ -88,6 +89,15 @@ public class BdWaresServiceImpl extends ServiceImpl<BdWaresMapper, BdWares> impl
@DubboReference
IRangeServiceApi iRangeServiceApi;
@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

@ -232,7 +232,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">
@ -448,7 +448,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>
<!-- 查询盒数商品对应产品列表 -->