Sfoglia il codice sorgente

fixed 商户端员工管理接口

fushengqian 1 mese fa
parent
commit
953b3b39e2

+ 4 - 12
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStaffController.java

@@ -126,8 +126,7 @@ public class BackendStaffController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('staff:list')")
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody StaffParam staffParam) 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) {
             return getFailureResult(5002);
         }
@@ -175,9 +174,7 @@ public class BackendStaffController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('staff:list')")
     public ResponseObject getStaffInfo(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"));
         MtStaff staffInfo = staffService.queryStaffById(id);
         if (accountInfo.getMerchantId() > 0 && !accountInfo.getMerchantId().equals(staffInfo.getMerchantId())) {
             return getFailureResult(1004);
@@ -199,9 +196,7 @@ public class BackendStaffController extends BaseController {
     @RequestMapping(value = "/storeStaffList/{storeId}", method = RequestMethod.GET)
     @CrossOrigin
     public ResponseObject storeStaffList(HttpServletRequest request, @PathVariable("storeId") Integer storeId) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(request.getHeader("Access-Token"));
 
         Map<String, Object> params = new HashMap<>();
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
@@ -230,10 +225,7 @@ public class BackendStaffController extends BaseController {
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('staff:list')")
     public ResponseObject deleteStaff(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"));
         staffService.updateAuditedStatus(id, StatusEnum.DISABLE.getKey(), accountInfo.getAccountName());
         return getSuccessResult(true);
     }

+ 0 - 9
fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientCouponController.java

@@ -66,9 +66,6 @@ public class ClientCouponController extends BaseController {
      */
     private StoreService storeService;
 
-    /**
-     * 获取卡券列表数据
-     */
     @ApiOperation(value = "获取卡券列表数据")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     @CrossOrigin
@@ -90,9 +87,6 @@ public class ClientCouponController extends BaseController {
         return getSuccessResult(responseObject.getData());
     }
 
-    /**
-     * 领取卡券
-     * */
     @ApiOperation(value = "领取卡券")
     @RequestMapping(value = "/receive", method = RequestMethod.POST)
     @CrossOrigin
@@ -115,9 +109,6 @@ public class ClientCouponController extends BaseController {
         return getSuccessResult(result);
     }
 
-    /**
-     * 查询卡券详情
-     */
     @ApiOperation(value = "查询卡券详情")
     @RequestMapping(value = "/detail", method = RequestMethod.POST)
     @CrossOrigin

+ 3 - 4
fuint-application/src/main/java/com/fuint/module/merchantApi/controller/MerchantCouponController.java

@@ -12,12 +12,13 @@ import com.fuint.repository.model.MtStaff;
 import com.fuint.repository.model.MtUser;
 import com.fuint.utils.StringUtil;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 
 /**
- * 卡券接口controller
+ * 商户卡券接口controller
  *
  * Created by FSQ
  * CopyRight https://www.fuint.cn
@@ -48,9 +49,7 @@ public class MerchantCouponController extends BaseController {
      */
     private CouponService couponService;
 
-    /**
-     * 充值余额
-     * */
+    @ApiOperation(value = "发放卡券")
     @RequestMapping(value = "/sendCoupon", method = RequestMethod.POST)
     @CrossOrigin
     public ResponseObject sendCoupon(HttpServletRequest request, @RequestBody CouponReceiveParam receiveParam) throws BusinessCheckException {

+ 127 - 0
fuint-application/src/main/java/com/fuint/module/merchantApi/controller/MerchantStaffController.java

@@ -0,0 +1,127 @@
+package com.fuint.module.merchantApi.controller;
+
+import com.fuint.common.dto.UserInfo;
+import com.fuint.common.param.StaffParam;
+import com.fuint.common.service.MerchantService;
+import com.fuint.common.service.StaffService;
+import com.fuint.common.service.MemberService;
+import com.fuint.common.util.TokenUtil;
+import com.fuint.framework.exception.BusinessCheckException;
+import com.fuint.framework.pagination.PaginationRequest;
+import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.web.BaseController;
+import com.fuint.framework.web.ResponseObject;
+import com.fuint.module.merchantApi.request.StaffListRequest;
+import com.fuint.repository.model.MtStaff;
+import com.fuint.repository.model.MtUser;
+import com.fuint.utils.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 商户员工管理接口controller
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Api(tags="商户端-员工相关接口")
+@RestController
+@AllArgsConstructor
+@RequestMapping(value = "/merchantApi/staff")
+public class MerchantStaffController extends BaseController {
+
+    /**
+     * 会员服务接口
+     */
+    private MemberService memberService;
+
+    /**
+     * 店铺员工服务接口
+     * */
+    private StaffService staffService;
+
+    /**
+     * 商户服务接口
+     * */
+    private MerchantService merchantService;
+
+    @ApiOperation(value = "员工列表")
+    @RequestMapping(value = "/staffList", method = RequestMethod.POST)
+    @CrossOrigin
+    public ResponseObject staffList(HttpServletRequest request, @RequestBody StaffListRequest requestParams) throws BusinessCheckException {
+        Integer merchantId = merchantService.getMerchantId(request.getHeader("merchantNo"));
+
+        UserInfo userInfo = TokenUtil.getUserInfoByToken(request.getHeader("Access-Token"));
+        MtUser mtUser = memberService.queryMemberById(userInfo.getId());
+
+        if (mtUser == null || StringUtil.isBlank(mtUser.getMobile())) {
+            return getFailureResult(201, "该账号不是商户");
+        }
+
+        MtStaff staff = staffService.queryStaffByMobile(mtUser.getMobile());
+        if (staff == null || !merchantId.equals(staff.getMerchantId())) {
+            return getFailureResult(201, "您没有操作权限");
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("merchantId", staff.getMerchantId());
+        if (staff.getStoreId() != null && staff.getStoreId() > 0) {
+            params.put("storeId", staff.getStoreId());
+        }
+        if (StringUtil.isNotEmpty(requestParams.getName())) {
+            params.put("name", requestParams.getName());
+        }
+        if (StringUtil.isNotEmpty(requestParams.getMobile())) {
+            params.put("mobile", requestParams.getMobile());
+        }
+
+        PaginationRequest paginationRequest = new PaginationRequest();
+        paginationRequest.setCurrentPage(requestParams.getPage());
+        paginationRequest.setPageSize(requestParams.getPageSize());
+        paginationRequest.setSearchParams(params);
+
+        PaginationResponse paginationResponse = staffService.queryStaffListByPagination(paginationRequest);
+        Map<String, Object> result = new HashMap<>();
+        result.put("staffList", paginationResponse.getContent());
+        result.put("pageSize", paginationResponse.getPageSize());
+        result.put("pageNumber", paginationResponse.getCurrentPage());
+        result.put("totalRow", paginationResponse.getTotalElements());
+        result.put("totalPage", paginationResponse.getTotalPages());
+
+        return getSuccessResult(result);
+    }
+
+    @ApiOperation(value = "保存员工信息")
+    @RequestMapping(value = "/saveStaff", method = RequestMethod.POST)
+    @CrossOrigin
+    public ResponseObject saveStaff(HttpServletRequest request, @RequestBody StaffParam staffInfo) throws BusinessCheckException {
+        Integer merchantId = merchantService.getMerchantId(request.getHeader("merchantNo"));
+
+        UserInfo userInfo = TokenUtil.getUserInfoByToken(request.getHeader("Access-Token"));
+        MtUser mtUser = memberService.queryMemberById(userInfo.getId());
+
+        if (mtUser == null || StringUtil.isBlank(mtUser.getMobile())) {
+            return getFailureResult(201, "该账号不是商户");
+        }
+
+        MtStaff staff = staffService.queryStaffByMobile(mtUser.getMobile());
+        if (staff == null || !merchantId.equals(staff.getMerchantId())) {
+            return getFailureResult(201, "您没有操作权限");
+        }
+
+        MtStaff mtStaff = new MtStaff();
+        if (staffInfo.getId() != null && staffInfo.getId() > 0) {
+            mtStaff = staffService.queryStaffById(staffInfo.getId());
+        }
+        BeanUtils.copyProperties(staffInfo, mtStaff);
+        staffService.saveStaff(mtStaff, staff.getRealName());
+
+        return getSuccessResult(true);
+    }
+}

+ 23 - 0
fuint-application/src/main/java/com/fuint/module/merchantApi/request/StaffListRequest.java

@@ -0,0 +1,23 @@
+package com.fuint.module.merchantApi.request;
+
+import com.fuint.common.param.PageParam;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+
+/**
+ * 员工列表请求参数
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Data
+public class StaffListRequest extends PageParam implements Serializable {
+
+    @ApiModelProperty(value="姓名", name="name")
+    private String name;
+
+    @ApiModelProperty(value="手机号", name="mobile")
+    private String mobile;
+
+}