Browse Source

(主账号)转变成企业用户后之前的订单统计的角标还是会统计。
(子账号)绑定企业用户后,之前自己订单会带入企业订单当中,包括待评价的订单

liangpeile 1 year ago
parent
commit
e1fb66f492

+ 9 - 5
crmeb-admin/src/main/java/com/zbkj/admin/controller/platform/NewPlatformApi.java

@@ -260,13 +260,17 @@ public class NewPlatformApi {
     @RequestMapping(value = "/updataBypassAccount/{id}", method = RequestMethod.POST)
     public CommonResult<String> updataBypassAccount(@PathVariable Integer id) {
         try {
-//            UserBypassAccount userBypassAccount = new UserBypassAccount();
-//            userBypassAccount.setId( id );
-//            userBypassAccount.setIsDelete( 1 );
-//            //需要软删除
-//            userBypassAccountService.updateById( userBypassAccount );
+
             UserBypassAccount byId = userBypassAccountService.getById(id);
             User user = new User();
+            LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            orderLambdaQueryWrapper.eq(Order::getIsDel, 0);
+            orderLambdaQueryWrapper.and(i -> i.eq(Order::getIsRemit, 2).or().isNull(Order::getIsRemit));
+            orderLambdaQueryWrapper.eq(Order::getUid,byId.getUserId());
+            List<Order> list = orderService.list(orderLambdaQueryWrapper);
+            if (null != list && list.size() > 0) {
+                return CommonResult.failed("删除子账号失败,存在未收款订单无法进行解除");
+            }
             user.setId(byId.getUserId());
             user.setIsAllOrders(2);
             user.setIsEnterpriseUser(1);

+ 4 - 0
crmeb-common/src/main/java/com/zbkj/common/model/order/Order.java

@@ -153,4 +153,8 @@ public class Order implements Serializable {
     @ApiModelProperty(value = "是否是企业用户订单 1是普通用户订单,2是企业用户订单")
     private Integer isEnterpriseUser;
 
+    @ApiModelProperty(value = "企业ID")
+    private Integer enterpriseId;
+
+
 }

+ 3 - 0
crmeb-common/src/main/java/com/zbkj/common/response/OrderFrontDataResponse.java

@@ -82,4 +82,7 @@ public class OrderFrontDataResponse implements Serializable {
 
     @ApiModelProperty(value = "采购手机号")
     private String phone;
+
+    @ApiModelProperty(value = "用户id")
+    private Integer userId;
 }

+ 3 - 1
crmeb-front/src/main/java/com/zbkj/front/controller/OrderController.java

@@ -1,5 +1,6 @@
 package com.zbkj.front.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.zbkj.common.model.order.OrderDetail;
 import com.zbkj.common.page.CommonPage;
 import com.zbkj.common.request.*;
@@ -63,7 +64,8 @@ public class OrderController {
     })
     public CommonResult<CommonPage<OrderFrontDataResponse>> orderList(@RequestParam(name = "status") Integer status,
                                                                       @ModelAttribute PageParamRequest pageRequest) {
-        return CommonResult.success(CommonPage.restPage(orderService.list(status, pageRequest)));
+        PageInfo<OrderFrontDataResponse> list = orderService.list(status, pageRequest);
+        return CommonResult.success(CommonPage.restPage(list));
     }
 
     @ApiOperation(value = "订单详情")

+ 12 - 1
crmeb-front/src/main/java/com/zbkj/front/service/impl/FrontOrderServiceImpl.java

@@ -378,12 +378,22 @@ public class FrontOrderServiceImpl implements FrontOrderService {
         if (2==user.getIsEnterpriseUser()){
             order.setIsEnterpriseUser(2);
         }else if(3==user.getIsEnterpriseUser()){
-            order.setIsEnterpriseUser(2);
+            order.setIsEnterpriseUser(3);
         }else{
             order.setIsEnterpriseUser(1);
         }
         order.setType(orderInfoVo.getType());// 默认普通订单
 
+        //企业子账户只能看自己企业的订单
+        if (2==user.getIsEnterpriseUser()||3==user.getIsEnterpriseUser()){
+            LambdaQueryWrapper<UserBypassAccount> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(UserBypassAccount::getUserId,user.getId());
+            queryWrapper.eq(UserBypassAccount::getIsDelete,0);
+            List<UserBypassAccount> list = userBypassAccountService.list();
+            Integer enterpriseId = list.get(0).getEnterpriseId();
+            order.setEnterpriseId(enterpriseId);
+        }
+
         // 商户订单
         List<Integer> couponIdList = CollUtil.newArrayList();
         List<MerchantOrder> merchantOrderList = new ArrayList<>();
@@ -978,6 +988,7 @@ public class FrontOrderServiceImpl implements FrontOrderService {
         List<OrderFrontDataResponse> responseList = CollUtil.newArrayList();
         for (Order order : orderList) {
             OrderFrontDataResponse infoResponse = new OrderFrontDataResponse();
+            infoResponse.setUserId(userId);
             BeanUtils.copyProperties(order, infoResponse);
 
             LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();

+ 1 - 1
crmeb-service/src/main/java/com/zbkj/service/dao/OrderDetailDao.java

@@ -22,7 +22,7 @@ public interface OrderDetailDao extends BaseMapper<OrderDetail> {
      * @param userId 用户id
      * @param isReply 是否评价,0-未评价,1-已评价
      */
-    List<OrderDetail> findReplyList(@Param("userId") Integer userId, @Param("isReply") Integer isReply);
+    List<OrderDetail> findReplyList(@Param("userId") Integer userId, @Param("isReply") Integer isReply,@Param("isEnterpriseUser") Integer isEnterpriseUser);
 
     /**
      * 售后申请列表(可申请售后列表)

+ 12 - 1
crmeb-service/src/main/java/com/zbkj/service/service/impl/OrderDetailServiceImpl.java

@@ -7,11 +7,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.zbkj.common.model.order.Order;
 import com.zbkj.common.model.order.OrderDetail;
+import com.zbkj.common.model.user.User;
 import com.zbkj.common.page.CommonPage;
 import com.zbkj.common.request.PageParamRequest;
 import com.zbkj.service.dao.OrderDetailDao;
 import com.zbkj.service.service.OrderDetailService;
+import com.zbkj.service.service.OrderService;
+import com.zbkj.service.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -27,6 +32,10 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailDao, OrderDet
 
     @Resource
     private OrderDetailDao dao;
+    @Autowired
+    private OrderService orderService;
+    @Autowired
+    private UserService userService;
 
     /**
      * 根据主订单号获取
@@ -49,8 +58,10 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailDao, OrderDet
      */
     @Override
     public PageInfo<OrderDetail> getReplyList(Integer userId, Boolean isReply, PageParamRequest pageRequest) {
+        User user = userService.getInfo();
+        Integer isEnterpriseUser = user.getIsEnterpriseUser();
         Page<OrderDetail> page = PageHelper.startPage(pageRequest.getPage(), pageRequest.getLimit());
-        List<OrderDetail> orderDetailList = dao.findReplyList(userId, isReply ? 1 : 0);
+        List<OrderDetail> orderDetailList = dao.findReplyList(userId, isReply ? 1 : 0,isEnterpriseUser);
         return CommonPage.copyPageInfo(page, orderDetailList);
     }
 

+ 20 - 5
crmeb-service/src/main/java/com/zbkj/service/service/impl/OrderServiceImpl.java

@@ -192,7 +192,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
         lqw.eq(Order::getIsMerchantDel, false);
         lqw.in(Order::getType, OrderConstants.ORDER_TYPE_NORMAL, OrderConstants.ORDER_TYPE_SECKILL);
         lqw.eq(Order::getIsDel, false);
-        lqw.eq(Order::getIsEnterpriseUser, 1);
+        Integer isEnterpriseUser = userInfo.getIsEnterpriseUser();
+        if (null != isEnterpriseUser){
+            lqw.eq(Order::getIsEnterpriseUser, isEnterpriseUser);
+        }else{
+            lqw.eq(Order::getIsEnterpriseUser, 999);
+        }
+
         lqw.orderByDesc(Order::getId);
         List<Order> orderList = dao.selectList(lqw);
         return CommonPage.copyPageInfo(page, orderList);
@@ -206,6 +212,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
         lqw.and(i -> i.ne(Order::getIsIntegral, 1).or().isNull(Order::getIsIntegral));
         lqw.and(i -> i.eq(Order::getQyId, id).or().isNull(Order::getQyId));
         lqw.in(Order::getUid, ids);
+        List<Order> orderList1 = dao.selectList(lqw);
+
 
         if (0 != isRemit) {
             lqw.eq(Order::getIsRemit, isRemit);
@@ -225,6 +233,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
         lqw.lt(Order::getRefundStatus, OrderConstants.ORDER_REFUND_STATUS_REFUND);
         lqw.eq(Order::getIsUserDel, false);
         lqw.eq(Order::getIsMerchantDel, false);
+        List<Order> orderList2 = dao.selectList(lqw);
 
         lqw.in(Order::getType, OrderConstants.ORDER_TYPE_NORMAL, OrderConstants.ORDER_TYPE_SECKILL);
         lqw.eq(Order::getIsDel, false);
@@ -237,7 +246,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String mDateTime = formatter.format(c.getTime());
         lqw.apply(StringUtils.isNotBlank(mDateTime), "DATE(create_time) >= STR_TO_DATE('" + mDateTime + "','%Y-%m-%d')");
-        lqw.eq(Order::getIsEnterpriseUser, 2);
+        List<Order> orderList3 = dao.selectList(lqw);
+        lqw.in(Order::getIsEnterpriseUser, 2,3);
+
+        List<Order> orderList4 = dao.selectList(lqw);
         lqw.orderByDesc(Order::getId);
         List<Order> orderList = dao.selectList(lqw);
         return CommonPage.copyPageInfo(page, orderList);
@@ -948,9 +960,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements Or
         }
         LambdaQueryWrapper<Order> lqw = Wrappers.lambdaQuery();
         lqw.eq(Order::getUid, userId);
-        if (2 == user.getIsEnterpriseUser() || 3 == user.getIsEnterpriseUser()) {
-            lqw.eq(Order::getIsEnterpriseUser, 2);
-        } else {
+        if (2 == user.getIsEnterpriseUser() ) {
+            lqw.in(Order::getIsEnterpriseUser, 2,3);
+        } else if (3 == user.getIsEnterpriseUser()){
+            lqw.eq(Order::getIsEnterpriseUser, 3);
+        }
+        else {
             lqw.eq(Order::getIsEnterpriseUser, 1);
         }
         lqw.eq(Order::getIsDel, false);

+ 1 - 0
crmeb-service/src/main/resources/mapper/order/OrderDetailMapper.xml

@@ -9,6 +9,7 @@
         od.is_receipt = 1
         and od.is_reply = #{isReply}
         and od.uid = #{userId}
+        and o.is_enterprise_user = #{isEnterpriseUser}
         order by od.id desc
     </select>