" ?>
.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_
)
<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
 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
( 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'
) AS PRODUCT_ID,
(SELECT GD.GOODS_ID
FROM GOODS GD
WHERE gd.goods_no = ttm.goods_no
AND gd.is_delete = 'N'
) AS GOODS_ID,
(), , '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

<include refid="queryTmallTcMessageParam" />
order by MESSAGE_TIME DESC
<include refid="ed_fy" />
</select>

<select id="getTmallTcMessageCount" resultClass="Integer"
parameterClass="TmallTcMessage">
) 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

<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>

<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)
, ),nvl(#strLength#,)),'*****') RECEIVE_FULL_ADDRESS,
replace(
TMM.RECEIVE_TEL, substr( TMM.RECEIVE_TEL, , nvl(#strLength#,)),
'****') 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

<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">

<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">
)
from ORDER_INFO t
where t.IS_DELETE='N'
<isNotEmpty prepend="and" property="orderId">
t.ORDER_ID = #orderId#
</isNotEmpty>
,,)
</select>
<select id="checkTmallTcMessage" parameterClass="java.util.HashMap" resultClass="Integer">
)
from TMALL_TC_MESSAGE ttm
where ttm.IS_DELETE='N'
<isNotEmpty prepend="and" property="orderId">
ttm.ORDER_ID like '%$orderId$%'
</isNotEmpty>
</select>

</sqlMap>

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

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

    Oracle数据库之开发PL/SQL子程序和包   PL/SQL块分为匿名块与命名块,命名块又包含子程序.包和触发器. 过程和函数统称为PL/SQL子程序,我们可以将商业逻辑.企业规则写成过程或函数保 ...

  2. 【ORACLE】记录通过执行Oracle的执行计划查询SQL脚本中的效率问题

    记录通过执行Oracle的执行计划查询SQL脚本中的效率问题   问题现象: STARiBOSS5.8.1R2版本中,河北对帐JOB执行时,无法生成发票对帐文件.   首先,Quartz表达式培植的启 ...

  3. Oracle安装步骤及PL/SQL Developer连接数据库

    一:Oracle安装步骤及PL/SQL Developer连接数据库 win7 64位 11g 点击(操作步骤):http://www.cnblogs.com/haoke/articles/27343 ...

  4. paip.oracle query export to insert sql

    paip.oracle query export to insert sql 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http:/ ...

  5. oracle 11g杀掉锁的sql

    oracle 11g杀掉锁的sql [引用 2013-3-6 17:19:12]     字号:大 中 小 --查询出出现锁的session_idselect session_id from v$lo ...

  6. Oracle学习DaySix(PL/SQL续)

    一.游标 在 PL/SQL 程序中,对于处理多行记录的事务经常使用游标来实现.游标是一个指向上下文的句柄( handle)或指针.通过游标,PL/SQL 可以控制上下文区和处理语句时上 下文区会发生些 ...

  7. Oracle使用技巧及PL/SQL Developer配置

    Oracle使用技巧及PL/SQL Developer配置 摘自:http://livenzhao.spaces.live.com/blog/cns!6E368BE9F6DDD872!595.entr ...

  8. Oracle数据库中,在SQL语句中连接字符串的方法是哪个?(选择1项)

    Oracle数据库中,在SQL语句中连接字符串的方法是哪个?(选择1项) A.cat B.concat C.join D.+ 解答:B

  9. Oracle数据库使用Analyze提升sql性能

    Oracle数据库使用Analyze提升sql性能 如果你不使用analyze完成sql优化,将意味着:你拒绝使用数据库的查询优化器,也失去了使用优化连接的机会.假设你创建了一张拥有100万条记录的临 ...

随机推荐

  1. 理解JavaScript中作用域链的关系

    javascript里的关系又多又乱.作用域链是一种单向的链式关系,还算简单清晰:this机制的调用关系,稍微有些复杂:而关于原型,则是prototype.proto和constructor的三角关系 ...

  2. 腾讯RTX登录提示失败问题及处理办法

    出现问题时图片: 解决步骤: 首先ping一下RTX管理器所在的的ip地址 telnet一下服务器的端口 8000,8010 是否能通. 具体操作: 在无法登陆的客户端电脑上开始-运行-输入cmd 确 ...

  3. javascript 获取图片原始尺寸

    javascript 获取图片原始尺寸 function getImgInfo(url){ var img = new Image(), loaded = false; var info = {}; ...

  4. poj1850

    是因为我好久不刷题了吗,这个题竟然做了俩小时,好几个思路都被推翻 用dp数组预处理出范围是a->a+x字符y长度有多少种递增串 然后例如def首先求a__有多少种情况那么自然后面就是只有b即dp ...

  5. uva 10212 - The Last Non-zero Digit.

    #include <cstdio> #define ll long long const ll MOD = 1e9; int main() { ll N, M; while(scanf(& ...

  6. C#自定义Attribute值的获取与优化

    C#自定义Attribute值的获取是开发中会经常用到的,一般我们的做法也就是用反射进行获取的,代码也不是很复杂. 1.首先有如下自定义的Attribute [AttributeUsage(Attri ...

  7. php 初学笔记

    1.变量定义和使用 php中定义变量名为:$aa 在类中一般定义一个新变量需要添加var字,如var $aaa. 但是过程或函数中是不需要添加var 关键字,如$aaa=$_POST['aaaa'], ...

  8. discuz3.2x增加邮箱验证功能

    为防止垃圾用户多次注册,为disczu增加邮箱验证功能. 大致分为二步: 1.申请邮箱,这里推荐使用腾讯免费企业邮箱:https://exmail.qq.com/portal/introducefre ...

  9. [算法]分治算法(Divide and Conquer)

    转载请注明:http://www.cnblogs.com/StartoverX/p/4575744.html 分治算法 在计算机科学中,分治法是建基于多项分支递归的一种很重要的算法范式.字面上的解释是 ...

  10. FreeBSd ports 安装软件

    1.ports的目录在/usr/ports2.POSTS安装软件有时可能这个包已经安装过了,会有提示,无法 继续安装.能够用提示中的参数:#make install clean FORCE_PKG_R ...