فهرست منبع

Merge branch 'feature/0613-opt' into test

# Conflicts:
#	cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/SysUserService.java
#	cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysUserServiceImpl.java
yuanliang 9 ماه پیش
والد
کامیت
0a43219170
23فایلهای تغییر یافته به همراه742 افزوده شده و 45 حذف شده
  1. 8 0
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/AdminFeignService.java
  2. 14 0
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/MallPortalFeignService.java
  3. 224 0
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/dto/OmsOrderDetail.java
  4. 11 0
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/AdminFeignServiceFallback.java
  5. 8 0
      cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/MallPortalFeignServiceFallback.java
  6. 43 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/SysUserController.java
  7. 7 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenTenantController.java
  8. 4 1
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java
  9. 30 1
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java
  10. 14 3
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java
  11. 11 0
      cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/OmsReturnApplyQueryParam.java
  12. 43 1
      cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderReturnApplyServiceImpl.java
  13. 2 0
      cooleshow-mall/mall-admin/src/main/resources/config/mybatis/OmsOrderDao.xml
  14. 5 1
      cooleshow-mall/mall-admin/src/main/resources/config/mybatis/OmsOrderReturnApplyDao.xml
  15. 11 0
      cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/OmsPortalOrderController.java
  16. 2 0
      cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/OmsPortalOrderService.java
  17. 34 0
      cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java
  18. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TenantApplyRecord.java
  19. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/SysUserService.java
  20. 206 5
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysUserServiceImpl.java
  21. 10 10
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantApplyRecordServiceImpl.java
  22. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantApplyRecordWrapper.java
  23. 42 23
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantApplyRecordMapper.xml

+ 8 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/AdminFeignService.java

@@ -209,4 +209,12 @@ public interface AdminFeignService {
     HttpResponseResult<Object> workOverdue();
 
 
+    /**
+     * 账号注销校验
+     */
+    @PostMapping("/sysUser/logoffCheck")
+    HttpResponseResult<List<String>> accountLogoffCheck(@RequestParam(value = "phone") String phone);
+
+    @PostMapping("/sysUser/logoffQuitImGroup")
+    HttpResponseResult<Boolean> logoffQuitImGroup(@RequestParam(value = "phone") String phone);
 }

+ 14 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/MallPortalFeignService.java

@@ -1,10 +1,19 @@
 package com.yonge.cooleshow.api.feign;
 
+import com.yonge.cooleshow.api.feign.dto.OmsOrderDetail;
 import com.yonge.cooleshow.api.feign.fallback.MallPortalFeignServiceFallback;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.feign.config.FeignConfiguration;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.List;
 
 @FeignClient(name = "${app-config.open-feign.mall-portal-server.name:mall-portal-server}", url = "${app-config.open-feign.mall-portal-server.url:}",
         configuration = FeignConfiguration.class, fallback = MallPortalFeignServiceFallback.class)
@@ -28,4 +37,9 @@ public interface MallPortalFeignService {
      */
     @GetMapping("/task/shareProfit")
     HttpResponseResult shareProfit();
+
+
+    @GetMapping("/order/queryOrderList")
+    HttpResponseResult<List<OmsOrderDetail>> queryOrderList(@RequestParam("status") String status,
+                                                            @RequestParam("userId") Long userId);
 }

+ 224 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/dto/OmsOrderDetail.java

@@ -0,0 +1,224 @@
+package com.yonge.cooleshow.api.feign.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class OmsOrderDetail {
+
+    private Long id;
+
+    private Long memberId;
+
+    private String couponId;
+
+    @ApiModelProperty("下单平台 STUDENT TEACHER")
+    private String platformType;
+
+    @ApiModelProperty(value = "订单编号")
+    private String orderSn;
+
+    @ApiModelProperty("购物车id(逗号隔开)")
+    private String cartIds;
+
+    @ApiModelProperty(value = "提交时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "用户帐号")
+    private String memberUsername;
+
+    @ApiModelProperty(value = "订单总金额")
+    private BigDecimal totalAmount;
+
+    @ApiModelProperty(value = "应付金额(实际支付金额)")
+    private BigDecimal payAmount;
+
+    @ApiModelProperty(value = "运费金额")
+    private BigDecimal freightAmount;
+
+    @ApiModelProperty(value = "促销优化金额(促销价、满减、阶梯价)")
+    private BigDecimal promotionAmount;
+
+    @ApiModelProperty(value = "积分抵扣金额")
+    private BigDecimal integrationAmount;
+
+    @ApiModelProperty(value = "优惠券抵扣金额")
+    private BigDecimal couponAmount;
+
+    @ApiModelProperty(value = "管理员后台调整订单使用的折扣金额")
+    private BigDecimal discountAmount;
+
+    @ApiModelProperty(value = "支付方式:0->未支付;1->支付宝;2->微信")
+    private Integer payType;
+
+    @ApiModelProperty(value = "订单来源:0->PC订单;1->app订单")
+    private Integer sourceType;
+
+    @ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单 6 ->未拉起支付")
+    private Integer status;
+
+    @ApiModelProperty(value = "订单类型:0->正常订单;1->秒杀订单")
+    private Integer orderType;
+
+    @ApiModelProperty(value = "物流公司(配送方式)")
+    private String deliveryCompany;
+
+    @ApiModelProperty(value = "物流单号")
+    private String deliverySn;
+
+    @ApiModelProperty(value = "自动确认时间(天)")
+    private Integer autoConfirmDay;
+
+    @ApiModelProperty(value = "可以获得的积分")
+    private Integer integration;
+
+    @ApiModelProperty(value = "可以活动的成长值")
+    private Integer growth;
+
+    @ApiModelProperty(value = "活动信息")
+    private String promotionInfo;
+
+    @ApiModelProperty(value = "发票类型:0->不开发票;1->电子发票;2->纸质发票")
+    private Integer billType;
+
+    @ApiModelProperty(value = "发票抬头")
+    private String billHeader;
+
+    @ApiModelProperty(value = "发票内容")
+    private String billContent;
+
+    @ApiModelProperty(value = "收票人电话")
+    private String billReceiverPhone;
+
+    @ApiModelProperty(value = "收票人邮箱")
+    private String billReceiverEmail;
+
+    @ApiModelProperty(value = "收货人姓名")
+    private String receiverName;
+
+    @ApiModelProperty(value = "收货人电话")
+    private String receiverPhone;
+
+    @ApiModelProperty(value = "收货人邮编")
+    private String receiverPostCode;
+
+    @ApiModelProperty(value = "省份/直辖市")
+    private String receiverProvince;
+
+    @ApiModelProperty(value = "城市")
+    private String receiverCity;
+
+    @ApiModelProperty(value = "区")
+    private String receiverRegion;
+
+    @ApiModelProperty(value = "详细地址")
+    private String receiverDetailAddress;
+
+    @ApiModelProperty(value = "订单备注")
+    private String note;
+
+    @ApiModelProperty(value = "确认收货状态:0->未确认;1->已确认")
+    private Integer confirmStatus;
+
+    @ApiModelProperty(value = "删除状态:0->未删除;1->已删除")
+    private Integer deleteStatus;
+
+    @ApiModelProperty(value = "下单时使用的积分")
+    private Integer useIntegration;
+
+    @ApiModelProperty(value = "支付时间")
+    private Date paymentTime;
+
+    @ApiModelProperty(value = "发货时间")
+    private Date deliveryTime;
+
+    @ApiModelProperty(value = "确认收货时间")
+    private Date receiveTime;
+
+    @ApiModelProperty(value = "评价时间")
+    private Date commentTime;
+
+    @ApiModelProperty("是否能申请售后 0:是 1:否")
+    private int afterSale;
+
+    @ApiModelProperty(value = "修改时间")
+    private Date modifyTime;
+
+    @ApiModelProperty("订单商品列表")
+    private List<OmsOrderItem> orderItemList;
+
+    @Data
+    public static class OmsOrderItem implements Serializable {
+        private Long id;
+
+        @ApiModelProperty(value = "订单id")
+        private Long orderId;
+
+        @ApiModelProperty(value = "订单编号")
+        private String orderSn;
+
+        private Long productId;
+
+        private String productPic;
+
+        private String productName;
+
+        private String productBrand;
+
+        private String productSn;
+
+        @ApiModelProperty("推广人id")
+        private Long promoterId;
+
+        @ApiModelProperty("分享比例(%)")
+        private String shareProportion;
+
+        @ApiModelProperty(value = "销售价格")
+        private BigDecimal productPrice;
+
+        @ApiModelProperty(value = "购买数量")
+        private Integer productQuantity;
+
+        @ApiModelProperty(value = "商品sku编号")
+        private Long productSkuId;
+
+        @ApiModelProperty(value = "商品sku条码")
+        private String productSkuCode;
+
+        @ApiModelProperty(value = "商品分类id")
+        private Long productCategoryId;
+
+        @ApiModelProperty(value = "商品促销名称")
+        private String promotionName;
+
+        @ApiModelProperty(value = "商品促销分解金额")
+        private BigDecimal promotionAmount;
+
+        @ApiModelProperty(value = "优惠券优惠分解金额")
+        private BigDecimal couponAmount;
+
+        @ApiModelProperty(value = "积分优惠分解金额")
+        private BigDecimal integrationAmount;
+
+        @ApiModelProperty(value = "该商品经过优惠后的分解金额")
+        private BigDecimal realAmount;
+
+        private Integer giftIntegration;
+
+        private Integer giftGrowth;
+
+        @ApiModelProperty(value = "商品销售属性:[{'key':'颜色','value':'颜色'},{'key':'容量','value':'4G'}]")
+        private String productAttr;
+
+        @ApiModelProperty("退货状态:-1 ->未退款;0->待处理;1->退货中;2->已完成;3->已拒绝")
+        private Integer returnStatus;
+
+        private BigDecimal precisionAmount;
+
+    }
+}

+ 11 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/AdminFeignServiceFallback.java

@@ -204,4 +204,15 @@ public class AdminFeignServiceFallback implements AdminFeignService {
     public ImUserInfo register(String userId, String clientType, String username, String avatar) {
         return null;
     }
+
+
+    @Override
+    public HttpResponseResult<List<String>> accountLogoffCheck(String phone) {
+        return null;
+    }
+
+    @Override
+    public HttpResponseResult<Boolean> logoffQuitImGroup(String phone) {
+        return null;
+    }
 }

+ 8 - 0
cooleshow-api/src/main/java/com/yonge/cooleshow/api/feign/fallback/MallPortalFeignServiceFallback.java

@@ -2,8 +2,11 @@ package com.yonge.cooleshow.api.feign.fallback;
 
 
 import com.yonge.cooleshow.api.feign.MallPortalFeignService;
+import com.yonge.cooleshow.api.feign.dto.OmsOrderDetail;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 
+import java.util.List;
+
 /**
  * Description
  *
@@ -25,4 +28,9 @@ public class MallPortalFeignServiceFallback implements MallPortalFeignService {
     public HttpResponseResult shareProfit() {
         return null;
     }
+
+    @Override
+    public HttpResponseResult<List<OmsOrderDetail>> queryOrderList(String status, Long userId) {
+        return null;
+    }
 }

+ 43 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/SysUserController.java

@@ -0,0 +1,43 @@
+package com.yonge.cooleshow.admin.controller;
+
+import com.yonge.cooleshow.biz.dal.service.SysUserService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("${app-config.url.admin:}/sysUser")
+@Api(value = "用户表", tags = "用户表")
+public class SysUserController extends BaseController {
+
+    @Autowired
+    private SysUserService sysUserService;
+
+
+    /**
+     * 账号注销校验
+     */
+    @PostMapping("/logoffCheck")
+    HttpResponseResult<List<String>> accountLogoffCheck(@RequestParam("phone") String phone) {
+        List<String> strings = sysUserService.accountLogoffCheck(phone);
+        if (!CollectionUtils.isEmpty(strings)) {
+            return HttpResponseResult.succeed(strings);
+        }
+        return HttpResponseResult.succeed();
+    }
+
+    @PostMapping("/logoffQuitImGroup")
+    HttpResponseResult<Boolean> logoffQuitImGroup(@RequestParam("phone") String phone){
+        sysUserService.logoffQuitImGroup(phone);
+        return HttpResponseResult.succeed(true);
+    }
+
+}

+ 7 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenTenantController.java

@@ -123,6 +123,13 @@ public class OpenTenantController {
             if (AuthStatusEnum.DOING.equals(one.getStatus())) {
                 throw new BizException(5003, "请等待审核完成");
             }
+            // 处理注销账号登录报错
+            if (AuthStatusEnum.PASS.equals(one.getStatus())) {
+                SysUser sysUser = sysUserService.getByUserId(one.getUserId());
+                if (sysUser != null && Boolean.TRUE.equals(sysUser.getDelFlag())) {
+                    throw new BizException(5002, "请先申请机构入驻");
+                }
+            }
         } else {
             Long tenantId = tenantStaff.getTenantId();
             TenantInfo tenantInfo = tenantInfoService.getById(tenantId);

+ 4 - 1
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java

@@ -7,6 +7,7 @@ import com.yonge.cooleshow.auth.api.dto.UserSetReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.cooleshow.auth.enums.EClientType;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.entity.ImUserModel;
 import com.yonge.toolset.mybatis.service.BaseService;
 
@@ -221,7 +222,9 @@ public interface SysUserService extends BaseService<Long, SysUser> {
      */
     SysUser getSysUserByOpenId(String openId, String clientId);
 
-    void logoffByPhone(String phone);
+    HttpResponseResult<Void> logoffByPhone(String phone);
+
+    HttpResponseResult<List<String>> logoffCheckByPhone(String phone);
 
 
     void updateStudentHideFlag(Long userId, int hideFlag);

+ 30 - 1
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.auth.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Lists;
+import com.sun.xml.internal.bind.v2.TODO;
 import com.yonge.cooleshow.api.feign.AdminFeignService;
 import com.yonge.cooleshow.api.feign.dto.UserFriendInfoVO;
 import com.yonge.cooleshow.auth.api.dto.QRLoginDto;
@@ -432,7 +433,18 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void logoffByPhone(String phone) {
+    public HttpResponseResult<Void> logoffByPhone(String phone) {
+
+        // todo: 暂时不上
+//        try {
+//            HttpResponseResult<List<String>> check = adminFeignService.accountLogoffCheck(phone);
+//            List<String> errMsg = check.getData();
+//            if (!CollectionUtils.isEmpty(errMsg)) {
+//                return HttpResponseResult.failed(5101, null, String.join(",", errMsg));
+//            }
+//        } catch (Exception e) {
+//            throw new BizException("数据检查失败");
+//        }
         int num = sysUserDao.countByPhone(phone);
         //冻结相关所有客户端账号
         sysUserDao.updateLockStatusByPhone(phone);
@@ -441,8 +453,25 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
         if(i < 1){
             throw new BizException("用户不存在或已注销");
         }
+        // 解散群、退群、删除好友关系
+//        adminFeignService.logoffQuitImGroup(phone);
+
         //退出登录
         tokenService.revokeTokenByPhone(phone);
+        return HttpResponseResult.succeed();
+    }
+
+    @Override
+    public HttpResponseResult<List<String>> logoffCheckByPhone(String phone) {
+        HttpResponseResult<List<String>> check = adminFeignService.accountLogoffCheck(phone);
+        if (check == null) {
+            throw new BizException("数据检查失败");
+        }
+        List<String> errMsg = check.getData();
+        if (!CollectionUtils.isEmpty(errMsg)) {
+            return HttpResponseResult.failed(500, errMsg, "存在未处理事项");
+        }
+        return HttpResponseResult.succeed();
     }
 
     @Override

+ 14 - 3
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.auth.web.controller;
 
+import com.yonge.cooleshow.api.feign.StudentFeignService;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.dto.SysUserQueryInfo;
 import com.yonge.cooleshow.auth.api.dto.UpdatePasswordDto;
@@ -439,7 +440,7 @@ public class UserController extends BaseController {
             @ApiImplicitParam(name = "smsCode", value = "短信验证码", paramType = "path", dataType = "long", required = true),
     })
     @GetMapping(value = "/logoff/{smsCode}")
-    public HttpResponseResult<Boolean> logoff(@PathVariable("smsCode") String smsCode) {
+    public HttpResponseResult<Void> logoff(@PathVariable("smsCode") String smsCode) {
         AuthUser authUser = SecurityUtils.getUser();
         SysUser sysUser = sysUserService.get(authUser.getUserId());
         if (sysUser == null) {
@@ -450,9 +451,19 @@ public class UserController extends BaseController {
         if (!b) {
             throw new BadCredentialsException("验证码校验失败");
         }
-        sysUserService.logoffByPhone(sysUser.getPhone());
+        return sysUserService.logoffByPhone(sysUser.getPhone());
 //        sysUserService.logoffById(sysUser.getId());
-        return succeed(true);
+    }
+
+    @ApiOperation(value = "用户注销账号校验")
+    @GetMapping(value = "/logoffCheck")
+    public HttpResponseResult<List<String>> logoffCheck() {
+        AuthUser authUser = SecurityUtils.getUser();
+        SysUser sysUser = sysUserService.get(authUser.getUserId());
+        if (sysUser == null) {
+            return failed("用户不存在");
+        }
+        return sysUserService.logoffCheckByPhone(sysUser.getPhone());
     }
 
     @ApiOperation(value = "刷新token")

+ 11 - 0
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/OmsReturnApplyQueryParam.java

@@ -22,6 +22,9 @@ public class OmsReturnApplyQueryParam {
     @ApiModelProperty(value = "处理时间")
     private String handleTime;
 
+    @ApiModelProperty(value = "订单编号")
+    private String orderSn;
+
     public Long getId() {
         return id;
     }
@@ -69,4 +72,12 @@ public class OmsReturnApplyQueryParam {
     public void setHandleTime(String handleTime) {
         this.handleTime = handleTime;
     }
+
+    public String getOrderSn() {
+        return orderSn;
+    }
+
+    public void setOrderSn(String orderSn) {
+        this.orderSn = orderSn;
+    }
 }

+ 43 - 1
cooleshow-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderReturnApplyServiceImpl.java

@@ -12,6 +12,7 @@ import com.yonge.cooleshow.common.service.IdGeneratorService;
 import com.yonge.cooleshow.mall.common.exception.ApiException;
 import com.yonge.cooleshow.mall.common.service.RedisService;
 import com.yonge.cooleshow.mbg.mapper.OmsOrderItemMapper;
+import com.yonge.cooleshow.mbg.mapper.OmsOrderMapper;
 import com.yonge.cooleshow.mbg.model.*;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.cooleshow.mbg.mapper.OmsOrderReturnApplyMapper;
@@ -36,6 +37,8 @@ import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 订单退货管理Service实现类
@@ -52,6 +55,9 @@ public class OmsOrderReturnApplyServiceImpl implements OmsOrderReturnApplyServic
     private OmsOrderReturnApplyMapper returnApplyMapper;
 
     @Autowired
+    private OmsOrderMapper orderMapper;
+
+    @Autowired
     private OmsOrderItemMapper orderItemMapper;
 
     @Autowired
@@ -136,7 +142,43 @@ public class OmsOrderReturnApplyServiceImpl implements OmsOrderReturnApplyServic
         } else {
             return 0;
         }
-        return returnApplyMapper.updateByPrimaryKeySelective(returnApply);
+        int update = returnApplyMapper.updateByPrimaryKeySelective(returnApply);
+        // 更新订单状态
+        updateOrderStatus(omsOrderReturnApply.getOrderSn());
+        return update;
+    }
+
+    private void updateOrderStatus(String orderSn) {
+        // 待发货订单,退费成功后,关闭订单
+        OmsOrder byOrderSn = orderMapper.getByOrderSn(orderSn);
+        if (byOrderSn.getStatus() != 1) {
+            return;
+        }
+
+        OmsOrderItemExample itemExample = new OmsOrderItemExample();
+        itemExample.createCriteria().andOrderSnEqualTo(orderSn);
+        List<OmsOrderItem> items = orderItemMapper.selectByExample(itemExample);
+        Map<Long, Integer> itemIdNumMap = items.stream().collect(Collectors.groupingBy(OmsOrderItem::getId, Collectors.summingInt(OmsOrderItem::getProductQuantity)));
+
+
+        OmsOrderReturnApplyExample applyExample = new OmsOrderReturnApplyExample();
+        applyExample.createCriteria().andOrderSnEqualTo(orderSn);
+        List<OmsOrderReturnApply> applyList = returnApplyMapper.selectByExample(applyExample);
+        Map<Long, Integer> returnMap = applyList.stream().collect(Collectors.groupingBy(OmsOrderReturnApply::getOrderItemId, Collectors.summingInt(OmsOrderReturnApply::getProductCount)));
+
+        // 全部退货才更新状态
+        for (Long itemId : itemIdNumMap.keySet()) {
+            if (!itemIdNumMap.get(itemId).equals(returnMap.getOrDefault(itemId, 0))) {
+                return;
+            }
+        }
+
+        List<Integer> statusList = applyList.stream().map(OmsOrderReturnApply::getStatus).distinct().collect(Collectors.toList());
+        // 全部退回完成,更新订单状态为已关闭
+        if (statusList.stream().allMatch(n -> n == 2)) {
+            byOrderSn.setStatus(4);
+            orderMapper.updateByPrimaryKey(byOrderSn);
+        }
     }
 
 

+ 2 - 0
cooleshow-mall/mall-admin/src/main/resources/config/mybatis/OmsOrderDao.xml

@@ -88,6 +88,7 @@
             oi.product_price item_product_price,
             oi.product_quantity item_product_quantity,
             oi.product_attr item_product_attr,
+            if(oora.status = 2, 1, 0) as item_returnStatus,
             oh.id history_id,
             oh.operate_man history_operate_man,
             oh.create_time history_create_time,
@@ -97,6 +98,7 @@
             oms_order o
             LEFT JOIN oms_order_item oi ON o.id = oi.order_id
             LEFT JOIN oms_order_operate_history oh ON o.id = oh.order_id
+            left join oms_order_return_apply oora on oi.id = oora.order_item_id
         WHERE
             o.id = #{id}
         ORDER BY oi.id ASC,oh.create_time DESC

+ 5 - 1
cooleshow-mall/mall-admin/src/main/resources/config/mybatis/OmsOrderReturnApplyDao.xml

@@ -13,7 +13,8 @@
         product_count,
         return_name,
         status,
-        handle_time
+        handle_time,
+        order_sn
         FROM
         oms_order_return_apply
         WHERE
@@ -40,6 +41,9 @@
             AND (return_name LIKE concat("%",#{queryParam.receiverKeyword},"%")
             OR return_phone LIKE concat("%",#{queryParam.receiverKeyword},"%"))
         </if>
+        <if test="queryParam.orderSn != null">
+            and order_sn like concat('%',#{queryParam.orderSn},'%')
+        </if>
         order by id desc
     </select>
     <select id="getDetail" resultMap="returnApplyDetailResultMap">

+ 11 - 0
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/OmsPortalOrderController.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.portal.controller;
 
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.mall.common.api.CommonPage;
 import com.yonge.cooleshow.mall.common.api.CommonResult;
 import com.yonge.cooleshow.mall.common.enums.OrderCacheEnum;
@@ -115,6 +116,16 @@ public class OmsPortalOrderController {
         return CommonResult.success(orderPage);
     }
 
+    /**
+     * feign 接口
+     */
+    @RequestMapping(value = "/queryOrderList", method = RequestMethod.GET)
+    @ResponseBody
+    public HttpResponseResult<List<OmsOrderDetail>> queryOrderList(@RequestParam("status") String status,
+                                                            @RequestParam("userId") Long userId) {
+        return HttpResponseResult.succeed(portalOrderService.queryOrderList(userId, status));
+    }
+
     @ApiOperation("根据ID获取订单详情")
     @RequestMapping(value = "/detail/{orderId}", method = RequestMethod.GET)
     @ResponseBody

+ 2 - 0
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/OmsPortalOrderService.java

@@ -161,4 +161,6 @@ public interface OmsPortalOrderService {
      * @return
      */
     Boolean lockSku(Long skuId, String platform, Boolean lockState);
+
+    List<OmsOrderDetail> queryOrderList(Long userId, String status);
 }

+ 34 - 0
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -88,6 +88,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -664,6 +665,39 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
     }
 
     @Override
+    public List<OmsOrderDetail> queryOrderList(Long userId, String status) {
+        OmsOrderExample orderExample = new OmsOrderExample();
+        OmsOrderExample.Criteria criteria = orderExample.createCriteria();
+        criteria.andMemberIdEqualTo(userId);
+        if (!StringUtils.isEmpty(status)) {
+            List<Integer> statusList = Arrays.stream(status.split(",")).map(Integer::valueOf).collect(Collectors.toList());
+            criteria.andStatusIn(statusList);
+        }
+        List<OmsOrder> omsOrders = orderMapper.selectByExample(orderExample);
+        if (omsOrders.isEmpty()) {
+            return new ArrayList<>();
+        }
+
+        //设置数据信息
+        List<Long> orderIds = omsOrders.stream().map(OmsOrder::getId).collect(Collectors.toList());
+        OmsOrderItemExample orderItemExample = new OmsOrderItemExample();
+        orderItemExample.createCriteria().andOrderIdIn(orderIds);
+        List<OmsOrderItem> orderItemList = orderItemMapper.selectByExample(orderItemExample);
+        List<OmsOrderDetail> orderDetailList = new ArrayList<>();
+        for (OmsOrder omsOrder : omsOrders) {
+            OmsOrderDetail orderDetail = new OmsOrderDetail();
+            BeanUtil.copyProperties(omsOrder, orderDetail);
+            List<OmsOrderItem> relatedItemList = orderItemList.stream()
+                    .filter(item -> item.getOrderId()
+                            .equals(orderDetail.getId()))
+                    .collect(Collectors.toList());
+            orderDetail.setOrderItemList(relatedItemList);
+            orderDetailList.add(orderDetail);
+        }
+        return orderDetailList;
+    }
+
+    @Override
     public OmsOrderDetail detail(Long orderId) {
         OmsOrder omsOrder = orderMapper.selectByPrimaryKey(orderId);
         OmsOrderItemExample example = new OmsOrderItemExample();

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TenantApplyRecord.java

@@ -60,6 +60,10 @@ public class TenantApplyRecord implements Serializable {
 	@TableField(value = "phone_")
     private String phone;
 
+    @ApiModelProperty("用户ID")
+    @TableField(value = "user_id_")
+    private Long userId;
+
     @ApiModelProperty("审核状态 DOING、审核中 PASS、通过 UNPASS、不通过") 
 	@TableField(value = "status_")
     private AuthStatusEnum status;

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/SysUserService.java

@@ -44,4 +44,7 @@ public interface SysUserService{
      */
     void imDeviceId(UserInfoWrapper.UpdateUser info);
 
+    List<String> accountLogoffCheck(String phone);
+
+    void logoffQuitImGroup(String phone);
 }

+ 206 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysUserServiceImpl.java

@@ -6,18 +6,28 @@ import com.dayaedu.cbs.openfeign.client.MessageFeignClientService;
 import com.dayaedu.cbs.openfeign.wrapper.message.CbsMessageWrapper;
 import com.google.common.collect.Lists;
 import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.api.feign.MallPortalFeignService;
+import com.yonge.cooleshow.api.feign.dto.OmsOrderDetail;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
+import com.yonge.cooleshow.biz.dal.entity.ImGroup;
+import com.yonge.cooleshow.biz.dal.entity.ImGroupMember;
+import com.yonge.cooleshow.biz.dal.entity.ImUserFriend;
 import com.yonge.cooleshow.biz.dal.entity.Student;
-import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
+import com.yonge.cooleshow.biz.dal.entity.UserOrder;
+import com.yonge.cooleshow.biz.dal.entity.UserOrderRefund;
+import com.yonge.cooleshow.biz.dal.entity.VideoLessonGroup;
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
+import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
+import com.yonge.cooleshow.biz.dal.enums.im.EImGroupMemberRoleType;
 import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
-import com.yonge.cooleshow.biz.dal.service.StudentService;
-import com.yonge.cooleshow.biz.dal.service.SysUserContractRecordService;
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
-import com.yonge.cooleshow.biz.dal.service.TeacherService;
+import com.yonge.cooleshow.biz.dal.service.*;
+import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
 import com.yonge.cooleshow.biz.dal.wrapper.UserInfoWrapper;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.enums.ContractTemplateTypeEnum;
@@ -27,16 +37,24 @@ import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import com.yonge.toolset.utils.idcard.IdcardValidator;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
+@Slf4j
 @Service
 public class SysUserServiceImpl implements SysUserService {
 
@@ -56,6 +74,34 @@ public class SysUserServiceImpl implements SysUserService {
     private MessageSenderPluginContext messageSenderPluginContext;
     @Resource
     private MessageFeignClientService messageFeignClientService;
+
+    @Autowired
+    private UserOrderService userOrderService;
+
+    @Autowired
+    private UserOrderRefundService userOrderRefundService;
+
+    @Autowired
+    private ImGroupMemberService imGroupMemberService;
+
+    @Autowired
+    private ImGroupService imGroupService;
+
+    @Autowired
+    private CourseGroupService courseGroupService;
+
+    @Autowired
+    private VideoLessonGroupService videoLessonGroupService;
+
+    @Autowired
+    private UserAccountService userAccountService;
+
+    @Autowired
+    private MallPortalFeignService mallPortalFeignService;
+
+    @Autowired
+    private ImUserFriendService imUserFriendService;
+
     @Override
     public SysUserMapper getDao() {
         return sysUserMapper;
@@ -201,4 +247,159 @@ public class SysUserServiceImpl implements SysUserService {
             return EClientType.BACKEND;
         }
     }
+
+    @Override
+    public List<String> accountLogoffCheck(String phone) {
+        SysUser sysUser = this.getDao().findUserByPhone(phone);
+        if (sysUser == null || Boolean.TRUE.equals(sysUser.getDelFlag())) {
+            throw new BizException("账号不存在");
+        }
+        List<String> errMsg = new ArrayList<>();
+        Long userId = sysUser.getId();
+
+        // 存在待支付、未确认收货、售后处理的订单
+        if(hasUnfinishedOrder(userId)){
+            errMsg.add("账户存在未支付、未确认收货、售后处理中的订单");
+        }
+
+        // 存在进行中的课程
+        // 陪练课
+        Integer course = courseGroupService.lambdaQuery()
+                .eq(CourseGroup::getTeacherId, userId)
+                .in(CourseGroup::getType, Arrays.asList("PRACTICE", "LIVE", "PIANO_ROOM_CLASS"))
+                .in(CourseGroup::getStatus, Arrays.asList("ING", "APPLY"))
+                .count();
+        // 视频课
+        Integer videoCourse = videoLessonGroupService.lambdaQuery()
+                .eq(VideoLessonGroup::getTeacherId, userId)
+                .eq(VideoLessonGroup::getShelvesFlag, 1)
+                .count();
+
+        if (course > 0 || videoCourse > 0) {
+            errMsg.add("存在进行中的课程");
+        }
+
+        Teacher teacher = teacherService.getById(userId);
+
+        if (teacher != null) {
+            // 存在群主身份
+            List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
+                    .eq(ImGroupMember::getUserId, userId)
+                    .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Owner)
+                    .list();
+            List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
+            if (!groupIdList.isEmpty()) {
+                Collection<ImGroup> imGroups = imGroupService.listByIds(groupIdList);
+                long orgGroups = imGroups.stream().filter(next -> ImGroupType.ORG.equals(next.getType())).count();
+                if (orgGroups > 0) {
+                    errMsg.add("账户为机构群群主、需要庄毅群主或解散群聊");
+                }
+            }
+
+            // 存在未提现的金额
+            UserAccountVo detail = userAccountService.detail(userId);
+            if (detail != null && (detail.getAmountTotal().compareTo(BigDecimal.ZERO) > 0 || detail.getAmountUnrecorded().compareTo(BigDecimal.ZERO) > 0)) {
+                errMsg.add("收入未结算/推广计划未入账");
+            }
+        }
+        return errMsg;
+    }
+
+    private boolean hasUnfinishedOrder(Long userId) {
+        // 商城订单 0->待付款;1->待发货;2->已发货
+        HttpResponseResult<List<OmsOrderDetail>> httpResponseResult = mallPortalFeignService.queryOrderList("0,1,2", userId);
+        if (httpResponseResult == null) {
+            throw new BizException("检查订单信息失败");
+        }
+        List<OmsOrderDetail> data = httpResponseResult.getData();
+        if (!CollectionUtils.isEmpty(data)) {
+            return true;
+        }
+
+        // 酷乐秀订单
+        Integer count = userOrderService.lambdaQuery()
+                .eq(UserOrder::getUserId, userId)
+                .in(UserOrder::getStatus, Arrays.asList(OrderStatusEnum.WAIT_PAY, OrderStatusEnum.PAYING))
+                .count();
+        if (count > 0) {
+            return true;
+        }
+        Integer refundCount = userOrderRefundService.lambdaQuery()
+                .eq(UserOrderRefund::getUserId, userId)
+                .eq(UserOrderRefund::getStatus, AuthStatusEnum.DOING)
+                .count();
+        return refundCount > 0;
+    }
+
+    /**
+     * 账号注销,群聊处理
+     * 学生:退群,删除好友关系
+     * 老师:非机构群 群主,注销群,删除好友
+     */
+    @Override
+    public void logoffQuitImGroup(String phone) {
+        SysUser sysUser = this.getDao().findUserByPhone(phone);
+        if (sysUser == null) {
+            return;
+        }
+        Long userId = sysUser.getId();
+        Student student = studentService.getById(userId);
+        if (student != null) {
+            List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
+                    .eq(ImGroupMember::getUserId, sysUser.getId())
+                    .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Member)
+                    .list();
+            List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
+            // 退群
+            for (String groupId : groupIdList) {
+                try {
+                    imGroupService.quit(groupId, userId, ClientEnum.STUDENT, true);
+                } catch (Exception e) {
+                    log.error("学生注销退群失败->学生:" + userId + "," + e.getMessage());
+                }
+            }
+            // 删除好友
+            imUserFriendService.lambdaUpdate()
+                    .eq(ImUserFriend::getUserId, userId)
+                    .eq(ImUserFriend::getClientType, EClientType.STUDENT)
+                    .remove();
+            imUserFriendService.lambdaUpdate()
+                    .eq(ImUserFriend::getFriendId, userId)
+                    .eq(ImUserFriend::getFriendType, EClientType.STUDENT)
+                    .remove();
+        }
+
+
+        Teacher teacher = teacherService.getById(sysUser.getId());
+        if (teacher != null) {
+            List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
+                    .eq(ImGroupMember::getUserId, sysUser.getId())
+                    .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Owner)
+                    .list();
+            List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
+            if (groupIdList.isEmpty()) {
+                return;
+            }
+            Collection<ImGroup> imGroups = imGroupService.listByIds(groupIdList);
+            List<String> groupIds = imGroups.stream().filter(next -> ImGroupType.FAN.equals(next.getType()) || ImGroupType.COURSE.equals(next.getType()))
+                    .map(ImGroup::getId).collect(Collectors.toList());
+
+            for (String groupId : groupIds) {
+                try {
+                    imGroupService.dismiss(groupId);
+                } catch (Exception e) {
+                    log.error("群解散失败:" + groupId);
+                }
+            }
+            // 删除好友
+            imUserFriendService.lambdaUpdate()
+                    .eq(ImUserFriend::getUserId, userId)
+                    .eq(ImUserFriend::getClientType, EClientType.TEACHER)
+                    .remove();
+            imUserFriendService.lambdaUpdate()
+                    .eq(ImUserFriend::getFriendId, userId)
+                    .eq(ImUserFriend::getFriendType, EClientType.TEACHER)
+                    .remove();
+        }
+    }
 }

+ 10 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantApplyRecordServiceImpl.java

@@ -296,10 +296,11 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
         tenantApplyRecord.setVerifyUserId(verifyUserId);
         tenantApplyRecord.setReason(entry.getReason());
         tenantApplyRecord.setBriefIntroduction(applyRecord.getBriefIntroduction());
+
+        applyRecord.setStatus(Boolean.TRUE.equals(ifPass) ? AuthStatusEnum.PASS : AuthStatusEnum.UNPASS);
+        applyRecord.setVerifyUserId(verifyUserId);
+        applyRecord.setReason(entry.getReason());
         if (ifPass == true){
-            tenantApplyRecord.setStatus(AuthStatusEnum.PASS);
-            //更改当前记录的审核状态
-            tenantApplyRecordMapper.updateStatusById(id);
 
             //机构账户新增逻辑
             TenantInfo tenantInfo = new TenantInfo();
@@ -312,16 +313,15 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
             tenantInfo.setPhone(applyRecord.getPhone());
             tenantInfo.setEnableFlag(true);
             tenantInfo.setBriefIntroduction(applyRecord.getBriefIntroduction());
-            tenantInfoService.add(tenantInfo);
-        } else {
-            tenantApplyRecord.setStatus(AuthStatusEnum.UNPASS);
-            tenantApplyRecordMapper.updateUnpassStatusById(id);
+            if (tenantInfoService.add(tenantInfo)) {
+                applyRecord.setUserId(tenantInfo.getUserId());
+            }
         }
+        tenantApplyRecordMapper.updateById(applyRecord);
+
 
-        String name = tenantEntryRecordMapper.selectName(verifyUserId);
-        tenantApplyRecord.setVerifyUserName(name);
 
-        TenantEntryRecord tenantEntryRecord = JSON.parseObject(JSON.toJSONString(tenantApplyRecord), TenantEntryRecord.class);
+        TenantEntryRecord tenantEntryRecord = JSON.parseObject(JSON.toJSONString(applyRecord), TenantEntryRecord.class);
          tenantEntryRecordMapper.insert(tenantEntryRecord);
 
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantApplyRecordWrapper.java

@@ -101,6 +101,12 @@ public class TenantApplyRecordWrapper {
         @NotNull(message = "手机号不能为空")
         private String phone;
 
+        @ApiModelProperty("用户ID")
+        private Long userId;
+
+        @ApiModelProperty("用户删除标记")
+        private Boolean userDelFlag;
+
         @ApiModelProperty("省份名称")
         private String provinceName;
 

+ 42 - 23
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantApplyRecordMapper.xml

@@ -15,6 +15,7 @@
         , t.region_code_ AS regionCode
         , t.username_ AS username
         , t.phone_ AS phone
+        , t.user_id_ AS userId
         , t.status_ AS status
         , t.verify_user_id_ AS verifyUserId
         , t.reason_ AS reason
@@ -34,29 +35,47 @@
     </update>
 
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantApplyRecordWrapper$TenantApplyRecord">
-		SELECT         
-        	<include refid="baseColumns" />
-		FROM tenant_apply_record t
-        <where>
-            <if test="param.keyword != null and param.keyword  != ''">
-                and (
-                t.name_ like concat('%',#{param.keyword},'%')
-                or t.username_ like concat('%',#{param.keyword},'%')
-                or t.phone_ like concat('%',#{param.keyword},'%')
-                )
-            </if>
-            <if test="param.provinceCode != null">
-                and t.province_code_ = #{param.provinceCode}
-            </if>
-            <if test="param.cityCode != null">
-                and t.city_code_ = #{param.cityCode}
-            </if>
-            <if test="param.regionCode != null">
-                and t.region_code_ = #{param.regionCode}
-            </if>
-        </where>
-
-	</select>
+        SELECT * from(
+            SELECT
+            t.id_ AS id
+            , t.name_ AS name
+            , t.logo_ AS logo
+            , t.province_code_ AS provinceCode
+            , t.city_code_ AS cityCode
+            , t.region_code_ AS regionCode
+            , t.username_ AS username
+            , t.phone_ AS phone
+            , t.user_id_ AS userId
+            , t.status_ AS status
+            , t.verify_user_id_ AS verifyUserId
+            , t.reason_ AS reason
+            , t.update_time_ AS updateTime
+            , t.create_time_ AS createTime
+            , t.brief_Introduction_ AS briefIntroduction
+            , if(t.status_='PASS',su.del_flag_,0) userDelFlag
+            FROM tenant_apply_record t
+            left join sys_user su on t.user_id_ = su.id_
+            <where>
+                <if test="param.keyword != null and param.keyword  != ''">
+                    and (
+                    t.name_ like concat('%',#{param.keyword},'%')
+                    or t.username_ like concat('%',#{param.keyword},'%')
+                    or t.phone_ like concat('%',#{param.keyword},'%')
+                    )
+                </if>
+                <if test="param.provinceCode != null">
+                    and t.province_code_ = #{param.provinceCode}
+                </if>
+                <if test="param.cityCode != null">
+                    and t.city_code_ = #{param.cityCode}
+                </if>
+                <if test="param.regionCode != null">
+                    and t.region_code_ = #{param.regionCode}
+                </if>
+            </where>
+        ) k
+        where k.userDelFlag = 0
+    </select>
     <select id="selectHistoryPage"
             resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantApplyRecordWrapper$TenantApply">
         select