Pu Zhibing
3 天以前 25cf266e99714ac5d428e66b40ce272325c91dd8
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TUserController.java
@@ -4,29 +4,27 @@
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.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.*;
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;
@@ -36,7 +34,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import com.stylefeng.guns.modular.system.util.ExcelExportUtil;
/**
 * 用户管理控制器
@@ -118,7 +115,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 +137,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);
    }
@@ -156,8 +153,8 @@
    public Object updateBalance(@RequestParam Integer tUserId,
                                @RequestParam Integer updateType,
                                @RequestParam BigDecimal money) {
        TUser tUser = tUserService.selectById(tUserId);
        Integer objectId = ShiroKit.getUser().getObjectId();
       TUser tUser = tUserService.selectById(tUserId);
       Integer objectId = ShiroExtUtil.getUser().getObjectId();
        List<TEnterpriseWithdrawal> companyId = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", objectId));
        if(companyId.size()==0){
@@ -173,26 +170,16 @@
            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){
                    tUser.setBalance(new BigDecimal(0));
                }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());
            tUserService.updateById(tUser);
           tUser.setUpdateTime(new Date());
           tUser.setUpdateUser(ShiroExtUtil.getUser().getId());
           tUserService.updateById(tUser);
            ///   插入余额修改记录
@@ -222,39 +209,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;
@@ -269,11 +223,10 @@
                                @RequestParam String password) {
        TUser tUser = tUserService.selectById(tUserId);
        if (SinataUtil.isNotEmpty(tUser)){
//            tUser.setPassWord(MD5Util.encrypt(password));
            tUser.setPassWord(ShiroKit.md5(password, "&a.s"));
            tUser.setUpdateTime(new Date());
            tUser.setUpdateUser(ShiroKit.getUser().getId());
            tUserService.updateById(tUser);
           tUser.setUpdateTime(new Date());
           tUser.setUpdateUser(ShiroExtUtil.getUser().getId());
           tUserService.updateById(tUser);
        }
        return SUCCESS_TIP;
    }
@@ -300,9 +253,9 @@
                tUser.setState(1);
                tUser.setRemark(remark);
            }
            tUser.setUpdateTime(new Date());
            tUser.setUpdateUser(ShiroKit.getUser().getId());
            tUserService.updateById(tUser);
           tUser.setUpdateTime(new Date());
           tUser.setUpdateUser(ShiroExtUtil.getUser().getId());
           tUserService.updateById(tUser);
        }
        return SUCCESS_TIP;
    }
@@ -497,9 +450,9 @@
                    user.setPassWord(ShiroKit.md5(passWord, "&a.s"));
                    user.setState(1);
                    user.setFlag("1");
                    user.setInsertTime(new Date());
                    user.setInsertUser(ShiroKit.getUser().getId());
                    tUserService.insert(user);
                   user.setInsertTime(new Date());
                   user.setInsertUser(ShiroExtUtil.getUser().getId());
                   tUserService.insert(user);
                }
            }
        } catch (Exception e) {
@@ -597,7 +550,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<>();