|
@@ -5,97 +5,101 @@
|
|
|
<mapper namespace="com.caimei.mapper.OrderSubmitMapper">
|
|
|
<select id="findShopByCartIds" resultType="com.caimei.model.vo.ShopVo">
|
|
|
SELECT DISTINCT
|
|
|
- s.shopID AS shopId,
|
|
|
- s.name,
|
|
|
- s.logo,
|
|
|
- p.splitCode
|
|
|
+ s.shopID AS shopId,
|
|
|
+ s.name,
|
|
|
+ s.logo,
|
|
|
+ p.splitCode
|
|
|
FROM
|
|
|
- cm_cart cc
|
|
|
- LEFT JOIN product p ON cc.productID = p.productID
|
|
|
- LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
+ cm_cart cc
|
|
|
+ LEFT JOIN product p ON cc.productID = p.productID
|
|
|
+ LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
WHERE
|
|
|
- cc.cm_cartID IN
|
|
|
+ cc.cm_cartID IN
|
|
|
<foreach item="cartId" index="index" collection="cartIds" open="(" separator="," close=")">
|
|
|
#{cartId}
|
|
|
</foreach>
|
|
|
ORDER BY
|
|
|
- cc.addTime DESC
|
|
|
+ cc.addTime DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="findByShopCartProduct" resultType="com.caimei.model.vo.CartProductVo">
|
|
|
SELECT
|
|
|
- cc.cm_cartID AS cartId,
|
|
|
- cc.productID AS productId,
|
|
|
- cc.productCount as num,
|
|
|
- cc.heUserId,
|
|
|
- chp.price,
|
|
|
- chp.price as normalPrice,
|
|
|
- chp.includedTax,
|
|
|
- chp.invoiceType,
|
|
|
- chp.clubTaxPoint,
|
|
|
- p.name,
|
|
|
- p.shopID AS shopId,
|
|
|
- p.mainImage as productImage,
|
|
|
- p.unit as productUnit
|
|
|
- FROM
|
|
|
- cm_cart cc
|
|
|
- LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
|
|
|
- LEFT JOIN product p ON cc.productID = p.productID
|
|
|
+ cc.skuId,
|
|
|
+ cc.cm_cartID AS cartId,
|
|
|
+ cc.productID AS productId,
|
|
|
+ cc.productCount as num,
|
|
|
+ cc.heUserId,
|
|
|
+ chs.price,
|
|
|
+ chs.price as normalPrice,
|
|
|
+ chp.includedTax,
|
|
|
+ chp.invoiceType,
|
|
|
+ chp.clubTaxPoint,
|
|
|
+ p.name,
|
|
|
+ p.shopID AS shopId,
|
|
|
+ p.mainImage as productImage,
|
|
|
+ cs.unit as productUnit
|
|
|
+ FROM cm_cart cc
|
|
|
+ LEFT JOIN cm_sku cs on cc.skuId=cs.skuId
|
|
|
+ LEFT JOIN cm_hehe_sku chs on cc.skuId=chs.skuId
|
|
|
+ LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
|
|
|
+ LEFT JOIN product p ON cc.productID = p.productID
|
|
|
WHERE
|
|
|
- chp.validFlag = 1
|
|
|
- AND p.shopID = #{shopId}
|
|
|
- and p.splitCode = #{splitCode}
|
|
|
- AND cc.cm_cartID IN
|
|
|
+ chp.validFlag = 1
|
|
|
+ AND p.shopID = #{shopId}
|
|
|
+ and p.splitCode = #{splitCode}
|
|
|
+ AND cc.cm_cartID IN
|
|
|
<foreach item="cartId" index="index" collection="cartIds" open="(" separator="," close=")">
|
|
|
#{cartId}
|
|
|
</foreach>
|
|
|
</select>
|
|
|
|
|
|
<select id="findUser" resultType="com.caimei.model.po.UserPo">
|
|
|
- SELECT
|
|
|
- userID,
|
|
|
- mobile,
|
|
|
- bindMobile,
|
|
|
- userName,
|
|
|
- name
|
|
|
- FROM
|
|
|
- user
|
|
|
- WHERE
|
|
|
- userID = #{userId}
|
|
|
+ SELECT userID,
|
|
|
+ mobile,
|
|
|
+ bindMobile,
|
|
|
+ userName,
|
|
|
+ name
|
|
|
+ FROM user
|
|
|
+ WHERE userID = #{userId}
|
|
|
</select>
|
|
|
|
|
|
<select id="getProduct" resultType="com.caimei.model.po.CmHeHeProductPo">
|
|
|
- SELECT
|
|
|
- chp.id,
|
|
|
- chp.productId,
|
|
|
- chp.price,
|
|
|
- chp.price as normalPrice,
|
|
|
- chp.includedTax,
|
|
|
- chp.invoiceType,
|
|
|
- p.costCheckFlag AS costType,
|
|
|
- chp.clubTaxPoint,
|
|
|
- chp.shopTaxPoint,
|
|
|
- p.costPrice,
|
|
|
- p.costProportional,
|
|
|
- p.shopID AS shopId,
|
|
|
- p.unit,
|
|
|
- p.name,
|
|
|
- p.mainImage,
|
|
|
- p.splitCode,
|
|
|
- s.name AS shopName
|
|
|
- FROM
|
|
|
- cm_hehe_product chp
|
|
|
- LEFT JOIN product p ON chp.productId = p.productID
|
|
|
- LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
- WHERE
|
|
|
- chp.productId = #{productId}
|
|
|
+ SELECT cs.skuId,
|
|
|
+ chp.id,
|
|
|
+ chp.productId,
|
|
|
+ chs.price,
|
|
|
+ chs.price as normalPrice,
|
|
|
+ chp.includedTax,
|
|
|
+ chp.invoiceType,
|
|
|
+ cs.costCheckFlag AS costType,
|
|
|
+ chp.clubTaxPoint,
|
|
|
+ chp.shopTaxPoint,
|
|
|
+ cs.costPrice,
|
|
|
+ cs.costProportional,
|
|
|
+ p.shopID AS shopId,
|
|
|
+ cs.unit,
|
|
|
+ p.name,
|
|
|
+ p.mainImage,
|
|
|
+ p.splitCode,
|
|
|
+ s.name AS shopName
|
|
|
+ FROM cm_hehe_product chp
|
|
|
+ LEFT JOIN cm_sku cs on cs.productId = chp.productId
|
|
|
+ LEFT JOIN cm_hehe_sku chs on cs.skuId=chs.skuId
|
|
|
+ LEFT JOIN product p ON chp.productId = p.productID
|
|
|
+ LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
+ WHERE cs.skuId = #{skuId}
|
|
|
</select>
|
|
|
|
|
|
<delete id="deleteCartByProductId">
|
|
|
- DELETE FROM cm_cart WHERE userID = #{userId} AND productID = #{productId} AND heUserId = #{heUserId}
|
|
|
+ DELETE
|
|
|
+ FROM cm_cart
|
|
|
+ WHERE userID = #{userId}
|
|
|
+ AND skuId = #{skuId}
|
|
|
+ AND heUserId = #{heUserId}
|
|
|
</delete>
|
|
|
|
|
|
- <insert id="insertOrder" keyColumn="orderID" keyProperty="orderID" parameterType="com.caimei.model.po.CmOrderPo" useGeneratedKeys="true">
|
|
|
+ <insert id="insertOrder" keyColumn="orderID" keyProperty="orderID" parameterType="com.caimei.model.po.CmOrderPo"
|
|
|
+ useGeneratedKeys="true">
|
|
|
insert into cm_order
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="orderNo != null">
|
|
@@ -440,19 +444,15 @@
|
|
|
</insert>
|
|
|
|
|
|
<select id="findMaxShopOrderNo" resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- shopOrderNo
|
|
|
- FROM
|
|
|
- cm_shop_order
|
|
|
- WHERE
|
|
|
- orderID = #{orderId}
|
|
|
- ORDER BY
|
|
|
- shopOrderNo DESC
|
|
|
- LIMIT
|
|
|
- 1
|
|
|
+ SELECT shopOrderNo
|
|
|
+ FROM cm_shop_order
|
|
|
+ WHERE orderID = #{orderId}
|
|
|
+ ORDER BY shopOrderNo DESC
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
- <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderID" parameterType="com.caimei.model.po.CmShopOrderPo" useGeneratedKeys="true">
|
|
|
+ <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderID"
|
|
|
+ parameterType="com.caimei.model.po.CmShopOrderPo" useGeneratedKeys="true">
|
|
|
insert into cm_shop_order
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="shopOrderNo != null">
|
|
@@ -910,9 +910,13 @@
|
|
|
</trim>
|
|
|
</insert>
|
|
|
|
|
|
- <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductID" parameterType="com.caimei.model.po.CmOrderProductPo" useGeneratedKeys="true">
|
|
|
+ <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductID"
|
|
|
+ parameterType="com.caimei.model.po.CmOrderProductPo" useGeneratedKeys="true">
|
|
|
insert into cm_order_product
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="skuId != null">
|
|
|
+ skuId,
|
|
|
+ </if>
|
|
|
<if test="orderNo != null">
|
|
|
orderNo,
|
|
|
</if>
|
|
@@ -1095,6 +1099,9 @@
|
|
|
</if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="skuId != null">
|
|
|
+ #{skuId},
|
|
|
+ </if>
|
|
|
<if test="orderNo != null">
|
|
|
#{orderNo,jdbcType=VARCHAR},
|
|
|
</if>
|
|
@@ -1278,13 +1285,10 @@
|
|
|
</trim>
|
|
|
</insert>
|
|
|
|
|
|
- <insert id="insertOrderProductLadderPrice" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.OrderProductLadderPricePo">
|
|
|
- insert into order_product_ladder_price (
|
|
|
- orderProductId, ladderNum, buyNum, buyPrice, createDate
|
|
|
- )
|
|
|
- values (
|
|
|
- #{orderProductId},#{ladderNum},#{buyNum},#{buyPrice},#{createDate}
|
|
|
- )
|
|
|
+ <insert id="insertOrderProductLadderPrice" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
|
|
|
+ parameterType="com.caimei.model.po.OrderProductLadderPricePo">
|
|
|
+ insert into order_product_ladder_price (orderProductId, ladderNum, buyNum, buyPrice, createDate)
|
|
|
+ values (#{orderProductId}, #{ladderNum}, #{buyNum}, #{buyPrice}, #{createDate})
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateOrder" parameterType="com.caimei.model.po.CmOrderPo">
|
|
@@ -1448,24 +1452,26 @@
|
|
|
where id = #{receiveCouponId}
|
|
|
</update>
|
|
|
<update id="updateReductionUserId">
|
|
|
- update cm_hehe_reduction_user set orderId = #{orderId} where id = #{reductionUserId}
|
|
|
+ update cm_hehe_reduction_user
|
|
|
+ set orderId = #{orderId}
|
|
|
+ where id = #{reductionUserId}
|
|
|
</update>
|
|
|
|
|
|
<select id="findByAddressId" resultType="com.caimei.model.vo.AddressVo">
|
|
|
- SELECT a.addressID AS addressId,
|
|
|
- a.userID AS userId,
|
|
|
+ SELECT a.addressID AS addressId,
|
|
|
+ a.userID AS userId,
|
|
|
a.shouHuoRen,
|
|
|
- a.townID AS townId,
|
|
|
+ a.townID AS townId,
|
|
|
a.address,
|
|
|
a.postalCode,
|
|
|
a.phone,
|
|
|
a.mobile,
|
|
|
a.defaultFlag,
|
|
|
- c.cityID AS cityId,
|
|
|
+ c.cityID AS cityId,
|
|
|
p.provinceID AS provinceId,
|
|
|
- t.name AS townName,
|
|
|
- c.name AS cityName,
|
|
|
- p.name AS provinceName
|
|
|
+ t.name AS townName,
|
|
|
+ c.name AS cityName,
|
|
|
+ p.name AS provinceName
|
|
|
FROM address a
|
|
|
LEFT JOIN town t ON t.townID = a.townID
|
|
|
LEFT JOIN city c ON c.cityID = t.cityID
|
|
@@ -1473,7 +1479,8 @@
|
|
|
WHERE a.addressID = #{addressId}
|
|
|
</select>
|
|
|
|
|
|
- <insert id="insertUserInfo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.BpOrderUserInfoPo" useGeneratedKeys="true">
|
|
|
+ <insert id="insertUserInfo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.BpOrderUserInfoPo"
|
|
|
+ useGeneratedKeys="true">
|
|
|
insert into bp_order_userinfo
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="orderId != null">
|
|
@@ -1559,47 +1566,46 @@
|
|
|
</trim>
|
|
|
</insert>
|
|
|
<insert id="insertCouponOrderRecord">
|
|
|
- INSERT INTO cm_hehe_coupon_order_record (orderId, receiveCouponId, couponType, couponAmount, touchPrice, createDate)
|
|
|
+ INSERT INTO cm_hehe_coupon_order_record (orderId, receiveCouponId, couponType, couponAmount, touchPrice,
|
|
|
+ createDate)
|
|
|
VALUES (#{orderId}, #{receiveCouponId}, #{couponType}, #{couponAmount}, #{touchPrice}, #{createDate})
|
|
|
</insert>
|
|
|
- <insert id="insertReductionUser" keyColumn="id" keyProperty="reductionUserId" parameterType="com.caimei.model.po.ReductionUserPo" useGeneratedKeys="true">
|
|
|
+ <insert id="insertReductionUser" keyColumn="id" keyProperty="reductionUserId"
|
|
|
+ parameterType="com.caimei.model.po.ReductionUserPo" useGeneratedKeys="true">
|
|
|
insert into cm_hehe_reduction_user (userId, reductionId, shareType, touchPrice, reductionAmount, shareTime)
|
|
|
values (#{userId}, #{reductionId}, #{shareType}, #{touchPrice}, #{reducedAmount}, NOW())
|
|
|
</insert>
|
|
|
|
|
|
<select id="findShopByProductId" resultType="com.caimei.model.vo.ShopVo">
|
|
|
- SELECT
|
|
|
- s.shopID AS shopId,
|
|
|
- s.name,
|
|
|
- s.logo,
|
|
|
- p.splitCode
|
|
|
- FROM
|
|
|
- cm_hehe_product chp
|
|
|
- LEFT JOIN product p ON chp.productId = p.productID
|
|
|
- LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
- WHERE
|
|
|
- chp.productId = #{productId}
|
|
|
+ SELECT s.shopID AS shopId,
|
|
|
+ s.name,
|
|
|
+ s.logo,
|
|
|
+ p.splitCode
|
|
|
+ FROM cm_hehe_product chp
|
|
|
+ LEFT JOIN product p ON chp.productId = p.productID
|
|
|
+ LEFT JOIN shop s ON p.shopID = s.shopID
|
|
|
+ WHERE chp.productId = #{productId}
|
|
|
AND chp.validFlag = 1
|
|
|
</select>
|
|
|
|
|
|
<select id="findProductById" resultType="com.caimei.model.vo.CartProductVo">
|
|
|
- SELECT
|
|
|
- chp.productId,
|
|
|
- chp.price,
|
|
|
- chp.price as normalPrice,
|
|
|
- chp.includedTax,
|
|
|
- chp.invoiceType,
|
|
|
- chp.clubTaxPoint,
|
|
|
- p.name,
|
|
|
- p.shopID AS shopId,
|
|
|
- p.mainImage as productImage,
|
|
|
- p.unit as productUnit
|
|
|
- FROM
|
|
|
- cm_hehe_product chp
|
|
|
- LEFT JOIN product p ON chp.productId = p.productID
|
|
|
- WHERE
|
|
|
- chp.validFlag = 1
|
|
|
- AND chp.productId = #{productId}
|
|
|
+ SELECT cs.skuId,
|
|
|
+ chp.productId,
|
|
|
+ chs.price,
|
|
|
+ chs.price as normalPrice,
|
|
|
+ chp.includedTax,
|
|
|
+ chp.invoiceType,
|
|
|
+ chp.clubTaxPoint,
|
|
|
+ p.name,
|
|
|
+ p.shopID AS shopId,
|
|
|
+ p.mainImage as productImage,
|
|
|
+ cs.unit as productUnit
|
|
|
+ FROM cm_hehe_product chp
|
|
|
+ LEFT JOIN product p ON chp.productId = p.productID
|
|
|
+ LEFT JOIN cm_sku cs on p.productID=cs.productId
|
|
|
+ LEFT JOIN cm_hehe_sku chs on chs.skuId=cs.skuId
|
|
|
+ WHERE chp.validFlag = 1
|
|
|
+ AND cs.skuId = #{skuId}
|
|
|
</select>
|
|
|
<select id="findCartProducts" resultType="com.caimei.model.vo.CartProductVo">
|
|
|
SELECT
|
|
@@ -1607,14 +1613,12 @@
|
|
|
cc.productID AS productId,
|
|
|
cc.productCount as num,
|
|
|
cc.heUserId,
|
|
|
- chp.price,
|
|
|
chp.includedTax,
|
|
|
chp.invoiceType,
|
|
|
chp.clubTaxPoint,
|
|
|
p.name,
|
|
|
p.shopID AS shopId,
|
|
|
p.mainImage as productImage,
|
|
|
- p.unit as productUnit
|
|
|
FROM
|
|
|
cm_cart cc
|
|
|
LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
|
|
@@ -1628,7 +1632,9 @@
|
|
|
</select>
|
|
|
<select id="findCurrentReduction" resultType="com.caimei.model.vo.ReductionVo">
|
|
|
select id as reductionId, reducedAmount, touchPrice, shareNum
|
|
|
- from cm_hehe_reduction where NOW() <![CDATA[ >= ]]> startTime and NOW() <![CDATA[ <= ]]> endTime
|
|
|
+ from cm_hehe_reduction
|
|
|
+ where NOW() <![CDATA[ >= ]]> startTime
|
|
|
+ and NOW() <![CDATA[ <= ]]> endTime
|
|
|
</select>
|
|
|
<select id="findShareNum" resultType="java.lang.Integer">
|
|
|
select count(*)
|
|
@@ -1637,8 +1643,10 @@
|
|
|
and reductionId = #{reductionId}
|
|
|
</select>
|
|
|
<select id="findReduction" resultType="com.caimei.model.vo.ReductionVo">
|
|
|
- select chr.id as reductionId, reducedAmount, chr.touchPrice from cm_hehe_reduction chr
|
|
|
- left join cm_hehe_reduction_user chru on chr.id = chru.reductionId
|
|
|
- where chru.id = #{reductionUserId} and chru.orderId is null
|
|
|
+ select chr.id as reductionId, reducedAmount, chr.touchPrice
|
|
|
+ from cm_hehe_reduction chr
|
|
|
+ left join cm_hehe_reduction_user chru on chr.id = chru.reductionId
|
|
|
+ where chru.id = #{reductionUserId}
|
|
|
+ and chru.orderId is null
|
|
|
</select>
|
|
|
</mapper>
|