From 5dacdee9b54c78372b68140e2b068d03a620eab9 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 02 七月 2025 19:00:52 +0800 Subject: [PATCH] 修改bug --- ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java | 157 +++++++++++++++++++--------------------------------- 1 files changed, 57 insertions(+), 100 deletions(-) diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java index a676abf..8bbfca0 100644 --- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java +++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java @@ -4,39 +4,39 @@ import com.baomidou.mybatisplus.plugins.Page; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.base.tips.ErrorTip; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.constant.factory.PageFactory; import com.stylefeng.guns.core.shiro.ShiroKit; -import com.stylefeng.guns.core.util.*; -import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; -import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; -import com.stylefeng.guns.modular.system.controller.util.Base64Util; -import com.stylefeng.guns.modular.system.model.*; +import com.stylefeng.guns.core.util.DateUtil; +import com.stylefeng.guns.core.util.SinataUtil; +import com.stylefeng.guns.core.util.ToolUtil; +import com.stylefeng.guns.core.util.WoUtil; +import com.stylefeng.guns.modular.system.model.TBalanceModifyRecord; +import com.stylefeng.guns.modular.system.model.TCompany; +import com.stylefeng.guns.modular.system.model.TUser; import com.stylefeng.guns.modular.system.service.*; +import com.stylefeng.guns.modular.system.util.ExcelExportUtil; import com.stylefeng.guns.modular.system.util.HttpRequestUtil; import com.stylefeng.guns.modular.system.util.PushURL; -import com.unionpay.upyzt.exception.UpyztException; -import com.unionpay.upyzt.resp.AllocationResp; import org.apache.commons.lang.time.DateUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; -import org.springframework.stereotype.Controller; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; -import org.springframework.ui.Model; import org.springframework.beans.factory.annotation.Autowired; -import com.stylefeng.guns.core.log.LogObjectHolder; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; -import com.stylefeng.guns.modular.system.util.ExcelExportUtil; /** * 用户管理控制器 @@ -47,12 +47,14 @@ @Controller @RequestMapping("/tUser") public class TUserController extends BaseController { - + private String PREFIX = "/system/tUser/"; - + @Autowired private ITUserService tUserService; - + @Resource + private ShiroExtUtil shiroExtUtil; + /** * 跳转到用户管理首页 */ @@ -60,7 +62,7 @@ public String index() { return PREFIX + "tUser.html"; } - + /** * 跳转到修改用户管理 */ @@ -118,7 +120,7 @@ endTime = timeArray[1]; } Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); - page.setRecords(tUserService.getUserList(page,beginTime,endTime,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),isAuth,state,id,nickName,phone,companyName)); + page.setRecords(tUserService.getUserList(page, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(), isAuth, state, id, nickName, phone, companyName)); return super.packForBT(page); } /** @@ -140,7 +142,7 @@ endTime = timeArray[1]; } Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); - page.setRecords(tUserService.getUserListCoupon(page,beginTime,endTime,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),isAuth,state,id,nickName,phone,companyName)); + page.setRecords(tUserService.getUserListCoupon(page, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(), isAuth, state, id, nickName, phone, companyName)); return super.packForBT(page); } @@ -157,54 +159,43 @@ @RequestParam Integer updateType, @RequestParam BigDecimal money) { TUser tUser = tUserService.selectById(tUserId); - Integer objectId = ShiroKit.getUser().getObjectId(); + Integer objectId = shiroExtUtil.getUser().getObjectId(); - List<TEnterpriseWithdrawal> companyId = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", objectId)); - if(companyId.size()==0){ - return "5000"; - } - - List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); - if(userWithdrawals.size()==0){ - return "5001"; - } - - if (SinataUtil.isNotEmpty(tUser)){ - if (1 == updateType.intValue()){ //增加 +// List<TEnterpriseWithdrawal> companyId = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", objectId)); +// if (companyId.size() == 0) { +// return "5000"; +// } +// +// List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); +// if (userWithdrawals.size() == 0) { +// return "5001"; +// } + + if (SinataUtil.isNotEmpty(tUser)) { + if (1 == updateType.intValue()) { //增加 tUser.setBalance(tUser.getBalance().add(money)); - - String allocationReq = createAllocationReq(objectId, tUserId, 1, money.doubleValue()); - if(!"ok".equals(allocationReq)){ - return allocationReq; - } - - - }else if (2 == updateType.intValue()){ //减少 - if((tUser.getBalance().subtract(money)).compareTo(new BigDecimal(0)) == -1){ + + } else if (2 == updateType.intValue()) { //减少 + if ((tUser.getBalance().subtract(money)).compareTo(new BigDecimal(0)) == -1) { tUser.setBalance(new BigDecimal(0)); - }else{ + } else { tUser.setBalance(tUser.getBalance().subtract(money)); - } - String allocationReq = createAllocationReq(objectId, tUserId, 2, money.doubleValue()); - if(!"ok".equals(allocationReq)){ - return allocationReq; } } tUser.setUpdateTime(new Date()); - tUser.setUpdateUser(ShiroKit.getUser().getId()); + tUser.setUpdateUser(shiroExtUtil.getUser().getId()); tUserService.updateById(tUser); - - + + /// 插入余额修改记录 TBalanceModifyRecord tBalanceModifyRecord = new TBalanceModifyRecord(); tBalanceModifyRecord.setCreateTime(DateUtil.parseTime(DateUtil.getTime())); tBalanceModifyRecord.setMoney(money); tBalanceModifyRecord.setType(updateType); - + Random random = new Random(); - String result=""; - for (int i=0;i<8;i++) - { + String result = ""; + for (int i = 0; i < 8; i++) { result+=random.nextInt(10); } tBalanceModifyRecord.setRecordID(result); @@ -222,39 +213,6 @@ } - public String createAllocationReq(Integer companyId,Integer userId,int type,double money){ - List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); - TUser tUser = tUserService.selectById(userId); - List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); - - AllocationReq allocationReq= new AllocationReq(); - allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); - if(type==1){ - allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); - allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); - - allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); - }else { - allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); - allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); - allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); - } - money=money*100; - allocationReq.setAmount((int)money); - allocationReq.setProductName("分账"); - allocationReq.setProductCount(1); - allocationReq.setOrderNo(ToolUtil.getRandomString(32)); - allocationReq.setOrderAmount(1l); - try { - AllocationResp allocationResp = AllocationExample.create(allocationReq); - System.out.println(allocationResp); - return "ok"; - } catch (UpyztException e) { - e.printStackTrace(); - return e.getMessage(); - } - - } @Autowired private ITBalanceModifyRecordService balanceModifyRecordService; @@ -268,11 +226,10 @@ public Object updatePassword(@RequestParam Integer tUserId, @RequestParam String password) { TUser tUser = tUserService.selectById(tUserId); - if (SinataUtil.isNotEmpty(tUser)){ -// tUser.setPassWord(MD5Util.encrypt(password)); + if (SinataUtil.isNotEmpty(tUser)) { tUser.setPassWord(ShiroKit.md5(password, "&a.s")); tUser.setUpdateTime(new Date()); - tUser.setUpdateUser(ShiroKit.getUser().getId()); + tUser.setUpdateUser(shiroExtUtil.getUser().getId()); tUserService.updateById(tUser); } return SUCCESS_TIP; @@ -286,22 +243,22 @@ public Object optUser(@RequestParam Integer tUserId,@RequestParam Integer optType,@RequestParam String remark) { TUser tUser = tUserService.selectById(tUserId); if (SinataUtil.isNotEmpty(tUser)){ - if (1 == optType.intValue()){ //冻结 + if (1 == optType.intValue()) { //冻结 tUser.setState(2); tUser.setRemark(remark); - + //增加推送 - Map<String,String> map = new HashMap<>(); + Map<String, String> map = new HashMap<>(); map.put("uid", tUser.getId().toString()); String result = HttpRequestUtil.postRequest(PushURL.freeze_user_url, map); - System.out.println("冻结用户:【userId="+tUser.getId().toString()+"】,调用接口:"+result); - - }else if (2 == optType.intValue()){ //解冻 + System.out.println("冻结用户:【userId=" + tUser.getId().toString() + "】,调用接口:" + result); + + } else if (2 == optType.intValue()) { //解冻 tUser.setState(1); tUser.setRemark(remark); } tUser.setUpdateTime(new Date()); - tUser.setUpdateUser(ShiroKit.getUser().getId()); + tUser.setUpdateUser(shiroExtUtil.getUser().getId()); tUserService.updateById(tUser); } return SUCCESS_TIP; @@ -486,9 +443,9 @@ } user.setEmergencyContact(emergencyContact); user.setEmergencyContactNumber(emergencyContactNumber); - if ("是".equals(isAuth)){ + if ("是".equals(isAuth)) { user.setIsAuth(2); - }else if ("否".equals(isAuth)){ + } else if ("否".equals(isAuth)) { user.setIsAuth(1); } user.setName(name); @@ -498,7 +455,7 @@ user.setState(1); user.setFlag("1"); user.setInsertTime(new Date()); - user.setInsertUser(ShiroKit.getUser().getId()); + user.setInsertUser(shiroExtUtil.getUser().getId()); tUserService.insert(user); } } @@ -597,7 +554,7 @@ */ @RequestMapping(value = "/outUser") public void outUser(HttpServletRequest request, HttpServletResponse response) { - List<Map<String,Object>> listMap = tUserService.getUserListNoPage(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId()); + List<Map<String, Object>> listMap = tUserService.getUserListNoPage(shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId()); // 表格数据【封装】 List<List<String>> dataList = new ArrayList<>(); -- Gitblit v1.7.1