Browse Source

fixed 会员密码修改功能

fushengqian 1 year ago
parent
commit
586301a2bc

+ 3 - 0
fuint-application/src/main/java/com/fuint/common/dto/UserDto.java

@@ -31,6 +31,9 @@ public class UserDto implements Serializable {
     @ApiModelProperty("称呼")
     private String name;
 
+    @ApiModelProperty("是否设置密码")
+    private String hasPassword;
+
     @ApiModelProperty("分组ID")
     private Integer groupId;
 

+ 18 - 0
fuint-application/src/main/java/com/fuint/common/service/MemberService.java

@@ -183,4 +183,22 @@ public interface MemberService extends IService<MtUser> {
      * @return
      * */
     List<GroupMemberDto> searchMembers(Integer merchantId, String keyword, String groupIds, Integer page, Integer pageSize);
+
+    /**
+     * 设定安全的密码
+     *
+     * @param password
+     * @param salt
+     * @return
+     */
+    String enCodePassword(String password, String salt);
+
+    /**
+     * 获取加密密码
+     *
+     * @param password
+     * @param salt
+     * @return
+     * */
+    String deCodePassword(String password, String salt);
 }

+ 5 - 9
fuint-application/src/main/java/com/fuint/common/service/impl/BannerServiceImpl.java

@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.github.pagehelper.Page;
+import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -89,29 +90,24 @@ public class BannerServiceImpl extends ServiceImpl<MtBannerMapper, MtBanner> imp
     }
 
     /**
-     * 添加Banner信息
+     * 添加焦点图
      *
      * @param bannerDto
      */
     @Override
-    @OperationServiceLog(description = "新增Banner图")
+    @OperationServiceLog(description = "新增焦点图")
     public MtBanner addBanner(BannerDto bannerDto) {
         MtBanner mtBanner = new MtBanner();
-        mtBanner.setTitle(bannerDto.getTitle());
+        BeanUtils.copyProperties(bannerDto, mtBanner);
         mtBanner.setStoreId(bannerDto.getStoreId() == null ? 0 : bannerDto.getStoreId());
-        mtBanner.setUrl(bannerDto.getUrl());
         mtBanner.setStatus(StatusEnum.ENABLED.getKey());
-        mtBanner.setImage(bannerDto.getImage());
-        mtBanner.setDescription(bannerDto.getDescription());
-        mtBanner.setOperator(bannerDto.getOperator());
         mtBanner.setUpdateTime(new Date());
         mtBanner.setCreateTime(new Date());
-        mtBanner.setSort(bannerDto.getSort());
-        mtBanner.setMerchantId(bannerDto.getMerchantId());
         Integer id = mtBannerMapper.insert(mtBanner);
         if (id > 0) {
             return mtBanner;
         } else {
+            logger.error("新增焦点图失败.");
             return null;
         }
     }

+ 31 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java

@@ -360,9 +360,9 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
         // 密码加密
         if (mtUser.getPassword() != null && StringUtil.isNotEmpty(mtUser.getPassword())) {
             String salt = SeqUtil.getRandomLetter(4);
-            String password = CommonUtil.createPassword(mtUser.getPassword(), salt);
-            mtUser.setPassword(password);
             mtUser.setSalt(salt);
+            String password = enCodePassword(mtUser.getPassword(), salt);
+            mtUser.setPassword(password);
             mtUser.setSource(MemberSourceEnum.REGISTER_BY_ACCOUNT.getKey());
         }
         if (mtUser.getSource() == null || StringUtil.isEmpty(mtUser.getSource())) {
@@ -431,6 +431,11 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
                 }
             }
         }
+        if (mtUser.getPassword() != null) {
+            String salt = SeqUtil.getRandomLetter(4);
+            mtUser.setSalt(salt);
+            mtUser.setPassword(enCodePassword(mtUser.getPassword(), salt));
+        }
         String gradeId = mtUser.getGradeId();
         mtUser.setGradeId(oldUserInfo.getGradeId());
         mtUser.setMerchantId(oldUserInfo.getMerchantId());
@@ -877,4 +882,28 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
         }
         return dataList;
     }
+
+    /**
+     * 设定安全的密码
+     *
+     * @param password
+     * @param salt
+     * @return
+     */
+    @Override
+    public String enCodePassword(String password, String salt) {
+        return MD5Util.getMD5(password + salt);
+    }
+
+    /**
+     * 获取加密密码
+     *
+     * @param password
+     * @param salt
+     * @return
+     * */
+    @Override
+    public String deCodePassword(String password, String salt) {
+        return MD5Util.getMD5(password + salt);
+    }
 }

+ 5 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java

@@ -942,7 +942,7 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
                     paymentInfo = paymentService.createPrepayOrder(userInfo, orderInfo, (wxPayAmount.intValue()), authCode, 0, ip, platform);
                 }
                 if (paymentInfo.getData() == null) {
-                    errorMessage = PropertiesUtil.getResponseErrorMessageByCode(3000);
+                    errorMessage = StringUtil.isNotEmpty(paymentInfo.getMessage()) ? paymentInfo.getMessage() : PropertiesUtil.getResponseErrorMessageByCode(3000);
                 }
             }
         } else {
@@ -1091,6 +1091,10 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
             if (orderGoodsList != null && orderGoodsList.size() > 0) {
                 for (MtOrderGoods mtOrderGoods : orderGoodsList) {
                      MtGoods mtGoods = mtGoodsMapper.selectById(mtOrderGoods.getGoodsId());
+                     // 商品已不存在
+                     if (mtGoods == null) {
+                         continue;
+                     }
                      mtGoods.setStock(mtOrderGoods.getNum() + mtGoods.getStock());
                      mtGoodsMapper.updateById(mtGoods);
                      if (mtOrderGoods.getSkuId() != null && mtOrderGoods.getSkuId() > 0) {

+ 2 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/WeixinServiceImpl.java

@@ -210,7 +210,7 @@ public class WeixinServiceImpl implements WeixinService {
         }
 
         // 2.更新预支付订单号
-        if (respData.get("return_code").equals("SUCCESS")) {
+        if (respData.get("result_code").equals("SUCCESS")) {
             if (respData.get("trade_type").equals(PayTypeEnum.JSAPI.getKey())) {
                 String prepayId = respData.get("prepay_id");
                 getApiConfig(orderInfo.getStoreId(), platform);
@@ -221,7 +221,7 @@ public class WeixinServiceImpl implements WeixinService {
             }
         } else {
             logger.error("微信支付接口返回状态失败......" + respData.toString() + "...reason");
-            return new ResponseObject(3000, "微信支付接口返回状态失败", null);
+            return new ResponseObject(3000, "微信支付失败:" + (respData.get("err_code_des") != null ? respData.get("err_code_des") : "未知错误"), null);
         }
 
         ResponseObject responseObject = new ResponseObject(200, "微信支付接口返回成功", respData);

+ 0 - 14
fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java

@@ -80,20 +80,6 @@ public class CommonUtil {
         return true;
     }
 
-    /**
-     * 生成密码
-     * */
-    public static String createPassword(String password, String salt) {
-        return MD5Util.getMD5(password + salt);
-    }
-
-    /**
-     * 验证密码
-     * */
-    public static String getPassword(String password, String salt) {
-        return MD5Util.getMD5(password + salt);
-    }
-
     /**
      * 生成随机会员号(13位数)
      * */

+ 1 - 1
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSignController.java

@@ -323,7 +323,7 @@ public class ClientSignController extends BaseController {
             MtUser userInfo = memberService.queryMemberByName(merchantId, account);
             if (userInfo != null) {
                 String myPassword = userInfo.getPassword();
-                String inputPassword = CommonUtil.getPassword(password, userInfo.getSalt());
+                String inputPassword = memberService.deCodePassword(password, userInfo.getSalt());
                 if (myPassword.equals(inputPassword)) {
                     UserInfo loginInfo = new UserInfo();
                     loginInfo.setToken(TokenUtil.generateToken(userAgent, userInfo.getId()));

+ 38 - 16
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientUserController.java

@@ -2,11 +2,9 @@ package com.fuint.module.clientApi.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.fuint.common.dto.AssetDto;
+import com.fuint.common.dto.UserDto;
 import com.fuint.common.dto.UserInfo;
-import com.fuint.common.enums.CouponTypeEnum;
-import com.fuint.common.enums.SettingTypeEnum;
-import com.fuint.common.enums.StatusEnum;
-import com.fuint.common.enums.UserCouponStatusEnum;
+import com.fuint.common.enums.*;
 import com.fuint.common.service.*;
 import com.fuint.common.util.Base64Util;
 import com.fuint.common.util.DateUtil;
@@ -22,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.io.ByteArrayOutputStream;
@@ -98,38 +97,50 @@ public class ClientUserController extends BaseController {
 
         Integer merchantId = merchantService.getMerchantId(merchantNo);
 
-        MtUser userInfo = null;
+        MtUser mtUser = null;
         if (loginInfo != null) {
-            userInfo = memberService.queryMemberById(loginInfo.getId());
+            mtUser = memberService.queryMemberById(loginInfo.getId());
         }
         if (StringUtil.isNotEmpty(userNo)) {
-            userInfo = memberService.queryMemberByUserNo(merchantId, userNo);
+            mtUser = memberService.queryMemberByUserNo(merchantId, userNo);
         }
         MtUserGrade gradeInfo = null;
-        if (userInfo != null) {
-            gradeInfo = memberService.queryMemberGradeByGradeId(Integer.parseInt(userInfo.getGradeId()));
+        if (mtUser != null) {
+            gradeInfo = memberService.queryMemberGradeByGradeId(Integer.parseInt(mtUser.getGradeId()));
         }
 
-        List<MtUserGrade> memberGrade = userGradeService.getPayUserGradeList(merchantId, userInfo);
+        List<MtUserGrade> memberGrade = userGradeService.getPayUserGradeList(merchantId, mtUser);
         Map<String, Object> outParams = new HashMap<>();
+
+        UserDto userInfo = null;
+        if (mtUser != null) {
+            userInfo = new UserDto();
+            BeanUtils.copyProperties(mtUser, userInfo);
+            if (StringUtil.isNotEmpty(mtUser.getPassword())) {
+                userInfo.setHasPassword(YesOrNoEnum.YES.getKey());
+            } else {
+                userInfo.setHasPassword(YesOrNoEnum.NO.getKey());
+            }
+        }
+
         outParams.put("userInfo", userInfo);
         outParams.put("gradeInfo", gradeInfo);
         outParams.put("memberGrade", memberGrade);
 
         // 会员到期时间
         String gradeEndTime = "";
-        if (userInfo != null) {
-            if (userInfo.getEndTime() != null) {
-                gradeEndTime = DateUtil.formatDate(userInfo.getEndTime(), "yyyy.MM.dd HH:mm");
+        if (mtUser != null) {
+            if (mtUser.getEndTime() != null) {
+                gradeEndTime = DateUtil.formatDate(mtUser.getEndTime(), "yyyy.MM.dd HH:mm");
             }
         }
         outParams.put("gradeEndTime", gradeEndTime);
 
         // 是否店铺员工
         boolean isMerchant = false;
-        if (userInfo != null) {
-            if (userInfo.getMobile() != null && StringUtil.isNotEmpty(userInfo.getMobile())) {
-                MtStaff staffInfo = staffService.queryStaffByMobile(userInfo.getMobile());
+        if (mtUser != null) {
+            if (mtUser.getMobile() != null && StringUtil.isNotEmpty(mtUser.getMobile())) {
+                MtStaff staffInfo = staffService.queryStaffByMobile(mtUser.getMobile());
                 if (staffInfo != null && staffInfo.getAuditedStatus().equals(StatusEnum.ENABLED.getKey())) {
                     isMerchant = true;
                 }
@@ -226,6 +237,8 @@ public class ClientUserController extends BaseController {
         String avatar = param.get("avatar") == null ? "" : param.get("avatar").toString();
         Integer sex = param.get("sex") == null ? 1 : Integer.parseInt(param.get("sex").toString());
         String code = param.get("code") == null ? "" : param.get("code").toString();
+        String password = param.get("password") == null ? "" : param.get("password").toString();
+        String passwordOld = param.get("passwordOld") == null ? "" : param.get("passwordOld").toString();
         String mobile = "";
         Integer merchantId = merchantService.getMerchantId(merchantNo);
         UserInfo userInfo = TokenUtil.getUserInfoByToken(token);
@@ -244,6 +257,15 @@ public class ClientUserController extends BaseController {
         if (StringUtil.isNotEmpty(name)) {
             mtUser.setName(name);
         }
+        if (StringUtil.isNotEmpty(password)) {
+            if (StringUtil.isNotEmpty(passwordOld) && StringUtil.isNotEmpty(mtUser.getSalt())) {
+                String pass = memberService.deCodePassword(passwordOld, mtUser.getSalt());
+                if (!pass.equals(mtUser.getPassword())) {
+                    return getFailureResult(201, "旧密码输入有误");
+                }
+            }
+            mtUser.setPassword(password);
+        }
         if (sex.equals(1) || sex.equals(0) || sex.equals(2)) {
             mtUser.setSex(sex);
         }