skyline 1 年之前
父節點
當前提交
c8459831ee

+ 11 - 0
admin-web/src/views/admin/account/index.vue

@@ -47,6 +47,16 @@
             @blur="loadData(true)"
             class="wd150 mr10">
         </el-input>
+        <ext-select
+            v-model="state.formQuery.stationId"
+            placeholder="站点"
+            url="washStation/list"
+            url-method="post"
+            label-key="stationName"
+            value-key="stationId"
+            data-key="list"
+            clearable
+            class="wd200 ml10"/>
 <!--        <ext-d-select-->
 <!--            v-model="state.formQuery.status"-->
 <!--            placeholder="状态"-->
@@ -136,6 +146,7 @@ import ExtPage from '/@/components/form/ExtPage.vue'
 import mittBus from '/@/utils/mitt';
 import ExtDLabel from "/@/components/form/ExtDLabel.vue";
 import ExtDSelect from "/@/components/form/ExtDSelect.vue";
+import ExtSelect from "/@/components/form/ExtSelect.vue";
 
 const AdminUserDialog = defineAsyncComponent(() => import("/@/views/admin/account/detail.vue"));
 

+ 15 - 5
car-wash-admin/src/main/java/com/kym/admin/controller/CustomController.java

@@ -2,14 +2,13 @@ package com.kym.admin.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import com.kym.common.R;
+import com.kym.common.annotation.ApiLog;
 import com.kym.common.annotation.SysLog;
 import com.kym.entity.queryParams.CommonQueryParam;
 import com.kym.service.PayLogService;
 import com.kym.service.UserService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.kym.service.wechat.WxPayService;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 用户相关信息
@@ -24,9 +23,12 @@ public class CustomController {
     private final UserService customUserService;
     private final PayLogService payLogService;
 
-    public CustomController(UserService customUserService, PayLogService payLogService) {
+    private final WxPayService wxPayService;
+
+    public CustomController(UserService customUserService, PayLogService payLogService, WxPayService wxPayService) {
         this.customUserService = customUserService;
         this.payLogService = payLogService;
+        this.wxPayService = wxPayService;
     }
 
     @SaCheckPermission("account.list")
@@ -42,4 +44,12 @@ public class CustomController {
         return R.success(payLogService.listRecharge(params));
     }
 
+    @SysLog("用户退款申请")
+    @PostMapping("/applyRefund")
+    @ResponseBody
+    R<?> wxAppRefund(@RequestParam String reason) {
+        wxPayService.applyWxRefund(reason);
+        return R.success();
+    }
+
 }

+ 14 - 7
car-wash-admin/src/main/java/com/kym/admin/controller/WashDeviceController.java

@@ -4,15 +4,9 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import com.kym.common.R;
 import com.kym.common.annotation.SysLog;
 import com.kym.entity.WashDevice;
-import com.kym.entity.WashStation;
 import com.kym.entity.queryParams.DeviceQueryParams;
 import com.kym.service.WashDeviceService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -72,5 +66,18 @@ public class WashDeviceController {
         return R.success();
     }
 
+    /**
+     * 停止设备关闭订单
+     *
+     * @param shortId
+     * @return
+     */
+    @SysLog("结算")
+    @PostMapping(value = "/stopDevice/{shortId}")
+    R<?> stopDevice(@PathVariable("shortId") String shortId) {
+        washDeviceService.stopDevice(shortId);
+        return R.success();
+    }
+
 
 }

+ 4 - 0
car-wash-entity/src/main/java/com/kym/entity/queryParams/CommonQueryParam.java

@@ -20,6 +20,10 @@ public class CommonQueryParam extends PageParams {
      * 用户id
      */
     private Long userId;
+    /**
+     * 归属站点id
+     */
+    private String stationId;
     /**
      * 手机号
      */

+ 1 - 0
car-wash-service/src/main/java/com/kym/service/WashOrderService.java

@@ -41,4 +41,5 @@ public interface WashOrderService extends MyBaseService<WashOrder> {
 
     Map<String, Integer> countMonthOrdersCount(LocalDate statDay);
 
+    WashOrder getOrderInProgressByUserId(long userId);
 }

+ 14 - 5
car-wash-service/src/main/java/com/kym/service/impl/UserServiceImpl.java

@@ -251,11 +251,20 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
      */
     @Override
     public PageBean<CustomUserVo> listCustomUser(CommonQueryParam params) {
-        List<Long> userIds = null;
-        if (!CommUtil.isEmptyOrNull(params.getMobilePhone())) {
-            userIds = lambdaQuery().
-                    eq(User::getMobilePhone, params.getMobilePhone())
-                    .eq(!CommUtil.isEmptyOrNull(params.getStatus()), User::getStatus, params.getStatus()).list().stream().map(User::getId).toList();
+        // 站点数据权限
+        var adminStationIds = KymCache.INSTANCE.getAdminUserStationIds(StpUtil.getLoginIdAsLong());
+        if (CommUtil.isEmptyOrNull(params.getStationId()) &&
+                CommUtil.isNotEmptyAndNull(KymCache.INSTANCE.getAdminUserStationIds(StpUtil.getLoginIdAsLong()))) {
+            params.setStationId(adminStationIds.get(0));
+        }
+        List<Long> userIds = lambdaQuery()
+                .eq(CommUtil.isNotEmptyAndNull(params.getMobilePhone()), User::getMobilePhone, params.getMobilePhone())
+                .eq(User::getStationId, params.getStationId())
+                .eq(CommUtil.isNotEmptyAndNull(params.getStatus()), User::getStatus, params.getStatus())
+                .list().stream().map(User::getId)
+                .toList();
+        if (CommUtil.isEmptyOrNull(userIds)) {
+            return new PageBean<>();
         }
         PageHelper.startPage(params.getPageNum(), params.getPageSize());
         var result = baseMapper.listUser(userIds);

+ 8 - 0
car-wash-service/src/main/java/com/kym/service/impl/WashOrderServiceImpl.java

@@ -265,5 +265,13 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
         // 按照站点分组统计订单数量
         return list(wrapper).stream().collect(Collectors.groupingBy(WashOrder::getStationId, Collectors.summingInt(o -> 1)));
     }
+
+    @Override
+    public WashOrder getOrderInProgressByUserId(long userId) {
+        return lambdaQuery()
+                .eq(WashOrder::getUserId, userId)
+                .eq(WashOrder::getPayStatus, WashOrder.PAY_STATUS_未支付)
+                .one();
+    }
     //endregion
 }

+ 10 - 7
car-wash-service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -90,6 +90,8 @@ public class WxPayServiceImpl implements WxPayService {
     private final StationAccountService stationAccountService;
     private final SplitRecordService splitRecordService;
 
+    private final WashOrderService washOrderService;
+
 
     /**
      * 微信支付专用,支持自动签名验签解密等
@@ -101,7 +103,7 @@ public class WxPayServiceImpl implements WxPayService {
                             PayLogService payLogService, AccountService accountService,
                             RefundLogService refundLogService,
                             ActivityService activityService, UserRechargeRightsService userRechargeRightsService,
-                            RechargeConfigService rechargeConfigService, StationAccountService stationAccountService, SplitRecordService splitRecordService) {
+                            RechargeConfigService rechargeConfigService, StationAccountService stationAccountService, SplitRecordService splitRecordService, WashOrderService washOrderService) {
         this.conf = conf;
         this.walletDetailService = walletDetailService;
         this.payLogService = payLogService;
@@ -112,6 +114,7 @@ public class WxPayServiceImpl implements WxPayService {
         this.rechargeConfigService = rechargeConfigService;
         this.stationAccountService = stationAccountService;
         this.splitRecordService = splitRecordService;
+        this.washOrderService = washOrderService;
     }
 
     /**
@@ -388,12 +391,12 @@ public class WxPayServiceImpl implements WxPayService {
     @Transactional(rollbackFor = Exception.class)
     public void applyWxRefund(String reason) {
         var userId = StpUtil.getLoginIdAsLong();
-//        var chargeOrder = chargeOrderService.getChargingOrderByUserId(userId);
-//        if (chargeOrder != null) {
-//            throw new BusinessException("存在未完结的订单,请等待所有订单完结之后重试");
-//        }
-        // todo 洗车未完结订单校验
-
+        var washOrder = washOrderService.getOrderInProgressByUserId(userId);
+        // 洗车未完结订单校验
+        if (washOrder != null) {
+            throw new BusinessException("存在未完结的订单,请完成所有订单完结之后重试");
+        }
+        
         var account = accountService.getAccountByUserId(userId);
         if (account.getBalance() <= 0) {
             throw new BusinessException("账户余额不足,无需退款");