| @@ -12,7 +12,9 @@ import java.util.Date; | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCardTransferInfo extends TenantEntity { | |||
| protected Long id; | |||
| private static final long serialVersionUID = -9050402557376410064L; | |||
| protected Long id; | |||
| //保存到转赠表中 id,coupon_order_id,tenant_id,title,amount,remain_amount,from_user,to_user,status,create_date,update_date | |||
| @@ -34,6 +34,8 @@ public class WxCouponOrder extends TenantEntity { | |||
| private Long ownerId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "操作券B端小程序用户ID", name = "bUserId") | |||
| private Long bUserId; | |||
| @TableField(exist = false) | |||
| private List<Long> bUserIdList; | |||
| @io.swagger.annotations.ApiModelProperty(value = "操作券A端用户ID", name = "aUserId") | |||
| private Long aUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "用户订单ID", name = "orderId") | |||
| @@ -7,9 +7,16 @@ import org.apache.ibatis.annotations.Param; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCardTransferInfo; | |||
| import com.iformall.domain.vo.WxCardCVo; | |||
| public interface WxCardTransferInfoMapper extends CommonMapper<WxCardTransferInfo, Long> { | |||
| void cardDefer(@Param("expiredTime")Date expiredTime,@Param("couponOrderIds")List<Long> couponOrderIds); | |||
| List<WxCardTransferInfo> findList(WxCardTransferInfo record); | |||
| WxCardTransferInfo selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCardCVo> findCardListOfCUser(WxCardCVo record); | |||
| } | |||
| @@ -83,8 +83,8 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //// 卡相关接口 | |||
| List<WxCardCVo> findCardListOfCUser(WxCardCVo wxCardCVo); | |||
| WxCardCVo findCardDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCouponOrder> findCardListOfCUser(WxCardCVo wxCardCVo); | |||
| WxCouponOrder findCardDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| /// POS接口 | |||
| @@ -220,7 +220,6 @@ public interface WxCouponOrderService { | |||
| List<MarkingCouponDataReportVo> couponDataMap(TenantEntity tenantEntity,Date startTime,Date endTime); | |||
| /// POS接口 | |||
| List<WxCouponOrderCVo> findAvailCouponOrder(TenantEntity tenantEntity,Long cUserId,Long merchantId,Long posOrderId); | |||
| @@ -692,6 +692,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| retPageInfo.setPageNum(pageInfo.getPageNum()); | |||
| retPageInfo.setPageSize(pageInfo.getPageSize()); | |||
| retPageInfo.setList(couponOrderListToCarVoList(wxCouponOrder,pageInfo.getList())); | |||
| retPageInfo.setPages(pageInfo.getPages()); | |||
| return retPageInfo; | |||
| } | |||
| @@ -2111,11 +2112,124 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| return count; | |||
| } | |||
| private WxCardCVo findCardDetailOfCUser(Long id,String tenantId) { | |||
| WxCouponOrder couponOrder = wxCouponOrderMapper.findCardDetailOfCUser(id,tenantId); | |||
| if (null == couponOrder) { | |||
| return null; | |||
| } | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.setTenantId(tenantId); | |||
| couponQ.setId(couponOrder.getCouponId()); | |||
| WxCoupon coupon = wxCouponMapper.findSimpleDetail(couponQ); | |||
| WxCardInfo cardInfo = wxCardInfoMapper.selectById(couponOrder.getId()); | |||
| return getCouponOrderCardCVo(couponOrder,coupon,cardInfo); | |||
| } | |||
| @Override | |||
| public ResultData listCardVoAsPage(WxCardCVo record, Integer pageIndex, Integer pageSize) { | |||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCardListOfCUser(record))); | |||
| //List<WxCardCVo> cardTransList = wxCardTransferInfoMapper.findCardListOfCUser(record); | |||
| PageInfo<WxCouponOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCardListOfCUser(record)); | |||
| PageInfo<WxCardCVo> retPageInfo = new PageInfo<WxCardCVo>(); | |||
| retPageInfo.setPageNum(pageInfo.getPageNum()); | |||
| retPageInfo.setPageSize(pageInfo.getPages()); | |||
| retPageInfo.setPages(pageInfo.getPages()); | |||
| retPageInfo.setList(couponOrderToCardCVoList(record,pageInfo.getList()));; | |||
| return new ResultData(retPageInfo); | |||
| } | |||
| private List<WxCardCVo> couponOrderToCardCVoList(TenantEntity tenantEntity,List<WxCouponOrder> couponOrderList) { | |||
| if (null != couponOrderList) { | |||
| //查询coupon | |||
| List<Long> couponIds = new ArrayList<Long>(); | |||
| List<Long> couponOrderIds = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < couponOrderList.size(); i++){ | |||
| WxCouponOrder co = couponOrderList.get(i); | |||
| Long couponId = co.getCouponId(); | |||
| if (null != couponId && (!couponIds.contains(couponId))) { | |||
| couponIds.add(couponId); | |||
| } | |||
| couponOrderIds.add(co.getId()); | |||
| } | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(tenantEntity); | |||
| if (couponIds.size() > 0 ) { | |||
| couponQ.setIds(couponIds); | |||
| } | |||
| List<WxCoupon> couponList = wxCouponMapper.findSimpleDetailList(couponQ); | |||
| Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); | |||
| if (null != couponList) { | |||
| for (int i = 0 ; i < couponList.size(); i++ ) { | |||
| WxCoupon c = couponList.get(i); | |||
| if (null != c) { | |||
| couponMap.put(c.getId(), c); | |||
| } | |||
| } | |||
| } | |||
| WxCardInfo couponCarQ = new WxCardInfo(); | |||
| couponCarQ.updateTenantInfo(tenantEntity); | |||
| if (couponOrderIds.size() > 0 ) { | |||
| couponCarQ.setIds(couponOrderIds); | |||
| } | |||
| List<WxCardInfo> cardInfoList = wxCardInfoMapper.findList(couponCarQ); | |||
| Map<Long,WxCardInfo> cardInfoMap = new HashMap<Long,WxCardInfo>(); | |||
| if (null != cardInfoList) { | |||
| for (int i = 0 ; i < cardInfoList.size(); i++ ) { | |||
| WxCardInfo cc = cardInfoList.get(i); | |||
| if (null != cc) { | |||
| cardInfoMap.put(cc.getId(), cc); | |||
| } | |||
| } | |||
| } | |||
| List<WxCardCVo> volist = new ArrayList<WxCardCVo>(); | |||
| for (int i = 0 ; i < couponOrderList.size(); i++){ | |||
| WxCouponOrder co = couponOrderList.get(i); | |||
| WxCardCVo cvo = getCouponOrderCardCVo(co,couponMap,cardInfoMap); | |||
| if (null != cvo) { | |||
| volist.add(cvo); | |||
| } | |||
| } | |||
| return volist; | |||
| } | |||
| return null; | |||
| } | |||
| private WxCardCVo getCouponOrderCardCVo(WxCouponOrder co,Map<Long,WxCoupon> couponMap,Map<Long,WxCardInfo> cardInfoMap) { | |||
| WxCoupon coupon = couponMap.get(co.getCouponId()); | |||
| WxCardInfo cardInfo= cardInfoMap.get(co.getId()); | |||
| return getCouponOrderCardCVo(co,coupon,cardInfo); | |||
| } | |||
| private WxCardCVo getCouponOrderCardCVo(WxCouponOrder co,WxCoupon coupon,WxCardInfo cardInfo) { | |||
| if (null == co) { | |||
| return null; | |||
| } | |||
| try { | |||
| WxCardCVo cvo = new WxCardCVo(); | |||
| BeanUtils.copyProperties(cvo, co); | |||
| if (null != coupon) { | |||
| cvo.setCoverImg(coupon.getCoverImg()); | |||
| cvo.setTitle(coupon.getTitle()); | |||
| cvo.setSubTitle(coupon.getSubTitle()); | |||
| cvo.setUnit(coupon.getUnit()); | |||
| cvo.setDetail(coupon.getDetail()); | |||
| cvo.setRemark(coupon.getRemark()); | |||
| } | |||
| if (null != cardInfo) { | |||
| cvo.setAmount(cardInfo.getAmount()); | |||
| cvo.setRemainingAmount(cardInfo.getRemainingAmount()); | |||
| cvo.setSupportTransfer(cardInfo.getSupportTransfer()); | |||
| } | |||
| return cvo; | |||
| } catch (IllegalAccessException | InvocationTargetException e) { | |||
| logger.error("getCouponOrderCardCVo error.",e); | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public ResultData cardDetailCUserVo(Long ownerId, TenantEntity tenantinfo, String couponOrderId) { | |||
| @@ -2125,7 +2239,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId()); | |||
| WxCardCVo cardCVo = findCardDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId()); | |||
| Long couponId = cardCVo.getCouponId(); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setCouponId(couponId); | |||
| @@ -2142,7 +2256,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public ResultData cardAccept(WxCouponOrder record) { | |||
| //卡券是否存在 | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| WxCardCVo cardCVo = findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| if (cardCVo == null) { | |||
| logger.info("卡券不存在" + record.getId()); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -2196,7 +2310,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public ResultData queryCardStatus(WxCouponOrder record) { | |||
| //卡券是否存在 | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| WxCardCVo cardCVo = findCardDetailOfCUser(record.getId(),record.getTenantId()); | |||
| if (cardCVo == null) { | |||
| logger.info("卡券不存在" + record.getId()); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| @@ -2581,16 +2695,29 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public void statisticsWriteOff(WxCouponOrder wxCouponOrder, Map<String, Object> resultMap) { | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | |||
| resultMap.put("couponWriteOff",wxCouponOrderMapper.findWriteOffCount(wxCouponOrder)); | |||
| resultMap.put("couponWriteOff",findWriteOffCount(wxCouponOrder)); | |||
| wxCouponOrder.setCouponType(EnumCouponType.COUPON_GROUP.getCode()); | |||
| resultMap.put("groupWriteOff",wxCouponOrderMapper.findWriteOffCount(wxCouponOrder)); | |||
| resultMap.put("groupWriteOff",findWriteOffCount(wxCouponOrder)); | |||
| wxCouponOrder.setCouponType(EnumCouponType.COUPON_PRESS.getCode()); | |||
| resultMap.put("pressWriteOff",wxCouponOrderMapper.findWriteOffCount(wxCouponOrder)); | |||
| resultMap.put("pressWriteOff",findWriteOffCount(wxCouponOrder)); | |||
| wxCouponOrder.setCouponType(EnumCouponType.COUPON_TINGCHE.getCode()); | |||
| wxCouponOrder.setSendMerchantId(wxCouponOrder.getMerchantId()); | |||
| wxCouponOrder.setMerchantId(null); | |||
| wxCouponOrder.setCouponOrderStatus(null); | |||
| resultMap.put("countTingche",wxCouponOrderMapper.findWriteOffCount(wxCouponOrder)); | |||
| resultMap.put("countTingche",findWriteOffCount(wxCouponOrder)); | |||
| } | |||
| private Integer findWriteOffCount(WxCouponOrder wxCouponOrder) { | |||
| if (null != wxCouponOrder.getMerchantId()) { | |||
| WxMerchantBUser merchantBUserQ = new WxMerchantBUser(); | |||
| merchantBUserQ.updateTenantInfo(wxCouponOrder); | |||
| merchantBUserQ.setMerchantId(wxCouponOrder.getMerchantId()); | |||
| List<Long> buserIds = wxMerchantBUserMapper.findIdList(merchantBUserQ); | |||
| if (null != buserIds && buserIds.size() > 0) { | |||
| wxCouponOrder.setBUserIdList(buserIds); | |||
| } | |||
| } | |||
| return wxCouponOrderMapper.findWriteOffCount(wxCouponOrder); | |||
| } | |||
| @Override | |||
| @@ -1,6 +1,114 @@ | |||
| <?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.iformall.mapper.WxCardTransferInfoMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardTransferInfo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="amount" jdbcType="INTEGER" property="amount" /> | |||
| <result column="remain_amount" jdbcType="INTEGER" property="remainAmount" /> | |||
| <result column="from_user" jdbcType="BIGINT" property="fromUser" /> | |||
| <result column="to_user" jdbcType="BIGINT" property="toUser" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`title`,`amount`,`remain_amount`,`from_user`,`to_user`,`status`,`expired_time`, | |||
| `create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != couponOrderId "> | |||
| and `coupon_order_id` = #{couponOrderId} | |||
| </if> | |||
| <if test=" null != fromUser "> | |||
| and `from_user` = #{fromUser} | |||
| </if> | |||
| <if test=" null != toUser "> | |||
| and `to_user` = #{toUser} | |||
| </if> | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_card_transfer_info where id = #{id} and tenant_id=#{tenantId} | |||
| </select> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCardTransferInfo" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_card_transfer_info | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="BIGINT" property="parentTenantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_type" jdbcType="INTEGER" property="couponType" /> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle" /> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="unit" jdbcType="INTEGER" property="unit" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="amount" jdbcType="INTEGER" property="amount" /> | |||
| <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" /> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| </resultMap> | |||
| <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap"> | |||
| select id,tenant_id,parent_tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as coupon_order_status,create_date,update_date, | |||
| '' cover_img,title,'' sub_title,'' detail,0 unit,'' remark,amount,remain_amount as remaining_amount,0 support_transfer | |||
| from wx_card_transfer_info where from_user = #{ownerId} and `tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <choose> | |||
| <when test="couponOrderStatus != null"> | |||
| and status = #{couponOrderStatus} | |||
| </when> | |||
| <otherwise> | |||
| and status=8 | |||
| </otherwise> | |||
| </choose> | |||
| </select> | |||
| <update id="cardDefer" parameterType="map"> | |||
| update wx_card_transfer_info set expired_time = #{expiredTime},update_date=now() where coupon_order_id in | |||
| @@ -1017,88 +1017,11 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_type" jdbcType="INTEGER" property="couponType" /> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="owner_id" jdbcType="BIGINT" property="ownerId" /> | |||
| <result column="b_user_id" jdbcType="BIGINT" property="bUserId" /> | |||
| <result column="order_id" jdbcType="BIGINT" property="orderId" /> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle" /> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="unit" jdbcType="INTEGER" property="unit" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="amount" jdbcType="INTEGER" property="amount" /> | |||
| <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" /> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| <collection column="{productId=coupon_id,tenantId=tenant_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||
| </collection> | |||
| <collection column="{cardId=id,tenantId=tenant_id}" property="cardSpendList" | |||
| ofType="com.iformall.domain.vo.WxCardSpendVo" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxCardSpendMapper.findCardSpendVoList" > | |||
| </collection> | |||
| </resultMap> | |||
| <sql id="allCUserCardListColumns"> | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date, | |||
| c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark, | |||
| a.amount,a.remaining_amount,a.support_transfer | |||
| </sql> | |||
| <sql id="allCUserCardDetailColumns"> | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, | |||
| c.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark, | |||
| a.amount,a.remaining_amount,a.support_transfer | |||
| </sql> | |||
| <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap"> | |||
| select c.* from ( | |||
| select id,tenant_id,parent_tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as | |||
| coupon_order_status,create_date,update_date,'' cover_img,title,'' sub_title,'' detail,0 unit, | |||
| '' remark,amount,remain_amount as remaining_amount,0 support_transfer | |||
| from wx_card_transfer_info where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="ownerId != null"> | |||
| and from_user = #{ownerId} | |||
| </if> | |||
| <choose> | |||
| <when test="couponOrderStatus != null"> | |||
| and status = #{couponOrderStatus} | |||
| </when> | |||
| <otherwise> | |||
| and status=8 | |||
| </otherwise> | |||
| </choose> | |||
| union | |||
| <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allCUserCardListColumns"/> | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date | |||
| from wx_coupon_order co | |||
| inner join wx_coupon c on co.coupon_id = c.id | |||
| inner join wx_card_info a on co.id=a.id | |||
| where 1=1 | |||
| and co.coupon_type = 100 | |||
| where co.coupon_type = 100 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| @@ -1121,15 +1044,14 @@ | |||
| #{sItem} | |||
| </foreach> | |||
| </if> | |||
| ) c | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <select id="findCardDetailOfCUser" parameterType="java.util.HashMap" resultMap="CCardVoResultMap"> | |||
| select <include refid="allCUserCardDetailColumns" /> | |||
| from wx_coupon_order co,wx_coupon c, wx_card_info a | |||
| where co.coupon_id = c.id and co.id = a.id | |||
| and co.id = #{id} and co.tenant_id = #{tenantId} | |||
| <select id="findCardDetailOfCUser" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status, | |||
| co.create_date,co.update_date,co.coupon_price | |||
| from wx_coupon_order co where co.id = #{id} and co.tenant_id = #{tenantId} | |||
| </select> | |||
| <update id="cardDefer" parameterType="map"> | |||
| @@ -1142,20 +1064,12 @@ | |||
| <select id="findWriteOffCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer"> | |||
| select count(co.id) | |||
| select count(1) | |||
| from wx_coupon_order co | |||
| left join wx_merchant_b_user mbu on co.b_user_id = mbu.id | |||
| where 1 = 1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| where co.`tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and co.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and mbu.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != couponType "> | |||
| and co.`coupon_type` = #{couponType} | |||
| </if> | |||
| @@ -1171,7 +1085,12 @@ | |||
| <if test=" null != endTime "> | |||
| AND co.update_date <= #{endTime} | |||
| </if> | |||
| <if test=" null != bUserIdList"> | |||
| and co.b_user_id in | |||
| <foreach collection="bUserIdList" index="index" item="bUserIdItem" open="(" separator="," close=")"> | |||
| #{bUserIdItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| </mapper> | |||