| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- <?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.MaterialMapper">
- <select id="buyList" resultType="com.gree.mall.miniapp.bean.material.SalesOrderBean">
- SELECT
- a.*
- FROM
- websit_sales a
- <where>
- a.company_wechat_id = #{companyWechatId}
- AND worker_id = #{userId}
- <if test="flag!=null and flag!=''">
- AND a.flag = #{flag}
- </if>
- <if test="flag==null or flag==''">
- AND a.flag IN ('SAVE', 'SUBMIT', 'PAY_NOT_TAKE', 'PAY_TAKE')
- </if>
- </where>
- ORDER BY a.create_time DESC
- </select>
- <select id="existStockCategory" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesCategoryVO">
- SELECT
- c.category_id,
- c.category_name
- FROM
- websit_stock a
- LEFT JOIN websit_goods b ON a.goods_id = b.goods_id
- LEFT JOIN websit_goods_category c ON b.goods_category_id = c.category_id
- WHERE
- a.company_wechat_id = #{companyWechatId}
- AND a.websit_id = #{websitId}
- AND a.goods_type = 'M'
- AND a.qty > 0
- GROUP BY b.goods_category_id
- </select>
- <select id="existStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
- SELECT
- a.goods_id,
- b.goods_name,
- <if test="goodsType=='M'.toString()">
- c.price,
- </if>
- <if test="goodsType=='P'.toString()">
- b.market_price AS price,
- </if>
- b.goods_code,
- b.goods_spell,
- b.goods_specification,
- b.goods_stock_unit,
- b.goods_sales_unit,
- b.brand_rela_name,
- b.product_rela_name,
- b.convert_bit_scale,
- b.goods_sales_convert_qty,
- b.manage_worker_stock,
- a.qty
- FROM
- websit_stock a
- JOIN websit_goods b ON a.goods_id = b.goods_id
- <if test="goodsType=='M'.toString()">
- LEFT JOIN websit_goods_price c ON a.websit_id = c.websit_id AND a.goods_id = c.goods_id
- </if>
- WHERE
- a.company_wechat_id = #{companyWechatId}
- <if test="goodsType=='M'.toString() and categoryId!=null and categoryId!=''">
- AND b.goods_category_id = #{categoryId}
- </if>
- <if test="goodsName!=null and goodsName!=''">
- AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
- </if>
- AND a.websit_id = #{websitId}
- AND a.goods_type = #{goodsType}
- AND a.qty > 0
- GROUP BY a.goods_id
- LIMIT 100
- </select>
- <select id="notStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
- SELECT
- b.goods_id,
- b.goods_name,
- b.market_price AS price,
- b.goods_code,
- b.goods_spell,
- b.goods_specification,
- b.goods_stock_unit,
- b.goods_sales_unit,
- b.brand_rela_name,
- b.product_rela_name,
- b.convert_bit_scale,
- b.goods_sales_convert_qty,
- b.manage_worker_stock,
- b.part_type,
- 0 AS qty
- FROM
- websit_goods b
- WHERE
- b.company_wechat_id = #{companyWechatId}
- <if test="goodsName!=null and goodsName!=''">
- AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
- </if>
- AND b.goods_type = #{goodsType}
- AND b.status = 'ON'
- AND b.norm_type = 'M'
- </select>
- <select id="normRecordList" resultType="com.gree.mall.miniapp.bean.material.NormRecordVO">
- SELECT
- a.*
- FROM
- websit_norm_record a
- WHERE
- a.company_wechat_id = #{companyWechatId}
- AND a.worker_id = #{userId}
- <if test="orderId!=null and orderId!=''">
- AND a.order_id LIKE CONCAT ('%', #{orderId}, '%')
- </if>
- <if test="goodsType!=null and goodsType!=''">
- AND a.goods_type = #{goodsType}
- </if>
- <if test="startTime!=null and startTime!=''">
- AND a.use_time BETWEEN #{startTime} AND #{endTime}
- </if>
- ORDER BY a.use_time DESC
- </select>
- <select id="partsRefundList" resultType="com.gree.mall.miniapp.bean.material.PartsRefundVO">
- SELECT
- a.*
- FROM
- websit_parts_ret a
- WHERE
- a.company_wechat_id = #{companyWechatId}
- AND a.worker_id = #{userId}
- <if test="type!=null and type!=''">
- AND a.type = #{type}
- </if>
- <if test="status!=null and status!=''">
- AND a.flag = #{status}
- </if>
- </select>
- <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.material.WebsitShoppingCartList">
- SELECT
- a.*
- FROM
- websit_shopping_cart a
- WHERE
- a.worker_id = #{workerId}
- AND a.websit_id = #{websitId}
- AND a.goods_type = #{goodsType}
- </select>
- <select id="queryWorkerStockQty"
- resultType="com.gree.mall.miniapp.bean.material.stock.WorkerNormStockBean">
- SELECT
- a.norm_id,
- a.worker_goods_id,
- a.qty,
- b.goods_name,
- b.is_small,
- b.sales_unit,
- c.qty AS stock_qty
- FROM
- websit_norm_rela a
- JOIN
- worker_goods b
- ON a.company_wechat_id = b.company_wechat_id AND a.worker_goods_id = b.goods_id
- LEFT JOIN
- worker_stock c
- ON c.worker_id = #{workerId} AND a.company_wechat_id = c.company_wechat_id AND a.worker_goods_id = c.goods_id
- WHERE
- a.norm_id = #{goodsId}
- </select>
- <select id="appList" resultType="com.gree.mall.miniapp.bean.material.parts.NewRefundManageBean">
- SELECT
- a.company_wechat_id,
- a.company_wechat_name,
- a.apply_no,
- a.sales_id,
- a.apply_category,
- CASE a.apply_category WHEN 'HOME' THEN '家用空调'
- WHEN 'TRADE' THEN '商用空调'
- WHEN 'ELEC' THEN '生活电器(小家电)'
- ELSE '' END AS applyCategoryName,
- a.apply_type,
- CASE a.apply_type WHEN 'NEW' THEN '新件返还'
- WHEN 'LOST' THEN '破损返还'
- WHEN 'BUG' THEN '故障返还'
- ELSE '' END AS applyTypeName,
- a.refund_mode,
- CASE a.refund_mode WHEN 'EXPRESS' THEN '快递'
- WHEN 'SELF' THEN '网点自还'
- ELSE '' END AS refundModeName,
- a.express_no,
- a.receive_address,
- a.receive_websit_id,
- a.receive_websit_name,
- a.receive_parts_websit_id,
- a.websit_Address,
- a.identity,
- a.worker_id,
- a.worker_name,
- a.refund_amount,
- a.refund_amount_mode,
- IF(refund_amount_mode = 'CASH', '现金', '微信') AS refundAmountModeName,
- a.remark,
- a.examine_remark,
- a.flag,
- CASE a.flag WHEN 'SAVE' THEN '保存'
- WHEN 'SUBMIT' THEN '待审批'
- WHEN 'AGREE' THEN '待返还'
- WHEN 'REJECT' THEN '驳回'
- WHEN 'REFUNDED' THEN '已返还'
- ELSE '' END AS flagName,
- a.create_by,
- a.create_time,
- a.update_by,
- a.update_time,
- a.submit_by,
- a.submit_time,
- a.examine_by,
- a.examine_time,
- a.refunded_by,
- a.refunded_time
- FROM
- websit_parts_new_refund_manage a
- LEFT JOIN websit_parts_new_refund_manage_item b ON a.apply_no = b.apply_no
- <where>
- <if test="applyNo != null and applyNo != ''">
- AND a.apply_no = #{applyNo}
- </if>
- <if test="flag != null and flag != ''">
- AND a.flag = #{flag}
- </if>
- <if test="identity != null and identity != ''">
- AND a.identity = #{identity}
- </if>
- <if test="partsNumber != null and partsNumber != ''">
- AND b.parts_number = #{partsNumber}
- </if>
- </where>
- GROUP BY a.apply_no, a.create_time
- ORDER BY a.create_time DESC
- </select>
- <select id="querySalesPushFlagItem" resultType="com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem">
- SELECT
- id,
- identity,
- websit_id,
- parts_websit_id,
- parts_id,
- parts_number,
- parts_name,
- material_group_name,
- goods_stock_unit,
- sales_id,
- sales_price,
- market_price,
- second_price,
- qty,
- examine_qty,
- new_refund_qty,
- old_refund_qty,
- total_amount,
- refund_amount_mode,
- push_flag,
- create_by,
- create_time,
- update_by,
- update_time,
- examine_time
- FROM
- websit_parts_sales_item
- WHERE
- identity = #{identity}
- AND websit_id = #{websitId}
- AND parts_websit_id = #{partsWebsitId}
- <if test="pushFlag != null and pushFlag != ''">
- AND push_flag = #{pushFlag}
- </if>
- <if test="salesId != null and salesId != ''">
- AND sales_id = #{salesId}
- </if>
- AND parts_number IN
- <foreach item="item" index="index" collection="records" open="(" separator=","
- close=")">
- #{item.partsNumber}
- </foreach>
- ORDER BY
- examine_time
- FOR UPDATE
- </select>
- <select id="appSalesList" resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderBean">
- SELECT
- a.*,
- CASE a.order_source WHEN 'SELF' THEN '自建订单'
- WHEN 'ONLINE' THEN '在线订单'
- ELSE '' END AS buyTypeName,
- CASE a.status WHEN 'SAVE' THEN '保存未提交'
- WHEN 'SUBMIT' THEN '已提交'
- <!-- WHEN '2' THEN '已支付' -->
- WHEN 'PAYED' THEN
- <!-- WHEN '3' THEN '已提货' -->
- (case when a.worker_confirm_date is not null and a.websit_confirm_date is not null then '已提货'
- when a.worker_confirm_date is not null then '师傅已提货'
- when a.websit_confirm_date is not null then '网点已提货' else '已支付' end)
- WHEN 'END' THEN '已完成'
- WHEN 'CANCEL' THEN '已取消'
- ELSE '' END AS stateName,
- CASE a.pushFlag WHEN 'SALES' THEN '销售'
- WHEN 'TRANS' THEN '转销售'
- WHEN 'END' THEN '完结'
- ELSE '' END AS pushFlagName
- FROM
- websit_parts_sales a, websit_parts_sales_item b
- WHERE
- a.id = b.sales_id
- AND a.del = 0
- AND a.identity = #{identity}
- <if test="salesId != null and salesId != ''">
- AND a.id = #{salesId}
- </if>
- <if test="status != null and status != ''">
- <!-- and 1 = 0 -->
- <if test="status == 'SAVE'.toString() or status == 'SUBMIT'.toString() or status == 'END'.toString() or status == 'CANCEL'.toString()">
- AND a.status = #{state}
- </if>
- <if test="state == 'PAYED'.toString()">
- AND a.status = 'PAYED' AND (a.worker_confirm_date is null and a.websit_confirm_date is null)
- </if>
- </if>
- <if test="pushFlag != null and pushFlag != ''">
- AND a.pushFlag = #{pushFlag}
- AND b.qty > 0
- </if>
- <if test="partsNumber != null and partsNumber != ''">
- AND b.parts_number = #{partsNumber}
- </if>
- GROUP BY
- a.identity, a.id, a.create_time
- ORDER BY
- a.create_time DESC
- </select>
- <select id="selectItemBySalesOrderId"
- resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderItemBean">
- select
- a.id ,
- a.identity ,
- a.websit_id,
- a.parts_websit_id,
- a.parts_id,
- a.parts_number,
- a.parts_name,
- a.material_group_name,
- a.goods_stock_unit,
- a.sales_id,
- a.sales_price,
- a.market_price,
- a.second_price,
- IF(d.status = 'END', a.examine_qty, a.qty) AS qty,
- a.examine_qty,
- a.new_refund_qty,
- a.old_refund_qty ,
- a.total_amount,
- a.push_flag ,
- a.create_by ,
- a.create_time,
- a.update_by,
- a.update_time,
- IFNULL(c.qty, 0) stockQty
- FROM websit_parts_sales_item a JOIN websit_goods b ON a.parts_id = b.goods_id
- LEFT JOIN websit_stock c ON a.websit_id = c.websit_id AND a.parts_number = c.goods_id AND a.parts_websit_id = c.parts_websit_id
- JOIN websit_parts_sales d ON a.sales_id = d.id
- WHERE a.sales_id = #{id}
- </select>
- <select id="queryOldRefundRecordById"
- resultType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageRecordBean">
- SELECT
- a.*
- FROM
- websit_parts_old_refund_manage_record a
- WHERE
- sales_id = #{id}
- </select>
- <select id="websitGroupList" resultType="com.gree.mall.miniapp.plus.entity.WebsitGoods">
- SELECT
- material_group_name AS `value`
- FROM
- websit_stock
- WHERE
- company_wechat_id = #{companyWechatId}
- AND websit_id = #{websitId}
- AND parts_websit_id = #{partsWebsiteNumber}
- AND qty > 0
- GROUP BY
- material_group_name
- </select>
- <select id="existWebsitStockList"
- resultType="com.gree.mall.miniapp.bean.material.parts.WebsitPartsStockBean">
- SELECT
- a.id,
- a.websit_id,
- a.websit_name,
- a.parts_websit_id,
- a.goods_id,
- a.goods_name,
- b.material_group_name,
- b.part_type,
- b.market_price,
- b.goods_stock_unit,
- a.qty,
- a.old_qty
- FROM
- websit_stock a LEFT JOIN websit_goods b ON a.goods_id = b.goods_code
- WHERE
- a.company_wechat_id = #{companyWechatId}
- AND a.websit_id = #{websitId}
- AND a.parts_websit_id = #{partsWebsitId}
- <if test="partsNumber != null and partsNumber != ''">
- AND a.goods_id = #{partsNumber}
- </if>
- <if test="partsName != null and partsName != ''">
- AND a.goods_name LIKE CONCAT('%', #{partsName}, '%')
- </if>
- <if test="materialGroupName != null and materialGroupName != ''">
- AND a.goods_stock_unit = #{materialGroupName}
- </if>
- AND a.goods_type = 'P'
- AND a.qty > 0
- </select>
- </mapper>
|