k.e.book.ddh.service.CcOrderAttributeService Maven / Gradle / Ivy
package k.e.book.ddh.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import k.e.book.common.utils.TimeFormatter;
import k.e.book.ddh.entity.CcOrderAttributeDO;
import k.e.book.ddh.entity.CcOrderAttributeDOItemDetail;
import k.e.book.ddh.entity.CcOrderAttributeQueryDTO;
import k.e.book.ddh.mapper.CcOrderAttributeMapper;
import org.springframework.stereotype.Service;
/**
* @author kk
* @date 2023-05-21 11:04
*/
@Service
public class CcOrderAttributeService extends ServiceImpl {
/**
*
* @param orderId d
* @param itemId 去除,没有使用
* @return
*/
public CcOrderAttributeDO getByOrder(String orderId, Long itemId) {
LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
qr.eq(CcOrderAttributeDO::getOrderid, orderId);
// qr.eq(CcOrderAttributeDO::getItemId, itemId);//一级市场订单没有itemId
qr.last("limit 1");
return this.getOne(qr);
}
public boolean updateNotify(String orderId) {
LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
qr.eq(CcOrderAttributeDO::getOrderid, orderId);
CcOrderAttributeDO dd = new CcOrderAttributeDO();
dd.setIsSold(1);
dd.setUpdatedAt(TimeFormatter.getUpdateAt());
return this.update(dd, qr);
}
/**
* @param orderId d
* @return 内涵解析-item_detail
*/
public CcOrderAttributeDO getFromMQ(String orderId) {
LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
qr.eq(CcOrderAttributeDO::getOrderid, orderId);
CcOrderAttributeDO ddd = this.getOne(qr);
ddd.setItemDetailVO(JSONObject.parseObject(ddd.getItemDetail(), CcOrderAttributeDOItemDetail.class));
return ddd;
}
public IPage selectProductPage(CcOrderAttributeQueryDTO dto) {
LambdaQueryWrapper qr = new LambdaQueryWrapper<>();
if (dto.getId() != null) {
qr.eq(CcOrderAttributeDO::getId, dto.getId());
}
if (dto.getOrderid() != null) {
qr.eq(CcOrderAttributeDO::getOrderid, dto.getOrderid());
}
if (dto.getUserId() != null) {
qr.eq(CcOrderAttributeDO::getUserId, dto.getUserId());
}
if (dto.getParentOrderId() != null) {
qr.eq(CcOrderAttributeDO::getParentOrderId, dto.getParentOrderId());
}
if (dto.getSellerId() != null) {
qr.eq(CcOrderAttributeDO::getSellerId, dto.getSellerId());
}
if (dto.getPrice() != null) {
qr.eq(CcOrderAttributeDO::getPrice, dto.getPrice());
}
if (dto.getQuantity() != null) {
qr.eq(CcOrderAttributeDO::getQuantity, dto.getQuantity());
}
if (dto.getTotalFee() != null) {
qr.eq(CcOrderAttributeDO::getTotalFee, dto.getTotalFee());
}
if (dto.getItemId() != null) {
qr.eq(CcOrderAttributeDO::getItemId, dto.getItemId());
}
if (dto.getUserBoxId() != null) {
qr.eq(CcOrderAttributeDO::getUserBoxId, dto.getUserBoxId());
}
if (dto.getItemDetail() != null) {
qr.eq(CcOrderAttributeDO::getItemDetail, dto.getItemDetail());
}
if (dto.getCreatetime() != null) {
qr.eq(CcOrderAttributeDO::getCreatetime, dto.getCreatetime());
}
if (dto.getUpdatetime() != null) {
qr.eq(CcOrderAttributeDO::getUpdatetime, dto.getUpdatetime());
}
if (dto.getIsSold() != null) {
qr.eq(CcOrderAttributeDO::getIsSold, dto.getIsSold());
}
if (dto.getProductId() != null) {
qr.eq(CcOrderAttributeDO::getProductId, dto.getProductId());
}
if (dto.getIsWhite() != null) {
qr.eq(CcOrderAttributeDO::getIsWhite, dto.getIsWhite());
}
if (dto.getCreatedAt() != null) {
qr.eq(CcOrderAttributeDO::getCreatedAt, dto.getCreatedAt());
}
if (dto.getUpdatedAt() != null) {
qr.eq(CcOrderAttributeDO::getUpdatedAt, dto.getUpdatedAt());
}
if (dto.getDeletedAt() != null) {
qr.eq(CcOrderAttributeDO::getDeletedAt, dto.getDeletedAt());
}
qr.orderByDesc(CcOrderAttributeDO::getId);
IPage page = new Page<>();
page.setCurrent(dto.getPage());
page.setSize(dto.getLimit());
return baseMapper.selectPage(page, qr);
}
}