| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?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.gree.mall.miniapp.commonmapper.AppMapper">
- <select id="findCommonFileById" resultType="com.gree.mall.miniapp.plus.entity.CommonFile">
- SELECT * FROM common_file
- WHERE
- id IN
- <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </select>
- <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.order.ShoppingCartList">
- SELECT
- a.*,
- b.price,
- c.goods_name,
- b.spec_value,
- b.org_price,
- b.price * num AS 'totalPrice', e.img_url 'goodsImg',
- IFNULL(d.stock_qty, 0) AS stock_qty
- FROM shopping_cart a
- JOIN goods_spec b ON a.goods_spec_id = b.goods_spec_id
- JOIN goods c ON c.goods_id = a.goods_id
- LEFT JOIN goods_material_storage d ON b.goods_code = d.goods_material_id AND a.storage_id = d.storage_id
- LEFT JOIN goods_detail e on c.goods_id = e.goods_id
- WHERE a.user_id = #{userId}
- <if test="storageId != null and storageId != ''">
- AND a.storage_id = #{storageId}
- </if>
- </select>
- <select id="orderStatusCount" resultType="com.gree.mall.miniapp.bean.order.OrderStatusBean">
- select sum(if(order_status = 'NOPAY', 1, 0)) noPay,
- sum(if(order_status in ('YFH','DFH'), 1, 0)) yfh,
- sum(if(order_status = 'DFH', 1, 0)) dfh,
- sum(if(order_status in ('REFUND'), 1, 0)) sh,
- sum(if(order_status = 'OVER' and comment_goods=0, 1, 0)) ywc
- from order_info
- where user_id = #{userId}
- </select>
- <select id="queryNewGoods" resultType="com.gree.mall.miniapp.bean.goods.GoodsNewBean">
- select
- a.*,
- c.img_url
- <if test="objId != null and objId != ''">
- ,b.obj_id
- </if>
- from goods a
- LEFT JOIN goods_detail c ON a.goods_id = c.goods_id
- <if test="objId != null and objId != ''">
- join goods_news_category_goods b on a.goods_id = b.goods_id
- </if>
- where
- a.company_wechat_id = #{companyWechatId} and a.del=0 and a.status=1
- <if test="objId != null and objId != ''">
- and b.obj_id = #{objId}
- </if>
- <if test="type != null and type != ''">
- and b.type = #{type}
- </if>
- <if test="sort != null and sort==0">
- order by a.sort_num
- </if>
- <if test="sort != null and sort==1">
- order by a.sold_num desc
- </if>
- <if test="sort != null and sort==2">
- order by goods_price asc
- </if>
- <if test="sort != null and sort==3">
- order by goods_price desc
- </if>
- <if test="sort != null and sort==4">
- order by a.create_time desc
- </if>
- </select>
- <select id="findStorageByLocate" resultType="com.gree.mall.miniapp.bean.StorageBean">
- SELECT
- storage_id,
- company_wechat_id,
- company_name,
- storage_name,
- storage_address,
- storage_mobile,
- type,
- status,
- is_default,
- lng,
- lat,
- -- 使用哈弗辛公式计算球面距离(单位:公里)
- ROUND(6371 * 2 * ASIN(
- SQRT(
- POW(SIN((RADIANS(23.09) - RADIANS(CAST(lat AS DECIMAL(10,6)))) / 2), 2) +
- COS(RADIANS(23.09)) * COS(RADIANS(CAST(lat AS DECIMAL(10,6)))) *
- POW(SIN((RADIANS(113.32) - RADIANS(CAST(lng AS DECIMAL(10,6)))) / 2), 2)
- )
- ), 2) AS distance
- FROM storage
- WHERE del = 0
- AND status = 1
- AND lng IS NOT NULL
- AND lat IS NOT NULL
- AND lng != ''
- AND lat != ''
- <if test="companyWechatId != null and companyWechatId !=''">
- AND company_wechat_id = #{companyWechatId}
- </if>
- ORDER BY distance ASC
- </select>
- <select id="queryTrainingList" resultType="com.gree.mall.miniapp.bean.message.TrainingVO">
- SELECT
- a.id,
- a.company_wechat_id,
- a.company_name,
- b.name,
- b.remark,
- b.file_type,
- b.url
- FROM training a
- LEFT JOIN common_file b ON a.obj_id = b.id
- WHERE
- a.company_wechat_id IN ('0', CONCAT(#{companyWechatId}))
- AND a.del = 0
- ORDER BY a.create_time DESC
- </select>
- </mapper>
|