Commit c1eb784e by 杨浩

查询调整

parent b3342487
...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order; ...@@ -2,6 +2,7 @@ package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.order;
import cn.iocoder.foodnexus.framework.common.pojo.PageParam; import cn.iocoder.foodnexus.framework.common.pojo.PageParam;
import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus; import cn.iocoder.foodnexus.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -90,4 +91,7 @@ public class ErpPurchaseOrderPageReqVO extends PageParam { ...@@ -90,4 +91,7 @@ public class ErpPurchaseOrderPageReqVO extends PageParam {
@Schema(description = "发货状态") @Schema(description = "发货状态")
private List<String> deliveryStatus; private List<String> deliveryStatus;
@Schema(description = "配送模式")
private DeliveryMode deliveryMode;
} }
\ No newline at end of file
...@@ -63,6 +63,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO> ...@@ -63,6 +63,10 @@ public interface ErpPurchaseOrderMapper extends BaseMapperX<ErpPurchaseOrderDO>
} else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_ALL)) { } else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_ALL)) {
query.apply("t.in_count = t.total_count"); query.apply("t.in_count = t.total_count");
} }
if (CommonUtil.isNotEmpty(reqVO.getDeliveryMode())) {
query.leftJoin("order_customer_order oco on t.customer_order_id = oco.id");
query.eq("oco.delivery_mode", reqVO.getDeliveryMode().getKey());
}
// 退货状态 // 退货状态
if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_NONE)) { if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_NONE)) {
query.eq(ErpPurchaseOrderDO::getReturnCount, 0); query.eq(ErpPurchaseOrderDO::getReturnCount, 0);
......
...@@ -82,7 +82,8 @@ public class AppInquireCustomerPushController { ...@@ -82,7 +82,8 @@ public class AppInquireCustomerPushController {
public CommonResult<PageResult<AppInquireCustomerPushRespVO>> getInquireCustomerPushPage(@Valid AppInquireCustomerPushPageReqVO pageReqVO) { public CommonResult<PageResult<AppInquireCustomerPushRespVO>> getInquireCustomerPushPage(@Valid AppInquireCustomerPushPageReqVO pageReqVO) {
pageReqVO.setCustomerId(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId())); pageReqVO.setCustomerId(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
PageResult<AppInquireCustomerPushRespVO> pageResult = inquireCustomerPushService.getAppInquireCustomerPushPage(pageReqVO); PageResult<AppInquireCustomerPushRespVO> pageResult = inquireCustomerPushService.getAppInquireCustomerPushPage(pageReqVO);
return success(pageResult); return success(BeanUtils.toBean(pageResult, AppInquireCustomerPushRespVO.class, item ->
item.setInquirePrice(BeanUtils.toBean(inquirePriceService.getInquirePrice(item.getInquirePriceId()), InquirePriceRespVO.class))));
} }
} }
\ No newline at end of file
...@@ -88,7 +88,7 @@ public class CustomerAddressController { ...@@ -88,7 +88,7 @@ public class CustomerAddressController {
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得客户 - 我的地址分页") @Operation(summary = "获得客户 - 我的地址分页")
public CommonResult<PageResult<CustomerAddressRespVO>> getCustomerAddressPage(@Valid CustomerAddressPageReqVO pageReqVO) { public CommonResult<PageResult<CustomerAddressRespVO>> getCustomerAddressPage(@Valid CustomerAddressPageReqVO pageReqVO) {
pageReqVO.setCreator(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId())); pageReqVO.setCreator(SecurityFrameworkUtils.getLoginUserId());
PageResult<CustomerAddressDO> pageResult = customerAddressService.getCustomerAddressPage(pageReqVO); PageResult<CustomerAddressDO> pageResult = customerAddressService.getCustomerAddressPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CustomerAddressRespVO.class)); return success(BeanUtils.toBean(pageResult, CustomerAddressRespVO.class));
} }
......
...@@ -30,7 +30,7 @@ public interface CustomerAddressMapper extends BaseMapperX<CustomerAddressDO> { ...@@ -30,7 +30,7 @@ public interface CustomerAddressMapper extends BaseMapperX<CustomerAddressDO> {
.eqIfPresent(CustomerAddressDO::getIsDefault, reqVO.getIsDefault()) .eqIfPresent(CustomerAddressDO::getIsDefault, reqVO.getIsDefault())
.betweenIfPresent(CustomerAddressDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(CustomerAddressDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(CustomerAddressDO::getCreator, reqVO.getCreator()) .eqIfPresent(CustomerAddressDO::getCreator, reqVO.getCreator())
.orderByDesc(CustomerAddressDO::getId)); .orderByDesc(CustomerAddressDO::getIsDefault, CustomerAddressDO::getId));
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.order.service.customeraddress; ...@@ -3,6 +3,7 @@ package cn.iocoder.foodnexus.module.order.service.customeraddress;
import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressPageReqVO; import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressSaveReqVO; import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -17,6 +18,7 @@ import cn.iocoder.foodnexus.module.order.dal.mysql.customeraddress.CustomerAddre ...@@ -17,6 +18,7 @@ import cn.iocoder.foodnexus.module.order.dal.mysql.customeraddress.CustomerAddre
import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.foodnexus.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.foodnexus.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*; import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*;
/** /**
...@@ -33,10 +35,15 @@ public class CustomerAddressServiceImpl implements CustomerAddressService { ...@@ -33,10 +35,15 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
@Override @Override
public Long createCustomerAddress(CustomerAddressSaveReqVO createReqVO) { public Long createCustomerAddress(CustomerAddressSaveReqVO createReqVO) {
if (createReqVO.getIsDefault()) {
customerAddressMapper.update(Wrappers.<CustomerAddressDO>lambdaUpdate()
.set(CustomerAddressDO::getIsDefault, Boolean.FALSE)
.eq(CustomerAddressDO::getIsDefault, Boolean.TRUE)
.eq(CustomerAddressDO::getCreator, getLoginUserId()));
}
// 插入 // 插入
CustomerAddressDO customerAddress = BeanUtils.toBean(createReqVO, CustomerAddressDO.class); CustomerAddressDO customerAddress = BeanUtils.toBean(createReqVO, CustomerAddressDO.class);
customerAddressMapper.insert(customerAddress); customerAddressMapper.insert(customerAddress);
// 返回 // 返回
return customerAddress.getId(); return customerAddress.getId();
} }
...@@ -44,7 +51,13 @@ public class CustomerAddressServiceImpl implements CustomerAddressService { ...@@ -44,7 +51,13 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
@Override @Override
public void updateCustomerAddress(CustomerAddressSaveReqVO updateReqVO) { public void updateCustomerAddress(CustomerAddressSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateCustomerAddressExists(updateReqVO.getId()); CustomerAddressDO customerAddressDO = validateCustomerAddressExists(updateReqVO.getId());
if (!customerAddressDO.getIsDefault() && updateReqVO.getIsDefault()) {
customerAddressMapper.update(Wrappers.<CustomerAddressDO>lambdaUpdate()
.set(CustomerAddressDO::getIsDefault, Boolean.FALSE)
.eq(CustomerAddressDO::getIsDefault, Boolean.TRUE)
.eq(CustomerAddressDO::getCreator, getLoginUserId()));
}
// 更新 // 更新
CustomerAddressDO updateObj = BeanUtils.toBean(updateReqVO, CustomerAddressDO.class); CustomerAddressDO updateObj = BeanUtils.toBean(updateReqVO, CustomerAddressDO.class);
customerAddressMapper.updateById(updateObj); customerAddressMapper.updateById(updateObj);
...@@ -65,10 +78,12 @@ public class CustomerAddressServiceImpl implements CustomerAddressService { ...@@ -65,10 +78,12 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
} }
private void validateCustomerAddressExists(Long id) { private CustomerAddressDO validateCustomerAddressExists(Long id) {
if (customerAddressMapper.selectById(id) == null) { CustomerAddressDO customerAddressDO = customerAddressMapper.selectById(id);
if (customerAddressDO == null) {
throw exception(CUSTOMER_ADDRESS_NOT_EXISTS); throw exception(CUSTOMER_ADDRESS_NOT_EXISTS);
} }
return customerAddressDO;
} }
@Override @Override
......
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