yujian
2019-04-22 e56237a31ca70bc6bb1ba8ffab12a0bea90cddb3
免单券使用记录查询优化
3个文件已修改
79 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponCountMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponCountMapper.java
@@ -6,6 +6,7 @@
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.vo.user.SystemCouponVO;
import com.yeshi.fanli.vo.user.UserSystemCouponCountVO;
@@ -101,7 +102,7 @@
     * @param percent
     * @return
     */
    List<UserSystemCouponCountVO> listFreeCouponRecord(@Param("start") long start, @Param("count") int count,
    List<UserSystemCouponRecord> listFreeCouponRecord(@Param("start") long start, @Param("count") int count,
            @Param("key") String key, @Param("keyType") Integer keyType,
            @Param("state") Integer state);
    
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml
@@ -50,6 +50,21 @@
  </resultMap>
  
  
   <resultMap id="BaseResultRecordMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord">
    <id column="ucr_id" property="id" jdbcType="BIGINT"/>
    <result column="ucr_good_id" property="goodId" jdbcType="BIGINT"/>
    <result column="ucr_good_source" property="goodSource" jdbcType="VARCHAR"/>
    <result column="ucr_coupon_type" property="couponType" jdbcType="VARCHAR"/>
    <result column="ucr_order_no" property="orderNo" jdbcType="VARCHAR"/>
    <result column="ucr_state" property="state" jdbcType="INTEGER"/>
    <result column="ucr_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="ucr_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association property="userSystemCoupon" column="ucr_user_coupon_id"
        resultMap="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper.BaseResultMap"/>
  </resultMap>
  <select id="listRebateCoupon" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    LEFT JOIN yeshi_ec_system_coupon p   ON  p.`sc_id`= uc.`usc_coupon_id`
@@ -216,7 +231,7 @@
        </if>
  </select>
  
  <select id="listFreeCouponRecord" resultMap="BaseResultMap">
  <select id="listFreeCouponRecord" resultMap="BaseResultRecordMap">
    SELECT * FROM `yeshi_ec_user_system_coupon_record` d 
        LEFT JOIN `yeshi_ec_user_system_coupon` uc  ON d.`ucr_user_coupon_id` = uc.`usc_id`
        LEFT JOIN yeshi_ec_system_coupon p  ON  p.`sc_id`= uc.`usc_coupon_id`
fanli/src/main/java/com/yeshi/fanli/service/impl/count/UserSystemCouponCountServiceImpl.java
@@ -7,11 +7,15 @@
import javax.annotation.Resource;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponCountMapper;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.entity.system.SystemCoupon;
import com.yeshi.fanli.service.inter.config.SystemCouponService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.count.UserSystemCouponCountService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
@@ -38,6 +42,9 @@
    
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private SystemCouponService systemCouponService;
    
    /**
     * 奖励券统计
@@ -179,7 +186,6 @@
                    orderMoney = new BigDecimal(0);
                }
                userSystemCouponVO.setOrderMoney(orderMoney);
            }
        }
        
@@ -197,36 +203,53 @@
    public List<UserSystemCouponCountVO> listFreeCouponRecord(long start,int count, String key, Integer keyType,
             Integer state){
        
        List<UserSystemCouponCountVO> list = userSystemCouponCountMapper.listFreeCouponRecord(start, count, key,
        List<UserSystemCouponRecord> list = userSystemCouponCountMapper.listFreeCouponRecord(start, count, key,
                keyType, state);
        
        if (list == null ) {
            list = new ArrayList<UserSystemCouponCountVO>();
        if (list == null || list.size() == 0) {
            return null;
        }
        
        for (UserSystemCouponCountVO userSystemCouponVO: list) {
        List<UserSystemCouponCountVO> listvo = new ArrayList<UserSystemCouponCountVO>();
        for (UserSystemCouponRecord couponRecord: list) {
            UserSystemCouponCountVO vo = new UserSystemCouponCountVO();
            UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
            try {
                PropertyUtils.copyProperties(vo, userSystemCoupon);
            } catch (Exception e) {
                e.printStackTrace();
            }
            vo.setUserSystemCouponRecord(couponRecord);
//            SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
//            SystemCoupon baseCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
//            if (baseCoupon == null || baseCoupon.getId() == null) {
//                continue;
//            }
//            vo.setSystemCoupon(baseCoupon);
            // 用户信息
            Long uid = userSystemCouponVO.getUid();
            Long uid = userSystemCoupon.getUid();
            UserInfo userInfo = userInfoService.selectByPKey(uid);
            if (userInfo == null) {
                userInfo = new UserInfo();
                userInfo.setId(uid);
            }
            userSystemCouponVO.setUserInfo(userInfo);
            vo.setUserInfo(userInfo);
            
            UserSystemCouponRecord couponRecord = userSystemCouponVO.getUserSystemCouponRecord();
            if (couponRecord != null) {
                String orderNo = couponRecord.getOrderNo();
                BigDecimal orderMoney = commonOrderCountService.getMoneyByOrderNo(orderNo);
                if (orderMoney == null) {
                    orderMoney = new BigDecimal(0);
                }
                userSystemCouponVO.setOrderMoney(orderMoney);
            String orderNo = couponRecord.getOrderNo();
            BigDecimal orderMoney = commonOrderCountService.getMoneyByOrderNo(orderNo);
            if (orderMoney == null) {
                orderMoney = new BigDecimal(0);
            }
            vo.setOrderMoney(orderMoney);
            listvo.add(vo);
        }
        return list;
        return listvo;
    }