diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java index ea88459..e5df76a 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java @@ -739,14 +739,29 @@ public class OrderclusterService extends BaseService { * @return */ public BigDecimal undoPrice(int customer_id) { - String sql = "select sum(t.`total_weight`* t.`unit_price`) `total_price`\n" + - " from `ordercluster` t\n" + - " where t.`customer_id`= ? \n" + - " and t.state< ? "; + String sql = "select(\n" + + " select sum(t.`total_weight` * t.`unit_price`) `total_price`\n" + + " from `ordercluster` t\n" + + " where t.`customer_id`= ?\n" + + " and t.state < ? ) - (\n" + + " select sum(t.`weight` * t.`unit_price`) total_price\n" + + " from order_temp t\n" + + " where exists(\n" + + " select 1 from `ordercluster` o\n" + + " where o.`customer_id`= ?\n" + + " and o.id= t.`ordercluster_id`\n" + + " and o.`state`< ?" + + " )\n" + + " and t.`customer_id`= ?\n" + + " and t.`state`= ?)"; BigDecimal out = Db.queryBigDecimal( sql, customer_id, + OrderStateEnum.RECEIVED.getStateid(), + customer_id, + OrderStateEnum.RECEIVED.getStateid(), + customer_id, OrderStateEnum.RECEIVED.getStateid() );