|
|
@@ -3,10 +3,11 @@ package com.sapit.client.app.store.controller.inspect;
|
|
|
import com.sapit.client.app.manage.inspect.service.RectificationService;
|
|
|
import com.sapit.common.constant.ReturnCode;
|
|
|
import com.sapit.common.entity.inspect.BuRectification;
|
|
|
-import com.sapit.common.framwork.AuthToken;
|
|
|
import com.sapit.common.framwork.ResultBean;
|
|
|
+import com.sapit.common.util.ApiUtil;
|
|
|
import com.sapit.common.util.DateUtil;
|
|
|
import com.sapit.common.util.FileFtpUploadUtil;
|
|
|
+import com.sapit.common.util.SystemParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -17,13 +18,15 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 店铺端整改接口。
|
|
|
*
|
|
|
- * 门店身份由现有销售端 token 体系负责解析,当前接口保留 storeId 参数,
|
|
|
- * 便于兼容项目已有 Controller 的参数绑定方式。
|
|
|
+ * 鉴权与商家端一致:timestamp + sign( = MD5(storeUserId+timestamp+secretKey) ) + storeId 签名校验。
|
|
|
+ * 数据均强制按 storeId 归属校验。
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "rectificationApi", produces = "application/json")
|
|
|
@@ -31,57 +34,126 @@ public class RectificationApiController {
|
|
|
@Autowired
|
|
|
private RectificationService rectificationService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取我的整改列表。
|
|
|
+ * @param storeId 店铺ID
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param sign 签名
|
|
|
+ * @return 整改列表
|
|
|
+ */
|
|
|
@PostMapping("/getMyRectList")
|
|
|
- @AuthToken(type = "sales")
|
|
|
- public ResultBean getMyRectList(Long storeId) {
|
|
|
- if (storeId == null) {
|
|
|
+ public ResultBean getMyRectList(Long storeId, Long storeUserId, String timestamp, String sign) {
|
|
|
+ if (storeId == null || storeUserId == null || timestamp == null || sign == null) {
|
|
|
return paramError();
|
|
|
}
|
|
|
+ if (!signValid(storeUserId, timestamp, sign)) {
|
|
|
+ return signWrong();
|
|
|
+ }
|
|
|
return listResult(rectificationService.getMyRectificationList(storeId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 开始整改。
|
|
|
+ * @param id 整改记录ID
|
|
|
+ * @param storeId 店铺ID
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param sign 签名
|
|
|
+ * @return 整改记录
|
|
|
+ */
|
|
|
@PostMapping("/startRect")
|
|
|
- @AuthToken(type = "sales")
|
|
|
- public ResultBean startRect(Long id, Long storeId) {
|
|
|
- if (id == null || storeId == null) {
|
|
|
+ public ResultBean startRect(Long id, Long storeId, Long storeUserId, String timestamp, String sign) {
|
|
|
+ if (id == null || storeId == null || storeUserId == null || timestamp == null || sign == null) {
|
|
|
return paramError();
|
|
|
}
|
|
|
+ if (!signValid(storeUserId, timestamp, sign)) {
|
|
|
+ return signWrong();
|
|
|
+ }
|
|
|
return updateResult(rectificationService.startRectification(id, storeId), "开始整改完成");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 提交整改反馈。
|
|
|
+ * @param id 整改记录ID
|
|
|
+ * @param storeId
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param sign 签名
|
|
|
+ * @param feedbackContent 反馈内容
|
|
|
+ * @param feedbackPictures 反馈图片URL
|
|
|
+ * @return 整改记录
|
|
|
+ */
|
|
|
@PostMapping("/submitRect")
|
|
|
- @AuthToken(type = "sales")
|
|
|
- public ResultBean submitRect(Long id, Long storeId, String feedbackContent, String feedbackPictures) {
|
|
|
- if (id == null || storeId == null) {
|
|
|
+ public ResultBean submitRect(Long id, Long storeId, Long storeUserId, String timestamp, String sign,
|
|
|
+ String feedbackContent, String feedbackPictures) {
|
|
|
+ if (id == null || storeId == null || storeUserId == null || timestamp == null || sign == null) {
|
|
|
return paramError();
|
|
|
}
|
|
|
+ if (!signValid(storeUserId, timestamp, sign)) {
|
|
|
+ return signWrong();
|
|
|
+ }
|
|
|
BuRectification rectification = rectificationService.getRectificationById(id);
|
|
|
if (rectification == null || !storeId.equals(rectification.getStoreId())) {
|
|
|
return failed("整改记录不存在");
|
|
|
}
|
|
|
+ // 严格按 PRD:仅整改中(2) 可提交反馈 → 待复检(3)
|
|
|
+ if (rectification.getStatus() == null || rectification.getStatus() != 2) {
|
|
|
+ return failed("仅整改中状态可提交反馈");
|
|
|
+ }
|
|
|
return updateResult(rectificationService.submitRectification(id, feedbackContent, feedbackPictures), "提交整改完成");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取整改详情。
|
|
|
+ * @param id 整改记录ID
|
|
|
+ * @param storeId 店铺ID
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param sign 签名
|
|
|
+ * @return 整改详情
|
|
|
+ */
|
|
|
@PostMapping("/getRectDetail")
|
|
|
- @AuthToken(type = "sales")
|
|
|
- public ResultBean getRectDetail(Long id, Long storeId) {
|
|
|
- if (id == null || storeId == null) {
|
|
|
+ public ResultBean getRectDetail(Long id, Long storeId, Long storeUserId, String timestamp, String sign) {
|
|
|
+ if (id == null || storeId == null || storeUserId == null || timestamp == null || sign == null) {
|
|
|
return paramError();
|
|
|
}
|
|
|
- BuRectification rectification = rectificationService.getRectificationById(id);
|
|
|
- if (rectification == null || !storeId.equals(rectification.getStoreId())) {
|
|
|
+ if (!signValid(storeUserId, timestamp, sign)) {
|
|
|
+ return signWrong();
|
|
|
+ }
|
|
|
+ List<BuRectification> rounds = rectificationService.getRectChain(id, storeId);
|
|
|
+ if (rounds == null || rounds.isEmpty()) {
|
|
|
return failed("整改记录不存在");
|
|
|
}
|
|
|
+ Map<String, Object> obj = new LinkedHashMap<>();
|
|
|
+ obj.put("rectId", id);
|
|
|
+ obj.put("rounds", rounds);
|
|
|
ResultBean bean = new ResultBean();
|
|
|
- bean.setObj(rectification);
|
|
|
+ bean.setObj(obj);
|
|
|
bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
|
|
|
return bean;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传整改图片。
|
|
|
+ * @param file 图片文件对象
|
|
|
+ * @param storeId 店铺ID
|
|
|
+ * @param storeUserId 店铺用户ID
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param sign 签名
|
|
|
+ * @param request HTTP请求对象
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@PostMapping("/uploadPicture")
|
|
|
- @AuthToken(type = "sales")
|
|
|
public ResultBean uploadPicture(@RequestParam(value = "file", required = false) MultipartFile file,
|
|
|
+ Long storeId, Long storeUserId, String timestamp, String sign,
|
|
|
HttpServletRequest request) {
|
|
|
+ if (storeId == null || storeUserId == null || timestamp == null || sign == null) {
|
|
|
+ return paramError();
|
|
|
+ }
|
|
|
+ if (!signValid(storeUserId, timestamp, sign)) {
|
|
|
+ return signWrong();
|
|
|
+ }
|
|
|
ResultBean bean = new ResultBean();
|
|
|
if (file == null || file.getOriginalFilename() == null || file.getOriginalFilename().isEmpty()) {
|
|
|
return paramError();
|
|
|
@@ -123,6 +195,10 @@ public class RectificationApiController {
|
|
|
return bean;
|
|
|
}
|
|
|
|
|
|
+ private boolean signValid(Long authKey, String timestamp, String sign) {
|
|
|
+ return ApiUtil.validate(authKey + timestamp + SystemParam.secretKey, sign);
|
|
|
+ }
|
|
|
+
|
|
|
private ResultBean updateResult(int result, String message) {
|
|
|
ResultBean bean = new ResultBean();
|
|
|
bean.getRtnBean().setRtnCode(result > 0 ? ReturnCode.SUCCESS : ReturnCode.FAILED);
|
|
|
@@ -141,6 +217,10 @@ public class RectificationApiController {
|
|
|
return failed("参数错误");
|
|
|
}
|
|
|
|
|
|
+ private ResultBean signWrong() {
|
|
|
+ return failed("签名错误!");
|
|
|
+ }
|
|
|
+
|
|
|
private ResultBean failed(String message) {
|
|
|
ResultBean bean = new ResultBean();
|
|
|
bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
|