lisai17@sina.com 2021-03-16 14:47:37 +08:00
parent e4cb4230a5
commit 62f32444a4
1 changed files with 19 additions and 4 deletions

View File

@ -739,14 +739,29 @@ public class OrderclusterService extends BaseService {
* @return * @return
*/ */
public BigDecimal undoPrice(int customer_id) { public BigDecimal undoPrice(int customer_id) {
String sql = "select sum(t.`total_weight`* t.`unit_price`) `total_price`\n" + String sql = "select(\n" +
" select sum(t.`total_weight` * t.`unit_price`) `total_price`\n" +
" from `ordercluster` t\n" + " from `ordercluster` t\n" +
" where t.`customer_id`= ? \n" + " where t.`customer_id`= ?\n" +
" and t.state< ? "; " 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( BigDecimal out = Db.queryBigDecimal(
sql, sql,
customer_id, customer_id,
OrderStateEnum.RECEIVED.getStateid(),
customer_id,
OrderStateEnum.RECEIVED.getStateid(),
customer_id,
OrderStateEnum.RECEIVED.getStateid() OrderStateEnum.RECEIVED.getStateid()
); );