Commit 691d7cb1 by 阮思源

Merge branch 'fix-zdw-10016730' into 'master'

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

See merge request rays/pcloud-book!239
parents 14d9faea 6b7d255d
......@@ -403,7 +403,8 @@ public class LunarCalendarUtils {
int ganYear = y % 10 > 3 ? (y % 10 - 3) : (y % 10 - 3 + 10);
int gan = (ganYear * 2 + m) % 10;
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 {
* @return
*/
GetClockCouponResponseVO getClockCoupon(String wxGroupId, Long wechatUserId);
/**
* 处理微信用户为空的用户优惠券
*/
void solveUserCoupon();
}
......@@ -786,6 +786,7 @@ public class WeixinClockBizImpl implements WeixinClockBiz {
amqpTemplate.convertAndSend(MQTopicProducer.EXCHAGE, MQTopicProducer.GIVE_GIFT, promotionOrderDto);
weixinClockPrizeRecordDao.deleteByWxUserId(wechatGroupUser.getWxUserId());
weixinClockMemberDao.updatMemberWechatUserId(wechatGroupUser.getWxUserId(), wechatGroupUser.getWechatUserId());
weixinClockUserCouponDao.updateWechatUserId(wechatGroupUser.getWxUserId(), wechatGroupUser.getWechatUserId());
}
@Override
......@@ -841,4 +842,22 @@ public class WeixinClockBizImpl implements WeixinClockBiz {
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;
import com.pcloud.book.weixinclock.entity.WeixinClockUserCoupon;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Describe: 微信群打卡用户优惠dao
* @Author: zhangdongwei
......@@ -16,4 +18,17 @@ public interface WeixinClockUserCouponDao extends BaseDao<WeixinClockUserCoupon>
* @return
*/
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;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -23,4 +24,17 @@ public class WeixinClockUserCouponDaoImpl extends BaseDaoImpl<WeixinClockUserCou
map.put("wechatUserId", wechatUserId);
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 {
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 @@
<id column="weixin_clock_member_id" property="weixinClockMemberId" jdbcType="BIGINT"/>
<result column="weixin_clock_id" property="weixinClockId" jdbcType="BIGINT"/>
<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="wx_group_id" property="wxGroupId" jdbcType="VARCHAR"/>
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
......@@ -48,7 +49,7 @@
<select id="getByWxUserId" parameterType="map" resultMap="BaseResultMap">
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
weixin_clock_member
where
......
......@@ -51,4 +51,14 @@
where wx_group_id = #{wxGroupId}
and wechat_user_id = #{wechatUserId}
</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>
\ 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