118 lines
4.4 KiB
XML
118 lines
4.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="OrderOwnGoods">
|
|
|
|
<insert id="insertOrderOwnGoods" parameterType="OrderOwnGoods">
|
|
INSERT INTO OrderOwnGoods ( orderOwnGoodsId, orderInfoId, goodsId,
|
|
years, startTime, endTime, price, amount , areaid )
|
|
Values ( #{orderOwnGoodsId}, #{orderInfoId}, #{goodsId},
|
|
#{years}, #{startTime}, #{endTime}, #{price}, #{amount} , #{areaid} )
|
|
</insert>
|
|
|
|
<update id="updateOrderOwnGoods" parameterType="OrderOwnGoods">
|
|
UPDATE OrderOwnGoods
|
|
SET orderOwnGoodsId = #{orderOwnGoodsId},
|
|
orderInfoId = #{orderInfoId}, goodsId = #{goodsId},
|
|
years = #{years}, startTime = #{startTime},
|
|
endTime = #{endTime}, price = #{price},
|
|
amount = #{amount} , areaid = #{areaid}
|
|
where orderOwnGoodsId=#{orderOwnGoodsId}
|
|
</update>
|
|
|
|
<select id="getOrderOwnGoodsByKey" parameterType="java.lang.Integer" resultType="OrderOwnGoods">
|
|
SELECT orderOwnGoodsId , orderInfoId , goodsId , years ,
|
|
startTime , endTime , price , amount , areaid
|
|
FROM OrderOwnGoods
|
|
WHERE orderOwnGoodsId=#{orderOwnGoodsId}
|
|
</select>
|
|
|
|
<select id="getSeqOrderOwnGoods" resultType="Integer" useCache="false" flushCache="true">
|
|
SELECT nextval('seq_orderOwnGoodsId')
|
|
</select>
|
|
|
|
<insert id="sendOrderOwnGoodsToUser" parameterType="java.util.Map" flushCache="true">
|
|
INSERT INTO OrderOwnGoods ( orderOwnGoodsId , orderInfoId , goodsId ,
|
|
years , startTime , endTime , price , amount , areaid )
|
|
SELECT nextval('seq_orderOwnGoodsId') , #{orderInfoId} , #{goodsId} ,
|
|
0 , #{startTime}, #{endTime} , 0 , 0 , #{areaid}
|
|
</insert>
|
|
|
|
<insert id="insertOrderOwnGoodsBatch" parameterType="java.util.List">
|
|
|
|
INSERT INTO OrderOwnGoods ( orderOwnGoodsId, orderInfoId, goodsId,
|
|
years, startTime, endTime, price, amount , areaid ) Values
|
|
|
|
<foreach collection="list" index="index" item="item" separator=",">
|
|
|
|
( #{item.orderOwnGoodsId}, #{item.orderInfoId},
|
|
#{item.goodsId}, #{item.years},
|
|
#{item.startTime}, #{item.endTime},
|
|
#{item.price}, #{item.amount} , #{item.areaid} )
|
|
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="getEndOrderOwnGoods" parameterType="java.util.Map" resultType="OrderOwnGoods">
|
|
|
|
SELECT oo.orderowngoodsid, oo.orderinfoid, oo.goodsid,
|
|
oo.years, oo.starttime, oo.endtime,
|
|
oo.price, oo.amount , oo.areaid
|
|
FROM OrderOwnGoods oo
|
|
join OrderInfo oi
|
|
on oo.orderinfoid = oi.orderinfoid
|
|
where oo.goodsid = #{goodsId} and oi.uid= #{uid}
|
|
and oo.areaid = #{areaid}
|
|
and oi.ispayed = 1
|
|
order by oo.endtime desc limit 1;
|
|
|
|
</select>
|
|
|
|
<select id="getOrderOwnGoodsList" parameterType="java.util.Map" resultType="OrderOwnGoods">
|
|
|
|
SELECT orderowngoodsid, orderinfoid, goodsid,
|
|
years, starttime, endtime, price, amount ,areaid
|
|
FROM orderowngoods
|
|
where orderinfoid = #{orderInfoId} and areaid = #{areaid};
|
|
|
|
</select>
|
|
|
|
<select id="getLastGoodsIdByUid" parameterType="java.lang.Long" resultType="Integer">
|
|
|
|
select o.goodsid from (
|
|
select * from orderinfo oi inner join orderowngoods oo
|
|
on oo.orderinfoid = oi.orderinfoid ) o
|
|
inner join goods g on g.goodsid = o.goodsid
|
|
where o.uid =#{uid} and g.isrecomm =0 and o.ispayed = 1
|
|
order by o.orderowngoodsid desc limit 1
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getGiveGoodsIdByUid" parameterType="java.lang.Long" resultType="Integer">
|
|
|
|
select distinct(oo.goodsId) from OrderOwnGoods oo
|
|
inner join OrderInfo oi on oo.orderInfoId = oi.orderInfoId
|
|
where oi.payWay = 0 and oi.uid = #{uid}
|
|
|
|
</select>
|
|
|
|
|
|
<update id="resetEndTimeAndYear" parameterType="java.util.Map">
|
|
UPDATE OrderOwnGoods
|
|
SET
|
|
years = #{newYears},endTime = ( endTime - interval ' ${refundYears} year '),price=#{price},amount=#{amount}
|
|
where orderinfoid = #{orderInfoId} and areaid = #{areaId}
|
|
|
|
</update>
|
|
|
|
<select id="getOrderOwnGoodsLimitOne" parameterType="java.lang.Integer" resultType="OrderOwnGoods">
|
|
|
|
SELECT orderowngoodsid, orderinfoid, goodsid,
|
|
years, starttime, endtime, price, amount ,areaid
|
|
FROM orderowngoods
|
|
where orderinfoid = #{orderInfoId}
|
|
order by orderowngoodsid desc limit 1
|
|
|
|
</select>
|
|
</mapper> |