oracle(天猫处方药留言sql)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="TmallTcMessage">
<typeAlias alias="TmallTcMessage"
type="com.founder.ec.product.model.TmallTcMessage" />
<typeAlias alias="OrderTcMessage" type="com.founder.ec.order.model.OrderTcMessage" />
<typeAlias alias="ecelMessage"
type="com.founder.ec.product.model.GoodsEvaluation" />
<typeAlias alias="Goods" type="com.founder.ec.product.model.Goods" />
<resultMap id="TmallTcMessageMap" class="TmallTcMessage">
<result column="TMALL_TC_MSG_ID" property="tmallTcMsgId" />
<result column="TMALL_ORDER_ID" property="tmallOrderId" />
<result column="MEMBER_NAME" property="memberName" />
<result column="ALIPAY_USER_NAME" property="alipayUserName" />
<result column="ALIPAY_PAID_FEE" property="alipayPaidFee" />
<result column="MESSAGE" property="message" />
<result column="MESSAGE_SOURCE" property="messageSource" />
<result column="RECEIVE_USER" property="receiveUser" />
<result column="RECEIVE_FULL_ADDRESS" property="receiveFullAddress" />
<result column="RECEIVE_TEL" property="receiveTel" />
<result column="RECEIVE_MOBILE" property="receiveMobile" />
<result column="ORDER_CREATE_TIME" property="orderCreateTime" />
<result column="GOODS_NO" property="goodsNo" />
<result column="GOODS_TOPIC" property="goodsTopic" />
<result column="IS_CALLBACK" property="isCallback" />
<result column="IS_BUY" property="isBuy" />
<result column="NOT_BUY_REASON" property="notBuyReason" />
<result column="NOT_BUY_REASON_NAME" property="notBuyReasonName" />
<result column="CALLBACK_TIME" property="callbackTime" />
<result column="COMMIT_USERNAME" property="commitUserName" />
<result column="CALLBACK_USERNAME" property="callbackUserName" />
<result column="SERVICE_NAME" property="serviceName" />
<result column="DISTRIBUTION_TYPE" property="distributionType" />
<result column="USER_TYPE" property="userType" />
<result column="MESSAGE_TIME" property="messageTime" />
<result column="IMPORT_ID" property="importId" />
<result column="GOODS_ID" property="goodsId" />
<result column="PRODUCT_ID" property="productId" />
<result column="CUSTOMER_NATURE" property="customerNature" />
<result column="HAS_LOG" property="hasLog" />
<result column="ASSIGN_NUM" property="assignNum" />
<result column="NOT_BUY_REASON_NOTE" property="notBuyReasonNote" />
<result column="ASSIGN_ID" property="assignId" />
<result column="ALIPAY_ORDER_FEE" property="alipayOrderFee" />
<result column="ALIPAY_DELIVERY_FEE" property="alipayDeliveryFee" />
<result column="ALIPAY_TOTAL_FEE" property="alipayTotalFee" />
<result column="NOTE" property="note" />
<result column="ORDER_ID" property="orderId" />
</resultMap>

<resultMap id="TmallMessageExportResultMap" class="TmallTcMessage">
<result column="TMALL_ORDER_ID" property="tmallOrderId" />
<result column="MEMBER_NAME" property="memberName" />
<result column="ALIPAY_USER_NAME" property="alipayUserName" />
<result column="ALIPAY_PAID_FEE" property="alipayPaidFee" />
<result column="MESSAGE" property="message" />
<result column="MESSAGE_SOURCE" property="messageSource" />
<result column="MESSAGE_SOURCE_NAME" property="messageSourceName" />
<result column="RECEIVE_USER" property="receiveUser" />
<result column="RECEIVE_FULL_ADDRESS" property="receiveFullAddress" />
<result column="RECEIVE_TEL" property="receiveTel" />
<result column="ORDER_CREATE_TIME" property="orderCreateTime" />
<result column="GOODS_NO" property="goodsNo" />
<result column="GOODS_TOPIC" property="goodsTopic" />
<result column="GOODS_COUNT" property="goodsCount" />
<result column="IS_CALLBACK" property="isCallback" />
<result column="IS_CALLBACK_NAME" property="isCallbackName" />
<result column="IS_BUY" property="isBuy" />
<result column="IS_BUY_NAME" property="isBuyName" />
<result column="NOT_BUY_REASON" property="notBuyReason" />
<result column="NOT_BUY_REASON_NAME" property="notBuyReasonName" />
<result column="CALLBACK_TIME" property="callbackTime" />
<result column="COMMIT_USERID" property="commitUserid" />
<result column="CALLBACK_USERID" property="callbackUserid" />
<result column="USER_TYPE" property="userType" />
<result column="USER_TYPE_NAME" property="userTypeName" />
<result column="DISTRIBUTION_TYPE" property="distributionType" />
<result column="DISTRIBUTION_TYPE_NAME" property="distributionTypeName" />
<result column="SERVICE_NAME" property="serviceName" />
<result column="CUSTOMER_NATURE" property="customerNature" />
<result column="CUSTOMER_NATURE_NAME" property="customerNatureName" />
<result column="NOT_BUY_REASON_NOTE" property="notBuyReasonNote" />
<result column="ASSIGN_NUM" property="assignNum" />
<result column="ASSIGN_ID" property="assignId" />
<result column="ALIPAY_ORDER_FEE" property="alipayOrderFee" />
<result column="ALIPAY_DELIVERY_FEE" property="alipayDeliveryFee" />
<result column="ALIPAY_TOTAL_FEE" property="alipayTotalFee" />
<result column="NOTE" property="note" />
<result column="ORDER_ID" property="orderId" />
</resultMap>

<!-- 商品相关 -->
<resultMap class="Goods" id="goodsTcQueryRes">
<result column="GOODS_ID" property="goodsId" />
<result column="PRODUCT_ID" property="goodsId" />
<result column="GOODS_NO" property="goodsNo" />
<result column="GOODS_NAME" property="goodsName" />
<result column="MARKET_PRICE" property="marketPrice" />
<result column="EC_PRICE" property="ecPrice" />
<result column="AVAILABLE_STOCK" property="availableStock" />
<result column="UNITNAME" property="unitName" />
</resultMap>
<resultMap class="TmallTcMessage" id="tcMessageResNew">
<result column="GOODS_NO" property="goodsNo" />
</resultMap>

<resultMap id="getMessageGainMap" class="TmallTcMessage">
<result column="TMALL_TC_MSG_ID" property="tmallTcMsgId" />
</resultMap>

<sql id="be_fy">
select * from (select row_.*, rownum rownum_ from (
</sql>
<sql id="ed_fy">
) row_ where 1=1
)where 1=1
<isNotEmpty prepend="and" property="endRow">
<![CDATA[ rownum_ <= #endRow# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="startRow">
<![CDATA[ rownum_ >= #startRow# ]]>
</isNotEmpty>
</sql>
<!-- 动态的拼接查询条件 -->
<sql id="queryTmallTcMessageParam">
<isEqual property="isRegister" compareValue="Y">
and exists (select
1 from member m where m.is_delete=‘N‘ and
m.mobile_state=‘Y‘ and
receive_mobile = m.mobile)
</isEqual>
<isEqual property="isRegister" compareValue="N">
and not exists
(select 1 from member m where m.is_delete=‘N‘ and
m.mobile_state=‘Y‘
and receive_mobile = m.mobile)
</isEqual>
<isNotEmpty prepend="and" property="assignId">
<![CDATA[ mai.ASSIGN_ID=#assignId# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="receiveUser">
<![CDATA[ mai.RECEIVE_USER=#receiveUser# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="receiveMobile">
<![CDATA[ mai.RECEIVE_MOBILE=#receiveMobile# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="isCallback">
<![CDATA[ mai.IS_CALLBACK=#isCallback# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="isBuy">
<![CDATA[ mai.IS_BUY=#isBuy# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="goodsNo">
<![CDATA[ mai.GOODS_NO=#goodsNo# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="receiveFullAddress">
<![CDATA[ mai.RECEIVE_FULL_ADDRESS like ‘%$receiveFullAddress$%‘ ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="bgMessageTime">
<![CDATA[ mai.MESSAGE_TIME>=#bgMessageTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="endMessageTime">
<![CDATA[ mai.MESSAGE_TIME<=#endMessageTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="callbackUserName">
<![CDATA[ mai.CALLBACK_USERNAME=#callbackUserName# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="bgCallBackTime">
<![CDATA[ mai.CALLBACK_TIME>=#bgCallBackTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="endCallBackTime">
<![CDATA[ mai.CALLBACK_TIME<=#endCallBackTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="userType">
<![CDATA[ mai.USER_TYPE=#userType# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="commitUserName">
<![CDATA[ mai.COMMIT_USERNAME=#commitUserName# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="messageSource">
<![CDATA[ mai.MESSAGE_SOURCE=#messageSource# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="notBuyReason">
<![CDATA[ mai.NOT_BUY_REASON=#notBuyReason# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="codeTypeNo">
<![CDATA[ mai.CODE_TYPE_NO=#codeTypeNo# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="distributionType">
<![CDATA[ mai.DISTRIBUTION_TYPE=#distributionType# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="customerNature">
<![CDATA[ mai.CUSTOMER_NATURE=#customerNature# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="serviceName">
<![CDATA[ mai.SERVICE_NAME=#serviceName# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="assignNum">
<![CDATA[ mai.ASSIGN_NUM=#assignNum# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="importId">
<![CDATA[ mai.IMPORT_ID=#importId# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="orderId">
<![CDATA[ mai.ORDER_ID like ‘%$orderId$%‘ ]]>
</isNotEmpty>
</sql>
<select id="getTmallTcMessagePage" resultMap="TmallTcMessageMap"
parameterClass="TmallTcMessage">
<include refid="be_fy" />
select *
from (select ttm.ORDER_ID,
ttm.TMALL_TC_MSG_ID,
ttm.TMALL_ORDER_ID,
ttm.MEMBER_NAME,
ttm.ALIPAY_USER_NAME,
ttm.ALIPAY_PAID_FEE,
ttm.MESSAGE,
MESSAGE_SOURCE,
USER_TYPE,
MESSAGE_TIME,
DISTRIBUTION_TYPE,
CUSTOMER_NATURE,
RECEIVE_USER,
RECEIVE_FULL_ADDRESS,
RECEIVE_TEL,
RECEIVE_MOBILE,
ORDER_CREATE_TIME,
GOODS_NO,
GOODS_TOPIC,
IS_CALLBACK,
IS_BUY,
NOT_BUY_REASON,
NOT_BUY_REASON_NOTE,
CALLBACK_TIME,
ASSIGN_NUM,
(select user_name
from fecerp.sys_user
where user_id = commit_userid
and is_delete = ‘N‘) AS COMMIT_USERNAME,
(select user_name
from fecerp.sys_user
where user_id = CALLBACK_USERID
and is_delete = ‘N‘) AS CALLBACK_USERNAME,
(select user_name
from fecerp.sys_user
where user_id = SERVICE_NUM
and is_delete = ‘N‘) AS SERVICE_NAME,
IMPORT_ID,
(select s.code_value
from sys_code s
where s.code_id = ttm.NOT_BUY_REASON
and s.is_delete = ‘N‘) as NOT_BUY_REASON_NAME,
(SELECT GD.PRODUCT_ID
FROM GOODS GD
WHERE gd.goods_no = ttm.goods_no
AND gd.is_delete = ‘N‘
and rownum = 1) AS PRODUCT_ID,
(SELECT GD.GOODS_ID
FROM GOODS GD
WHERE gd.goods_no = ttm.goods_no
AND gd.is_delete = ‘N‘
and rownum = 1) AS GOODS_ID,
(select decode(count(1), 0, ‘N‘, ‘Y‘) as cnt
from TMALL_TC_MESSAGE_LOG ttml
where ttml.is_delete = ‘N‘
and ttml.tmall_tc_msg_id =
ttm.tmall_tc_msg_id) as has_log,
(select user_id
from fecerp.sys_user
where user_name = ttm.ASSIGN_NUM
and is_delete = ‘N‘) as ASSIGN_ID,
ALIPAY_ORDER_FEE,
ALIPAY_DELIVERY_FEE,
ALIPAY_TOTAL_FEE,
(select s.code_type_no
from sys_code s
where s.code_id = ttm.NOT_BUY_REASON
and s.is_delete = ‘N‘) as CODE_TYPE_NO,
NOTE
from TMALL_TC_MESSAGE ttm
where IS_DELETE = ‘N‘) mai
where 1 = 1
<include refid="queryTmallTcMessageParam" />
order by MESSAGE_TIME DESC
<include refid="ed_fy" />
</select>

<select id="getTmallTcMessageCount" resultClass="Integer"
parameterClass="TmallTcMessage">
select count(1) from (select ORDER_ID,
TMALL_TC_MSG_ID,TMALL_ORDER_ID,MEMBER_NAME,ALIPAY_USER_NAME,ALIPAY_PAID_FEE,MESSAGE,MESSAGE_SOURCE,RECEIVE_USER,
RECEIVE_FULL_ADDRESS,RECEIVE_TEL,RECEIVE_MOBILE,ORDER_CREATE_TIME,GOODS_NO,GOODS_TOPIC,IS_CALLBACK,
IS_BUY,NOT_BUY_REASON,CALLBACK_TIME,ASSIGN_NUM,(select user_name from
fecerp.sys_user where user_id = commit_userid and
is_delete=‘N‘) AS
COMMIT_USERNAME,
(select user_name from fecerp.sys_user where user_id =
CALLBACK_USERID and
is_delete=‘N‘) AS CALLBACK_USERNAME,
(select
user_name from fecerp.sys_user where user_id = SERVICE_NUM and
is_delete=‘N‘) AS
SERVICE_NAME,USER_TYPE,MESSAGE_TIME,DISTRIBUTION_TYPE,IMPORT_ID,CUSTOMER_NATURE,
(select user_id from fecerp.sys_user where user_name = ASSIGN_NUM and is_delete = ‘N‘) as ASSIGN_ID,
(select s.code_type_no
from sys_code s
where s.code_id = NOT_BUY_REASON
and s.is_delete = ‘N‘) as CODE_TYPE_NO
from
TMALL_TC_MESSAGE
where IS_DELETE=‘N‘) mai
where 1=1
<include refid="queryTmallTcMessageParam" />
</select>
<!-- 改为已回访 -->
<update id="updateVisited" parameterClass="TmallTcMessage">
update TMALL_TC_MESSAGE
<dynamic prepend="set">
<isNotEmpty prepend="," property="editUserId">
<![CDATA[ EDIT_USER_ID=#editUserId# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="isCallback">
<![CDATA[ IS_CALLBACK=#isCallback# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="callbackTime">
<![CDATA[ CALLBACK_TIME=#callbackTime# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="callbackUserid">
<![CDATA[ CALLBACK_USERID=#callbackUserid# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="editTime">
<![CDATA[ EDIT_TIME=#editTime# ]]>
</isNotEmpty>
</dynamic>
where TMALL_TC_MSG_ID=#tmallTcMsgId#
</update>
<!-- 改为已购买 -->
<update id="updateBuy" parameterClass="TmallTcMessage">
update TMALL_TC_MESSAGE
<dynamic prepend="set">
<isNotEmpty prepend="," property="editUserId">
<![CDATA[ EDIT_USER_ID=#editUserId# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="isBuy">
<![CDATA[ IS_BUY=#isBuy# ]]>
</isNotEmpty>

<isNotEmpty prepend="," property="editTime">
<![CDATA[ EDIT_TIME=#editTime# ]]>
</isNotEmpty>
</dynamic>
where TMALL_TC_MSG_ID=#tmallTcMsgId#
</update>
<!-- 更新操作 -->
<update id="update" parameterClass="TmallTcMessage">
update TMALL_TC_MESSAGE
<dynamic prepend="set">
<isNotEmpty prepend="," property="orderId">
<![CDATA[ ORDER_ID= ORDER_ID || #orderId# || ‘,‘]]>
</isNotEmpty>
<isNotEmpty prepend="," property="addUserId">
<![CDATA[ ADD_USER_ID=#addUserId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="messageSource">
<![CDATA[ MESSAGE_SOURCE=#messageSource# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="receiveMobile">
<![CDATA[ RECEIVE_MOBILE=#receiveMobile# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="receiveUser">
<![CDATA[ RECEIVE_USER=#receiveUser# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="editUserId">
<![CDATA[ EDIT_USER_ID=#editUserId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="commitUserid">
<![CDATA[ COMMIT_USERID=#commitUserid# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="memberName">
<![CDATA[ MEMBER_NAME=#memberName# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="orderCreateTime">
<![CDATA[ ORDER_CREATE_TIME=#orderCreateTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="goodsTopic">
<![CDATA[ GOODS_TOPIC=#goodsTopic# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="isCallback">
<![CDATA[ IS_CALLBACK=#isCallback# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="callbackUserid">
<![CDATA[ CALLBACK_USERID=#callbackUserid# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="editTime">
<![CDATA[ EDIT_TIME=#editTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="receiveFullAddress">
<![CDATA[ RECEIVE_FULL_ADDRESS=#receiveFullAddress# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="receiveTel">
<![CDATA[ RECEIVE_TEL=#receiveTel# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="isDelete">
<![CDATA[ IS_DELETE=#isDelete# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="addTime">
<![CDATA[ ADD_TIME=#addTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="userType">
<![CDATA[ USER_TYPE=#userType# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="goodsCount">
<![CDATA[ GOODS_COUNT=#goodsCount# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="goodsNo">
<![CDATA[ GOODS_NO=#goodsNo# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="alipayUserName">
<![CDATA[ ALIPAY_USER_NAME=#alipayUserName# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="message">
<![CDATA[ MESSAGE=#message# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="callbackTime">
<![CDATA[ CALLBACK_TIME=#callbackTime# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="notBuyReason">
<![CDATA[ NOT_BUY_REASON=#notBuyReason# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="notBuyReasonNote">
<![CDATA[ NOT_BUY_REASON_NOTE=#notBuyReasonNote# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="customerNature">
<![CDATA[ CUSTOMER_NATURE=#customerNature# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="tmallOrderId">
<![CDATA[ TMALL_ORDER_ID=#tmallOrderId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="alipayPaidFee">
<![CDATA[ ALIPAY_PAID_FEE=#alipayPaidFee# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="isBuy">
<![CDATA[ IS_BUY=#isBuy# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="assignNum">
<![CDATA[ ASSIGN_NUM=#assignNum# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="distributionType">
<![CDATA[ DISTRIBUTION_TYPE=#distributionType# ]]>
</isNotEmpty>
</dynamic>
where 1=1
<isNotEmpty prepend="and" property="tmallTcMsgId">
<![CDATA[ TMALL_TC_MSG_ID=#tmallTcMsgId# ]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="importId">
<![CDATA[ IMPORT_ID=#importId# ]]>
</isNotEmpty>
</update>

<select id="TmallMessageExportExcel" resultMap="TmallMessageExportResultMap"
parameterClass="TmallTcMessage">
select * from(
SELECT
TMM.ORDER_ID,
TMM.IMPORT_ID,
TMM.TMALL_ORDER_ID,
TMM.MEMBER_NAME,
TMM.ALIPAY_USER_NAME,
TMM.ALIPAY_PAID_FEE,
TMM.MESSAGE,
TMM.MESSAGE_SOURCE,
CASE TMM.MESSAGE_SOURCE
WHEN ‘app‘ THEN
‘app端‘
WHEN ‘pc‘ THEN
‘PC端‘
WHEN ‘wap‘ THEN
‘wap端‘
WHEN ‘tm‘ THEN
‘天猫‘
END AS MESSAGE_SOURCE_NAME,
TMM.RECEIVE_USER,
replace(TMM.RECEIVE_FULL_ADDRESS,substr(TMM.RECEIVE_FULL_ADDRESS,round(length(TMM.RECEIVE_FULL_ADDRESS)
/ 2, 0),nvl(#strLength#,0)),‘*****‘) RECEIVE_FULL_ADDRESS,
replace(
TMM.RECEIVE_TEL, substr( TMM.RECEIVE_TEL, 4, nvl(#strLength#,0)),
‘****‘) AS RECEIVE_TEL,
TMM.ORDER_CREATE_TIME,
TMM.GOODS_NO,
TMM.GOODS_TOPIC,
TMM.GOODS_COUNT,
TMM.IS_CALLBACK,
DECODE(TMM.IS_CALLBACK,‘N‘,‘未回访‘,‘Y‘,‘已回访‘) as IS_CALLBACK_NAME,
TMM.IS_BUY,
DECODE(tmm.IS_BUY,‘N‘,‘未购买‘,‘Y‘,‘已购买‘) as IS_BUY_NAME,
TMM.NOT_BUY_REASON,
TMM.NOT_BUY_REASON_NOTE,
TMM.CALLBACK_TIME,
TMM.COMMIT_USERID,
TMM.CALLBACK_USERID,
TMM.USER_TYPE,
DECODE(tmm.USER_TYPE,‘N‘,‘一次购买用户‘,‘Y‘,‘二次购买用户‘) as USER_TYPE_NAME,
TMM.CUSTOMER_NATURE,
CASE TMM.CUSTOMER_NATURE
WHEN ‘dg‘ THEN
‘代购‘
WHEN ‘zy‘ THEN
‘自用‘
WHEN ‘yf‘ THEN
‘药贩‘
END AS CUSTOMER_NATURE_NAME,
DECODE(tmm.DISTRIBUTION_TYPE,‘N‘,‘未分配‘,‘A‘,‘系统自动分配‘,‘H‘,‘手动分配‘) as DISTRIBUTION_TYPE_NAME,
TMM.DISTRIBUTION_TYPE,
(select user_name from fecerp.sys_user where user_id = tmm.SERVICE_NUM and
is_delete=‘N‘) AS SERVICE_NAME,
TMM.MESSAGE_TIME,
(select s.code_value from sys_code s where s.code_id=TMM.NOT_BUY_REASON and s.is_delete=‘N‘) as NOT_BUY_REASON_NAME,
tmm.ASSIGN_NUM,
(select user_id from fecerp.sys_user where user_name = TMM.ASSIGN_NUM and is_delete = ‘N‘) as ASSIGN_ID,
ALIPAY_ORDER_FEE,
ALIPAY_DELIVERY_FEE,
ALIPAY_TOTAL_FEE,
(select s.code_type_no
from sys_code s
where s.code_id = NOT_BUY_REASON
and s.is_delete = ‘N‘) as CODE_TYPE_NO,
NOTE
FROM TMALL_TC_MESSAGE TMM
where TMM.Is_Delete=‘N‘) mai
where 1=1
<include refid="queryTmallTcMessageParam" />
order by mai.MESSAGE_TIME desc
</select>
<insert id="save" parameterClass="TmallTcMessage">
<selectKey resultClass="Long" keyProperty="tmallTcMsgId">
SELECT
TMALL_TC_MESSAGE_SEQ.nextval AS id from dual
</selectKey>
insert into TMALL_TC_MESSAGE (
ADD_USER_ID,
MESSAGE_SOURCE,
TMALL_TC_MSG_ID,
RECEIVE_MOBILE,
RECEIVE_USER,
COMMIT_USERID,
MEMBER_NAME,
ORDER_CREATE_TIME,
GOODS_TOPIC,
IMPORT_ID,
CALLBACK_USERID,
RECEIVE_FULL_ADDRESS,
RECEIVE_TEL,
ADD_TIME,
USER_TYPE,
GOODS_COUNT,
GOODS_NO,
ALIPAY_USER_NAME,
MESSAGE,
CALLBACK_TIME,
NOT_BUY_REASON,
TMALL_ORDER_ID,
ALIPAY_PAID_FEE,
SERVICE_NUM,
MESSAGE_TIME,
CUSTOMER_NATURE
<isNotEmpty prepend="," property="alipayOrderFee">
ALIPAY_ORDER_FEE
</isNotEmpty>
<isNotEmpty prepend="," property="alipayDeliveryFee">
ALIPAY_DELIVERY_FEE
</isNotEmpty>
<isNotEmpty prepend="," property="alipayTotalFee">
ALIPAY_TOTAL_FEE
</isNotEmpty>
<isNotEmpty prepend="," property="distributionType">
DISTRIBUTION_TYPE
</isNotEmpty>
<isNotEmpty prepend="," property="note">
NOTE
</isNotEmpty>
)
values
(
#addUserId#,
#messageSource#,
#tmallTcMsgId#,
#receiveMobile#,
#receiveUser#,
#commitUserid#,
#memberName#,
#orderCreateTime#,
#goodsTopic#,
#importId#,
#callbackUserid#,
#receiveFullAddress#,
#receiveTel#,
#addTime#,
#userType#,
#goodsCount#,
#goodsNo#,
#alipayUserName#,
#message#,
#callbackTime#,
#notBuyReason#,
#tmallOrderId#,
#alipayPaidFee#,
#serviceNum#,
#messageTime#,
#customerNature#
<isNotEmpty prepend="," property="alipayOrderFee">
#alipayOrderFee#
</isNotEmpty>
<isNotEmpty prepend="," property="alipayDeliveryFee">
#alipayDeliveryFee#
</isNotEmpty>
<isNotEmpty prepend="," property="alipayTotalFee">
#alipayTotalFee#
</isNotEmpty>
<isNotEmpty prepend="," property="distributionType" >
#distributionType#
</isNotEmpty>
<isNotEmpty prepend="," property="note">
#note#
</isNotEmpty>
)
</insert>

<select id="querySelectGoods" resultMap="goodsTcQueryRes"
parameterClass="TmallTcMessage">
SELECT G.GOODS_ID,
G.PRODUCT_ID,
G.GOODS_NO,
G.GOODS_NAME,
G.MARKET_PRICE,
G.EC_PRICE,
G.AVAILABLE_STOCK,
PU.UNIT_NAME AS UNITNAME,
P.IS_ONSALE AS ISONSALE
FROM GOODS G
LEFT JOIN PRODUCT P
ON G.PRODUCT_ID
= P.PRODUCT_ID
AND P.IS_DELETE = ‘N‘
LEFT JOIN PRODUCT_UNIT PU
ON
P.UNIT_ID = PU.UNIT_ID
LEFT JOIN PRODUCT_YW_CATALOG_GOODS PYC
ON
G.GOODS_NO = PYC.GOODS_NO
WHERE G.IS_DELETE = ‘N‘
AND P.IS_ONSALE = ‘Y‘
AND G.IS_DEFAULT = ‘Y‘
<isNotEmpty prepend="and" property="goodsNos">
G.goods_no in
($goodsNos$)
</isNotEmpty>
</select>

<select id="getIsBuy" parameterClass="TmallTcMessage"
resultClass="Integer">
select count(*) from order_info oi where oi.is_delete=‘N‘
and oi.receive_mobile = #receiveMobile#
</select>
<select id="getMessageGain" resultMap="getMessageGainMap" parameterClass="TmallTcMessage">
select TMALL_TC_MSG_ID from TMALL_TC_MESSAGE ee where (ee.goods_no != ‘Mkk1000‘ or ee.goods_no is null) and ee.not_buy_reason is null and ee.assign_num is null and ee.is_buy=‘N‘ and ee.is_delete = ‘N‘ and rownum=1
<isNotEmpty prepend="and" property="importId">
ee.import_id=#importId#
</isNotEmpty>
order by MESSAGE_TIME desc
</select>

<select id="getUnProcessedMsgCount" parameterClass="TmallTcMessage"
resultClass="Integer">
select count(*)
from TMALL_TC_MESSAGE t
where t.is_delete = ‘N‘
<isNotEmpty prepend="and" property="importId">
t.import_id = #importId#
</isNotEmpty>
and t.is_buy = ‘N‘
and (t.is_callback = ‘N‘ or t.not_buy_reason is null)
and t.assign_num = #assignNum#
</select>

<select id="checkOrderInfo" parameterClass="java.util.HashMap" resultClass="Integer">
select count(1)
from ORDER_INFO t
where t.IS_DELETE=‘N‘
<isNotEmpty prepend="and" property="orderId">
t.ORDER_ID = #orderId#
</isNotEmpty>
and t.ORDER_STATE not in(18,19,25)
</select>
<select id="checkTmallTcMessage" parameterClass="java.util.HashMap" resultClass="Integer">
select count(1)
from TMALL_TC_MESSAGE ttm
where ttm.IS_DELETE=‘N‘
<isNotEmpty prepend="and" property="orderId">
ttm.ORDER_ID like ‘%$orderId$%‘
</isNotEmpty>
</select>

</sqlMap>

时间: 2024-10-02 23:43:30

oracle(天猫处方药留言sql)的相关文章

Oracle数据库之开发PL/SQL子程序和包

Oracle数据库之开发PL/SQL子程序和包 PL/SQL块分为匿名块与命名块,命名块又包含子程序.包和触发器. 过程和函数统称为PL/SQL子程序,我们可以将商业逻辑.企业规则写成过程或函数保存到数据库中,以便共享. 过程和函数均存储在数据库中,并通过参数与其调用者交换信息.过程和函数的唯一区别是函数总向调用者返回数据,而过程不返回数据. 1. 存储过程概念 存储过程(Stored Procedure)是在大型数据库系统中,一组为了完成特定功能的SQL语句集,存储在数据库中.经过第一次编译后

oracle数据库性能影响之Sql parse

1,Sql parse的种类 Sql parse又通常分为硬解析和软解析,当sql第一次执行的时候,会发生硬解析,之后的执行如果在shared pool中能找到就是软解析.因此,为提高数据性能,尽可能的让每次执行的SQL在shared pool找到. 2,SQL在哪些情况下会发送硬解析? 1)统计信息改变  2)Sql中的表上有做ddl操作,包括grant和revoke. 3)执行计划被踢出shared pool 4)开启了trace 5)绑定变量长度变化 6)启用outlin

Oracle学习(十一):PL/SQL

1.知识点:可以对照下面的录屏进行阅读 PL/SQL程序结构 declare 说明部分 (变量说明,光标申明,例外说明 ] begin 语句序列 (DML语句]- exception 例外处理语句 End; / ------------------------------------------------------------------ --第一个PL/SQL程序:HelloWorld set serveroutput on --如果要在屏幕上输出信息,需要将serveroutput开关打

hibernate4中oracle,sqlserver,mysql数据库的sql方言配置(SQL Dialects)

hibernate4中oracle,mysql,sqlserver数据库的sql方言配置(SQL Dialects) 数据库类型 Hibernate sql方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect PostgreSQL 8.1 org.hibernate.dialect.Po

oracle 字符串与日期转换sql

常用sql语句: select to_char(sysdate,'yy-mm-dd hh24:mi:ss') from dual;   //显示:08-11-07 13:22:42 select to_date('2005-12-25,13:25:59','yyyy-mm-dd,hh24:mi:ss') from dual; //显示:2005-12-25 13:25:59 获取系统时间: select sysdate from dual; 转换的格式: 表示year的:y  表示年的最后一位

Oracle Transparent Gateway Connect to SQL Server 透明网关

Oracle Transparent Gateway Connect to SQL Server 使用Oracle提供的透明网关建立异构数据库连接关系.实现数据传输. 支持Distribution Transaction, 效能极好,使用时与普通SQL用法基本一致,异构数据库之间的联系非常透明,且在使用SQL Server提供的数据时同样可以应用到Oracle Procedure等特有资源,因此仅需一次性的配置,基本不需要在使用中再进行任何培训. 适合同时使用以Oracle为主的多种数据库且有数

处方药(Rx)

处方药(Rx),是指有处方权的医生所开具出来的处方,并由此从医院药房购买的药物.这种药通常都具有一定的毒性及其他潜在的影响,用药方法和时间都有特殊要求,必须在医生指导下使用 处方药简称Rx药,是为了保证用药安全,由国家卫生行政部门规定或审定的,需凭医师或其它有处方权的医疗专业人员开写处方出售,并在医师.药师或其它医疗专处方药处方药业人员监督或指导下方可使用的药品.处方药大多属于以下几种情况:1.上市的新药,对其活性或副作用还要进一步观察.2.可产生依赖性的某些药物,例如吗啡类镇痛药及某些催眠安定

配置Oracle Gateway 12连接到SQL server 2014

最近的工作中需要基于Oracle连接到SQLserver2014,我们可以通过配置Gateway的方式来实现这个功能.这个Gateway的实质是透过dblink来实现的.即把SQLserver模拟成一个远端的Oracle实例,这个实例由Gateway来负责进行接收,转发等等.本文简要描述其配置过程. 一.安装环境介绍 gateway: 12.1.0.2 Oracle db: 11.2.0.4 + RHEL6.3 Sqlserver: 2014 + Win2012 如果安装在已经安装Oracle相

重新发现Oracle太美之glogin.sql

刚开始接触Oracle的时候,有时候一登陆一个生产环境,经常会出现下面的情况: [[email protected] app]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Thu May 15 03:17:34 2014 Copyright (c) 1982, 2013, Oracle.  All rights reserved. Connected to: Oracle Database 11g Enterpr