Commit 6b7d255d by zhangdongwei-intern

fix-1016730: 打卡优惠券成员id为空

parent 14d9faea
...@@ -403,7 +403,8 @@ public class LunarCalendarUtils { ...@@ -403,7 +403,8 @@ public class LunarCalendarUtils {
int ganYear = y % 10 > 3 ? (y % 10 - 3) : (y % 10 - 3 + 10); int ganYear = y % 10 > 3 ? (y % 10 - 3) : (y % 10 - 3 + 10);
int gan = (ganYear * 2 + m) % 10; int gan = (ganYear * 2 + m) % 10;
gan = gan == 0 ? 10 : gan; gan = gan == 0 ? 10 : gan;
return GAN[gan-1] + ZHI[m%12 + 1] + "月"; int zhi = (m + 1)%12;
return GAN[gan-1] + ZHI[zhi] + "月";
} }
/** /**
......
...@@ -117,4 +117,9 @@ public interface WeixinClockBiz { ...@@ -117,4 +117,9 @@ public interface WeixinClockBiz {
* @return * @return
*/ */
GetClockCouponResponseVO getClockCoupon(String wxGroupId, Long wechatUserId); GetClockCouponResponseVO getClockCoupon(String wxGroupId, Long wechatUserId);
/**
* 处理微信用户为空的用户优惠券
*/
void solveUserCoupon();
} }
...@@ -786,6 +786,7 @@ public class WeixinClockBizImpl implements WeixinClockBiz { ...@@ -786,6 +786,7 @@ public class WeixinClockBizImpl implements WeixinClockBiz {
amqpTemplate.convertAndSend(MQTopicProducer.EXCHAGE, MQTopicProducer.GIVE_GIFT, promotionOrderDto); amqpTemplate.convertAndSend(MQTopicProducer.EXCHAGE, MQTopicProducer.GIVE_GIFT, promotionOrderDto);
weixinClockPrizeRecordDao.deleteByWxUserId(wechatGroupUser.getWxUserId()); weixinClockPrizeRecordDao.deleteByWxUserId(wechatGroupUser.getWxUserId());
weixinClockMemberDao.updatMemberWechatUserId(wechatGroupUser.getWxUserId(), wechatGroupUser.getWechatUserId()); weixinClockMemberDao.updatMemberWechatUserId(wechatGroupUser.getWxUserId(), wechatGroupUser.getWechatUserId());
weixinClockUserCouponDao.updateWechatUserId(wechatGroupUser.getWxUserId(), wechatGroupUser.getWechatUserId());
} }
@Override @Override
...@@ -841,4 +842,22 @@ public class WeixinClockBizImpl implements WeixinClockBiz { ...@@ -841,4 +842,22 @@ public class WeixinClockBizImpl implements WeixinClockBiz {
return vo; return vo;
} }
@Override
public void solveUserCoupon(){
List<WeixinClockUserCoupon> userCoupons = weixinClockUserCouponDao.getNoWechatUserId();
if (ListUtils.isEmpty(userCoupons)){
return;
}
for (WeixinClockUserCoupon userCoupon : userCoupons){
if (null == userCoupon || null == userCoupon.getWxUserId() || null == userCoupon.getWxGroupId()){
continue;
}
WeixinClockMember clockMember = weixinClockMemberDao.getByWxUserId(userCoupon.getWxGroupId(), userCoupon.getWxUserId());
if (null == clockMember || null == clockMember.getWechatUserId()){
continue;
}
weixinClockUserCouponDao.updateWechatUserId(userCoupon.getWxUserId(), clockMember.getWechatUserId());
}
}
} }
...@@ -3,6 +3,8 @@ package com.pcloud.book.weixinclock.dao; ...@@ -3,6 +3,8 @@ package com.pcloud.book.weixinclock.dao;
import com.pcloud.book.weixinclock.entity.WeixinClockUserCoupon; import com.pcloud.book.weixinclock.entity.WeixinClockUserCoupon;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/** /**
* @Describe: 微信群打卡用户优惠dao * @Describe: 微信群打卡用户优惠dao
* @Author: zhangdongwei * @Author: zhangdongwei
...@@ -16,4 +18,17 @@ public interface WeixinClockUserCouponDao extends BaseDao<WeixinClockUserCoupon> ...@@ -16,4 +18,17 @@ public interface WeixinClockUserCouponDao extends BaseDao<WeixinClockUserCoupon>
* @return * @return
*/ */
WeixinClockUserCoupon getByGroupAndUser(String wxGroupId, Long wechatUserId); WeixinClockUserCoupon getByGroupAndUser(String wxGroupId, Long wechatUserId);
/**
* 修改微信用户id
* @param wxUserId
* @param wechatUserId
*/
void updateWechatUserId(String wxUserId, Long wechatUserId);
/**
* 获取没有wechatUserId的用户优惠券
* @return
*/
List<WeixinClockUserCoupon> getNoWechatUserId();
} }
...@@ -7,6 +7,7 @@ import com.pcloud.common.core.dao.BaseDaoImpl; ...@@ -7,6 +7,7 @@ import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -23,4 +24,17 @@ public class WeixinClockUserCouponDaoImpl extends BaseDaoImpl<WeixinClockUserCou ...@@ -23,4 +24,17 @@ public class WeixinClockUserCouponDaoImpl extends BaseDaoImpl<WeixinClockUserCou
map.put("wechatUserId", wechatUserId); map.put("wechatUserId", wechatUserId);
return super.sqlSessionTemplate.selectOne(getStatement("getByGroupAndUser"),map); return super.sqlSessionTemplate.selectOne(getStatement("getByGroupAndUser"),map);
} }
@Override
public void updateWechatUserId(String wxUserId, Long wechatUserId) {
Map<String, Object> map = new HashMap<>();
map.put("wxUserId", wxUserId);
map.put("wechatUserId", wechatUserId);
super.sqlSessionTemplate.update(getStatement("updateWechatUserId"),map);
}
@Override
public List<WeixinClockUserCoupon> getNoWechatUserId() {
return super.sqlSessionTemplate.selectList(getStatement("getNoWechatUserId"));
}
} }
...@@ -240,4 +240,10 @@ public class WeixinClockFacadeImpl implements WeixinClockFacade { ...@@ -240,4 +240,10 @@ public class WeixinClockFacadeImpl implements WeixinClockFacade {
return new ResponseDto<>(weixinClockBiz.getClockCoupon(wxGroupId, wechatUserId)); return new ResponseDto<>(weixinClockBiz.getClockCoupon(wxGroupId, wechatUserId));
} }
@RequestMapping(value = "solveUserCoupon", method = RequestMethod.GET)
public ResponseDto<?> solveUserCoupon(){
weixinClockBiz.solveUserCoupon();
return new ResponseDto<>();
}
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<id column="weixin_clock_member_id" property="weixinClockMemberId" jdbcType="BIGINT"/> <id column="weixin_clock_member_id" property="weixinClockMemberId" jdbcType="BIGINT"/>
<result column="weixin_clock_id" property="weixinClockId" jdbcType="BIGINT"/> <result column="weixin_clock_id" property="weixinClockId" jdbcType="BIGINT"/>
<result column="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/> <result column="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="book_group_classify_id" property="bookGroupClassifyId" jdbcType="BIGINT"/> <result column="book_group_classify_id" property="bookGroupClassifyId" jdbcType="BIGINT"/>
<result column="wx_group_id" property="wxGroupId" jdbcType="VARCHAR"/> <result column="wx_group_id" property="wxGroupId" jdbcType="VARCHAR"/>
<result column="nickname" property="nickname" jdbcType="VARCHAR"/> <result column="nickname" property="nickname" jdbcType="VARCHAR"/>
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
<select id="getByWxUserId" parameterType="map" resultMap="BaseResultMap"> <select id="getByWxUserId" parameterType="map" resultMap="BaseResultMap">
select select
weixin_clock_member_id, weixin_clock_id, wx_user_id, book_group_classify_id, wx_group_id, nickname, head_pic, all_clock_day, score, create_time weixin_clock_member_id, weixin_clock_id, wx_user_id, book_group_classify_id, wx_group_id, nickname, head_pic, all_clock_day, score, create_time, wechat_user_id
from from
weixin_clock_member weixin_clock_member
where where
......
...@@ -51,4 +51,14 @@ ...@@ -51,4 +51,14 @@
where wx_group_id = #{wxGroupId} where wx_group_id = #{wxGroupId}
and wechat_user_id = #{wechatUserId} and wechat_user_id = #{wechatUserId}
</select> </select>
<update id="updateWechatUserId" parameterType="map">
update weixin_clock_user_coupon set wechat_user_id = #{wechatUserId}
where wx_user_id = #{wxUserId} and wechat_user_id is null
</update>
<select id="getNoWechatUserId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from weixin_clock_user_coupon where wechat_user_id is null
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment