|
|
|
@ -4,16 +4,17 @@ import com.base.springcloud.aspect.annotation.BusinessException; |
|
|
|
import com.base.springcloud.bo.OrderBO; |
|
|
|
import com.base.springcloud.bo.SaleBillBO; |
|
|
|
import com.base.springcloud.constant.ErrorConstant; |
|
|
|
import com.base.springcloud.constant.PaymentConstant; |
|
|
|
import com.base.springcloud.dao.SaleBillMapper; |
|
|
|
import com.base.springcloud.entity.SaleBill; |
|
|
|
import com.base.springcloud.service.BillService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
@Service |
|
|
|
@ -31,11 +32,12 @@ public class BillServiceImp implements BillService { |
|
|
|
@Override |
|
|
|
public void billCheck(OrderBO orderBO) { |
|
|
|
SaleBill saleBill = new SaleBill(); |
|
|
|
saleBill.setId(orderBO.getBillId()); |
|
|
|
saleBill.setId(orderBO.getBillIds()); |
|
|
|
SaleBill queryResult = saleBillMapper.queryBillInfo(saleBill); |
|
|
|
if(!Optional.ofNullable(queryResult).isPresent()){ |
|
|
|
throw new BusinessException(ErrorConstant.BILL_INVALID); |
|
|
|
} |
|
|
|
orderBO.setAmount(queryResult.getTotalAmount()); |
|
|
|
orderBO.setSaleBill(queryResult); |
|
|
|
} |
|
|
|
|
|
|
|
@ -53,4 +55,23 @@ public class BillServiceImp implements BillService { |
|
|
|
if(count > 0) return; |
|
|
|
throw new BusinessException(ErrorConstant.BILL_WRITE_OFF_FAIL); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 销售单据合并 |
|
|
|
* @param orderBO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void mergeBillAmount(OrderBO orderBO) { |
|
|
|
String billIds = orderBO.getBillIds(); |
|
|
|
if(StringUtils.isBlank(billIds)){ |
|
|
|
throw new BusinessException(ErrorConstant.NULL_OBJ); |
|
|
|
} |
|
|
|
String[] billIdArray = billIds.split(","); |
|
|
|
List<BigDecimal> billAmountList = saleBillMapper.mergeBillAmount(billIdArray); |
|
|
|
if(!Optional.ofNullable(billAmountList).isPresent()) |
|
|
|
throw new BusinessException(ErrorConstant.SALE_BILL__INVALID); |
|
|
|
BigDecimal orderAmount = new BigDecimal(0); |
|
|
|
billAmountList.forEach(amount-> orderAmount.add(amount)); |
|
|
|
orderBO.setAmount(orderAmount); |
|
|
|
} |
|
|
|
} |
|
|
|
|