Browse Source

fixed 商户管理相关接口优化

fushengqian 1 month ago
parent
commit
f226be8b24

+ 68 - 0
fuint-application/src/main/java/com/fuint/common/dto/MerchantDto.java

@@ -0,0 +1,68 @@
+package com.fuint.common.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 商户实体
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Data
+public class MerchantDto implements Serializable {
+
+    @ApiModelProperty("自增ID")
+    private Integer id;
+
+    @ApiModelProperty("类型")
+    private String type;
+
+    @ApiModelProperty("微信小程序appId")
+    private String wxAppId;
+
+    @ApiModelProperty("微信小程序秘钥")
+    private String wxAppSecret;
+
+    @ApiModelProperty("微信公众号appId")
+    private String wxOfficialAppId;
+
+    @ApiModelProperty("微信公众号秘钥")
+    private String wxOfficialAppSecret;
+
+    @ApiModelProperty("商户号")
+    private String no;
+
+    @ApiModelProperty("商户名称")
+    private String name;
+
+    @ApiModelProperty("商户logo")
+    private String logo;
+
+    @ApiModelProperty("联系人姓名")
+    private String contact;
+
+    @ApiModelProperty("联系电话")
+    private String phone;
+
+    @ApiModelProperty("联系地址")
+    private String address;
+
+    @ApiModelProperty("备注信息")
+    private String description;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty("状态,A:有效/启用;D:无效")
+    private String status;
+
+    @ApiModelProperty("最后操作人")
+    private String operator;
+
+}

+ 2 - 1
fuint-application/src/main/java/com/fuint/common/service/MerchantService.java

@@ -1,6 +1,7 @@
 package com.fuint.common.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.common.dto.MerchantDto;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
@@ -22,7 +23,7 @@ public interface MerchantService extends IService<MtMerchant> {
      * @param paginationRequest
      * @return
      */
-    PaginationResponse<MtMerchant> queryMerchantListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
+    PaginationResponse<MerchantDto> queryMerchantListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
 
     /**
      * 保存商户信息

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

@@ -265,7 +265,7 @@ public class CommissionLogServiceImpl extends ServiceImpl<MtCommissionLogMapper,
                          // 分佣金额计算,散客和会员佣金比例不同
                          BigDecimal rate = mtCommissionRuleItem.getMember();
                          if (mtOrder.getStaffId() != null && mtOrder.getStaffId() > 0 && mtOrder.getIsVisitor().equals(YesOrNoEnum.YES.getKey())) {
-                            rate = mtCommissionRuleItem.getGuest();
+                             rate = mtCommissionRuleItem.getGuest();
                          }
                          BigDecimal amount = mtOrder.getAmount().multiply(rate.divide(new BigDecimal("100")));
                          addCommissionLog(mtOrder, mtCommissionRule, amount, mtCommissionRuleItem, 0);

+ 14 - 3
fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java

@@ -3,6 +3,7 @@ package com.fuint.common.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fuint.common.dto.MerchantDto;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.MerchantService;
 import com.fuint.common.service.StoreService;
@@ -24,6 +25,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
@@ -61,7 +63,7 @@ public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchan
      * @return
      */
     @Override
-    public PaginationResponse<MtMerchant> queryMerchantListByPagination(PaginationRequest paginationRequest) {
+    public PaginationResponse<MerchantDto> queryMerchantListByPagination(PaginationRequest paginationRequest) {
         Page<MtMerchant> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         LambdaQueryWrapper<MtMerchant> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.ne(MtMerchant::getStatus, StatusEnum.DISABLE.getKey());
@@ -80,11 +82,20 @@ public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchan
         }
 
         lambdaQueryWrapper.orderByAsc(MtMerchant::getStatus).orderByDesc(MtMerchant::getId);
-        List<MtMerchant> dataList = mtMerchantMapper.selectList(lambdaQueryWrapper);
+        List<MtMerchant> merchantList = mtMerchantMapper.selectList(lambdaQueryWrapper);
+        List<MerchantDto> dataList = new ArrayList<>();
+        if (merchantList != null && merchantList.size() > 0) {
+            for (MtMerchant mtMerchant : merchantList) {
+                 MerchantDto merchantDto = new MerchantDto();
+                 BeanUtils.copyProperties(mtMerchant, merchantDto);
+                 merchantDto.setPhone(CommonUtil.hidePhone(mtMerchant.getPhone()));
+                 dataList.add(merchantDto);
+            }
+        }
 
         PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
-        PaginationResponse<MtMerchant> paginationResponse = new PaginationResponse(pageImpl, MtMerchant.class);
+        PaginationResponse<MerchantDto> paginationResponse = new PaginationResponse(pageImpl, MtMerchant.class);
         paginationResponse.setTotalPages(pageHelper.getPages());
         paginationResponse.setTotalElements(pageHelper.getTotal());
         paginationResponse.setContent(dataList);

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

@@ -14,6 +14,7 @@ import com.fuint.common.enums.YesOrNoEnum;
 import com.fuint.common.service.MerchantService;
 import com.fuint.common.service.StoreService;
 import com.fuint.common.service.WeixinService;
+import com.fuint.common.util.CommonUtil;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -119,6 +120,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
         for (MtStore mtStore : storeList) {
              StoreDto storeDto = new StoreDto();
              BeanUtils.copyProperties(mtStore, storeDto);
+             storeDto.setPhone(CommonUtil.hidePhone(mtStore.getPhone()));
              MtMerchant mtMerchant = mtMerchantMapper.selectById(mtStore.getMerchantId());
              if (mtMerchant != null) {
                  storeDto.setMerchantName(mtMerchant.getName());

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

@@ -44,7 +44,7 @@ public class CommonUtil {
      * @return
      * */
     public static String hidePhone(String phone) {
-        if (StringUtil.isEmpty(phone)) {
+        if (StringUtil.isBlank(phone)) {
             return "";
         }
         if (phone.length() < 11) {

+ 6 - 10
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendMerchantController.java

@@ -2,6 +2,7 @@ package com.fuint.module.backendApi.controller;
 
 import com.fuint.common.Constants;
 import com.fuint.common.dto.AccountInfo;
+import com.fuint.common.dto.MerchantDto;
 import com.fuint.common.dto.ParamDto;
 import com.fuint.common.enums.MerchantTypeEnum;
 import com.fuint.common.enums.StatusEnum;
@@ -57,7 +58,6 @@ public class BackendMerchantController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('merchant:index')")
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
 
@@ -65,7 +65,7 @@ public class BackendMerchantController extends BaseController {
         String merchantName = request.getParameter("name");
         String status = request.getParameter("status");
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             merchantId = accountInfo.getMerchantId().toString();
         }
@@ -85,7 +85,7 @@ public class BackendMerchantController extends BaseController {
             params.put("status", status);
         }
         paginationRequest.setSearchParams(params);
-        PaginationResponse<MtMerchant> paginationResponse = merchantService.queryMerchantListByPagination(paginationRequest);
+        PaginationResponse<MerchantDto> paginationResponse = merchantService.queryMerchantListByPagination(paginationRequest);
 
         // 商户类型列表
         List<ParamDto> typeList = MerchantTypeEnum.getMerchantTypeList();
@@ -131,11 +131,10 @@ public class BackendMerchantController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('merchant:index')")
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
         Integer merchantId = params.get("merchantId") == null ? 0 : Integer.parseInt(params.get("merchantId").toString());
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             merchantId = accountInfo.getMerchantId();
         }
@@ -151,8 +150,7 @@ public class BackendMerchantController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('merchant:index')")
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody MerchantSubmitRequest merchantInfo) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
         Integer merchantId = accountInfo.getMerchantId();
 
         MtMerchant mtMerchant = new MtMerchant();
@@ -188,14 +186,12 @@ public class BackendMerchantController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('merchant:index')")
     public ResponseObject getMerchantInfo(HttpServletRequest request, @PathVariable("id") Integer merchantId) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             merchantId = accountInfo.getMerchantId();
         }
 
         MtMerchant merchantInfo = merchantService.queryMerchantById(merchantId);
-
         Map<String, Object> result = new HashMap<>();
         result.put("merchantInfo", merchantInfo);
 

+ 4 - 10
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStoreController.java

@@ -4,11 +4,9 @@ import com.fuint.common.Constants;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.StoreDto;
 import com.fuint.common.enums.StatusEnum;
-import com.fuint.common.enums.YesOrNoEnum;
 import com.fuint.common.service.MerchantService;
 import com.fuint.common.service.SettingService;
 import com.fuint.common.service.StoreService;
-import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -65,14 +63,13 @@ public class BackendStoreController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('store:list')")
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
         Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
 
         String storeName = request.getParameter("name");
         String storeStatus = request.getParameter("status");
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
 
         PaginationRequest paginationRequest = new PaginationRequest();
         paginationRequest.setCurrentPage(page);
@@ -111,12 +108,11 @@ public class BackendStoreController extends BaseController {
     @RequestMapping(value = "/searchStore",  method = RequestMethod.GET)
     @CrossOrigin
     public ResponseObject search(HttpServletRequest request) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
         String merchantId = request.getParameter("merchantId") == null ? "" : request.getParameter("merchantId");
         String storeId = request.getParameter("id") == null ? "" : request.getParameter("id");
         String storeName = request.getParameter("name") == null ? "" : request.getParameter("name");
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
 
         if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
             storeId = accountInfo.getStoreId().toString();
@@ -152,11 +148,10 @@ public class BackendStoreController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('store:add')")
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
         Integer storeId = params.get("storeId") == null ? 0 : Integer.parseInt(params.get("storeId").toString());
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
         storeService.updateStatus(storeId, accountInfo.getAccountName(), status);
 
         return getSuccessResult(true);
@@ -215,8 +210,7 @@ public class BackendStoreController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('store:list')")
     public ResponseObject getStoreInfo(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
 
         StoreDto storeInfo = storeService.queryStoreDtoById(id);
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {