Procházet zdrojové kódy

feat:“添加订单通知开关功能“

soobin před 1 rokem
rodič
revize
f13ccdeb5b

+ 25 - 0
src/main/java/com/szwl/controller/TAdminController.java

@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
@@ -71,6 +72,9 @@ public class TAdminController {
 
     PayFeign payFeign;
 
+    @Autowired
+    TWechatService wechatService;
+
     public TAdminController(SysRoleService sysRoleService, SysUserRoleService sysUserRoleService, TokenManager tokenManager, TAdminService tAdminService, TAdminEquipmentService tAdminEquipmentService, TMessageCodeService tMessageCodeService, TAirwallexWalletService airwallexWalletService, PayFeign payFeign) {
         this.sysRoleService = sysRoleService;
         this.sysUserRoleService = sysUserRoleService;
@@ -1100,5 +1104,26 @@ public class TAdminController {
         }
         return R.ok();
     }
+
+    @ApiOperation(value = "切换订单通知开关")
+    @GetMapping("/updateOrderNotice")
+    public ResponseModel<?> updateOrderNotice(String adminId, String orderNotice) {
+        if (StringUtils.isEmpty(adminId) || StringUtils.isEmpty(orderNotice)) {
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        // 查询是否有绑定微信
+        if (orderNotice.equals("1")) {
+            LambdaQueryWrapper<TWechat> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(TWechat::getAdminId, adminId);
+            TWechat wechat = wechatService.getOne(wrapper);
+            if (wechat == null) {
+                return R.fail(ResponseCodesEnum.A0001, "请先绑定微信");
+            }
+        }
+        TAdmin admin = tAdminService.getById(adminId);
+        admin.setOrderNotice(orderNotice);
+        tAdminService.updateById(admin);
+        return R.ok();
+    }
 }