Merge remote-tracking branch 'origin/feature-20240104' into feature-20240104

master
elliott 2 years ago
commit d5595fbab8

@ -59,4 +59,6 @@ public interface WxScriptMessageMapper
* @return * @return
*/ */
public int deleteWxScriptMessageByIds(Long[] ids); public int deleteWxScriptMessageByIds(Long[] ids);
public WxScriptMessage selectOneByMessageType(Integer messageType);
} }

@ -63,5 +63,5 @@ public interface WxUserIntegralLogMapper
List<WxUserIntegralLog> obtainUserIntegral(@Param("userId") Long userId); List<WxUserIntegralLog> obtainUserIntegral(@Param("userId") Long userId);
List<WxUserIntegralLog> deleteWxUserIntegralLogByUserId(@Param("userId") Long userId); int deleteWxUserIntegralLogByUserId(@Param("userId") Long userId);
} }

@ -132,4 +132,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="selectOneByMessageType" parameterType="integer" resultMap="WxScriptMessageResult">
<include refid="selectWxScriptMessageVo"/>
where
message_type = #{messageType}
and status = #{status}
order by create_time desc
LIMIT 1
</select>
</mapper> </mapper>

@ -199,6 +199,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertWxUserMember" parameterType="WxUserMember" useGeneratedKeys="true" keyProperty="id"> <insert id="insertWxUserMember" parameterType="WxUserMember" useGeneratedKeys="true" keyProperty="id">
<selectKey keyProperty="id" resultType="Long" order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>
insert into wx_user_member insert into wx_user_member
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="nickname != null">nickname,</if> <if test="nickname != null">nickname,</if>

@ -67,7 +67,7 @@ public class UserMemberController extends BaseController {
* @return * @return
*/ */
@PostMapping("/updateUser") @PostMapping("/updateUser")
public R updateUser(@RequestParam(value = "file", required = false) MultipartFile file, @Validated UserMemberUpdateVo userMemberUpdateVo) { public R updateUser(@RequestParam(value = "headimg", required = false) MultipartFile file, @Validated UserMemberUpdateVo userMemberUpdateVo) {
if (file != null) { if (file != null) {
R<SysFile> result = remoteFileService.upload(file); R<SysFile> result = remoteFileService.upload(file);
if (result.getCode() != Constants.SUCCESS) { if (result.getCode() != Constants.SUCCESS) {

@ -1,11 +1,20 @@
package com.flossom.miniProgram.service.impl; package com.flossom.miniProgram.service.impl;
import com.flossom.common.core.domain.entity.CtLeaveMessage; import com.flossom.common.core.domain.entity.CtLeaveMessage;
import com.flossom.common.core.domain.entity.WxScriptMessage;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.enums.CtLeaveMessageEnum; import com.flossom.common.core.enums.CtLeaveMessageEnum;
import com.flossom.common.core.enums.MessageTypeEnum;
import com.flossom.common.core.enums.WxUserIntegralMessageTypeEnum;
import com.flossom.common.core.mapper.CtLeaveMessageMapper; import com.flossom.common.core.mapper.CtLeaveMessageMapper;
import com.flossom.common.core.mapper.WxScriptMessageMapper;
import com.flossom.common.core.mapper.WxUserScriptLogMapper;
import com.flossom.common.security.utils.SecurityUtils;
import com.flossom.miniProgram.service.ICtleaveMeassageService; import com.flossom.miniProgram.service.ICtleaveMeassageService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
@ -14,8 +23,28 @@ public class CtleaveMessageServiceImpl implements ICtleaveMeassageService {
@Autowired @Autowired
private CtLeaveMessageMapper ctLeaveMessageMapper; private CtLeaveMessageMapper ctLeaveMessageMapper;
@Autowired
private WxScriptMessageMapper wxScriptMessageMapper;
@Autowired
private WxUserScriptLogMapper wxUserScriptLogMapper;
@Transactional
@Override @Override
public int saveCtleaveMeassage(CtLeaveMessage ctLeaveMessage) { public int saveCtleaveMeassage(CtLeaveMessage ctLeaveMessage) {
// 留言成功发送消息
WxScriptMessage wxScriptMessage = wxScriptMessageMapper.selectOneByMessageType(MessageTypeEnum.SUBMIT_MESSAGE.getCode());
WxUserScriptLog wxUserScriptLog = new WxUserScriptLog();
BeanUtils.copyProperties(wxScriptMessage, wxUserScriptLog);
wxUserScriptLog.setId(null);
wxUserScriptLog.setWxUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
wxUserScriptLog.setMessageType(WxUserIntegralMessageTypeEnum.USER_REGISTRATION.getCode());
wxUserScriptLog.setIsCustom(0);
wxUserScriptLog.setTitile(wxScriptMessage.getMessageTitle());
wxUserScriptLog.setContent(wxScriptMessage.getMessageContent());
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
// 保存消息
CtLeaveMessageEnum ctLeaveMessageEnum = CtLeaveMessageEnum.fromString(ctLeaveMessage.getSource()); CtLeaveMessageEnum ctLeaveMessageEnum = CtLeaveMessageEnum.fromString(ctLeaveMessage.getSource());
ctLeaveMessage.setSourceName(ctLeaveMessageEnum.getRemark()); ctLeaveMessage.setSourceName(ctLeaveMessageEnum.getRemark());
ctLeaveMessage.setCreateTime(new Date()); ctLeaveMessage.setCreateTime(new Date());

@ -5,9 +5,15 @@ import com.flossom.common.core.constant.CacheConstants;
import com.flossom.common.core.constant.UserConstants; import com.flossom.common.core.constant.UserConstants;
import com.flossom.common.core.domain.R; import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.RegisterBody; import com.flossom.common.core.domain.RegisterBody;
import com.flossom.common.core.domain.entity.WxScriptMessage;
import com.flossom.common.core.domain.entity.WxUserMember; import com.flossom.common.core.domain.entity.WxUserMember;
import com.flossom.common.core.domain.entity.WxUserScriptLog;
import com.flossom.common.core.enums.MessageTypeEnum;
import com.flossom.common.core.enums.WxUserIntegralMessageTypeEnum;
import com.flossom.common.core.exception.ServiceException; import com.flossom.common.core.exception.ServiceException;
import com.flossom.common.core.mapper.WxScriptMessageMapper;
import com.flossom.common.core.mapper.WxUserMemberMapper; import com.flossom.common.core.mapper.WxUserMemberMapper;
import com.flossom.common.core.mapper.WxUserScriptLogMapper;
import com.flossom.common.core.utils.DateUtils; import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.redis.service.RedisService; import com.flossom.common.redis.service.RedisService;
import com.flossom.common.security.utils.SecurityUtils; import com.flossom.common.security.utils.SecurityUtils;
@ -42,6 +48,12 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired
private WxScriptMessageMapper wxScriptMessageMapper;
@Autowired
private WxUserScriptLogMapper wxUserScriptLogMapper;
@Override @Override
public LoginUserVo login(String code) throws Exception { public LoginUserVo login(String code) throws Exception {
// 1、使用临时凭证 code 获取 appi + appsecret + unionid // 1、使用临时凭证 code 获取 appi + appsecret + unionid
@ -76,6 +88,17 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
logger.error("测试后台账号失败:{}", registerResult.getMsg()); logger.error("测试后台账号失败:{}", registerResult.getMsg());
throw new ServiceException(registerResult.getMsg()); throw new ServiceException(registerResult.getMsg());
} }
// 2.4、用户注册成功发送消息
WxScriptMessage wxScriptMessage = wxScriptMessageMapper.selectOneByMessageType(MessageTypeEnum.USER_REGISTRATION.getCode());
WxUserScriptLog wxUserScriptLog = new WxUserScriptLog();
BeanUtils.copyProperties(wxScriptMessage, wxUserScriptLog);
wxUserScriptLog.setId(null);
wxUserScriptLog.setWxUserId(wxUserMember.getId());
wxUserScriptLog.setMessageType(WxUserIntegralMessageTypeEnum.USER_REGISTRATION.getCode());
wxUserScriptLog.setIsCustom(0);
wxUserScriptLog.setTitile(wxScriptMessage.getMessageTitle());
wxUserScriptLog.setContent(wxScriptMessage.getMessageContent());
wxUserScriptLogMapper.insertWxUserScriptLog(wxUserScriptLog);
} }
// 3、登录请求获取 token // 3、登录请求获取 token
@ -137,6 +160,7 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
} }
WxUserMember update = new WxUserMember(); WxUserMember update = new WxUserMember();
update.setId(wxUserMember.getId());
BeanUtils.copyProperties(userMemberUpdateVo, update); BeanUtils.copyProperties(userMemberUpdateVo, update);
update.setUpdateTime(DateUtils.getNowDate()); update.setUpdateTime(DateUtils.getNowDate());
wxUserMemberMapper.updateWxUserMember(update); wxUserMemberMapper.updateWxUserMember(update);

Loading…
Cancel
Save