diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java index 69419d1..e912c91 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppleOrderController.java @@ -5341,70 +5341,49 @@ public class AppleOrderController extends BaseController { if (order.getStatus() == null || order.getStatus() != 1L) { return AppletControllerUtil.appletWarning("订单状态不正确,无法接单"); } - -// // 获取当前登录用户(师傅) -// String token = request.getHeader("token"); -// if (StringUtils.isEmpty(token)) { -// return AppletControllerUtil.appletdengluWarning("用户未登录"); -// } -// -//// Users currentUser = AppletLoginUtil.getUserByToken(token); -//// if (currentUser == null) { -//// return AppletControllerUtil.appletdengluWarning("用户未登录或token无效"); -//// } -// Users currentUser = (Users) userValidation.get("user"); -// if (currentUser == null) { -// return AppletControllerUtil.appletdengluWarning("用户信息获取失败"); -// } - -// // 检查用户是否为师傅 -// if (!"2".equals(currentUser.getType()) || currentUser.getIsWork() != 1) { -// return AppletControllerUtil.appletWarning("只有师傅才能接单"); -// } - // 检查订单是否已被其他师傅接单 if (order.getWorkerId() != null && order.getWorkerId() > 0) { return AppletControllerUtil.appletWarning("该订单已被其他师傅接单"); } - - // 更新订单状态为2(待服务)并分配师傅 - order.setStatus(2L); - order.setWorkerId(currentUser.getId()); - order.setReceiveTime(new Date()); - order.setReceiveType(1L); // 1:自由抢单 - order.setIsAccept(1); // 1:已经接单 - - // 如果是第一次接单,设置firstWorkerId - if (order.getFirstWorkerId() == null) { - order.setFirstWorkerId(currentUser.getId()); - } - - // 更新订单 - int updateResult = orderService.updateOrder(order); - if (updateResult <= 0) { - return AppletControllerUtil.appletError("订单状态更新失败"); - } - - // 添加订单日志 - OrderLog orderLog = new OrderLog(); - orderLog.setOid(orderId); - orderLog.setOrderId(order.getOrderId()); - orderLog.setLogOrderId(order.getOrderId()); - orderLog.setTitle("师傅接单"); - orderLog.setType(new BigDecimal("2")); // 2:接单 - JSONObject content = new JSONObject(); - content.put("name", "师傅" + currentUser.getName() + "接单成功"); - orderLog.setContent(content.toJSONString()); - orderLog.setWorkerId(currentUser.getId()); - orderLog.setWorkerName(currentUser.getName()); - orderLog.setFirstWorkerId(currentUser.getId()); - orderLog.setOrdertype(1L); - - int logResult = orderLogService.insertOrderLog(orderLog); - if (logResult <= 0) { - logger.warn("订单日志添加失败,订单ID:{}", orderId); - } + DispatchUtil.creatWorkerForOrder(order, currentUser); +// // 更新订单状态为2(待服务)并分配师傅 +// order.setStatus(2L); +// order.setWorkerId(currentUser.getId()); +// order.setReceiveTime(new Date()); +// order.setReceiveType(1L); // 1:自由抢单 +// order.setIsAccept(1); // 1:已经接单 +// +// // 如果是第一次接单,设置firstWorkerId +// if (order.getFirstWorkerId() == null) { +// order.setFirstWorkerId(currentUser.getId()); +// } +// +// // 更新订单 +// int updateResult = orderService.updateOrder(order); +// if (updateResult <= 0) { +// return AppletControllerUtil.appletError("订单状态更新失败"); +// } +// +// // 添加订单日志 +// OrderLog orderLog = new OrderLog(); +// orderLog.setOid(orderId); +// orderLog.setOrderId(order.getOrderId()); +// orderLog.setLogOrderId(order.getOrderId()); +// orderLog.setTitle("师傅接单"); +// orderLog.setType(new BigDecimal("2")); // 2:接单 +// JSONObject content = new JSONObject(); +// content.put("name", "师傅" + currentUser.getName() + "接单成功"); +// orderLog.setContent(content.toJSONString()); +// orderLog.setWorkerId(currentUser.getId()); +// orderLog.setWorkerName(currentUser.getName()); +// orderLog.setFirstWorkerId(currentUser.getId()); +// orderLog.setOrdertype(1L); +// +// int logResult = orderLogService.insertOrderLog(orderLog); +// if (logResult <= 0) { +// logger.warn("订单日志添加失败,订单ID:{}", orderId); +// } return AppletControllerUtil.appletSuccess("接单成功"); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java index b581b69..5f07478 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java @@ -2726,7 +2726,7 @@ public class AppletController extends BaseController { // 10. 记录积分变动日志 IntegralLog integralLog = AppletControllerUtil.buildIntegralLog( - user, -totalIntegral, order.getOrderId(), product.getTitle()); + user, totalIntegral, order.getOrderId(), product.getTitle()); integralLogService.insertIntegralLog(integralLog); // 11. 更新商品库存(如果有库存管理) @@ -7120,6 +7120,7 @@ public class AppletController extends BaseController { // 3. 查询状态为1(待接单)的订单 Order orderQuery = new Order(); orderQuery.setStatus(1L); // 待接单状态 + // orderQuery.setWorkerId(Long.parseLong(request.getHeader("userId"))); orderQuery.setQiangdan("1"); List orderList = orderService.selectOrderList(orderQuery); PageInfo pageInfo = new PageInfo<>(orderList); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersController.java index db0f56d..9bdb730 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/UsersController.java @@ -313,10 +313,10 @@ public class UsersController extends BaseController Users newUsers = usersService.selectUsersById(users.getId()); System.out.println("###############"+newUsers.getType()); - if (newUsers.getType().equals("2")&&users.getStatus()==0){ - newUsers.setType("1"); - newUsers.setIsWork(0); - } +// if (newUsers!=null){ +// // newUsers.setType("1"); +// newUsers.setIsWork(0); +// } newUsers.setStatus(users.getStatus()); return toAjax(usersService.updateUsers(newUsers)); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMoneyLogController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMoneyLogController.java index ea3fc59..d833bcf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMoneyLogController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/WorkerMoneyLogController.java @@ -3,7 +3,7 @@ package com.ruoyi.system.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; + import java.time.ZoneId; import java.util.Date; import java.util.Map; @@ -129,7 +129,7 @@ public class WorkerMoneyLogController extends BaseController /** * 批量锁住收益 - * @param params {ids:[], lockType:'forever'|'timed', lockday:int} + * @param params {ids:[], lockType:'forever'|'days', lockday:int, remark:string} * @return AjaxResult */ @PreAuthorize("@ss.hasPermi('system:workerMoneyLog:lock')") @@ -137,34 +137,48 @@ public class WorkerMoneyLogController extends BaseController public AjaxResult lockMoney(@RequestBody Map params) { Object idsObj = params.get("ids"); if (idsObj == null) return AjaxResult.error("未选择数据"); + @SuppressWarnings("unchecked") List ids = (List) idsObj; String lockType = (String) params.get("lockType"); Integer lockday = params.get("lockday") == null ? null : Integer.parseInt(params.get("lockday").toString()); + String remark = (String) params.get("remark"); + Date now = new Date(); Date end = null; - if ("timed".equals(lockType) && lockday != null && lockday > 0) { + + // 如果是按天锁住,计算结束时间 + if ("days".equals(lockType) && lockday != null && lockday > 0) { LocalDateTime ldt = LocalDateTime.now().plusDays(lockday); end = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant()); } + // 如果是永久锁住,结束时间设置为null + for (Integer id : ids) { WorkerMoneyLog log = workerMoneyLogService.selectWorkerMoneyLogById(id); if (log == null) continue; + + // 检查是否已经锁定 + if (log.getStatus() != null && log.getStatus() == 1) { + continue; // 跳过已锁定的数据 + } + log.setStatus(1); // 锁定 log.setStatusType(1); // 后台锁定 log.setBeginlook(now); - if ("timed".equals(lockType) && end != null) { + log.setLookMoney(log.getPrice()); + log.setAdminUpReamk(remark); // 设置锁住原因 + + if ("days".equals(lockType) && end != null) { + // 按天锁住:设置结束时间和锁住天数 log.setEndlook(end); log.setLookday(lockday); + } else if ("forever".equals(lockType)) { + // 永久锁住:结束时间设置为null,锁住天数设置为null + log.setEndlook(null); + log.setLookday(null); } -// else { -// // 永久锁住 -// -// } - log.setLookMoney(log.getPrice()); + workerMoneyLogService.updateWorkerMoneyLog(log); - if ("forever".equals(lockType)){ - workerMoneyLogService.updateWorkerMoneyLogforever(log); - } } return AjaxResult.success("锁住收益成功"); } @@ -179,6 +193,7 @@ public class WorkerMoneyLogController extends BaseController public AjaxResult unlockMoney(@RequestBody Map params) { Object idsObj = params.get("ids"); if (idsObj == null) return AjaxResult.error("未选择数据"); + @SuppressWarnings("unchecked") List ids = (List) idsObj; for (Integer id : ids) { WorkerMoneyLog log = workerMoneyLogService.selectWorkerMoneyLogById(id); @@ -193,7 +208,7 @@ public class WorkerMoneyLogController extends BaseController /** * 调整收益(奖励/扣除) - * @param params {id, amount, remark} + * @param params {id, type:'reward'|'deduct', amount, remark} * @return AjaxResult */ @PreAuthorize("@ss.hasPermi('system:workerMoneyLog:adjust')") @@ -203,10 +218,36 @@ public class WorkerMoneyLogController extends BaseController WorkerMoneyLog log = workerMoneyLogService.selectWorkerMoneyLogById(id); if (log == null) return AjaxResult.error("数据不存在"); if (log.getStatus() == null || log.getStatus() != 1) return AjaxResult.error("只能调整锁定状态的数据"); + + String type = (String) params.get("type"); BigDecimal amount = new BigDecimal(params.get("amount").toString()); String remark = (String) params.get("remark"); - log.setAdminUpPrice(amount); + + // 获取当前金额 + BigDecimal currentPrice = log.getPrice() != null ? log.getPrice() : BigDecimal.ZERO; + BigDecimal newPrice; + + if ("reward".equals(type)) { + // 奖励:增加金额 + newPrice = currentPrice.add(amount); + log.setAdminUpPrice(amount); // 记录调整金额(正数) + } else if ("deduct".equals(type)) { + // 扣除:减少金额 + newPrice = currentPrice.subtract(amount); + // 确保金额不为负数 + if (newPrice.compareTo(BigDecimal.ZERO) < 0) { + return AjaxResult.error("扣除金额不能超过当前金额"); + } + log.setAdminUpPrice(amount.negate()); // 记录调整金额(负数) + } else { + return AjaxResult.error("调整类型参数错误"); + } + + // 更新价格和备注 + log.setPrice(newPrice); + log.setLookMoney(newPrice); // 同时更新锁单金额 log.setAdminUpReamk(remark); + workerMoneyLogService.updateWorkerMoneyLog(log); return AjaxResult.success("调整收益成功"); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java index a2dbf75..3a75114 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/AppletControllerUtil.java @@ -2577,7 +2577,7 @@ public class AppletControllerUtil { log.setTitle("积分商品兑换"); log.setMark("兑换商品:" + productTitle + ",订单号:" + orderId); // 使用mark字段 log.setType(2L); // 类型:2-减少 - + log.setOrderId(orderId); Date now = new Date(); log.setCreatedAt(now); log.setUpdatedAt(now); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/DispatchUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/DispatchUtil.java index 8dd7535..c9d408b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/DispatchUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/DispatchUtil.java @@ -2975,4 +2975,55 @@ public class DispatchUtil { return worker; } + + //抢单的时候处理有不同的处理逻辑 + public static Users creatWorkerForOrderQiangDan(Order order,Users worker) throws Exception { + + order.setWorkerId(worker.getId()); + order.setStatus(1L); + order.setIsPause(1); + order.setReceiveTime(new Date()); + order.setWorkerPhone(worker.getPhone()); + UserAddress userAddress = userAddressService.selectUserAddressById(order.getAddressId()); + if (userAddress != null){ + order.setUserPhone(userAddress.getPhone()); + } + // order.setMiddlePhone("18339212639"); + order.setReceiveType(3l); + order.setLogStatus(9); + com.alibaba.fastjson2.JSONObject jSONObject = new com.alibaba.fastjson2.JSONObject(); + jSONObject.put("type", 9); + order.setLogJson(jSONObject.toJSONString()); + orderService.updateOrder(order); + + + OrderLog orderLognew = new OrderLog(); + orderLognew.setOid(order.getId()); + orderLognew.setOrderId(order.getOrderId()); + orderLognew.setTitle("系统派单"); + orderLognew.setType(new BigDecimal(1.1)); + com.alibaba.fastjson2.JSONObject jSONObject1 = new com.alibaba.fastjson2.JSONObject(); + jSONObject1.put("name", "师傅收到派单信息"); + orderLognew.setContent(jSONObject1.toJSONString()); + orderLognew.setWorkerId(worker.getId()); + orderLognew.setWorkerLogId(worker.getId()); + orderLogService.insertOrderLog(orderLognew); + //绑定虚拟号码 + //微信推送 + ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(order.getProductId()); + //给师傅派单的时候的推送 + WXsendMsgUtil.sendMsgForWorkerInfo(worker.getOpenid(), order, serviceGoods); + //派单的时候需要绑定虚拟号码 + Map map= OrderBindWorkerUtil.getOrderBindWorkerQiangDan(order.getId()); + //电话通知师傅接单 + YunXinPhoneUtilAPI.httpsAxbTransfer(order.getWorkerPhone(), order.getId()); +// if (map.get("code").equals("200")) { +// //电话通知 +// YunXinPhoneUtilAPI.httpsAxbTransfer(order.getWorkerPhone()); +// } + + + return worker; + } + } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderBindWorkerUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderBindWorkerUtil.java index e38e8af..b3299f3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderBindWorkerUtil.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controllerUtil/OrderBindWorkerUtil.java @@ -34,6 +34,100 @@ public class OrderBindWorkerUtil { private static final IAreaService areaService= SpringUtils.getBean(IAreaService.class); + /** + * 订单绑定师傅电话号码操作 + * @param orderId 订单ID + * @return 绑定结果Map,包含code和msg + */ + public static Map getOrderBindWorkerQiangDan(long orderId) { + Map result = new HashMap<>(); + try { + // 1. 查询订单 + Order order = orderService.selectOrderById(orderId); + if (order == null) { + result.put("code", 404); + result.put("msg", "订单不存在"); + return result; + } + // 2. 查询师傅信息 + Users workerUser = usersService.selectUsersById(order.getWorkerId()); + if (workerUser == null) { + result.put("code", 404); + result.put("msg", "师傅信息不存在"); + return result; + } + // 3. 查询订单地址 + UserAddress userAddress = userAddressService.selectUserAddressById(order.getAddressId()); + if (userAddress == null) { + result.put("code", 404); + result.put("msg", "订单地址不存在"); + return result; + } + // 4. 经纬度转城市 + double lng = Double.parseDouble(userAddress.getLongitude()); + double lat = Double.parseDouble(userAddress.getLatitude()); + String city = GaoDeMapUtil.getCityByLocation(lng, lat); + if (city == null || city.isEmpty()) { + result.put("code", 500); + result.put("msg", "无法根据经纬度获取城市信息"); + return result; + } + // 5. 查询城市编码 + Area area = new Area(); + area.setTitle(city); + List areaList = areaService.selectAreaList(area); + if (areaList == null || areaList.isEmpty()) { + areaList=areaService.selectAreaList(new Area()); +// result.put("code", 404); +// result.put("msg", "未找到城市编码"); +// return result; + } + Long cityCode = areaList.get(0).getId(); + // 6. 查询可用中间号 + MobileMiddle mobileMiddleQuery = new MobileMiddle(); + mobileMiddleQuery.setCityId(cityCode); + List mobileMiddleList = mobileMiddleService.selectMobileMiddleList(mobileMiddleQuery); + if (mobileMiddleList == null || mobileMiddleList.isEmpty()) { + mobileMiddleList=mobileMiddleService.selectMobileMiddleList(new MobileMiddle()); +// result.put("code", 404); +// result.put("msg", "该城市暂无可用中间号"); +// return result; + } + // 7. 获取用户和师傅手机号 + String userPhone = userAddress.getPhone(); + String workerPhone = workerUser.getPhone(); + if (userPhone == null || workerPhone == null) { + result.put("code", 400); + result.put("msg", "用户或师傅手机号为空"); + return result; + } + // 8. 绑定中间号,直到成功 + for (MobileMiddle middle : mobileMiddleList) { + VoiceResponseResult bindResult = YunXinPhoneUtilAPI.httpsPrivacyBindAxb(middle.getPhone(), userPhone, workerPhone); + System.out.println(middle.getPhone()+"__________"+userPhone+"__________"+workerPhone); + if ("000000".equals(bindResult.getResult())) { + // 绑定成功,更新订单 + order.setMiddlePhone(middle.getPhone()); + order.setUserPhone(userPhone); + order.setWorkerPhone(workerPhone); + orderService.updateOrder(order); + result.put("code", 200); + result.put("msg", "绑定成功"); + return result; + } + } + // 9. 所有中间号都绑定失败 + result.put("code", 500); + result.put("msg", "所有中间号均绑定失败"); + } catch (Exception e) { + result.put("code", 500); + result.put("msg", "绑定异常: " + e.getMessage()); + } + return result; + } + + + /** * 订单绑定师傅电话号码操作 * @param orderId 订单ID @@ -123,4 +217,5 @@ public class OrderBindWorkerUtil { } return result; } + } diff --git a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml index 98df7aa..5cb8a1b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml @@ -209,6 +209,9 @@ AND FROM_UNIXTIME(make_time, '%Y-%m-%d') = #{dayDate} + + AND worker_id is null + and id in (select oid from user_demand_quotation b where b.workerid=#{baojiasf} and b.status=1) diff --git a/ruoyi-ui/src/views/system/Coupons/index.vue b/ruoyi-ui/src/views/system/Coupons/index.vue index b067e51..e061f4c 100644 --- a/ruoyi-ui/src/views/system/Coupons/index.vue +++ b/ruoyi-ui/src/views/system/Coupons/index.vue @@ -829,7 +829,7 @@ export default { // 任务状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用" - this.$modal.confirm('确认要"' + text + '""' + row.title + '"状态吗?').then(function() { + this.$modal.confirm('确认要操作' + row.title + '状态吗?').then(function() { return changetypeStatus(row.id, row.status) }).then(() => { this.$modal.msgSuccess(text + "成功") diff --git a/ruoyi-ui/src/views/system/IntegralCate/index.vue b/ruoyi-ui/src/views/system/IntegralCate/index.vue index 31b4edc..aabc4a8 100644 --- a/ruoyi-ui/src/views/system/IntegralCate/index.vue +++ b/ruoyi-ui/src/views/system/IntegralCate/index.vue @@ -9,7 +9,7 @@ @keyup.enter.native="handleQuery" /> - + 搜索 重置 @@ -49,7 +49,7 @@ v-hasPermi="['system:IntegralCate:remove']" >删除 - + @@ -252,7 +252,7 @@ export default { // 任务状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用" - this.$modal.confirm('确认要"' + text + '""' + row.title + '"状态吗?').then(function() { + this.$modal.confirm('确认要操作' + row.title + '状态吗?').then(function() { return changetypeStatus(row.id, row.status) }).then(() => { this.$modal.msgSuccess(text + "成功") diff --git a/ruoyi-ui/src/views/system/IntegralProduct/index.vue b/ruoyi-ui/src/views/system/IntegralProduct/index.vue index 638f865..70d69af 100644 --- a/ruoyi-ui/src/views/system/IntegralProduct/index.vue +++ b/ruoyi-ui/src/views/system/IntegralProduct/index.vue @@ -661,7 +661,7 @@ export default { handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用"; this.$modal - .confirm('确认要"' + text + '""' + row.title + '"状态吗?') + .confirm('确认要操作' + row.title + '状态吗?') .then(function () { return changetypeStatus(row.id, row.status); }) @@ -706,7 +706,7 @@ export default { submitForm() { // 设置规格类型 this.form.skuType = this.skuType; - + // 处理规格信息 if (this.skuType === 2) { // 多规格模式 diff --git a/ruoyi-ui/src/views/system/QuoteMaterialType/index.vue b/ruoyi-ui/src/views/system/QuoteMaterialType/index.vue index 765f5c1..09178f2 100644 --- a/ruoyi-ui/src/views/system/QuoteMaterialType/index.vue +++ b/ruoyi-ui/src/views/system/QuoteMaterialType/index.vue @@ -297,7 +297,7 @@ export default { // 任务状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用" - this.$modal.confirm('确认要"' + text + '""' + row.title + '"状态吗?').then(function() { + this.$modal.confirm('确认要操作' + row.title + '状态吗?').then(function() { return changetypeStatus(row.id, row.status) }).then(() => { this.$modal.msgSuccess(text + "成功") diff --git a/ruoyi-ui/src/views/system/QuoteType/index.vue b/ruoyi-ui/src/views/system/QuoteType/index.vue index 4235df8..2523546 100644 --- a/ruoyi-ui/src/views/system/QuoteType/index.vue +++ b/ruoyi-ui/src/views/system/QuoteType/index.vue @@ -273,7 +273,7 @@ export default { // 任务状态修改 handleStatusChange(row) { let text = row.status === "0" ? "启用" : "停用" - this.$modal.confirm('确认要"' + text + '""' + row.title + '"状态吗?').then(function() { + this.$modal.confirm('确认要操作' + row.title + '状态吗?').then(function() { return changetypeStatus(row.id, row.status) }).then(() => { this.$modal.msgSuccess(text + "成功") diff --git a/ruoyi-ui/src/views/system/UsersWorker/index.vue b/ruoyi-ui/src/views/system/UsersWorker/index.vue index 565e72b..3a95c0a 100644 --- a/ruoyi-ui/src/views/system/UsersWorker/index.vue +++ b/ruoyi-ui/src/views/system/UsersWorker/index.vue @@ -373,6 +373,7 @@ { + // 调用API更新状态 + return changetypeStatus(row.id, newStatus); }).then(() => { - this.$modal.msgSuccess(text + "成功") - }).catch(function() { - row.status = row.status === "0" ? "1" : "0" - }) + // 成功提示 + this.$modal.msgSuccess(`${operation}成功`); + // 刷新列表以获取最新数据 + this.getList(); + }).catch((error) => { + console.error('状态更新失败:', error); + // 如果更新失败,恢复原状态 + row.status = newStatus === "1" ? "0" : "1"; + this.$message.error(`${operation}失败,请重试`); + }); }, /** 提交按钮 */ submitForm() { @@ -751,6 +769,7 @@ export default { return; } this.currentWorkerId = row.id; + this.currentWorkerMargin = parseFloat(row.margin) || 0; this.workerMarginLogDialogVisible = true; }, showWorkerLevelDialog(row) { diff --git a/ruoyi-ui/src/views/system/WorkerApply/index.vue b/ruoyi-ui/src/views/system/WorkerApply/index.vue index 3bc26d6..7d23844 100644 --- a/ruoyi-ui/src/views/system/WorkerApply/index.vue +++ b/ruoyi-ui/src/views/system/WorkerApply/index.vue @@ -50,7 +50,7 @@ 搜索 重置 - 查看待审核 + @@ -136,20 +136,20 @@ --> - - - 批量审核 - - - + + + + + + + + + + + + + + diff --git a/ruoyi-ui/src/views/system/workerMoneyLog/WorkerMoneyLogTable.vue b/ruoyi-ui/src/views/system/workerMoneyLog/WorkerMoneyLogTable.vue index c25dedb..bb91aff 100644 --- a/ruoyi-ui/src/views/system/workerMoneyLog/WorkerMoneyLogTable.vue +++ b/ruoyi-ui/src/views/system/workerMoneyLog/WorkerMoneyLogTable.vue @@ -41,6 +41,7 @@ plain icon="el-icon-lock" size="mini" + :disabled="!canLock" @click="handleLockMoney" v-hasPermi="['system:workerMoneyLog:lock']" >锁住收益 @@ -51,6 +52,7 @@ plain icon="el-icon-unlock" size="mini" + :disabled="!canLock" @click="handleUnlockMoney" v-hasPermi="['system:workerMoneyLog:unlock']" >解锁收益 @@ -61,6 +63,7 @@ plain icon="el-icon-edit-outline" size="mini" + :disabled="!canAdjust" @click="handleAdjustMoney" v-hasPermi="['system:workerMoneyLog:adjust']" >调整收益 @@ -156,15 +159,126 @@ :limit.sync="queryParams.pageSize" @pagination="getList" /> - +

暂无师傅佣金明细数据

师傅ID: {{ queryParams.workerId }}

- - + + +
+ + 请选择一条记录进行操作。锁住收益:未锁定状态 | 解锁收益:已锁定状态 | 调整收益:已锁定状态 +
+ + + + + + + + + + + + 永久锁住 + 按天数锁住 + + + + + + + + + +
+ 将锁住 {{ lockForm.count }} 条记录,总金额 ¥{{ formatMoney(lockForm.total) }} +
+
+
+ +
+ + + + + + + + +
+ 将解锁 {{ unlockForm.count }} 条记录,总金额 ¥{{ formatMoney(unlockForm.total) }} +
+
+
+ +
+ + + + + + + 奖励 + 扣除 + + + + +
+ 当前金额: ¥{{ formatMoney(adjustForm.maxPrice) }},最大可扣除: ¥{{ formatMoney(adjustForm.maxPrice) }} +
+
+ 当前金额: ¥{{ formatMoney(adjustForm.maxPrice) }},奖励后金额: ¥{{ formatMoney(adjustForm.maxPrice + (adjustForm.amount || 0)) }} +
+
+ + + +
+ +
@@ -205,13 +319,15 @@ export default { lockday: 1, ids: [], count: 0, - total: 0 + total: 0, + remark: '' }, unlockDialogVisible: false, unlockForm: { count: 0, total: 0, - ids: [] + ids: [], + remark: '' }, adjustDialogVisible: false, adjustForm: { @@ -221,6 +337,45 @@ export default { remark: '', maxPrice: 0 }, + lockLoading: false, + unlockLoading: false, + adjustLoading: false, + lockRules: { + lockType: [ + { required: true, message: '请选择锁住类型', trigger: 'change' } + ], + lockday: [ + { + validator: (rule, value, callback) => { + if (this.lockForm.lockType === 'days' && (!value || value < 1)) { + callback(new Error('按天锁住时必须输入锁住天数')); + } else { + callback(); + } + }, + trigger: 'blur' + } + ], + remark: [ + { required: true, message: '请输入锁住原因', trigger: 'blur' } + ] + }, + unlockRules: { + remark: [ + { required: true, message: '请输入解锁原因', trigger: 'blur' } + ] + }, + adjustRules: { + type: [ + { required: true, message: '请选择调整类型', trigger: 'change' } + ], + amount: [ + { required: true, message: '请输入调整金额', trigger: 'blur' } + ], + remark: [ + { required: true, message: '请输入调整原因', trigger: 'blur' } + ] + } } }, watch: { @@ -285,9 +440,20 @@ export default { this.ids = selection.map(item => item.id) this.single = selection.length!==1 this.multiple = !selection.length - this.canAdjust = selection.length === 1 && selection[0].status === 1; - this.canLock = selection.length === 1 && selection[0].status === 1; - this.canUnlock = selection.length === 1 && selection[0].status === 1; + + if (selection.length === 1) { + const selectedItem = selection[0]; + // 调整收益:只能操作已锁定的数据(status === 1) + this.canAdjust = selectedItem.status === 1; + // 锁住收益:只能操作未锁定的数据(status !== 1) + this.canLock = selectedItem.status !== 1; + // 解锁收益:只能操作已锁定的数据(status === 1) + this.canUnlock = selectedItem.status === 1; + } else { + this.canAdjust = false; + this.canLock = false; + this.canUnlock = false; + } }, handleLockMoney() { if (this.ids.length !== 1) { @@ -295,8 +461,8 @@ export default { return; } const row = this.workerMoneyLogList.find(item => item.id === this.ids[0]); - if (!row || row.status !== 1) { - this.$message.warning('只能操作冻结中的数据'); + if (!row || row.status === 1) { + this.$message.warning('只能锁住未锁定状态的数据'); return; } this.lockForm.count = 1; @@ -305,6 +471,7 @@ export default { this.lockForm.lockType = 'forever'; this.lockForm.lockday = 1; this.lockForm.ids = [row.id]; + this.lockForm.remark = ''; this.lockDialogVisible = true; }, handleUnlockMoney() { @@ -312,14 +479,17 @@ export default { this.$message.warning('请选择一条要解锁收益的数据'); return; } + console.log('开始解锁收益数据,ids:', this.ids) const row = this.workerMoneyLogList.find(item => item.id === this.ids[0]); - if (!row || row.status !== 1) { + console.log('开始解锁收益数据,ids:', row.status) + if (!row || row.status === 1) { this.$message.warning('只能操作冻结中的数据'); return; } this.unlockForm.count = 1; this.unlockForm.total = row.price; this.unlockForm.ids = [row.id]; + this.unlockForm.remark = ''; this.unlockDialogVisible = true; }, handleAdjustMoney() { @@ -338,7 +508,125 @@ export default { this.adjustForm.remark = ''; this.adjustForm.maxPrice = parseFloat(row.price) || 0; this.adjustDialogVisible = true; + }, + // 确认锁住收益 + confirmLockMoney() { + this.$refs.lockForm.validate(valid => { + if (valid) { + this.lockLoading = true; + const lockData = { + ids: this.lockForm.ids, + lockType: this.lockForm.lockType, + lockday: this.lockForm.lockType === 'days' ? this.lockForm.lockday : null, + remark: this.lockForm.remark + }; + + lockWorkerMoney(lockData).then(response => { + this.$message.success('锁住收益成功'); + this.lockDialogVisible = false; + this.getList(); // 刷新列表 + // 重置表单 + this.$nextTick(() => { + if (this.$refs.lockForm) { + this.$refs.lockForm.resetFields(); + } + }); + }).catch(error => { + console.error('锁住收益失败:', error); + this.$message.error('锁住收益失败: ' + (error.message || '未知错误')); + }).finally(() => { + this.lockLoading = false; + }); + } + }); + }, + // 确认解锁收益 + confirmUnlockMoney() { + this.$refs.unlockForm.validate(valid => { + if (valid) { + this.unlockLoading = true; + const unlockData = { + ids: this.unlockForm.ids, + remark: this.unlockForm.remark + }; + + unlockWorkerMoney(unlockData).then(response => { + this.$message.success('解锁收益成功'); + this.unlockDialogVisible = false; + this.getList(); // 刷新列表 + // 重置表单 + this.$nextTick(() => { + if (this.$refs.unlockForm) { + this.$refs.unlockForm.resetFields(); + } + }); + }).catch(error => { + console.error('解锁收益失败:', error); + this.$message.error('解锁收益失败: ' + (error.message || '未知错误')); + }).finally(() => { + this.unlockLoading = false; + }); + } + }); + }, + // 确认调整收益 + confirmAdjustMoney() { + this.$refs.adjustForm.validate(valid => { + if (valid) { + this.adjustLoading = true; + const adjustData = { + id: this.adjustForm.id, + type: this.adjustForm.type, + amount: this.adjustForm.amount, + remark: this.adjustForm.remark + }; + + adjustWorkerMoney(adjustData).then(response => { + this.$message.success('调整收益成功'); + this.adjustDialogVisible = false; + this.getList(); // 刷新列表 + // 重置表单 + this.$nextTick(() => { + if (this.$refs.adjustForm) { + this.$refs.adjustForm.resetFields(); + } + }); + }).catch(error => { + console.error('调整收益失败:', error); + this.$message.error('调整收益失败: ' + (error.message || '未知错误')); + }).finally(() => { + this.adjustLoading = false; + }); + } + }); + }, + // 取消锁住收益弹窗 + cancelLockDialog() { + this.lockDialogVisible = false; + this.$nextTick(() => { + if (this.$refs.lockForm) { + this.$refs.lockForm.resetFields(); + } + }); + }, + // 取消解锁收益弹窗 + cancelUnlockDialog() { + this.unlockDialogVisible = false; + this.$nextTick(() => { + if (this.$refs.unlockForm) { + this.$refs.unlockForm.resetFields(); + } + }); + }, + // 取消调整收益弹窗 + cancelAdjustDialog() { + this.adjustDialogVisible = false; + this.$nextTick(() => { + if (this.$refs.adjustForm) { + this.$refs.adjustForm.resetFields(); + } + }); } } } - \ No newline at end of file +