id,tenant_id,parent_tenant_id,
record_id,order_no,order_money,
merchant_id,activity_id,activity_item_id,
award_itam_id,grant_id,grant_item_id,grant_awards_mode,grant_price,
mall_share_rate,merchant_share_rate,order_ratio,
real_grant_price,real_mall_share_price,real_merchant_share_price,
create_date,update_date
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `record_id` = #{recordId}
and `order_no` like concat('%', #{orderNo},'%')
and `merchant_id` = #{merchantId}
and `activity_id` = #{activityId}
and `activity_item_id` = #{activityItemId}
and `award_itam_id` = #{awardItamId}
and `grant_id` = #{grantId}
and `grant_item_id` = #{grantItemId}
and `grant_awards_mode` = #{grantAwardsMode}
and `create_date` >= #{createDateBegin}
and `create_date` <= #{createDateEnd}
and `status` = #{status}
and merchant_id in
#{midItem}
and id in
#{idItem}
order by ${sortColumns}
insert into wx_offline_activity_grant_settlement
(id,
record_id,order_no,order_money,
merchant_id,activity_id,activity_item_id,
award_itam_id,grant_id,grant_item_id,grant_awards_mode,grant_price,
mall_share_rate,merchant_share_rate,order_ratio,
real_grant_price,real_mall_share_price,real_merchant_share_price,
create_date,update_date)
values
(#{item.id,jdbcType=BIGINT},
#{item.recordId,jdbcType=BIGINT},#{item.orderNo,jdbcType=VARCHAR},#{item.orderMoney,jdbcType=DECIMAL},
#{item.merchantId,jdbcType=BIGINT},#{item.activityId,jdbcType=BIGINT},#{item.activityItemId,jdbcType=BIGINT},
#{item.awardItamId,jdbcType=BIGINT},#{item.grantId,jdbcType=BIGINT},#{item.grantItemId,jdbcType=BIGINT},#{item.grantAwardsMode,jdbcType=INTEGER},#{item.grantPrice,jdbcType=DECIMAL},
#{item.mallShareRate,jdbcType=DECIMAL},#{item.merchantShareRate,jdbcType=DECIMAL},#{item.orderRatio,jdbcType=DECIMAL},
#{item.realGrantPrice,jdbcType=DECIMAL},#{item.realMallSharePrice,jdbcType=DECIMAL},#{item.realMerchantSharePrice,jdbcType=DECIMAL},
#{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP})
update wx_offline_activity_grant_settlement set status = 0,update_date = now()
where grant_id in (
select id from wx_offline_activity_grant_award
where `activity_id` = #{activityId} and `cus_phone` = #{cusPhone} and `id` != #{id})