liangpeile 1 年之前
父節點
當前提交
7bdf72c6ad
共有 1 個文件被更改,包括 119 次插入106 次删除
  1. 119 106
      crmeb-front/src/main/java/com/zbkj/front/controller/NewFrontApi.java

+ 119 - 106
crmeb-front/src/main/java/com/zbkj/front/controller/NewFrontApi.java

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageInfo;
 
@@ -113,30 +114,30 @@ public class NewFrontApi {
             JSONObject obj = new JSONObject();
             User info = userService.getInfo();
             LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq( UserEnterprise::getUserId, info.getId() );
-            queryWrapper.eq( UserEnterprise::getIsDelete, 0 );
-            UserEnterprise one = userEnterpriseService.getOne( queryWrapper, false );
+            queryWrapper.eq(UserEnterprise::getUserId, info.getId());
+            queryWrapper.eq(UserEnterprise::getIsDelete, 0);
+            UserEnterprise one = userEnterpriseService.getOne(queryWrapper, false);
             if (one == null) {
                 LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-                queryWrapper2.eq( UserBypassAccount::getUserId, info.getId() );
-                queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
-                UserBypassAccount one1 = userBypassAccountService.getOne( queryWrapper2, false );
+                queryWrapper2.eq(UserBypassAccount::getUserId, info.getId());
+                queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
+                UserBypassAccount one1 = userBypassAccountService.getOne(queryWrapper2, false);
                 if (one1 == null) {
 //                    obj.put( "UserEnterprise",null);
-                    obj.put( "user", "普通用户" );
-                    return CommonResult.success( obj );
+                    obj.put("user", "普通用户");
+                    return CommonResult.success(obj);
                 } else {
-                    UserEnterprise byId = userEnterpriseService.getById( one1.getEnterpriseId() );
-                    obj.put( "UserEnterprise", byId );
-                    obj.put( "UserBypassAccount", one1 );
-                    obj.put( "user", "企业子用户" );
+                    UserEnterprise byId = userEnterpriseService.getById(one1.getEnterpriseId());
+                    obj.put("UserEnterprise", byId);
+                    obj.put("UserBypassAccount", one1);
+                    obj.put("user", "企业子用户");
 
-                    return CommonResult.success( obj );
+                    return CommonResult.success(obj);
                 }
             } else {
-                obj.put( "UserEnterprise", one );
-                obj.put( "user", "企业用户" );
-                return CommonResult.success( obj );
+                obj.put("UserEnterprise", one);
+                obj.put("user", "企业用户");
+                return CommonResult.success(obj);
             }
         } catch (Exception e) {
             return CommonResult.failed();
@@ -148,11 +149,11 @@ public class NewFrontApi {
     @RequestMapping(value = "/getLineOfCredit/{id}", method = RequestMethod.POST)
     public CommonResult<UserEnterprise> getLineOfCredit(@PathVariable Integer id) {
         try {
-            UserBypassAccount byId1 = userBypassAccountService.getById( id );
+            UserBypassAccount byId1 = userBypassAccountService.getById(id);
 
-            UserEnterprise byId = userEnterpriseService.getById( byId1.getEnterpriseId() );
+            UserEnterprise byId = userEnterpriseService.getById(byId1.getEnterpriseId());
 
-            return CommonResult.success( byId );
+            return CommonResult.success(byId);
         } catch (Exception e) {
             return CommonResult.failed();
         }
@@ -162,8 +163,8 @@ public class NewFrontApi {
     @RequestMapping(value = "/getLineOfCredit2/{id}", method = RequestMethod.POST)
     public CommonResult<UserEnterprise> getLineOfCredit2(@PathVariable Integer id) {
         try {
-            UserEnterprise byId = userEnterpriseService.getById( id );
-            return CommonResult.success( byId );
+            UserEnterprise byId = userEnterpriseService.getById(id);
+            return CommonResult.success(byId);
         } catch (Exception e) {
             return CommonResult.failed();
         }
@@ -174,10 +175,10 @@ public class NewFrontApi {
     public CommonResult<List<UserBypassAccount>> getBypassAccount(@PathVariable Integer id) {
         try {
             LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-            queryWrapper2.eq( UserBypassAccount::getEnterpriseId, id );
-            queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
-            List<UserBypassAccount> list = userBypassAccountService.list( queryWrapper2 );
-            return CommonResult.success( list );
+            queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
+            queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
+            List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper2);
+            return CommonResult.success(list);
         } catch (Exception e) {
             return CommonResult.failed();
         }
@@ -190,18 +191,18 @@ public class NewFrontApi {
 //        User info = userService.getInfo();
         try {
             LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-            queryWrapper2.eq( UserBypassAccount::getEnterpriseId, id );
-            queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
-            List<UserBypassAccount> list = userBypassAccountService.list( queryWrapper2 );
+            queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
+            queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
+            List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper2);
             List<String> pepartments = list.stream()
-                    .map( UserBypassAccount::getDepartment )
-                    .collect( Collectors.toList() );
+                    .map(UserBypassAccount::getDepartment)
+                    .collect(Collectors.toList());
 
             List<String> distinctDepartments = new ArrayList<>(new HashSet<>(pepartments));
-            distinctDepartments.add( "主账号" );
-            return CommonResult.success( distinctDepartments );
+            distinctDepartments.add("主账号");
+            return CommonResult.success(distinctDepartments);
         } catch (Exception e) {
-            return CommonResult.failed( "查看部门失败,接口错误" );
+            return CommonResult.failed("查看部门失败,接口错误");
         }
     }
 
@@ -220,49 +221,49 @@ public class NewFrontApi {
                                                                        @PathVariable String id,
                                                                        @ModelAttribute PageParamRequest pageRequest) {
         LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-        queryWrapper2.eq( UserBypassAccount::getEnterpriseId, id );
+        queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
 
-        if (!department.equals( "" )) {
+        if (!department.equals("")) {
             String[] departments = department.split(",");
-            queryWrapper2.in( UserBypassAccount::getDepartment, departments );
+            queryWrapper2.in(UserBypassAccount::getDepartment, departments);
         }
-        if (!name.equals( "" )) {
+        if (!name.equals("")) {
             String[] names = name.split(",");
-            queryWrapper2.in( UserBypassAccount::getRealName, names );
+            queryWrapper2.in(UserBypassAccount::getRealName, names);
         }
-        List<UserBypassAccount> list = userBypassAccountService.list( queryWrapper2 );
+        List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper2);
 
         List<Integer> ids = list.stream()
-                .map( UserBypassAccount::getUserId )
-                .collect( Collectors.toList() );
+                .map(UserBypassAccount::getUserId)
+                .collect(Collectors.toList());
 
-        return CommonResult.success( CommonPage.restPage( frontOrderService.list2(isRemit,status, pageRequest, ids,
-                Integer.valueOf( id ),department
-                , name ) ) );
+        return CommonResult.success(CommonPage.restPage(frontOrderService.list2(isRemit, status, pageRequest, ids,
+                Integer.valueOf(id), department
+                , name)));
     }
 
 
     @ApiOperation(value = "(支付之前的操作和之前一样)信用支付")
     @RequestMapping(value = "/creditPay", method = RequestMethod.POST)
     public CommonResult<OrderPayResultResponse> creditPay(@RequestBody @Validated OrderPayRequest2 orderPayRequest) {
-        return CommonResult.success( payService.payment2( orderPayRequest ) );
+        return CommonResult.success(payService.payment2(orderPayRequest));
     }
 
     @ApiOperation(value = "我的积分商品收藏列表")
     @RequestMapping(value = "/integralProductList", method = RequestMethod.GET)
     public CommonResult<PageInfo<UserProductRelationResponse2>> integralProductList(@Validated PageParamRequest pageParamRequest) {
-        return CommonResult.success( productRelationService.getUserList2( pageParamRequest ) );
+        return CommonResult.success(productRelationService.getUserList2(pageParamRequest));
     }
 
     @ApiOperation(value = "添加收藏积分产品id为商品id")
     @RequestMapping(value = "/addIntegralProduct/{id}", method = RequestMethod.POST)
     public CommonResult<String> addIntegralProduct(@PathVariable Integer id) {
         ProductRelation productRelation = new ProductRelation();
-        productRelation.setProductId( id );
-        productRelation.setUid( userService.getUserIdException() );
-        productRelation.setType( "collect" );
-        productRelation.setCategory( 4 );
-        boolean save = productRelationService.save( productRelation );
+        productRelation.setProductId(id);
+        productRelation.setUid(userService.getUserIdException());
+        productRelation.setType("collect");
+        productRelation.setCategory(4);
+        boolean save = productRelationService.save(productRelation);
         if (save) {
             return CommonResult.success();
         }
@@ -272,7 +273,7 @@ public class NewFrontApi {
     @ApiOperation(value = "取消收藏积分产品")
     @RequestMapping(value = "/cancelIntegralProduct", method = RequestMethod.POST)
     public CommonResult<String> cancelIntegralProduct(@RequestBody CancelCollectRequest request) {
-        if (productRelationService.delete( request )) {
+        if (productRelationService.delete(request)) {
             return CommonResult.success();
         }
         return CommonResult.failed();
@@ -282,21 +283,21 @@ public class NewFrontApi {
     @ApiOperation(value = "积分商品分页列表")
     @RequestMapping(value = "/integralList", method = RequestMethod.GET)
     public CommonResult<CommonPage<ProductFrontResponse2>> getList(@ModelAttribute @Validated PageParamRequest pageParamRequest) {
-        return CommonResult.success( CommonPage.restPage( productService.getList2( pageParamRequest ) ) );
+        return CommonResult.success(CommonPage.restPage(productService.getList2(pageParamRequest)));
     }
 
     //需要加入该用户是否收藏
     @ApiOperation(value = "积分商品详情")
     @RequestMapping(value = "/integralDetail/{id}", method = RequestMethod.GET)
     public CommonResult<ProductDetailResponse2> getDetail(@Validated @PathVariable Integer id) {
-        return CommonResult.success( productService.getDetail2( id ) );
+        return CommonResult.success(productService.getDetail2(id));
     }
 
     @ApiOperation(value = "设置积分商城图片")
     @RequestMapping(value = "/picConfigInfo", method = RequestMethod.GET)
     public CommonResult<HashMap<String, String>> picConfigInfo() {
         Integer formId = 102;
-        return CommonResult.success( systemConfigService.info( formId ) );
+        return CommonResult.success(systemConfigService.info(formId));
     }
 
     @ApiOperation(value = "获取小程序码")
@@ -304,8 +305,8 @@ public class NewFrontApi {
     public CommonResult<String> getwxacode(@RequestBody @Validated GetwxacodeRequest getwxacodeRequest) {
 
 
-        String image = aaaService.getImage( getwxacodeRequest );
-        return CommonResult.success( image );
+        String image = aaaService.getImage(getwxacodeRequest);
+        return CommonResult.success(image);
     }
 
     @ApiOperation(value = "获取购物车信息(分享完购物车后用的)ids 为购物车表id")
@@ -315,8 +316,8 @@ public class NewFrontApi {
             List<Integer> ids = Arrays.stream(jsonIds.split(","))
                     .map(Integer::parseInt)
                     .collect(Collectors.toList());
-            List<CartMerchantResponse> list2 = cartService.getList2( ids );
-            return CommonResult.success( list2 );
+            List<CartMerchantResponse> list2 = cartService.getList2(ids);
+            return CommonResult.success(list2);
         } catch (Exception e) {
             e.printStackTrace();
             return CommonResult.failed();
@@ -326,27 +327,27 @@ public class NewFrontApi {
     @ApiOperation(value = "获取个人信息(分享完购物车后用的)id为userId")
     @RequestMapping(value = "/getwxacode2/{id}", method = RequestMethod.GET)
     public CommonResult<User> getwxacode2(@PathVariable Integer id) {
-        User byId = userService.getById( id );
-        return CommonResult.success( byId );
+        User byId = userService.getById(id);
+        return CommonResult.success(byId);
     }
 
     //积分兑换
     @ApiOperation(value = "预下单")
     @RequestMapping(value = "/pre/order", method = RequestMethod.POST)
     public CommonResult<OrderNoResponse2> preOrder(@RequestBody @Validated PreOrderRequest2 request) {
-        return CommonResult.success( frontOrderService.preOrder2( request ) );
+        return CommonResult.success(frontOrderService.preOrder2(request));
     }
 
     @ApiOperation(value = "加载预下单")
     @RequestMapping(value = "load/pre/{preOrderNo}", method = RequestMethod.GET)
     public CommonResult<PreOrderResponse> loadPreOrder(@PathVariable String preOrderNo) {
-        return CommonResult.success( frontOrderService.loadPreOrder2( preOrderNo ) );
+        return CommonResult.success(frontOrderService.loadPreOrder2(preOrderNo));
     }
 
     @ApiOperation(value = "积分兑换")
     @RequestMapping(value = "/creditsExchange", method = RequestMethod.POST)
     public CommonResult<OrderNoResponse2> creditsExchange(@Validated @RequestBody CreateOrderRequest2 orderRequest) {
-        return CommonResult.success( frontOrderService.creditsExchange( orderRequest ) );
+        return CommonResult.success(frontOrderService.creditsExchange(orderRequest));
     }
 
     @ApiOperation(value = "查看积分订单(企业用户调用的)(id为企业账号id)")
@@ -362,21 +363,21 @@ public class NewFrontApi {
                                                                         @PathVariable String id,
                                                                         @ModelAttribute PageParamRequest pageRequest) {
         LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-        queryWrapper2.eq( UserBypassAccount::getEnterpriseId, id );
-        if (!department.equals( "" )) {
-            queryWrapper2.eq( UserBypassAccount::getDepartment, department );
+        queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
+        if (!department.equals("")) {
+            queryWrapper2.eq(UserBypassAccount::getDepartment, department);
         }
-        if (!name.equals( "" )) {
-            queryWrapper2.eq( UserBypassAccount::getRealName, name );
+        if (!name.equals("")) {
+            queryWrapper2.eq(UserBypassAccount::getRealName, name);
         }
-        List<UserBypassAccount> list = userBypassAccountService.list( queryWrapper2 );
+        List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper2);
 
         List<Integer> ids = list.stream()
-                .map( UserBypassAccount::getUserId )
-                .collect( Collectors.toList() );
+                .map(UserBypassAccount::getUserId)
+                .collect(Collectors.toList());
 
-        return CommonResult.success( CommonPage.restPage( frontOrderService.list3( status, pageRequest, ids, department
-                , name , Integer.valueOf( id ) ) ) );
+        return CommonResult.success(CommonPage.restPage(frontOrderService.list3(status, pageRequest, ids, department
+                , name, Integer.valueOf(id))));
     }
 
 
@@ -387,13 +388,13 @@ public class NewFrontApi {
     })
     public CommonResult<CommonPage<OrderFrontDataResponse2>> orderList4(@RequestParam(name = "status") Integer status,
                                                                         @ModelAttribute PageParamRequest pageRequest) {
-        return CommonResult.success( CommonPage.restPage( frontOrderService.list4( status, pageRequest ) ) );
+        return CommonResult.success(CommonPage.restPage(frontOrderService.list4(status, pageRequest)));
     }
 
     @ApiOperation(value = "积分订单详情")
     @RequestMapping(value = "/orderDetail/{orderNo}", method = RequestMethod.GET)
     public CommonResult<OrderFrontDetailResponse2> orderDetail(@PathVariable String orderNo) {
-        return CommonResult.success( frontOrderService.frontDetail2( orderNo ) );
+        return CommonResult.success(frontOrderService.frontDetail2(orderNo));
     }
 
 
@@ -405,51 +406,51 @@ public class NewFrontApi {
     public String weChat(@RequestBody String request) {
         JSONObject jsonObject = JSONObject.parseObject(request);
         try {
-            if (jsonObject.getString( "summary" ).equals( "支付成功" )){
-                JSONObject resource = jsonObject.getJSONObject( "resource" );
+            if (jsonObject.getString("summary").equals("支付成功")) {
+                JSONObject resource = jsonObject.getJSONObject("resource");
 
                 String apiV3Key = "1tOXUE8y2vqO6NFxHBoK2F1gtn4Ls6dO";
-                String nonce = resource.getString( "nonce" );
-                String associatedData = resource.getString( "associated_data" );
-                String ciphertext = resource.getString( "ciphertext" );
+                String nonce = resource.getString("nonce");
+                String associatedData = resource.getString("associated_data");
+                String ciphertext = resource.getString("ciphertext");
 
                 Cipher cipher = Cipher.getInstance(ALGORITHM);
-                SecretKeySpec key = new SecretKeySpec(apiV3Key.getBytes( StandardCharsets.UTF_8), "AES");
+                SecretKeySpec key = new SecretKeySpec(apiV3Key.getBytes(StandardCharsets.UTF_8), "AES");
                 GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce.getBytes(StandardCharsets.UTF_8));
                 cipher.init(Cipher.DECRYPT_MODE, key, spec);
                 cipher.updateAAD(associatedData.getBytes(StandardCharsets.UTF_8));
                 byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(ciphertext));
 //                return new String(decryptedData, StandardCharsets.UTF_8);
-                String s = new String( decryptedData, StandardCharsets.UTF_8 );
-                log.info( "商户端短信回调解析:"+ s);
+                String s = new String(decryptedData, StandardCharsets.UTF_8);
+                log.info("商户端短信回调解析:" + s);
                 JSONObject ss = JSONObject.parseObject(s);
-                if (ss.getString( "trade_state" ).equals( "SUCCESS" )){
+                if (ss.getString("trade_state").equals("SUCCESS")) {
                     //这里可以选择数据库操作
-                    String out_trade_no = ss.getString( "out_trade_no" );
+                    String out_trade_no = ss.getString("out_trade_no");
                     List<String> list = Arrays.asList(out_trade_no.split("_"));
-                    Integer MId= Integer.valueOf( list.get( 0 ) );
-                    Integer num= Integer.valueOf( list.get( 1 ) );
+                    Integer MId = Integer.valueOf(list.get(0));
+                    Integer num = Integer.valueOf(list.get(1));
                     LambdaQueryWrapper<MerchantSms> queryWrapper = new LambdaQueryWrapper<>();
-                    queryWrapper.eq( MerchantSms::getMerId, MId );
-                    MerchantSms one = merchantSmsService.getOne( queryWrapper,false );
-                    if (one==null){
+                    queryWrapper.eq(MerchantSms::getMerId, MId);
+                    MerchantSms one = merchantSmsService.getOne(queryWrapper, false);
+                    if (one == null) {
                         //没有开通  创建
-                        MerchantSms merchantSms =new MerchantSms();
-                        merchantSms.setMerId( MId );
+                        MerchantSms merchantSms = new MerchantSms();
+                        merchantSms.setMerId(MId);
                         //到时候需要改变
-                        merchantSms.setTransmissionTimes( num );
-                        merchantSms.setTransmissionTimesThen( 0 );
-                        merchantSmsService.save( merchantSms );
-                    }else {
-                        one.setTransmissionTimes( one.getTransmissionTimes()+num );
-                        merchantSmsService.updateById( one );
+                        merchantSms.setTransmissionTimes(num);
+                        merchantSms.setTransmissionTimesThen(0);
+                        merchantSmsService.save(merchantSms);
+                    } else {
+                        one.setTransmissionTimes(one.getTransmissionTimes() + num);
+                        merchantSmsService.updateById(one);
                     }
                     //支付成功
                     return "{\"code\": \"200\",\"message\": \"\"}";
-                }else {
+                } else {
                     return "{\"code\": \"FAIL\",\"message\": \"失败\"}";
                 }
-            }else {
+            } else {
                 return "{\"code\": \"FAIL\",\"message\": \"失败\"}";
             }
         } catch (Exception e) {
@@ -459,11 +460,23 @@ public class NewFrontApi {
 
     @ApiOperation(value = "查看部门下用户")
     @RequestMapping(value = "departUser", method = RequestMethod.GET)
-    public CommonResult<?> departUser(@RequestParam(name = "departmentId") String departmentId) {
-        String[] split = departmentId.split(",");
-        LambdaQueryWrapper<OrganizationDepartmentUser> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(OrganizationDepartmentUser::getDepartmentId,split);
-        List<OrganizationDepartmentUser> list = organizationDepartmentUserService.list(queryWrapper);
+    public CommonResult<?> departUser(@RequestParam(name = "departmentId", required = false) String departmentId,
+                                      @RequestParam(name = "organizationId", required = false) String organizationId
+    ) {
+        List<OrganizationDepartmentUser> list = null;
+        if (StringUtils.isNotBlank(organizationId)) {
+            LambdaQueryWrapper<OrganizationDepartmentUser> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(OrganizationDepartmentUser::getOrganizationId, organizationId);
+            list = organizationDepartmentUserService.list(queryWrapper);
+        }
+        if (StringUtils.isNotBlank(departmentId)) {
+            String[] split = departmentId.split(",");
+            LambdaQueryWrapper<OrganizationDepartmentUser> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(OrganizationDepartmentUser::getDepartmentId, split);
+            list = organizationDepartmentUserService.list(queryWrapper);
+        }
+
+
         return CommonResult.success(list);
 
     }