liujie
2023-08-16 5cb1979f05446792cc33a8cb6b7aaae906da5a70
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.system.controller.general;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -14,11 +15,9 @@
import com.stylefeng.guns.modular.system.controller.util.HttpUtils;
import com.stylefeng.guns.modular.system.controller.util.TokenUtils;
import com.stylefeng.guns.modular.system.controller.util.UUIDUtil;
import com.stylefeng.guns.modular.system.dao.AccountChangeDetailMapper;
import com.stylefeng.guns.modular.system.enums.UserTypeEnum;
import com.stylefeng.guns.modular.system.model.TDriver;
import com.stylefeng.guns.modular.system.model.TDriverWork;
import com.stylefeng.guns.modular.system.model.TRechargeRecord;
import com.stylefeng.guns.modular.system.model.TRegion;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.DateUtil;
import com.stylefeng.guns.modular.system.util.RedisUtil;
@@ -36,12 +35,10 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
@@ -93,6 +90,12 @@
    @Autowired
    private ITRechargeRecordService tRechargeRecordService;
    @Autowired
    private ITSystemConfigService systemConfigService;
    @Resource
    private AccountChangeDetailMapper accountChangeDetailMapper;
    private Logger log = LoggerFactory.getLogger(this.getClass());
    /**
@@ -128,6 +131,13 @@
        TDriverResp tDriverResp = new TDriverResp();
        BeanUtils.copyProperties(tDriver,tDriverResp);
        if(Objects.nonNull(tDriverResp.getFirstCertificateTime())){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            String format1 = format.format(tDriverResp.getFirstCertificateTime());
            tDriverResp.setFirstCertificateTimeStr(format1);
        }
//        tDriverResp.setFirstCertificateTime(format.parse(format1));
        // 查询邀请人
        TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId());
        if(Objects.nonNull(tDriver1)){
@@ -160,6 +170,7 @@
        }
        model.addAttribute("item",tDriverResp);
        model.addAttribute("driver",tDriver);
        LogObjectHolder.me().set(tDriver);
        return PREFIX + "tDriver_edit.html";
    }
@@ -520,6 +531,28 @@
        tDriver.setApprovalUserId(shiroUser.getId());
        tDriver.setApprovalTime(new Date());
        tDriverService.updateById(tDriver);
        //增加积分奖励
        if(approvalStatus == 2 &&  null != tDriver.getInviterId()){
            TSystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 4));
            Integer num7 = JSON.parseObject(systemConfig.getContent()).getInteger("num7");
            TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId());
            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
            accountChangeDetail.setUserType(2);
            accountChangeDetail.setUserId(tDriver1.getId());
            accountChangeDetail.setType(2);
            accountChangeDetail.setChangeType(10);
            accountChangeDetail.setOldData(tDriver1.getIntegral().doubleValue());
            tDriver1.setIntegral(tDriver1.getIntegral() + num7);
            accountChangeDetail.setNewData(tDriver1.getIntegral().doubleValue());
            accountChangeDetail.setExplain("推荐奖励");
            accountChangeDetail.setCreateTime(new Date());
            accountChangeDetailMapper.insert(accountChangeDetail);
            tDriverService.updateById(tDriver1);
        }
        return SUCCESS_TIP;
    }
@@ -876,4 +909,17 @@
            e.printStackTrace();
        }
    }
    /**
     * 获取详情中的汇总数据查询
     * @param id
     * @param time
     * @return
     */
    @ResponseBody
    @PostMapping("/querySummaryData")
    public Object querySummaryData(Integer id, String time){
        return tDriverService.querySummaryData(id, time);
    }
}