Commit c1eb784e by 杨浩

查询调整

parent b3342487
......@@ -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.module.erp.api.enums.ErpDeliveryStatus;
import cn.iocoder.foodnexus.module.order.enums.DeliveryMode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -90,4 +91,7 @@ public class ErpPurchaseOrderPageReqVO extends PageParam {
@Schema(description = "发货状态")
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>
} else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_ALL)) {
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)) {
query.eq(ErpPurchaseOrderDO::getReturnCount, 0);
......
......@@ -82,7 +82,8 @@ public class AppInquireCustomerPushController {
public CommonResult<PageResult<AppInquireCustomerPushRespVO>> getInquireCustomerPushPage(@Valid AppInquireCustomerPushPageReqVO pageReqVO) {
pageReqVO.setCustomerId(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
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 {
@GetMapping("/page")
@Operation(summary = "获得客户 - 我的地址分页")
public CommonResult<PageResult<CustomerAddressRespVO>> getCustomerAddressPage(@Valid CustomerAddressPageReqVO pageReqVO) {
pageReqVO.setCreator(customerApi.queryCustomerIdByUserId(SecurityFrameworkUtils.getLoginUserId()));
pageReqVO.setCreator(SecurityFrameworkUtils.getLoginUserId());
PageResult<CustomerAddressDO> pageResult = customerAddressService.getCustomerAddressPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CustomerAddressRespVO.class));
}
......
......@@ -30,7 +30,7 @@ public interface CustomerAddressMapper extends BaseMapperX<CustomerAddressDO> {
.eqIfPresent(CustomerAddressDO::getIsDefault, reqVO.getIsDefault())
.betweenIfPresent(CustomerAddressDO::getCreateTime, reqVO.getCreateTime())
.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;
import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressPageReqVO;
import cn.iocoder.foodnexus.module.order.controller.app.customeraddress.vo.CustomerAddressSaveReqVO;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
......@@ -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.util.collection.CollectionUtils.convertList;
import static cn.iocoder.foodnexus.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.foodnexus.module.order.enums.ErrorCodeConstants.*;
/**
......@@ -33,10 +35,15 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
@Override
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);
customerAddressMapper.insert(customerAddress);
// 返回
return customerAddress.getId();
}
......@@ -44,7 +51,13 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
@Override
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);
customerAddressMapper.updateById(updateObj);
......@@ -65,10 +78,12 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
}
private void validateCustomerAddressExists(Long id) {
if (customerAddressMapper.selectById(id) == null) {
private CustomerAddressDO validateCustomerAddressExists(Long id) {
CustomerAddressDO customerAddressDO = customerAddressMapper.selectById(id);
if (customerAddressDO == null) {
throw exception(CUSTOMER_ADDRESS_NOT_EXISTS);
}
return customerAddressDO;
}
@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