|
|
@@ -16,13 +16,19 @@
|
|
|
*/
|
|
|
package org.springblade.land.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.land.entity.Order;
|
|
|
import org.springblade.land.entity.OrderAddress;
|
|
|
import org.springblade.land.mapper.OrderAddressMapper;
|
|
|
+import org.springblade.land.mapper.OrderMapper;
|
|
|
import org.springblade.land.service.IOrderAddressService;
|
|
|
import org.springblade.land.vo.OrderAddressVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -33,20 +39,58 @@ import java.util.List;
|
|
|
* @since 2022-03-07
|
|
|
*/
|
|
|
@Service
|
|
|
+@AllArgsConstructor
|
|
|
public class OrderAddressServiceImpl extends ServiceImpl<OrderAddressMapper, OrderAddress> implements IOrderAddressService {
|
|
|
|
|
|
+ private final OrderMapper orderMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<OrderAddressVO> selectOrderAddressPage(IPage<OrderAddressVO> page, OrderAddressVO orderAddress) {
|
|
|
return page.setRecords(baseMapper.selectOrderAddressPage(page, orderAddress));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public boolean removeOrderAddress(List<Long> idList) {
|
|
|
idList.forEach(id -> {
|
|
|
+ OrderAddress temp = baseMapper.selectById(id);
|
|
|
+
|
|
|
OrderAddress orderAddress = new OrderAddress();
|
|
|
orderAddress.setId(id);
|
|
|
orderAddress.setIsDeleted(1);
|
|
|
baseMapper.updateById(orderAddress);
|
|
|
+
|
|
|
+ List<OrderAddress> addressList = baseMapper.selectList(new LambdaQueryWrapper<OrderAddress>()
|
|
|
+ .eq(OrderAddress::getOrderId, temp.getOrderId())
|
|
|
+ .eq(OrderAddress::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ int i = 1;
|
|
|
+ StringBuilder addressDetail = new StringBuilder();
|
|
|
+ for (OrderAddress address : addressList) {
|
|
|
+ if (StringUtil.isNotBlank(address.getCorpName())) {
|
|
|
+ addressDetail.append(i).append(".").append(address.getCorpName()).append("(");
|
|
|
+
|
|
|
+ if (StringUtil.isNotBlank(address.getContacts())) {
|
|
|
+ addressDetail.append(address.getContacts());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(address.getTel())) {
|
|
|
+ addressDetail.append(" ").append(address.getTel());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(address.getAddress())) {
|
|
|
+ addressDetail.append(") ").append(address.getAddress()).append("\n");
|
|
|
+ } else {
|
|
|
+ addressDetail.append(") ").append("\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Order order = new Order();
|
|
|
+ order.setId(temp.getOrderId());
|
|
|
+ order.setAddressDetail(addressDetail.toString());
|
|
|
+ orderMapper.updateById(order);
|
|
|
});
|
|
|
return true;
|
|
|
}
|