1.MyBatis使用foreach遍历
Service:
@Override
public String updateShipmentProducts( List shipmentProducts) {
orderMapper.insertShipmentProducts(shipmentProducts);
return "null";
}
Mapper:
void insertShipmentProducts(ListshipmentProducts);
Xml:
INSERT INTO user_order_shipment_pro (order_no, tracking_no, carrier, catalog_no, size, quantity, id_key) VALUES #{shipmentProduct.orderNo}, #{shipmentProduct.trackingNo}, #{shipmentProduct.carrier}, #{shipmentProduct.catalogNo}, #{shipmentProduct.size}, #{shipmentProduct.quantity}, #{shipmentProduct.IDkey}
2.新增查询添加语句
INSERT INTO user_integral(user_id, order_no, integral_change, start_date, end_date, `explain`) SELECT user_id, order_no, CONCAt('+',FLOOR(pay_money)) integral_change, NOW() start_date, DATE_ADD(NOW(), INTERVAL +1 year) end_date, '物流发货' as `explain` FROM user_order WHERe order_no = #{orderNo};
3.mybatis拼接函数:
SELECt DISTINCT
IFNULL( SUM( number ), 0 ) AS number,
IFNULL( GROUP_CONCAt( CONCAt( city, ':', number ) SEPARATOR ',' ), 0 ) AS stock_info
FROM
product_inventory_price_info
结果:



