Ver código fonte

Merge remote-tracking branch 'origin/developerA' into developerA

Aslee 3 anos atrás
pai
commit
2881a77076

+ 2 - 0
src/main/java/com/caimei365/user/mapper/SuperVipMapper.java

@@ -150,4 +150,6 @@ public interface SuperVipMapper {
      * 查询未支付的当前超级会员套餐购买记录
      */
     Integer getVipHistoryId(Integer userId, Integer packageId);
+
+    List<Integer> findCouponUse(@Param("userId") Integer userId,@Param("ueeTime")String useTime);
 }

+ 18 - 0
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -15,6 +15,7 @@ import com.caimei365.user.model.po.VipPayHistoryPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.BaseService;
 import com.caimei365.user.utils.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -23,6 +24,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 
@@ -467,11 +470,26 @@ public class BaseServiceImpl implements BaseService {
         //1.封装vipDto看超级会员是否过期,0未开通,-1过期,1未过期
         SuperVipDto vipEnd = findEnd(userId);
         Map<String, Object> map = new HashMap(3);
+        try {
+            if(vipEnd.getVipFlag().equals(1)){
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+                String mat = format.format(vipEnd.getEndTime());
+                Date parse = format.parse(mat);
+                vipEnd.setEndTime(parse);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
         map.put("vip", vipEnd);
         //2.查当月vip优惠卷
         String nowMonth = DateUtil.getNowMonth();
         List<CouponVo> vipCoupon = vipMapper.findVipCoupon(userId, nowMonth);
         List<Integer> couponGet = vipMapper.findCouponGet(userId, nowMonth);
+        List<Integer> couponUse = vipMapper.findCouponUse(userId, nowMonth);
+        if (couponUse != null && couponUse.size() > 0) {
+            //couponuse有就给2,没有就给1,2使用1未用
+            vipCoupon.forEach(couponVo -> couponVo.setUseStatus(couponUse.contains(couponVo.getCouponId()) ? 2 : 1));
+        }
         vipCoupon.forEach(couponVo -> couponVo.setGetFlag(couponGet.contains(couponVo.getCouponId()) ? 1 : 0));
         map.put("coupon", vipCoupon);
         return ResponseJson.success(map);

+ 10 - 0
src/main/resources/mapper/SuperVipMapper.xml

@@ -143,6 +143,15 @@
           AND useTime = #{useTime}
     </select>
 
+    <select id="findCouponUse" resultType="java.lang.Integer">
+        select couponId from cm_coupon_club ccb
+        inner join cm_svip_coupon cs ON cs.couponId = ccb.couponId
+        where ccb.userId=#{userId} and ccb.status=2
+        <if test="useTime != null and useTime !=''">
+            and cs.useTime=#{useTime}
+        </if>
+    </select>
+
     <select id="findMobile" resultType="java.lang.String">
         select bindMobile
         from user
@@ -154,6 +163,7 @@
         from cm_svip_package
         where delFlag = 0
     </select>
+
     <select id="getVipHistoryId" resultType="java.lang.Integer">
         SELECT id FROM cm_svip_history
         WHERE payStatus=0 AND userId = #{userId} AND packageId=#{packageId}