123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- <?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="com.caimei365.order.mapper.BaseMapper">
- <select id="getOrganizeId" resultType="java.lang.Integer">
- SELECT userOrganizeID FROM USER WHERE userId = #{userId}
- </select>
- <select id="getShopNameById" resultType="java.lang.String">
- SELECT `name`
- FROM shop
- WHERE shopID = #{shopId}
- LIMIT 1
- </select>
- <select id="getClubNameById" resultType="java.lang.String">
- SELECT `name`
- FROM club
- WHERE clubID = #{clubId}
- LIMIT 1
- </select>
- <insert id="insertUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
- INSERT INTO cm_user_invoiceinfo (userId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone,
- bankAccountNo, openBank)
- VALUES (#{userId}, #{invoiceTitle}, #{corporationTaxNum}, #{registeredAddress}, #{registeredPhone},
- #{bankAccountNo}, #{openBank})
- </insert>
- <insert id="insertPurchasePrice" keyColumn="id" keyProperty="id"
- parameterType="com.caimei365.order.model.po.PurchasePricePo" useGeneratedKeys="true">
- INSERT INTO repeat_purchase_price (userId, skuId, clubId, orderId, productId, shopId, shopName,
- taxRate, currentPrice, createTime, updateTime, delFlag)
- VALUES (#{userId}, #{skuId}, #{clubId}, #{orderId}, #{productId}, #{shopId}, #{shopName},
- #{taxRate}, #{currentPrice}, #{createTime}, #{updateTime}, #{delFlag})
- </insert>
- <insert id="insertPurchaseHistory" keyColumn="id" keyProperty="id"
- parameterType="com.caimei365.order.model.po.PurchaseHistoryPo" useGeneratedKeys="true">
- INSERT INTO repeat_purchase_price_history (userId, skuId, clubId, orderId, productId, price, currentCostPrice,
- createTime, delFlag)
- VALUES (#{userId}, #{skuId}, #{clubId}, #{orderId}, #{productId}, #{price}, #{currentCostPrice}, #{createTime},
- #{delFlag})
- </insert>
- <update id="updateUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
- UPDATE cm_user_invoiceinfo
- SET invoiceTitle = #{invoiceTitle},
- corporationTaxNum = #{corporationTaxNum},
- registeredAddress = #{registeredAddress},
- registeredPhone = #{registeredPhone},
- bankAccountNo = #{bankAccountNo},
- openBank = #{openBank}
- WHERE userId = #{userId}
- </update>
- <update id="updatePurchasePrice">
- UPDATE repeat_purchase_price
- SET currentPrice = #{currentPrice},
- taxRate = #{taxRate},
- updateTime = #{updateTime},
- orderId = #{orderId}
- WHERE id = #{id}
- </update>
- <select id="firstClubTypeById" resultType="java.lang.String">
- select firstClubType
- from club
- where clubID = #{clubId}
- </select>
- <select id="machineTypeByID" resultType="java.lang.String">
- SELECT p.machineType FROM product p LEFT JOIN cm_sku cs ON p.productID = cs.productId
- WHERE
- cs.skuID in
- <foreach collection="skuIds" open="(" separator="," close=")" item="skuId">
- #{skuId}
- </foreach>
- </select>
- <select id="getUserIdByClubId" resultType="java.lang.Integer">
- select userID
- from user
- where clubID = #{clubId}
- LIMIT 1
- </select>
- <select id="getIdentityByUserId" resultType="java.lang.Integer">
- select ifnull(userIdentity, 0)
- from user
- where userID = #{userId}
- LIMIT 1
- </select>
- <select id="getUserNameByUserId" resultType="java.lang.String">
- select userName
- from user
- where userID = #{userId}
- LIMIT 1
- </select>
- <select id="getLadderPriceList" resultType="com.caimei365.order.model.vo.LadderPriceVo">
- select id,
- productId,
- skuId,
- ladderNum,
- buyNum,
- buyPrice
- from product_ladder_price
- where skuId = #{skuId}
- and userType = 3
- and delFlag = 0
- order by ladderNum asc
- </select>
- <select id="getRepurchasePrice" resultType="java.lang.Double">
- select r.currentPrice
- from repeat_purchase_price r
- left join cm_sku cs on r.skuId = cs.skuId
- where r.skuId = #{skuId}
- and r.userId = #{userId}
- and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
- and cs.price <![CDATA[ >= ]]> r.currentPrice
- and r.delFlag = 0
- </select>
- <select id="getPromotionByShopId" resultType="com.caimei365.order.model.vo.PromotionsVo">
- SELECT pr.id,
- pr.name,
- pr.description,
- pr.type,
- pr.mode,
- pr.touchPrice,
- pr.reducedPrice,
- pr.beginTime,
- pr.endTime,
- pr.status,
- prp.productId,
- prp.supplierId AS shopId,
- pr.seen,
- pr.discount
- FROM cm_promotions pr
- LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
- WHERE prp.supplierId = #{shopId}
- and pr.delFlag = 0
- and pr.type = 3
- AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
- ORDER BY pr.type DESC
- LIMIT 1
- </select>
- <select id="getPromotionByProductId" resultType="com.caimei365.order.model.vo.PromotionsVo">
- SELECT pr.id,
- pr.name,
- pr.description,
- pr.type,
- pr.mode,
- pr.touchPrice,
- pr.reducedPrice,
- pr.beginTime,
- pr.endTime,
- pr.status,
- prp.productId,
- prp.supplierId AS shopId,
- pr.discount,
- pr.seen
- FROM cm_promotions pr
- LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
- WHERE prp.productId = #{productId}
- and pr.delFlag = 0
- and pr.type in (1, 2)
- AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
- ORDER BY pr.type DESC
- LIMIT 1
- </select>
- <select id="getPromotionGifts" resultType="com.caimei365.order.model.vo.CartItemVo">
- SELECT cpg.id AS id,
- cs.productID AS productId,
- cpg.skuId AS skuId,
- p.shopID AS shopId,
- p.`name` AS `name`,
- p.mainImage AS image,
- cpg.number AS number,
- 0 AS price,
- 2 as giftType,
- cs.price AS originalPrice,
- cs.unit AS unit,
- cs.stock AS stock,
- cpg.skuId AS giftSkuId,
- p.validFlag AS validFlag,
- p.productType
- FROM cm_promotions_gift cpg
- LEFT JOIN cm_sku cs ON cpg.skuId = cs.skuId
- LEFT JOIN product p ON cs.productId = p.productID
- WHERE cpg.promotionsId = #{promotionsId}
- ORDER BY cpg.id DESC
- </select>
- <select id="getShopByProductId" resultType="com.caimei365.order.model.vo.CartShopVo">
- SELECT s.shopID AS shopId,
- s.name AS shopName,
- s.logo AS shopLogo
- FROM shop s
- LEFT JOIN product p ON p.shopID = s.shopID
- WHERE p.productId = #{productId}
- LIMIT 1
- </select>
- <select id="getUserInvoice" resultType="com.caimei365.order.model.vo.InvoiceVo">
- SELECT id,
- userId,
- invoiceTitle,
- corporationTaxNum,
- registeredAddress,
- registeredPhone,
- bankAccountNo,
- openBank
- FROM cm_user_invoiceinfo
- WHERE userId = #{userId}
- LIMIT 1
- </select>
- <select id="getUserMoney" resultType="java.lang.Double">
- SELECT IFNULL(userMoney, 0)
- FROM user
- WHERE userID = #{userId}
- </select>
- <select id="getAbleUserMoney" resultType="java.lang.Double">
- SELECT IFNULL(ableUserMoney, 0)
- FROM user
- WHERE userID = #{userId}
- </select>
- <select id="getUserBeans" resultType="java.lang.Integer">
- SELECT IFNULL(userBeans, 0)
- FROM user
- WHERE userID = #{userId}
- </select>
- <select id="getPostageFlagList" resultType="com.caimei365.order.model.vo.ProductPostageVo">
- SELECT
- p.productID AS productId,
- freePostFlag AS postageFlag,
- commodityType,
- productType
- FROM product p
- left join cm_sku cs on p.productID=cs.productId
- WHERE validFlag='2' AND cs.skuId in
- <foreach collection="skuIds" open="(" separator="," close=")" item="skuId">
- #{skuId}
- </foreach>
- </select>
- <select id="countUserOrder" resultType="java.lang.Integer">
- SELECT COUNT(*)
- FROM cm_order
- WHERE userID = #{userId}
- AND delFlag = 0
- AND STATUS != 6
- </select>
- <select id="getProvinceIdAndCityId" resultType="com.caimei365.order.model.vo.AddressVo">
- SELECT provinceID AS provinceId, cityID AS cityId
- FROM city
- WHERE cityID = (SELECT cityID from town where townID = #{townId})
- </select>
- <select id="getTownIdByAddressId" resultType="java.lang.Integer">
- SELECT townID
- FROM address
- WHERE addressID = #{addressId}
- </select>
- <select id="getPurchasePricePo" resultType="com.caimei365.order.model.po.PurchasePricePo">
- SELECT skuId,
- id,
- userId,
- clubId,
- orderId,
- productId,
- shopId,
- shopName,
- taxRate,
- currentPrice,
- createTime
- FROM repeat_purchase_price
- WHERE userId = #{userId}
- AND skuId = #{skuId}
- AND delFlag = '0'
- </select>
- <select id="getBindMobileByUserId" resultType="java.lang.String">
- SELECT bindMobile
- FROM user
- WHERE userID = #{userId}
- </select>
- <select id="getShopIdByproductId" resultType="java.lang.Integer">
- SELECT p.shopID, p.productType
- FROM product p
- LEFT JOIN cm_sku cs on cs.productId = p.productID
- WHERE cs.skuId = #{skuId}
- </select>
- <select id="getClauseList" resultType="com.caimei365.order.model.vo.ClauseVo">
- SELECT id,
- name,
- content,
- clauseType,
- enabledStatus
- FROM bp_clause
- </select>
- <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id"
- parameterType="com.caimei365.order.model.po.DiscernReceiptPo" useGeneratedKeys="true">
- INSERT INTO cm_discern_receipt (payWay, payType, receiptType, receiptStatus, receiptAmount, confirmType,
- receiptDate, confirmDate, reviewDate, updateDate, delFlag, rePayFlag, formData,
- quickInfoId)
- VALUES (#{payWay}, #{payType}, #{receiptType}, #{receiptStatus}, #{receiptAmount}, #{confirmType},
- #{receiptDate}, #{confirmDate}, #{reviewDate}, #{updateDate}, #{delFlag}, #{rePayFlag}, #{formData},
- #{infoId})
- </insert>
- <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
- parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
- INSERT INTO cm_receipt_order_relation (relationType, receiptId, associationType, associateAmount, orderId,
- couponRecordId, vipRecordId, authVipRecordId, delFlag,
- mbOrderId, orderRequestNo, splitStatus, productId, shopOrderId)
- VALUES (#{relationType}, #{receiptId}, #{associationType}, #{associateAmount}, #{orderId}, #{couponRecordId},
- #{vipRecordId}, #{authVipRecordId}, #{delFlag},
- #{mbOrderId}, #{orderRequestNo}, #{splitStatus}, #{productId}, #{shopOrderId})
- </insert>
- <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
- INSERT INTO user_beans_history (userId, type, beansType, orderId, num, pushStatus, addTime, delFlag)
- VALUES (#{userId}, #{type}, #{beansType}, #{orderId}, #{num}, #{pushStatus}, #{addTime}, #{delFlag})
- </insert>
- <update id="updateUserBeans">
- UPDATE USER
- SET userBeans = #{userBeans}
- WHERE userID = #{userId}
- </update>
- <update id="updateUserClubStatus">
- UPDATE user
- SET clubStatus = #{clubStatus}
- WHERE userID = #{userId}
- </update>
- <update id="updateClubStatus">
- UPDATE club
- SET status = #{clubStatus}
- WHERE userID = #{userId}
- </update>
- <update id="updateUserMoney">
- UPDATE USER
- SET userMoney = #{userMoney},
- ableUserMoney = #{ableUserMoney}
- WHERE userID = #{userId}
- </update>
- <update id="updateOrderOnlineFlag">
- update cm_order
- set onlinePayFlag = 1
- where orderID = #{orderId}
- </update>
- <insert id="insertBalanceRecord" parameterType="com.caimei365.order.model.po.BalanceRecordPo">
- INSERT INTO cm_user_balance_record (userId, type, balanceType, addDate, amount, orderId, receiptId, remark,
- delFlag)
- VALUES (#{userId}, #{type}, #{balanceType}, #{addDate}, #{amount}, #{orderId}, #{receiptId}, #{remark},
- #{delFlag})
- </insert>
- <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
- select userId
- from cm_svip_user
- where userId = #{userId}
- and delFlag = '0'
- and now() <![CDATA[ < ]]> endTime
- </select>
- <select id="getSvipUserIdByClubId" resultType="java.lang.Integer">
- select svu.userId
- from cm_svip_user svu
- left join club c on svu.userId = c.userID
- where c.clubID = #{clubId}
- and delFlag = '0'
- and now() <![CDATA[ < ]]> endTime;
- </select>
- <select id="getClubStatus" resultType="java.lang.Integer">
- select clubStatus
- from user
- where userID = #{userId}
- </select>
- <select id="getClubConfirmTime" resultType="java.util.Date">
- SELECT confirmTime
- FROM club_confirm_record
- WHERE userId = #{userId}
- ORDER BY confirmTime DESC
- LIMIT 1
- </select>
- <select id="findLowOrder" resultType="com.caimei365.order.model.po.UserBeansHistoryPo">
- select id, userId, type, beansType, orderId, num, addTime
- from user_beans_history
- where orderId = #{orderId}
- and delFlag = 0
- and type = 2
- and num = 500
- </select>
- <select id="findBeans" resultType="java.lang.Integer">
- select userBeans
- from user
- where userID = #{userId}
- </select>
- <select id="getAuthUser" resultType="com.caimei365.order.model.vo.AuthUserVo">
- select authUserId, name, mobile
- from cm_brand_auth_user
- where authUserId = #{userId}
- LIMIT 1
- </select>
- <select id="findType" resultType="java.lang.String">
- SELECT payType
- FROM cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptID
- WHERE cror.mbOrderId = #{mbOrderId}
- </select>
- <select id="findShopOrderIds" resultType="java.lang.String">
- select shopOrderIDs
- from cm_order
- where orderID = #{orderId}
- </select>
- <select id="findCoupon" resultType="com.caimei365.order.model.vo.CouponVo">
- select id as couponId, name, moneyCouponPrice, couponAmount, touchPrice
- from cm_coupon
- where id = #{couponId}
- and delflag = 0
- and couponPayWay = 2
- and moneyCouponFlag = 1
- </select>
- <select id="getSvipSku" resultType="com.caimei365.order.model.dto.VipSkuPriceDto">
- select priceType, discount, discountPrice, csps.productId, skuId
- from cm_svip_product_sku csps
- left join cm_svip_product csp on csps.productId = csp.productId
- where skuId = #{skuId}
- and csp.status = 0
- </select>
- <select id="getTouchPriceBySku" resultType="java.lang.Double">
- select touchPrice
- from cm_promotion_sku
- where skuId = #{skuId}
- and promotionId = #{promotionId}
- </select>
- </mapper>
|