浏览代码

商城企业绑定接口添加

liusw 7 年之前
父节点
当前提交
962db15bb9

+ 13 - 0
sso-common/src/main/java/com/uas/sso/entity/ApplyUserSpaceView.java

@@ -15,6 +15,11 @@ public class ApplyUserSpaceView implements Serializable {
      */
     private static final long serialVersionUID = 1L;
 
+    /**
+     * id
+     */
+    private Long id;
+
     /**
      * 用户uu号
      */
@@ -50,6 +55,14 @@ public class ApplyUserSpaceView implements Serializable {
      */
     private Date processTime;
 
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
     public ApplyUserSpaceView() {
     }
 

+ 50 - 0
sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

@@ -1241,4 +1241,54 @@ public class AccountUtils {
 		}
 		return null;
 	}
+
+    public static Page<ApplyUserSpaceView> findApplyAllToMall(Long speaceUU, int page, int size, Integer status, String keyword) throws Exception {
+        String url = AccountConfig.getSpaceSaveUrl();
+        if (!StringUtils.isEmpty(url)) {
+            url = url + "/apply/info/mall";
+            String appId = SSOHelper.getSSOService().getConfig().getAppName();
+            ModelMap data = new ModelMap();
+            data.put("speaceUU", speaceUU);
+            data.put("page", page);
+            data.put("size", size);
+            data.put("status", status);
+            data.put("keyword", keyword);
+            HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
+            if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+                if (!result.isSuccess()) {
+                    throw new Exception(result.getErrMsg());
+                } else if (result.getContent() != null) {
+                    return JSON.parseObject(result.getContent().toString(), new TypeReference<Page<ApplyUserSpaceView>>() {});
+                }
+            }
+        }
+        return null;
+    }
+
+    public static String auditApply(Long userUU, Long id, Integer status) throws Exception {
+        String url = AccountConfig.getSpaceSaveUrl();
+        if (!StringUtils.isEmpty(url)) {
+            url = url + "/audit/apply";
+            String appId = SSOHelper.getSSOService().getConfig().getAppName();
+            ModelMap data = new ModelMap();
+            data.put("userUU", userUU);
+            data.put("id", id);
+            data.put("status", status);
+            HttpUtil.ResponseWrap res = HttpUtil.doPost(url, data);
+            if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+                if (!result.isSuccess()) {
+                    throw new Exception(result.getErrMsg());
+                } else if (result.getContent() != null) {
+                    return result.getContent().toString();
+                }
+            }
+        }
+        return null;
+    }
 }

+ 30 - 0
sso-server/src/main/java/com/uas/sso/controller/UserspaceManagerController.java

@@ -15,6 +15,7 @@ import com.uas.sso.core.Status;
 import com.uas.sso.dao.UserspaceDao;
 import com.uas.sso.entity.App;
 import com.uas.sso.entity.User;
+import com.uas.sso.entity.UserAccount;
 import com.uas.sso.entity.Userspace;
 import com.uas.sso.service.AppService;
 import com.uas.sso.service.ApplyUserSpaceService;
@@ -380,4 +381,33 @@ public class UserspaceManagerController extends BaseController {
     public List<Userspace> findAll(String ids) {
         return userspaceService.findAll(ids);
     }
+
+    /**
+     * 商城分页查询申请信息
+     * @param page
+     * @param size
+     * @param speaceUU
+     * @return
+     */
+    @RequestMapping(value = "/apply/info/mall", method = RequestMethod.GET)
+    @ResponseBody
+    public ModelMap findApplyAllToMall(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size, Long speaceUU, Integer status, String keyword) {
+        if (speaceUU == null) {
+            return error(Const.SPACEUU_PERSONAL+"", "个人账号");
+        }
+        // 查询页面是从0开始,所以要减1
+        return success(applyUserSpaceService.findApplyAllToMall(page, size, speaceUU, status, keyword));
+    }
+
+    /**
+     * 审核申请
+     * @param userUU 用户uu号
+     * @return
+     */
+    @RequestMapping(value = "/audit/apply", method = RequestMethod.POST)
+    @ResponseBody
+    public ModelMap auditApply(Long userUU, Long id, Integer status) {
+        applyUserSpaceService.auditApply(userUU, id, status);
+        return success();
+    }
 }

+ 19 - 0
sso-server/src/main/java/com/uas/sso/service/ApplyUserSpaceService.java

@@ -60,4 +60,23 @@ public interface ApplyUserSpaceService {
     void disagreeApply(Long userUU, Long id);
 
     Page<ApplyUserSpace> findApplyByUserUU(Long userUU, int page, int size);
+
+    /**
+     * 审核申请
+     * @param userUU
+     * @param id
+     * @param status
+     */
+    void auditApply(Long userUU, Long id, Integer status);
+
+    /**
+     * 查询企业申请绑定列表
+     * @param pageNumber
+     * @param pageSize
+     * @param spaceUU
+     * @param status
+     * @param keyword
+     * @return
+     */
+    Page<ApplyUserSpace> findApplyAllToMall(Integer pageNumber, Integer pageSize, Long spaceUU, Integer status, String keyword);
 }

+ 52 - 0
sso-server/src/main/java/com/uas/sso/service/impl/ApplyUserSpaceServiceImpl.java

@@ -2,6 +2,7 @@ package com.uas.sso.service.impl;
 
 import com.uas.sso.AccountConfig;
 import com.uas.sso.support.SystemSession;
+import com.uas.sso.util.StringUtil;
 import org.springframework.data.domain.Page;
 import com.uas.sso.core.Status;
 import com.uas.sso.dao.ApplyUserSpaceDao;
@@ -18,6 +19,7 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
 import javax.persistence.criteria.*;
 import java.sql.Timestamp;
@@ -88,6 +90,7 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
                                          CriteriaQuery<?> query, CriteriaBuilder cb) {
                 List<Predicate> list = new ArrayList<>();
                 list.add(cb.equal(root.get("spaceUU").as(Long.class), spaceUU));
+
                 Predicate[] predicates = new Predicate[list.size()];
                 predicates = list.toArray(predicates);
                 return cb.and(predicates);
@@ -185,4 +188,53 @@ public class ApplyUserSpaceServiceImpl implements ApplyUserSpaceService {
         }, pageable);
         return new PageInfo<>(pApply.getContent(), pageable, pApply.getTotalElements());
     }
+
+    @Override
+    public void auditApply(Long userUU, Long id, Integer status) {
+        // 找到申请信息
+        ApplyUserSpace applyUserSpace = applyUserSpaceDao.findOne(id);
+        if (!userUU.equals(applyUserSpace.getUserUU())) {
+            // 简单的校验下参数
+            throw new VisibleError("参数错误");
+        }
+
+        // 修改状态
+        applyUserSpace.setStatus(status);
+        applyUserSpace.setProcessTime(new Timestamp(System.currentTimeMillis()));
+        applyUserSpace = applyUserSpaceDao.save(applyUserSpace);
+
+        if (status == Status.AGREE.getCode()) {
+            // 将用户添加到企业
+            userService.bindUserspace(AccountConfig.ACCOUNT_CENTER, userUU, applyUserSpace.getSpaceUU());
+        }
+    }
+
+    @Override
+    public Page<ApplyUserSpace> findApplyAllToMall(Integer pageNumber, Integer pageSize, Long spaceUU, Integer status, String keyword) {
+        Pageable pageable = PageInfo.pageRequest(new PageRequest(pageNumber, pageSize));
+        Page<ApplyUserSpace> page = applyUserSpaceDao.findAll(new Specification<ApplyUserSpace>() {
+            @Override
+            public Predicate toPredicate(Root<ApplyUserSpace> root,
+                                         CriteriaQuery<?> query, CriteriaBuilder cb) {
+                List<Predicate> list = new ArrayList<>();
+                list.add(cb.equal(root.get("spaceUU").as(Long.class), spaceUU));
+                if (StringUtils.isEmpty(status)) {
+                    list.add(cb.equal(root.get("status").as(Integer.class), Status.UNAUDIT.getCode()));
+                } else {
+                    list.add(cb.equal(root.get("status").as(Integer.class), status));
+                }
+                if (!StringUtils.isEmpty(keyword)) {
+                    Predicate predicate1 = cb.like(root.join("user", JoinType.INNER).get("vipName").as(String.class), "%" + keyword + "%");
+                    Predicate predicate2 = cb.like(root.join("user", JoinType.INNER).get("userUU").as(String.class), "%" + keyword + "%");
+                    Predicate predicate3 = cb.like(root.join("user", JoinType.INNER).get("mobile").as(String.class), "%" + keyword + "%");
+                    list.add(cb.or(predicate1, predicate2, predicate3));
+                }
+                Predicate[] predicates = new Predicate[list.size()];
+                predicates = list.toArray(predicates);
+                query.where(cb.and(predicates));
+                return query.getRestriction();
+            }
+        }, pageable);
+        return new PageInfo<>(page.getContent(), pageable, page.getTotalElements());
+    }
 }