refactor(framework): 优化代码中的空值判断和字符串处理- 使用 CollUtil.isNotEmpty() 替代空集合判断
- 使用 CharSequenceUtil.isNotEmpty() 替代空字符串判断 - 使用 Objects.nonNull() 替代对象非空判断- 优化部分代码结构以提高可读性
This commit is contained in:
@@ -59,7 +59,7 @@ public class MemberAddressBuyerController {
|
||||
public ResultMessage<MemberAddress> addShippingAddress(@Valid MemberAddress shippingAddress) {
|
||||
//添加会员地址
|
||||
shippingAddress.setMemberId(Objects.requireNonNull(UserContext.getCurrentUser()).getId());
|
||||
if(shippingAddress.getIsDefault()==null){
|
||||
if(Objects.isNull(shippingAddress.getIsDefault())){
|
||||
shippingAddress.setIsDefault(false);
|
||||
}
|
||||
return ResultUtil.data(memberAddressService.saveMemberAddress(shippingAddress));
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 商品查询条件
|
||||
@@ -99,6 +100,8 @@ public class GoodsSearchParams extends PageVO {
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
// 统一使用 CharSequenceUtil.isNotEmpty() 处理字符串
|
||||
if (CharSequenceUtil.isNotEmpty(goodsId)) {
|
||||
queryWrapper.eq("goods_id", goodsId);
|
||||
}
|
||||
@@ -108,9 +111,12 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(id)) {
|
||||
queryWrapper.in("id", Arrays.asList(id.split(",")));
|
||||
}
|
||||
|
||||
// 统一使用 CollUtil.isNotEmpty() 处理集合
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
queryWrapper.in("id", ids);
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
@@ -125,51 +131,53 @@ public class GoodsSearchParams extends PageVO {
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(goodsStatus)) {
|
||||
if(goodsStatus.equals(GoodsStatusEnum.UPPER.name())){
|
||||
//审核通过+已上架
|
||||
queryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name());
|
||||
queryWrapper.eq("market_enable", GoodsStatusEnum.UPPER.name());
|
||||
}else if(goodsStatus.equals(GoodsStatusEnum.DOWN.name())){
|
||||
//审核通过+未上架
|
||||
queryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name());
|
||||
queryWrapper.eq("market_enable", GoodsStatusEnum.DOWN.name());
|
||||
}else if(goodsStatus.equals(GoodsAuthEnum.TOBEAUDITED.name())){
|
||||
//待审核
|
||||
queryWrapper.eq("auth_flag", GoodsAuthEnum.TOBEAUDITED.name());
|
||||
}else if(goodsStatus.equals(GoodsAuthEnum.REFUSE.name())){
|
||||
//审核拒绝
|
||||
queryWrapper.eq("auth_flag", GoodsAuthEnum.REFUSE.name());
|
||||
}
|
||||
}
|
||||
if (selfOperated != null) {
|
||||
|
||||
// 统一使用 Objects.nonNull() 处理对象非空判断
|
||||
if (Objects.nonNull(selfOperated)) {
|
||||
queryWrapper.eq("self_operated", selfOperated);
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(marketEnable)) {
|
||||
queryWrapper.eq("market_enable", marketEnable);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(authFlag)) {
|
||||
queryWrapper.eq("auth_flag", authFlag);
|
||||
}
|
||||
if (leQuantity != null) {
|
||||
|
||||
if (Objects.nonNull(leQuantity)) {
|
||||
queryWrapper.le("quantity", leQuantity);
|
||||
}
|
||||
if (geQuantity != null) {
|
||||
if (Objects.nonNull(geQuantity)) {
|
||||
queryWrapper.gt("quantity", geQuantity);
|
||||
}
|
||||
if (recommend != null) {
|
||||
if (Objects.nonNull(recommend)) {
|
||||
queryWrapper.le("recommend", recommend);
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(goodsType)) {
|
||||
queryWrapper.eq("goods_type", goodsType);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(salesModel)) {
|
||||
queryWrapper.eq("sales_model", salesModel);
|
||||
}
|
||||
if(alertQuantity != null && alertQuantity){
|
||||
|
||||
if(Objects.nonNull(alertQuantity) && alertQuantity){
|
||||
queryWrapper.apply("quantity <= alert_quantity");
|
||||
queryWrapper.ge("alert_quantity", 0);
|
||||
}
|
||||
|
||||
queryWrapper.in(CollUtil.isNotEmpty(ids), "id", ids);
|
||||
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
this.betweenWrapper(queryWrapper);
|
||||
return queryWrapper;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.logistics.plugin.kuaidi100;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.modules.logistics.LogisticsPlugin;
|
||||
import cn.lili.modules.logistics.entity.dto.LabelOrderDTO;
|
||||
import cn.lili.modules.logistics.entity.enums.LogisticsEnum;
|
||||
@@ -148,25 +149,25 @@ public class Kuaidi100Plugin implements LogisticsPlugin {
|
||||
//电子面单客户账户或月结账号,需贵司向当地快递公司网点申请(参考电子面单申请指南); 是否必填该属性,请查看参数字典
|
||||
orderReq.setPartnerId(storeLogistics.getCustomerName());
|
||||
//电子面单密码,需贵司向当地快递公司网点申请; 是否必填该属性,请查看参数字典
|
||||
if(storeLogistics.getCustomerPwd()!=null){
|
||||
if(CharSequenceUtil.isNotEmpty(storeLogistics.getCustomerPwd())){
|
||||
orderReq.setPartnerKey(storeLogistics.getCustomerPwd());
|
||||
}
|
||||
|
||||
//电子面单密钥,需贵司向当地快递公司网点申请; 是否必填该属性,请查看参数字典
|
||||
if(storeLogistics.getMonthCode()!=null) {
|
||||
if(CharSequenceUtil.isNotEmpty(storeLogistics.getMonthCode())) {
|
||||
orderReq.setPartnerSecret(storeLogistics.getMonthCode());
|
||||
}
|
||||
//电子面单客户账户名称,需贵司向当地快递公司网点申请; 是否必填该属性,请查看参数字典
|
||||
if(storeLogistics.getPartnerName()!=null) {
|
||||
if(CharSequenceUtil.isNotEmpty(storeLogistics.getPartnerName())) {
|
||||
orderReq.setPartnerName(storeLogistics.getPartnerName());
|
||||
}
|
||||
// orderReq.setNet();
|
||||
// 电子面单承载编号,需贵司向当地快递公司网点申请; 是否必填该属性,请查看参数字典
|
||||
if(storeLogistics.getSendSite()!=null) {
|
||||
if(CharSequenceUtil.isNotEmpty(storeLogistics.getSendSite())) {
|
||||
orderReq.setCode(storeLogistics.getSendSite());
|
||||
}
|
||||
//电子面单承载快递员名,需贵司向当地快递公司网点申请; 是否必填该属性,请查看参数字典
|
||||
if(storeLogistics.getSendStaff()!=null) {
|
||||
if(CharSequenceUtil.isNotEmpty(storeLogistics.getSendStaff())) {
|
||||
orderReq.setCheckMan(storeLogistics.getSendStaff());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.member.entity.dos;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.modules.member.entity.dto.ClerkAddDTO;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
@@ -59,7 +60,7 @@ public class Clerk extends BaseEntity {
|
||||
* @param clerkAddDTO
|
||||
*/
|
||||
public Clerk(ClerkAddDTO clerkAddDTO) {
|
||||
if (clerkAddDTO.getRoles()!=null && !clerkAddDTO.getRoles().isEmpty()) {
|
||||
if (CollUtil.isNotEmpty(clerkAddDTO.getRoles()) && !clerkAddDTO.getRoles().isEmpty()) {
|
||||
this.roleIds = CharSequenceUtil.join(",", clerkAddDTO.getRoles());
|
||||
}
|
||||
this.memberId = clerkAddDTO.getMemberId();
|
||||
|
||||
@@ -1289,13 +1289,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
row.createCell(2).setCellValue(dto.getGoodsName());
|
||||
row.createCell(3).setCellValue(dto.getNum());
|
||||
row.createCell(4).setCellValue(dto.getGoodsId());
|
||||
row.createCell(5).setCellValue(dto.getUnitPrice()!=null?dto.getUnitPrice():0);
|
||||
row.createCell(6).setCellValue(dto.getFlowPrice()!=null?dto.getFlowPrice():0);
|
||||
row.createCell(7).setCellValue(dto.getFreightPrice()!=null?dto.getFreightPrice():0);
|
||||
row.createCell(8).setCellValue(dto.getDiscountPrice()!=null?dto.getDiscountPrice():0);
|
||||
row.createCell(9).setCellValue(dto.getSiteMarketingCost()!=null?dto.getSiteMarketingCost():0);
|
||||
row.createCell(10).setCellValue(dto.getStoreMarketingCost()!=null?dto.getStoreMarketingCost():0);
|
||||
row.createCell(11).setCellValue(dto.getUpdatePrice()!=null?dto.getUpdatePrice():0);
|
||||
row.createCell(5).setCellValue(Objects.nonNull(dto.getUnitPrice())?dto.getUnitPrice():0);
|
||||
row.createCell(6).setCellValue(Objects.nonNull(dto.getFlowPrice())?dto.getFlowPrice():0);
|
||||
row.createCell(7).setCellValue(Objects.nonNull(dto.getFreightPrice())?dto.getFreightPrice():0);
|
||||
row.createCell(8).setCellValue(Objects.nonNull(dto.getDiscountPrice())?dto.getDiscountPrice():0);
|
||||
row.createCell(9).setCellValue(Objects.nonNull(dto.getSiteMarketingCost())?dto.getSiteMarketingCost():0);
|
||||
row.createCell(10).setCellValue(Objects.nonNull(dto.getStoreMarketingCost())?dto.getStoreMarketingCost():0);
|
||||
row.createCell(11).setCellValue(Objects.nonNull(dto.getUpdatePrice())?dto.getUpdatePrice():0);
|
||||
row.createCell(12).setCellValue(dto.getPaymentMethod());
|
||||
row.createCell(13).setCellValue(dto.getConsigneeName());
|
||||
row.createCell(14).setCellValue(dto.getConsigneeMobile());
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流量数据展示VO
|
||||
@@ -36,14 +37,14 @@ public class PlatformViewVO {
|
||||
}
|
||||
|
||||
public Long getPvNum() {
|
||||
if(pvNum==null){
|
||||
if(Objects.isNull(pvNum)){
|
||||
return 0L;
|
||||
}
|
||||
return pvNum;
|
||||
}
|
||||
|
||||
public Long getUvNum() {
|
||||
if(uvNum==null){
|
||||
if(Objects.isNull(uvNum)){
|
||||
return 0L;
|
||||
}
|
||||
return uvNum;
|
||||
|
||||
@@ -186,10 +186,10 @@ public class OrderStatisticsServiceImpl extends ServiceImpl<OrderStatisticsMappe
|
||||
queryWrapper.between("oi.create_time", dates[0], dates[1]);
|
||||
queryWrapper.ne("oi.is_refund", RefundStatusEnum.ALL_REFUND.name());
|
||||
|
||||
if(paymentMethodEnum!=null){
|
||||
if(Objects.nonNull(paymentMethodEnum)){
|
||||
queryWrapper.eq("o.payment_method",paymentMethodEnum.name());
|
||||
}
|
||||
if(deliveryMethodEnum!=null){
|
||||
if(Objects.nonNull(deliveryMethodEnum)){
|
||||
if(DeliveryMethodEnum.VIRTUAL.equals(deliveryMethodEnum)){
|
||||
queryWrapper.eq("o.order_type", OrderTypeEnum.VIRTUAL.name());
|
||||
}else{
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 预存款业务层实现
|
||||
@@ -124,7 +125,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
|
||||
LambdaQueryWrapper<Recharge> queryWrapper = new LambdaQueryWrapper<Recharge>();
|
||||
queryWrapper.eq(Recharge::getPayStatus, PayStatusEnum.PAID.name());
|
||||
queryWrapper.between(Recharge::getPayTime, dates[0], dates[1]);
|
||||
if(paymentMethodEnum!=null){
|
||||
if(Objects.nonNull(paymentMethodEnum)){
|
||||
queryWrapper.eq(Recharge::getRechargeWay,paymentMethodEnum.name());
|
||||
}
|
||||
return this.baseMapper.getRecharge(queryWrapper);
|
||||
|
||||
@@ -15,6 +15,7 @@ import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsNumVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.entity.vos.StockWarningVO;
|
||||
@@ -81,6 +82,12 @@ public class GoodsStoreController {
|
||||
return ResultUtil.data(goodsService.queryByParams(goodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商品数量")
|
||||
@GetMapping(value = "/goodsNumber")
|
||||
public ResultMessage<GoodsNumVO> getGoodsNumVO(GoodsSearchParams goodsSearchParams) {
|
||||
return ResultUtil.data(goodsService.getGoodsNumVO(goodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页获取商品Sku列表")
|
||||
@GetMapping(value = "/sku/list")
|
||||
public ResultMessage<IPage<GoodsSku>> getSkuByPage(GoodsSearchParams goodsSearchParams) {
|
||||
|
||||
Reference in New Issue
Block a user