Pu Zhibing
2025-04-02 af335bf1ef9104dc62c721e142eca790356d18b6
修改bug
18个文件已修改
4566 ■■■■ 已修改文件
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/PlatformController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/UserActivityController.java 886 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderLogisticsController.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TReassignController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/TReassignMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderLogisticsMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderPrivateCarMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TReassignMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml 2912 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/DriverActivityHistory.java 257 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITReassignService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TReassignServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/appWithdrawalRule/appWithdrawalRule.js 149 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/tOrderLogistics/tOrderLogistics.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/tOrderPrivateCar/tOrderPrivateCar.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/userActivity/userActivity.js 307 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/PlatformController.java
@@ -188,7 +188,6 @@
        }
        EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>();
        settlementDetailEntityWrapper.between("createTime", start, end);
        if (state!=null && state == 2){
            List<SettlementRecord> paymentStatus = settlementRecordService.selectList(new EntityWrapper<SettlementRecord>().eq("paymentStatus", 1));
            if(paymentStatus.size() > 0){
@@ -1784,7 +1783,6 @@
                    break;
            }
        }
        Page<Map<String,Object>> page = new PageFactory<Map<String,Object>>().defaultPage();
        List<Income> incomes = new ArrayList<>();
        List<SettlementDetail> settlementDetails = new ArrayList<>();
        if (time == 5 && !StringUtils.hasLength(insertTime)){
@@ -1803,18 +1801,20 @@
        }
        EntityWrapper<SettlementDetail> settlementDetailEntityWrapper = new EntityWrapper<>();
        settlementDetailEntityWrapper.between("createTime", start, end);
//        settlementDetailEntityWrapper.between("createTime", start, end);
        if (state!=null && state == 2){
            List<SettlementRecord> paymentStatus = settlementRecordService.selectList(new EntityWrapper<SettlementRecord>().eq("paymentStatus", 1));
            if(paymentStatus.size() > 0){
                settlementDetailEntityWrapper.in("settlementRecordId", paymentStatus.stream().map(SettlementRecord::getId).collect(Collectors.toList()));
                settlementDetailEntityWrapper.in("settlementRecordId", paymentStatus.stream().map(SettlementRecord::getId).collect(Collectors.toList()))
                        .or().isNull("settlementRecordId");
            }else{
                settlementDetailEntityWrapper.eq("settlementRecordId", 0);
            }
        }else if (state!=null && state == 1){
            List<SettlementRecord> paymentStatus = settlementRecordService.selectList(new EntityWrapper<SettlementRecord>().eq("paymentStatus", 2));
            if(paymentStatus.size() > 0){
                settlementDetailEntityWrapper.in("settlementRecordId", paymentStatus.stream().map(SettlementRecord::getId).collect(Collectors.toList()));
                settlementDetailEntityWrapper.in("settlementRecordId", paymentStatus.stream().map(SettlementRecord::getId).collect(Collectors.toList()))
                        .or().isNull("settlementRecordId");;
            }else{
                settlementDetailEntityWrapper.eq("settlementRecordId", 0);
            }
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java
@@ -1263,7 +1263,7 @@
        // 已领取司机奖励
        for (DriverActivityHistory driverActivityHistory : driverActivityHistories) {
            GrantVO grantVO = new GrantVO();
            grantVO.setInsertTime(format.format(driverActivityHistory.getInsertTime()));
            grantVO.setInsertTime(null == driverActivityHistory.getCompletionTime() ? format.format(driverActivityHistory.getInsertTime()) : format.format(driverActivityHistory.getCompletionTime()));
            grantVO.setType("司机奖励");
            grantVO.setAmount(driverActivityHistory.getMoney().toString());
            TDriver tDriver = driverMap.get(driverActivityHistory.getDriverId());
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/UserActivityController.java
@@ -1,25 +1,23 @@
package com.stylefeng.guns.modular.system.controller.general;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.page.PageInfoBT;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
@@ -37,424 +35,460 @@
@Controller
@RequestMapping("/userActivity")
public class UserActivityController extends BaseController {
    private String PREFIX = "/system/userActivity/";
    @Autowired
    private IUserActivityService userActivityService;
    @Autowired
    private IUserActivityBalanceService userActivityBalanceService;
    @Autowired
    private IUserActivityDiscount1Service userActivityDiscount1Service;
    @Autowired
    private IUserActivityInviteService userActivityInviteService;
    @Autowired
    private IUserActivityRedenvelopeService userActivityRedenvelopeService;
    @Autowired
    private IUserActivityRegisteredService userActivityRegisteredService;
    @Autowired
    private ISysCouponRecordService sysCouponRecordService;
    @Autowired
    private ISysRedPacketRecordService sysRedPacketRecordService;
    @Autowired
    private IUserCouponRecordService userCouponRecordService;
    @Autowired
    private ITUserRedPacketRecordService redPacketRecordService;
    /**
     * 跳转领取统计
     * @return
     */
    @RequestMapping("/receiveRecord")
    public String receiveRecord(Model model,Integer activityId){
        model.addAttribute("activityId",activityId);
        UserActivity userActivity = userActivityService.selectById(activityId);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId",activityId));
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId",activityId));
        UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId",activityId));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId",activityId));
        if(SinataUtil.isNotEmpty(userActivityRegistered)){
            model.addAttribute("userActivityRegisteredId",userActivityRegistered.getId());
        }else{
            model.addAttribute("userActivityRegisteredId",0);
        }
        if(SinataUtil.isNotEmpty(userActivityInvite)){
            model.addAttribute("userActivityInviteId",userActivityInvite.getId());
        }else{
            model.addAttribute("userActivityInviteId",0);
        }
        if(SinataUtil.isNotEmpty(userActivityDiscount1)){
            model.addAttribute("userActivityDiscount1Id",userActivityDiscount1.getId());
        }else{
            model.addAttribute("userActivityDiscount1Id",0);
        }
        if(SinataUtil.isNotEmpty(userActivityRedenvelope)){
            model.addAttribute("userActivityRedenvelopeId",userActivityRedenvelope.getId());
        }else{
            model.addAttribute("userActivityRedenvelopeId",0);
        }
        return PREFIX + "receiveRecord.html";
    }
    @RequestMapping(value = "/receiveRecordDetail")
    @ResponseBody
    public Object receiveRecordDetail(String createTime,Integer activityId) {
        String startTimes = null;
        String endTimes = null;
        if (SinataUtil.isNotEmpty(createTime)){
            String[] timeArray = createTime.split(" - ");
            startTimes = timeArray[0];
            endTimes = timeArray[1];
        }else{
            UserActivity userActivity = userActivityService.selectById(activityId);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            startTimes=sdf.format(userActivity.getStartTime());
            endTimes=sdf.format(userActivity.getEndTime());
        }
        Map<String,Object> map = new HashMap<>();
        Double totalMOney=0d;
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId",activityId));
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId",activityId));
        UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId",activityId));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId",activityId));
        if(SinataUtil.isNotEmpty(userActivityRegistered)){
            Map<String,Object> resultMap = userCouponRecordService.getCouponStatic(startTimes,endTimes,userActivityRegistered.getId(),2);
            totalMOney+=Double.parseDouble(resultMap.get("money").toString());
            map.put("userActivityRegisteredMoney",resultMap.get("money"));
            map.put("userActivityRegisteredNumber",resultMap.get("number"));
            map.put("userActivityRegisteredUseMoney",resultMap.get("useMoney"));
        }else{
            map.put("userActivityRegisteredMoney",0);
            map.put("userActivityRegisteredNumber",0);
            map.put("userActivityRegisteredUseMoney",0);
        }
        if(SinataUtil.isNotEmpty(userActivityInvite)){
            Map<String,Object> resultMap = userCouponRecordService.getCouponStatic(startTimes,endTimes,userActivityInvite.getId(),3);
            totalMOney+=Double.parseDouble(resultMap.get("money").toString());
            map.put("userActivityInviteMoney",resultMap.get("money"));
            map.put("userActivityInviteNumber",resultMap.get("number"));
            map.put("userActivityInviteUseMoney",resultMap.get("useMoney"));
        }else{
            map.put("userActivityInviteMoney",0);
            map.put("userActivityInviteNumber",0);
            map.put("userActivityInviteUseMoney",0);
        }
        if(SinataUtil.isNotEmpty(userActivityDiscount1)){
            // 专车
            Map<String,Object> resultMap = userCouponRecordService.getDiscountStatic(startTimes,endTimes,userActivityDiscount1.getId());
            BigDecimal bigDecimal = new BigDecimal(resultMap.get("money").toString());
            String string = resultMap.get("number").toString();
            Integer i = Integer.valueOf(string);
            // 小件物流
            Map<String,Object> resultMap1 = userCouponRecordService.getDiscountStatic1(startTimes,endTimes,userActivityDiscount1.getId());
            BigDecimal bigDecimal1 = new BigDecimal(resultMap1.get("money").toString());
            String string1 = resultMap1.get("number").toString();
            Integer i1 = Integer.valueOf(string1);
            BigDecimal add = bigDecimal.add(bigDecimal1);
            i +=i1;
            map.put("userActivityDiscount1Money",add);
            map.put("userActivityDiscount1Number",i);
        }else{
            map.put("userActivityDiscount1Money",0);
            map.put("userActivityDiscount1Number",0);
        }
        if(SinataUtil.isNotEmpty(userActivityRedenvelope)){
            Map<String,Object> resultMap = userCouponRecordService.getRedStatic(startTimes,endTimes,userActivityRedenvelope.getId());
            totalMOney+=Double.parseDouble(resultMap.get("money").toString());
            map.put("userActivityRedenvelopeMoney",resultMap.get("money"));
            map.put("userActivityRedenvelopeNumber",resultMap.get("number"));
            map.put("userActivityRedenvelopeUseMoney",resultMap.get("useMoney"));
        }else{
            map.put("userActivityRedenvelopeMoney",0);
            map.put("userActivityRedenvelopeNumber",0);
            map.put("userActivityRedenvelopeUseMoney",0);
        }
        Map<String,Object> resultMap = userCouponRecordService.getRegStatic(startTimes,endTimes,activityId);
        totalMOney+=Double.parseDouble(resultMap.get("money").toString());
        map.put("totalMOney",totalMOney);
        return map;
    }
    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "userActivity.html";
    }
    /**
     * 跳转添加注册送优惠券页面
     * @return
     */
    @RequestMapping("addRegist")
    public String addRegist() {
        return PREFIX + "addRegist.html";
    }
    /**
     * 跳转红包选择页面
     * @return
     */
    @RequestMapping("/sysRedPacketRecord")
    public String sysRedPacketRecord() {
        return PREFIX + "sysRedPacketRecord.html";
    }
    /**
     * 跳转到选择优惠券页面
     * @return
     */
    @RequestMapping("/sysCouponRecord")
    public String sysCouponRecord() {
        return PREFIX + "sysCouponRecord.html";
    }
    @RequestMapping("/sysCouponRecord1")
    public String sysCouponRecord1() {
        return PREFIX + "sysCouponRecord1.html";
    }
    @RequestMapping("/sysCouponRecord2")
    public String sysCouponRecord2(Model model,Integer type) {
        model.addAttribute("type",type);
        return PREFIX + "sysCouponRecord2.html";
    }
    /**
     * 跳转到添加
     */
    @RequestMapping("/userActivity_add")
    public String userActivityAdd() {
        return PREFIX + "userActivity_add.html";
    }
    /**
     * 跳转到修改
     */
    @RequestMapping("/userActivity_update/{userActivityId}")
    public String userActivityUpdate(@PathVariable Integer userActivityId, Model model) {
        UserActivity userActivity = userActivityService.selectById(userActivityId);
        model.addAttribute("item",userActivity);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item1",userActivityRegistered);
        if(userActivityRegistered!=null){
            model.addAttribute("item1Coupon",sysCouponRecordService.selectById(userActivityRegistered.getCouponId()));
        }
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item2",userActivityInvite);
        if(userActivityInvite!=null){
            model.addAttribute("item2Coupon",sysCouponRecordService.selectById(userActivityInvite.getCouponId()));
        }
        List<UserActivityBalance> balanceInfoList = userActivityBalanceService.selectList(new EntityWrapper<UserActivityBalance>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("balanceInfoList",balanceInfoList);
        model.addAttribute("item4",userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId",userActivity.getId())));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item5",userActivityRedenvelope);
        if(userActivityRedenvelope!=null){
            model.addAttribute("item5Red",sysRedPacketRecordService.selectById(userActivityRedenvelope.getRedEnvelopeId()));
        }
        LogObjectHolder.me().set(userActivity);
        return PREFIX + "userActivity_edit.html";
    }
    /**
     * 获取列表
     */
    @RequestMapping(value = "/blanceList")
    @ResponseBody
    public Object blanceList(String createTime,Integer activityId) {
        ShiroUser user = ShiroKit.getUser();
        String beginTime = null;
        String endTime = null;
        if (SinataUtil.isNotEmpty(createTime)){
            String[] timeArray = createTime.split(" - ");
            beginTime = timeArray[0];
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(userCouponRecordService.getBlanceList(page,beginTime,endTime,activityId));
        return super.packForBT(page);
    }
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String createTime,String name,Integer status, Integer offset, Integer limit) {
        Date startTimes = null;
        Date endTimes = null;
        if (SinataUtil.isNotEmpty(createTime)){
            String[] timeArray = createTime.split(" - ");
            startTimes = DateUtil.getDate_str3(timeArray[0]+" 00:00:00");
            endTimes = DateUtil.getDate_str3(timeArray[1]+" 23:59:59");
        }
        Integer uid = ShiroKit.getUser().getId();
        Map<String, Object> map = userActivityService.queryUserActivityList(uid, startTimes, endTimes, name, status, offset, limit);
        return map;
    }
    /**
     *
     * @param name 活动时间
     * @param startTime  时间区间
     * @param registCouponId 注册活动-优惠券id
     * @param registEnable 注册活动-是否启动(1=不启动,2=启动)
     * @param registNumber 注册活动-优惠券数量
     * @param registEffective 注册活动-优惠券有效期
     * @param inviteCouponId 邀请活动-优惠券id
     * @param inviteEnable 邀请活动-是否启动(1=不启动,2=启动)
     * @param inviteNumber 邀请活动-优惠券数量
     * @param inviteEffective 邀请活动-优惠券有效期
     * @param balanceEnable 充值活动-是否启动(1=不启动,2=启动)
     * @param balanceInfo 充值活动-详情
     * @param discountEnable 折扣活动-是否启动(1=不启动,2=启动)
     * @param discountSpecial 折扣活动-专车
     * @param discountTaxi 折扣活动-出租车
     * @param discountLogistics 折扣活动-小件物流
     * @param redenvelopeId -红包活动-红包id
     * @param redenvelopeEnable 红包活动-是否启动(1=不启动,2=启动)
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(String name,String startTime,Integer registCouponId,
                      Integer registEnable,Integer registNumber,Integer registEffective,
                      Integer inviteCouponId,Integer inviteEnable,Integer inviteNumber,Integer inviteEffective,
                      Integer balanceEnable,String balanceInfo,
                      Integer discountEnable,Double discountSpecial,Double discountTaxi,Double discountLogistics,
                      Integer redenvelopeId,Integer redenvelopeEnable, Double registerPrice, Double invitationPrice, Double redPrice,Double discountDistance,Integer discountOrderNum) {
        userActivityService.insertOrUpdate(null,name,startTime, registCouponId,
                 registEnable, registNumber, registEffective,
                 inviteCouponId, inviteEnable, inviteNumber, inviteEffective,
                 balanceEnable, balanceInfo,
                 discountEnable, discountSpecial, discountTaxi, discountLogistics,
                 redenvelopeId, redenvelopeEnable, registerPrice, invitationPrice, redPrice,discountDistance,discountOrderNum);
        return SUCCESS_TIP;
    }
    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer userActivityId) {
        userActivityService.deleteById(userActivityId);
        return SUCCESS_TIP;
    }
    /**
     *
     * @param name 活动时间
     * @param startTime  时间区间
     * @param registCouponId 注册活动-优惠券id
     * @param registEnable 注册活动-是否启动(1=不启动,2=启动)
     * @param registNumber 注册活动-优惠券数量
     * @param registEffective 注册活动-优惠券有效期
     * @param inviteCouponId 邀请活动-优惠券id
     * @param inviteEnable 邀请活动-是否启动(1=不启动,2=启动)
     * @param inviteNumber 邀请活动-优惠券数量
     * @param inviteEffective 邀请活动-优惠券有效期
     * @param balanceEnable 充值活动-是否启动(1=不启动,2=启动)
     * @param balanceInfo 充值活动-详情
     * @param discountEnable 折扣活动-是否启动(1=不启动,2=启动)
     * @param discountSpecial 折扣活动-专车
     * @param discountTaxi 折扣活动-出租车
     * @param discountLogistics 折扣活动-小件物流
     * @param redenvelopeId -红包活动-红包id
     * @param redenvelopeEnable 红包活动-是否启动(1=不启动,2=启动)
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Integer id,String name,String startTime,Integer registCouponId,
                         Integer registEnable,Integer registNumber,Integer registEffective,
                         Integer inviteCouponId,Integer inviteEnable,Integer inviteNumber,Integer inviteEffective,
                         Integer balanceEnable,String balanceInfo,
                         Integer discountEnable,Double discountSpecial,Double discountTaxi,Double discountLogistics,
                         Integer redenvelopeId,Integer redenvelopeEnable, Double registerPrice, Double invitationPrice, Double redPrice,Double discountDistance,Integer discountOrderNum) {
        userActivityService.insertOrUpdate(id,name,startTime, registCouponId,
                registEnable, registNumber, registEffective,
                inviteCouponId, inviteEnable, inviteNumber, inviteEffective,
                balanceEnable, balanceInfo,
                discountEnable, discountSpecial, discountTaxi, discountLogistics,
                redenvelopeId, redenvelopeEnable, registerPrice, invitationPrice, redPrice,discountDistance,discountOrderNum);
        return SUCCESS_TIP;
    }
    /**
     * 修改状态
     * @param driverActivity
     * @return
     */
    @RequestMapping(value = "/updateStatus")
    @ResponseBody
    public Object updateStatus(UserActivity driverActivity) {
        userActivityService.updateById(driverActivity);
        return SUCCESS_TIP;
    }
    /**
     * 详情
     */
    @RequestMapping(value = "/userActivity_detail/{userActivityId}")
    public Object detail(@PathVariable("userActivityId") Integer userActivityId,Model model) {
        UserActivity userActivity = userActivityService.selectById(userActivityId);
        model.addAttribute("item",userActivity);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item1",userActivityRegistered);
        if(userActivityRegistered!=null){
            model.addAttribute("item1Coupon",sysCouponRecordService.selectById(userActivityRegistered.getCouponId()));
        }
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item2",userActivityInvite);
        if(userActivityInvite!=null){
            model.addAttribute("item2Coupon",sysCouponRecordService.selectById(userActivityInvite.getCouponId()));
        }
        List<UserActivityBalance> balanceInfoList = userActivityBalanceService.selectList(new EntityWrapper<UserActivityBalance>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("balanceInfoList",balanceInfoList);
        model.addAttribute("item4",userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId",userActivity.getId())));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId",userActivity.getId()));
        model.addAttribute("item5",userActivityRedenvelope);
        if(userActivityRedenvelope!=null){
            model.addAttribute("item5Red",sysRedPacketRecordService.selectById(userActivityRedenvelope.getRedEnvelopeId()));
        }
        return PREFIX + "userActivity_detail.html";
    }
    /**
     * 跳转到立即处理页面
     */
    @RequestMapping("/userActivity_immediately/{id}")
    public String userActivityImmediately(@PathVariable Integer id, Model model) {
        model.addAttribute("id",id);
        return PREFIX + "userActivity_immediately.html";
    }
    /**
     * 立即处理操作
     */
    @RequestMapping(value = "/immediately")
    @ResponseBody
    public Object immediately(@RequestParam Integer id,@RequestParam Integer state,@RequestParam String remark) {
        UserActivity userActivity = userActivityService.selectById(id);
        if (SinataUtil.isNotEmpty(userActivity)){
            userActivity.setStatus(state);
            userActivity.setRemark(remark);
            userActivityService.updateById(userActivity);
        }
        return SUCCESS_TIP;
    }
    private String PREFIX = "/system/userActivity/";
    @Autowired
    private IUserActivityService userActivityService;
    @Autowired
    private IUserActivityBalanceService userActivityBalanceService;
    @Autowired
    private IUserActivityDiscount1Service userActivityDiscount1Service;
    @Autowired
    private IUserActivityInviteService userActivityInviteService;
    @Autowired
    private IUserActivityRedenvelopeService userActivityRedenvelopeService;
    @Autowired
    private IUserActivityRegisteredService userActivityRegisteredService;
    @Autowired
    private ISysCouponRecordService sysCouponRecordService;
    @Autowired
    private ISysRedPacketRecordService sysRedPacketRecordService;
    @Autowired
    private IUserCouponRecordService userCouponRecordService;
    @Autowired
    private ITUserRedPacketRecordService redPacketRecordService;
    /**
     * 跳转领取统计
     *
     * @return
     */
    @RequestMapping("/receiveRecord")
    public String receiveRecord(Model model, Integer activityId) {
        model.addAttribute("activityId", activityId);
        UserActivity userActivity = userActivityService.selectById(activityId);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId", activityId));
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId", activityId));
        UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId", activityId));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId", activityId));
        if (SinataUtil.isNotEmpty(userActivityRegistered)) {
            model.addAttribute("userActivityRegisteredId", userActivityRegistered.getId());
        } else {
            model.addAttribute("userActivityRegisteredId", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityInvite)) {
            model.addAttribute("userActivityInviteId", userActivityInvite.getId());
        } else {
            model.addAttribute("userActivityInviteId", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityDiscount1)) {
            model.addAttribute("userActivityDiscount1Id", userActivityDiscount1.getId());
        } else {
            model.addAttribute("userActivityDiscount1Id", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityRedenvelope)) {
            model.addAttribute("userActivityRedenvelopeId", userActivityRedenvelope.getId());
        } else {
            model.addAttribute("userActivityRedenvelopeId", 0);
        }
        return PREFIX + "receiveRecord.html";
    }
    @RequestMapping(value = "/receiveRecordDetail")
    @ResponseBody
    public Object receiveRecordDetail(String createTime, Integer activityId) {
        String startTimes = null;
        String endTimes = null;
        if (SinataUtil.isNotEmpty(createTime)) {
            String[] timeArray = createTime.split(" - ");
            startTimes = timeArray[0];
            endTimes = timeArray[1];
        } else {
            UserActivity userActivity = userActivityService.selectById(activityId);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            startTimes = sdf.format(userActivity.getStartTime());
            endTimes = sdf.format(userActivity.getEndTime());
        }
        Map<String, Object> map = new HashMap<>();
        Double totalMOney = 0d;
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId", activityId));
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId", activityId));
        UserActivityDiscount1 userActivityDiscount1 = userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId", activityId));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId", activityId));
        if (SinataUtil.isNotEmpty(userActivityRegistered)) {
            Map<String, Object> resultMap = userCouponRecordService.getCouponStatic(startTimes, endTimes, userActivityRegistered.getId(), 2);
            if (null != resultMap) {
                totalMOney += Double.parseDouble(resultMap.get("money").toString());
                map.put("userActivityRegisteredMoney", resultMap.get("money"));
                map.put("userActivityRegisteredNumber", resultMap.get("number"));
                map.put("userActivityRegisteredUseMoney", resultMap.get("useMoney"));
            } else {
                map.put("userActivityRegisteredMoney", 0);
                map.put("userActivityRegisteredNumber", 0);
                map.put("userActivityRegisteredUseMoney", 0);
            }
        } else {
            map.put("userActivityRegisteredMoney", 0);
            map.put("userActivityRegisteredNumber", 0);
            map.put("userActivityRegisteredUseMoney", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityInvite)) {
            Map<String, Object> resultMap = userCouponRecordService.getCouponStatic(startTimes, endTimes, userActivityInvite.getId(), 3);
            if (null != resultMap) {
                totalMOney += Double.parseDouble(resultMap.get("money").toString());
                map.put("userActivityInviteMoney", resultMap.get("money"));
                map.put("userActivityInviteNumber", resultMap.get("number"));
                map.put("userActivityInviteUseMoney", resultMap.get("useMoney"));
            } else {
                map.put("userActivityInviteMoney", 0);
                map.put("userActivityInviteNumber", 0);
                map.put("userActivityInviteUseMoney", 0);
            }
        } else {
            map.put("userActivityInviteMoney", 0);
            map.put("userActivityInviteNumber", 0);
            map.put("userActivityInviteUseMoney", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityDiscount1)) {
            // 专车
            Map<String, Object> resultMap = userCouponRecordService.getDiscountStatic(startTimes, endTimes, userActivityDiscount1.getId());
            BigDecimal bigDecimal = new BigDecimal(resultMap.get("money").toString());
            String string = resultMap.get("number").toString();
            Integer i = Integer.valueOf(string);
            // 小件物流
            Map<String, Object> resultMap1 = userCouponRecordService.getDiscountStatic1(startTimes, endTimes, userActivityDiscount1.getId());
            if (null != resultMap1) {
                BigDecimal bigDecimal1 = new BigDecimal(resultMap1.get("money").toString());
                String string1 = resultMap1.get("number").toString();
                Integer i1 = Integer.valueOf(string1);
                BigDecimal add = bigDecimal.add(bigDecimal1);
                i += i1;
                map.put("userActivityDiscount1Money", add);
                map.put("userActivityDiscount1Number", i);
            } else {
                map.put("userActivityDiscount1Money", 0);
                map.put("userActivityDiscount1Number", 0);
            }
        } else {
            map.put("userActivityDiscount1Money", 0);
            map.put("userActivityDiscount1Number", 0);
        }
        if (SinataUtil.isNotEmpty(userActivityRedenvelope)) {
            Map<String, Object> resultMap = userCouponRecordService.getRedStatic(startTimes, endTimes, userActivityRedenvelope.getId());
            if (null != resultMap) {
                totalMOney += Double.parseDouble(resultMap.get("money").toString());
                map.put("userActivityRedenvelopeMoney", resultMap.get("money"));
                map.put("userActivityRedenvelopeNumber", resultMap.get("number"));
                map.put("userActivityRedenvelopeUseMoney", resultMap.get("useMoney"));
            } else {
                map.put("userActivityRedenvelopeMoney", 0);
                map.put("userActivityRedenvelopeNumber", 0);
                map.put("userActivityRedenvelopeUseMoney", 0);
            }
        } else {
            map.put("userActivityRedenvelopeMoney", 0);
            map.put("userActivityRedenvelopeNumber", 0);
            map.put("userActivityRedenvelopeUseMoney", 0);
        }
        Map<String, Object> resultMap = userCouponRecordService.getRegStatic(startTimes, endTimes, activityId);
        totalMOney += Double.parseDouble(resultMap.get("money").toString());
        map.put("totalMOney", totalMOney);
        return map;
    }
    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "userActivity.html";
    }
    /**
     * 跳转添加注册送优惠券页面
     *
     * @return
     */
    @RequestMapping("addRegist")
    public String addRegist() {
        return PREFIX + "addRegist.html";
    }
    /**
     * 跳转红包选择页面
     *
     * @return
     */
    @RequestMapping("/sysRedPacketRecord")
    public String sysRedPacketRecord() {
        return PREFIX + "sysRedPacketRecord.html";
    }
    /**
     * 跳转到选择优惠券页面
     *
     * @return
     */
    @RequestMapping("/sysCouponRecord")
    public String sysCouponRecord() {
        return PREFIX + "sysCouponRecord.html";
    }
    @RequestMapping("/sysCouponRecord1")
    public String sysCouponRecord1() {
        return PREFIX + "sysCouponRecord1.html";
    }
    @RequestMapping("/sysCouponRecord2")
    public String sysCouponRecord2(Model model, Integer type) {
        model.addAttribute("type", type);
        return PREFIX + "sysCouponRecord2.html";
    }
    /**
     * 跳转到添加
     */
    @RequestMapping("/userActivity_add")
    public String userActivityAdd() {
        return PREFIX + "userActivity_add.html";
    }
    /**
     * 跳转到修改
     */
    @RequestMapping("/userActivity_update/{userActivityId}")
    public String userActivityUpdate(@PathVariable Integer userActivityId, Model model) {
        UserActivity userActivity = userActivityService.selectById(userActivityId);
        model.addAttribute("item", userActivity);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item1", userActivityRegistered);
        if (userActivityRegistered != null) {
            model.addAttribute("item1Coupon", sysCouponRecordService.selectById(userActivityRegistered.getCouponId()));
        }
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item2", userActivityInvite);
        if (userActivityInvite != null) {
            model.addAttribute("item2Coupon", sysCouponRecordService.selectById(userActivityInvite.getCouponId()));
        }
        List<UserActivityBalance> balanceInfoList = userActivityBalanceService.selectList(new EntityWrapper<UserActivityBalance>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("balanceInfoList", balanceInfoList);
        model.addAttribute("item4", userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId", userActivity.getId())));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item5", userActivityRedenvelope);
        if (userActivityRedenvelope != null) {
            model.addAttribute("item5Red", sysRedPacketRecordService.selectById(userActivityRedenvelope.getRedEnvelopeId()));
        }
        LogObjectHolder.me().set(userActivity);
        return PREFIX + "userActivity_edit.html";
    }
    /**
     * 获取列表
     */
    @RequestMapping(value = "/blanceList")
    @ResponseBody
    public Object blanceList(String createTime, Integer activityId) {
        ShiroUser user = ShiroKit.getUser();
        String beginTime = null;
        String endTime = null;
        if (SinataUtil.isNotEmpty(createTime)) {
            String[] timeArray = createTime.split(" - ");
            beginTime = timeArray[0];
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(userCouponRecordService.getBlanceList(page, beginTime, endTime, activityId));
        return super.packForBT(page);
    }
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String createTime, String name, Integer status, Integer offset, Integer limit) {
        Date startTimes = null;
        Date endTimes = null;
        if (SinataUtil.isNotEmpty(createTime)) {
            String[] timeArray = createTime.split(" - ");
            startTimes = DateUtil.getDate_str3(timeArray[0] + " 00:00:00");
            endTimes = DateUtil.getDate_str3(timeArray[1] + " 23:59:59");
        }
        Integer uid = ShiroKit.getUser().getId();
        Map<String, Object> map = userActivityService.queryUserActivityList(uid, startTimes, endTimes, name, status, offset, limit);
        return map;
    }
    /**
     * @param name              活动时间
     * @param startTime         时间区间
     * @param registCouponId    注册活动-优惠券id
     * @param registEnable      注册活动-是否启动(1=不启动,2=启动)
     * @param registNumber      注册活动-优惠券数量
     * @param registEffective   注册活动-优惠券有效期
     * @param inviteCouponId    邀请活动-优惠券id
     * @param inviteEnable      邀请活动-是否启动(1=不启动,2=启动)
     * @param inviteNumber      邀请活动-优惠券数量
     * @param inviteEffective   邀请活动-优惠券有效期
     * @param balanceEnable     充值活动-是否启动(1=不启动,2=启动)
     * @param balanceInfo       充值活动-详情
     * @param discountEnable    折扣活动-是否启动(1=不启动,2=启动)
     * @param discountSpecial   折扣活动-专车
     * @param discountTaxi      折扣活动-出租车
     * @param discountLogistics 折扣活动-小件物流
     * @param redenvelopeId     -红包活动-红包id
     * @param redenvelopeEnable 红包活动-是否启动(1=不启动,2=启动)
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(String name, String startTime, Integer registCouponId,
                      Integer registEnable, Integer registNumber, Integer registEffective,
                      Integer inviteCouponId, Integer inviteEnable, Integer inviteNumber, Integer inviteEffective,
                      Integer balanceEnable, String balanceInfo,
                      Integer discountEnable, Double discountSpecial, Double discountTaxi, Double discountLogistics,
                      Integer redenvelopeId, Integer redenvelopeEnable, Double registerPrice, Double invitationPrice, Double redPrice, Double discountDistance, Integer discountOrderNum) {
        userActivityService.insertOrUpdate(null, name, startTime, registCouponId,
                registEnable, registNumber, registEffective,
                inviteCouponId, inviteEnable, inviteNumber, inviteEffective,
                balanceEnable, balanceInfo,
                discountEnable, discountSpecial, discountTaxi, discountLogistics,
                redenvelopeId, redenvelopeEnable, registerPrice, invitationPrice, redPrice, discountDistance, discountOrderNum);
        return SUCCESS_TIP;
    }
    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer userActivityId) {
        userActivityService.deleteById(userActivityId);
        return SUCCESS_TIP;
    }
    /**
     * @param name              活动时间
     * @param startTime         时间区间
     * @param registCouponId    注册活动-优惠券id
     * @param registEnable      注册活动-是否启动(1=不启动,2=启动)
     * @param registNumber      注册活动-优惠券数量
     * @param registEffective   注册活动-优惠券有效期
     * @param inviteCouponId    邀请活动-优惠券id
     * @param inviteEnable      邀请活动-是否启动(1=不启动,2=启动)
     * @param inviteNumber      邀请活动-优惠券数量
     * @param inviteEffective   邀请活动-优惠券有效期
     * @param balanceEnable     充值活动-是否启动(1=不启动,2=启动)
     * @param balanceInfo       充值活动-详情
     * @param discountEnable    折扣活动-是否启动(1=不启动,2=启动)
     * @param discountSpecial   折扣活动-专车
     * @param discountTaxi      折扣活动-出租车
     * @param discountLogistics 折扣活动-小件物流
     * @param redenvelopeId     -红包活动-红包id
     * @param redenvelopeEnable 红包活动-是否启动(1=不启动,2=启动)
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Integer id, String name, String startTime, Integer registCouponId,
                         Integer registEnable, Integer registNumber, Integer registEffective,
                         Integer inviteCouponId, Integer inviteEnable, Integer inviteNumber, Integer inviteEffective,
                         Integer balanceEnable, String balanceInfo,
                         Integer discountEnable, Double discountSpecial, Double discountTaxi, Double discountLogistics,
                         Integer redenvelopeId, Integer redenvelopeEnable, Double registerPrice, Double invitationPrice, Double redPrice, Double discountDistance, Integer discountOrderNum) {
        userActivityService.insertOrUpdate(id, name, startTime, registCouponId,
                registEnable, registNumber, registEffective,
                inviteCouponId, inviteEnable, inviteNumber, inviteEffective,
                balanceEnable, balanceInfo,
                discountEnable, discountSpecial, discountTaxi, discountLogistics,
                redenvelopeId, redenvelopeEnable, registerPrice, invitationPrice, redPrice, discountDistance, discountOrderNum);
        return SUCCESS_TIP;
    }
    /**
     * 修改状态
     *
     * @param driverActivity
     * @return
     */
    @RequestMapping(value = "/updateStatus")
    @ResponseBody
    public Object updateStatus(UserActivity driverActivity) {
        userActivityService.updateById(driverActivity);
        return SUCCESS_TIP;
    }
    /**
     * 详情
     */
    @RequestMapping(value = "/userActivity_detail/{userActivityId}")
    public Object detail(@PathVariable("userActivityId") Integer userActivityId, Model model) {
        UserActivity userActivity = userActivityService.selectById(userActivityId);
        model.addAttribute("item", userActivity);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        model.addAttribute("startTime", sdf.format(userActivity.getStartTime()));
        model.addAttribute("endTime", sdf.format(userActivity.getEndTime()));
        UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectOne(new EntityWrapper<UserActivityRegistered>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item1", userActivityRegistered);
        if (userActivityRegistered != null) {
            model.addAttribute("item1Coupon", sysCouponRecordService.selectById(userActivityRegistered.getCouponId()));
        }
        UserActivityInvite userActivityInvite = userActivityInviteService.selectOne(new EntityWrapper<UserActivityInvite>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item2", userActivityInvite);
        if (userActivityInvite != null) {
            model.addAttribute("item2Coupon", sysCouponRecordService.selectById(userActivityInvite.getCouponId()));
        }
        List<UserActivityBalance> balanceInfoList = userActivityBalanceService.selectList(new EntityWrapper<UserActivityBalance>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("balanceInfoList", balanceInfoList);
        model.addAttribute("item4", userActivityDiscount1Service.selectOne(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId", userActivity.getId())));
        UserActivityRedenvelope userActivityRedenvelope = userActivityRedenvelopeService.selectOne(new EntityWrapper<UserActivityRedenvelope>().eq("userActivityId", userActivity.getId()));
        model.addAttribute("item5", userActivityRedenvelope);
        if (userActivityRedenvelope != null) {
            model.addAttribute("item5Red", sysRedPacketRecordService.selectById(userActivityRedenvelope.getRedEnvelopeId()));
        }
        return PREFIX + "userActivity_detail.html";
    }
    /**
     * 跳转到立即处理页面
     */
    @RequestMapping("/userActivity_immediately/{id}")
    public String userActivityImmediately(@PathVariable Integer id, Model model) {
        model.addAttribute("id", id);
        return PREFIX + "userActivity_immediately.html";
    }
    /**
     * 立即处理操作
     */
    @RequestMapping(value = "/immediately")
    @ResponseBody
    public Object immediately(@RequestParam Integer id, @RequestParam Integer state, @RequestParam String remark) {
        UserActivity userActivity = userActivityService.selectById(id);
        if (SinataUtil.isNotEmpty(userActivity)) {
            userActivity.setStatus(state);
            userActivity.setRemark(remark);
            userActivityService.updateById(userActivity);
        }
        return SUCCESS_TIP;
    }
}
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderLogisticsController.java
@@ -24,6 +24,7 @@
import com.stylefeng.guns.modular.system.service.ITOrderLogisticsService;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -122,7 +123,9 @@
    @ResponseBody
    public Object cancel(@RequestParam Integer tOrderLogisticsId) {
        TOrderLogistics tOrderLogistics = tOrderLogisticsService.selectById(tOrderLogisticsId);
        if(Arrays.asList(6, 7, 8, 9, 10).contains(tOrderLogistics.getState())){
            return ERROR;
        }
        //修改之前司机状态 -- 空闲
        if(null != tOrderLogistics.getDriverId()){
            TDriver driver = itDriverService.selectById(tOrderLogistics.getDriverId());
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java
@@ -615,7 +615,9 @@
    @ResponseBody
    public Object cancel(@RequestParam Integer tOrderPrivateCarId) {
        TOrderPrivateCar tOrderPrivateCar = tOrderPrivateCarService.selectById(tOrderPrivateCarId);
        if(Arrays.asList(6, 7, 8, 9, 10).contains(tOrderPrivateCar.getState())){
            return ERROR;
        }
        //修改之前司机状态 -- 空闲
        if(null != tOrderPrivateCar.getDriverId()){
            TDriver driver = tDriverService.selectById(tOrderPrivateCar.getDriverId());
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TReassignController.java
@@ -251,7 +251,7 @@
        TReassign reassign = tReassignService.selectById(orderId);
        TOrderPrivateCar privateCar = itOrderPrivateCarService.selectById(reassign.getOrderId());
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tReassignService.getCanSelectPrivateCarDriverList(page,privateCar.getCompanyId(),name,phone));
        page.setRecords(tReassignService.getCanSelectPrivateCarDriverList(page,privateCar.getCompanyId(),privateCar.getDriverId(),name,phone));
        return super.packForBT(page);
    }
@@ -284,7 +284,7 @@
        TReassign reassign = tReassignService.selectById(orderId);
        TOrderLogistics tOrderLogistics = orderLogisticsService.selectById(reassign.getOrderId());
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tReassignService.getCanSelectSmallDriverList(page,tOrderLogistics.getCompanyId(), tOrderLogistics.getType(),name,phone));
        page.setRecords(tReassignService.getCanSelectSmallDriverList(page,tOrderLogistics.getCompanyId(), tOrderLogistics.getDriverId(), tOrderLogistics.getType(),name,phone));
        return super.packForBT(page);
    }
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/TReassignMapper.java
@@ -42,6 +42,7 @@
     */
    List<Map<String,Object>> getCanSelectPrivateCarDriverList(@Param("page") Page<Map<String, Object>> page,
                                                              @Param("companyId") Integer companyId,
                                                              @Param("driverId") Integer driverId,
                                                              @Param("name") String name,
                                                              @Param("phone") String phone);
@@ -53,6 +54,7 @@
     */
    List<Map<String,Object>> getCanSelectSmallDriverList(@Param("page") Page<Map<String, Object>> page,
                                                         @Param("companyId") Integer companyId,
                                                         @Param("driverId") Integer driverId,
                                                         @Param("type") Integer type,
                                                         @Param("name") String name,
                                                         @Param("phone") String phone);
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderLogisticsMapper.xml
@@ -77,7 +77,7 @@
        LEFT JOIN t_driver as di on di.id = ot.driverId
        LEFT JOIN t_car as ci on ci.id= ot.carId
        LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId
        left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 4 and oc.state = 2)
        left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 4)
        ) as o
        <where>
            o.isDelete = 1
@@ -148,7 +148,8 @@
        oc.money as cancelMoney,
        case when oc.payType = 1 then '手机支付'
             when oc.payType = 2 then '银行卡支付'
             when oc.payType = 3 then '余额支付' else '现金支付' end as cancelPayTypeStr
             when oc.payType = 3 then '余额支付'
             when oc.payType = 4 then '现金支付'else '' end as cancelPayTypeStr
        FROM t_order_logistics as ot
        LEFT JOIN t_user as ui on ui.id = ot.userId
        LEFT JOIN t_driver as di on di.id = ot.driverId
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderPrivateCarMapper.xml
@@ -85,7 +85,7 @@
        LEFT JOIN t_car as ci on ci.id= ot.carId
        LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId
        LEFT JOIN t_server_carmodel as sc on sc.id = ot.serverCarModelId
        left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 1 and oc.state = 2)
        left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 1)
        ) as o
        <where>
            o.isDelete = 1 and o.type = 1
@@ -175,7 +175,7 @@
        LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId
        LEFT JOIN t_company as cc on cc.id = ot.companyId
        LEFT JOIN t_server_carmodel as sc on sc.id = ot.serverCarModelId
        LEFT JOIN t_order_cancel as oc on ot.id = oc.orderId and oc.orderType = 1 and oc.state = 2
        LEFT JOIN t_order_cancel as oc on ot.id = oc.orderId and oc.orderType = 1
        LEFT JOIN (
            SELECT sum(ii.money) as money,ii.incomeId,cc.type FROM t_income as ii
            LEFT JOIN t_company as cc on ii.objectId = cc.id
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TReassignMapper.xml
@@ -90,6 +90,7 @@
        LEFT JOIN t_company as c2 on c2.id = dd.franchiseeId
        LEFT JOIN (SELECT * from t_driver_service where type = 1) as ds on ds.driverId = dd.id
        <where>
            dd.id != driverId and
            (dd.companyId = #{companyId} or dd.franchiseeId = #{companyId}) and dd.authState = 2 and dd.state = 2 and (ds.id is not null ) and (dd.carId is not null)
            <if test="name != null and name != ''">
                and CONCAT(dd.firstName, ' ', dd.lastName) LIKE CONCAT('%',#{name},'%')
@@ -109,6 +110,7 @@
        LEFT JOIN t_company as c2 on c2.id = dd.franchiseeId
        LEFT JOIN (SELECT * from t_driver_service where type = #{type}) as ds on ds.driverId = dd.id
        <where>
            dd.id != driverId and
            (dd.companyId = #{companyId} or dd.franchiseeId = #{companyId}) and dd.authState = 2 and dd.state = 2 and (ds.id is not null ) and (dd.carId is not null)
            <if test="name != null and name != ''">
                and CONCAT(dd.firstName, ' ', dd.lastName) LIKE CONCAT('%',#{name},'%')
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/UserCouponRecordMapper.xml
@@ -1,1463 +1,1457 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stylefeng.guns.modular.system.dao.UserCouponRecordMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.UserCouponRecord">
        <id column="id" property="id" />
        <result column="money" property="money" />
        <result column="fullMoney" property="fullMoney" />
        <result column="expirationTime" property="expirationTime" />
        <result column="insertTime" property="insertTime" />
        <result column="companyId" property="companyId" />
        <result column="state" property="state" />
        <result column="endTime" property="endTime"/>
        <result column="couponUseType" property="couponUseType" />
        <result column="couponType" property="couponType" />
        <result column="userId" property="userId" />
        <result column="couponId" property="couponId" />
        <result column="couponActivityId" property="couponActivityId" />
        <result column="activityType" property="activityType" />
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, money, fullMoney, expirationTime, insertTime, companyId, state, couponUseType, couponType, userId, couponId, couponActivityId, activityType
    </sql>
    <select id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
            c.id,
            c.money,
            c.fullMoney,
            c.expirationTime,
            c.insertTime,
            c.companyId,
            c.state,
            c.couponUseType,
            c.couponType,
            c.userId,
            c.couponId,
            c.couponActivityId,
            c.activityType,
            u.nickName,
            u.phone,
            if(a.id is null, if(b.id is null, if(d.id is null, if(e.id is null, '', e.endServiceTime), d.endServiceTime), b.endServiceTime), a.endServiceTime) as useTime
        FROM
            t_user_coupon_record c
        LEFT JOIN t_user u ON c.userId = u.id
        left join t_order_private_car a on (a.couponId = c.id)
        left join t_order_taxi b on (b.couponId = c.id)
        left join t_order_cross_city d on (d.couponId = c.id)
        left join t_order_logistics e on (e.couponId = c.id)
        WHERE 1=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (c.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        <if test="userName != null and userName !=''">
            and u.nickName like CONCAT('%',#{userName},'%')
        </if>
        <if test="activityType != null and activityType !=''">
            and c.activityType=#{activityType}
        </if>
        <if test="userPhone != null and userPhone !=''">
            and u.phone like CONCAT('%',#{userPhone},'%')
        </if>
        <if test="couponActivityId != null">
            and c.couponActivityId=#{couponActivityId}
        </if>
        <if test="state != null and state !=''">
            and c.state=#{state}
        </if>
    </select>
    <select  id="getRedList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
            c.id,
            c.money,
            c.endTime as expirationTime,
            c.insertTime,
            c.companyId,
            c.state,
            c.userId,
            c.redPacketActivityId,
            u.nickName,
            u.phone,
          if(a.id is null, if(b.id is null, if(d.id is null, if(e.id is null, '', e.endServiceTime), d.endServiceTime), b.endServiceTime), a.endServiceTime) as useTime
        FROM
            t_user_red_packet_record c
        LEFT JOIN t_user u ON c.userId = u.id
        left join t_order_private_car a on (a.redPacketId = c.id)
        left join t_order_taxi b on (b.redPacketId = c.id)
        left join t_order_cross_city d on (d.redPacketId = c.id)
        left join t_order_logistics e on (e.redPacketId = c.id)
        WHERE 1=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (c.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        <if test="userName != null and userName !=''">
            and u.nickName like CONCAT('%',#{userName},'%')
        </if>
        <if test="userPhone != null and userPhone !=''">
            and u.phone like CONCAT('%',#{userPhone},'%')
        </if>
        <if test="couponActivityId != null and couponActivityId !=''">
            and c.redPacketActivityId=#{couponActivityId}
        </if>
        <if test="state != null and state !=''">
            and c.state=#{state}
        </if>
    </select>
    <select id="getCouponStatic" resultType="map">
        SELECT
            IFNULL(SUM(money), 0) money,
            IFNULL(
                SUM(
                    CASE
                    WHEN state = 2 THEN
                        money
                    ELSE
                        0
                    END
                ),
                0
            ) useMoney,
            (
            select count(c.userId) from (select userId from t_user_coupon_record where activityType = #{activityType} and couponActivityId = #{activityId}
                <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
                    and (insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
                </if>
                group by userId) as c
            ) number
        FROM
            t_user_coupon_record
        WHERE
            activityType = #{activityType}
        AND couponActivityId = #{activityId}
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
    </select>
    <select id="getRedStatic" resultType="map">
        SELECT
            IFNULL(SUM(money), 0) money,
            IFNULL(
                SUM(
                    CASE
                    WHEN state = 2 THEN
                        money
                    ELSE
                        0
                    END
                ),
                0
            ) useMoney,
            COUNT(id) number
        FROM
            t_user_red_packet_record
        WHERE
         redPacketActivityId = #{activityId}
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
    </select>
    <select id="getDiscountStatic" resultType="map">
        SELECT IFNULL(SUM(discountMoney),0) money,COUNT(id) number FROM t_order_private_car WHERE activityId=#{activityId}
    </select>
    <select id="getDiscountStatic1" resultType="map">
        SELECT IFNULL(SUM(discountMoney),0) money,COUNT(id) number FROM t_order_logistics WHERE activityId=#{activityId}
    </select>
    <select id="getRegStatic" resultType="map">
        SELECT
            IFNULL(SUM(r.money), 0) money,
            IFNULL(
                SUM(
                    CASE
                    WHEN r.state = 2 THEN
                        r.money
                    ELSE
                        0
                    END
                ),
                0
            ) useMoney,
            COUNT(r.id) number
        FROM
            t_user_coupon_record r
        LEFT JOIN t_user_activity_balance u ON u.id = r.couponActivityId
        WHERE
            u.userActivityId = #{activityId} and r.activityType =4
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
    </select>
    <select id="getBlanceList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
            b.id,
            b.money,
            c1.number,c1.useMoney,c1.useNumber,
            c2.number speNumber,c2.useMoney speUserMoney,c2.useNumber speUseNumber,
            c3.number taxiNumber,c3.useMoney taxiUserMoney,c3.useNumber taxiUseNumber,
            c4.number intercityNumber,c4.useMoney intercityUserMoney,c4.useNumber intercityUseNumber
        FROM
            t_user_activity_balance b
        LEFT JOIN (
            SELECT
                couponActivityId,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            r.money
                        ELSE
                            0
                        END
                    ),
                    0
                ) useMoney,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            1
                        ELSE
                            0
                        END
                    ),
                    0
                ) useNumber,
                COUNT(r.id) number
            FROM
                t_user_coupon_record r
            WHERE
                r.activityType = 4 AND r.couponUseType=0
                <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
                    and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
                </if>
                GROUP BY couponActivityId
        ) c1 ON c1.couponActivityId=b.id
        LEFT JOIN (
            SELECT
                couponActivityId,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            r.money
                        ELSE
                            0
                        END
                    ),
                    0
                ) useMoney,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            1
                        ELSE
                            0
                        END
                    ),
                    0
                ) useNumber,
                COUNT(r.id) number
            FROM
                t_user_coupon_record r
            WHERE
                r.activityType = 4 AND r.couponUseType=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c2 ON c2.couponActivityId=b.id
        LEFT JOIN (
            SELECT
                couponActivityId,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            r.money
                        ELSE
                            0
                        END
                    ),
                    0
                ) useMoney,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            1
                        ELSE
                            0
                        END
                    ),
                    0
                ) useNumber,
                COUNT(r.id) number
            FROM
                t_user_coupon_record r
            WHERE
                r.activityType = 4 AND r.couponUseType=2
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c3 ON c3.couponActivityId=b.id
        LEFT JOIN (
            SELECT
                couponActivityId,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            r.money
                        ELSE
                            0
                        END
                    ),
                    0
                ) useMoney,
                IFNULL(
                    SUM(
                        CASE
                        WHEN r.state = 2 THEN
                            1
                        ELSE
                            0
                        END
                    ),
                    0
                ) useNumber,
                COUNT(r.id) number
            FROM
                t_user_coupon_record r
            WHERE
                r.activityType = 4 AND r.couponUseType=4
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c4 ON c4.couponActivityId=b.id
        WHERE
            b.userActivityId = #{activityId}
    </select>
    <select id="queryCouponRegister" resultType="map">
        select
        da.time,
        sum(da.receivePeople) as receivePeople,
        sum(da.giving) as giving,
        (sum(da.receivePeople) + sum(da.giving)) as receive,
        sum(da.receiveMoney) as receiveMoney,
        sum(da.usePeople) as usePeople,
        sum(da.`use`) as `use`,
        sum(da.useMoney) as useMoney
        from (
            select
            aa.time,
            count(aa.userId) as receivePeople,
            0 as giving,
            sum(aa.receiveMoney) as receiveMoney,
            0 as usePeople,
            0 as `use`,
            0 as useMoney
            from (
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
                a.userId,
                count(a.id) as receive,
                sum(a.money) as receiveMoney
                from t_user_coupon_record a
                <if test="2 == type">
                    left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                <if test="3 == type">
                    left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                <if test="4 == type">
                    left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                where a.activityType = #{type}
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
            union all
            select
            aa.time,
            0,
            0,
            0,
            count(aa.userId) as usePeople,
            sum(aa.receive) as `use`,
            sum(aa.receiveMoney) as useMoney
            from (
                select
                DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
                a.userId,
                count(a.id) as receive,
                sum(a.money) as receiveMoney
                from t_user_coupon_record a
                <if test="2 == type">
                    left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                <if test="3 == type">
                    left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                <if test="4 == type">
                    left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                    left join t_user_activity c on (b.userActivityId = c.id)
                </if>
                where a.activityType = #{type} and a.state = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
            <if test="2 == type">
                union all
                select
                aa.time,
                0,
                count(aa.userId) as giving,
                sum(aa.receiveMoney) as receiveMoney,
                0 as usePeople,
                0 as `use`,
                0 as useMoney
                from (
                    select
                    DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
                    a.userId,
                    count(a.id) as receive,
                    sum(a.money) as receiveMoney
                    from t_user_coupon_record a
                    left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
                    where a.activityType = 1
                    <if test="null != name and '' != name">
                        and b.`name` like CONCAT('%', #{name}, '%')
                    </if>
                    <if test="null != start and '' != start and null != end and '' != end">
                        and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                    </if>
                    <if test="null != companyId">
                        and b.companyId = #{companyId}
                    </if>
                    GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId
                ) as aa GROUP BY aa.time
                union all
                select
                aa.time,
                0,
                0,
                0,
                count(aa.userId) as usePeople,
                sum(aa.receive) as `use`,
                sum(aa.receiveMoney) as useMoney
                from (
                    select
                    DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
                    a.userId,
                    count(a.id) as receive,
                    sum(a.money) as receiveMoney
                    from t_user_coupon_record a
                    left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
                    where a.activityType = 1 and a.state = 2
                    <if test="null != name and '' != name">
                        and b.`name` like CONCAT('%', #{name}, '%')
                    </if>
                    <if test="null != start and '' != start and null != end and '' != end">
                        and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
                    </if>
                    <if test="null != companyId">
                        and b.companyId = #{companyId}
                    </if>
                    GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
                ) as aa GROUP BY aa.time
            </if>
          ) as da GROUP BY da.time order by da.time desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterCount" resultType="int">
        select count(time) from (
            select
            count(da.time) as time
            from (
                select
                aa.time,
                count(aa.userId) as receivePeople,
                0 as giving,
                sum(aa.receiveMoney) as receiveMoney,
                0 as usePeople,
                0 as `use`,
                0 as useMoney
                from (
                    select
                    DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
                    a.userId,
                    count(a.id) as receive,
                    sum(a.money) as receiveMoney
                    from t_user_coupon_record a
                    <if test="2 == type">
                        left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    <if test="3 == type">
                        left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    <if test="4 == type">
                        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    where activityType = #{type}
                    <if test="null != name and '' != name">
                        and c.`name` like CONCAT('%', #{name}, '%')
                    </if>
                    <if test="null != start and '' != start and null != end and '' != end">
                        and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                    </if>
                    <if test="null != companyId">
                        and c.companyId = #{companyId}
                    </if>
                    GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId
                ) as aa GROUP BY aa.time
                union all
                select
                aa.time,
                0,
                0,
                0,
                count(aa.userId) as usePeople,
                sum(aa.receive) as `use`,
                sum(aa.receiveMoney) as useMoney
                from (
                    select
                    DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
                    a.userId,
                    count(a.id) as receive,
                    sum(a.money) as receiveMoney
                    from t_user_coupon_record a
                    <if test="2 == type">
                        left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    <if test="3 == type">
                        left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    <if test="4 == type">
                        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                        left join t_user_activity c on (b.userActivityId = c.id)
                    </if>
                    where a.activityType = #{type} and a.state = 2
                    <if test="null != name and '' != name">
                        and c.`name` like CONCAT('%', #{name}, '%')
                    </if>
                    <if test="null != start and '' != start and null != end and '' != end">
                        and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
                    </if>
                    <if test="null != companyId">
                        and c.companyId = #{companyId}
                    </if>
                    GROUP BY DATE_FORMAT(endTime, '%Y-%m-%d'),userId
                ) as aa GROUP BY aa.time
                <if test="2 == type">
                    union all
                    select
                    aa.time,
                    0,
                    count(aa.userId) as giving,
                    sum(aa.receiveMoney) as receiveMoney,
                    0 as usePeople,
                    0 as `use`,
                    0 as useMoney
                    from (
                        select
                        DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
                        a.userId,
                        count(a.id) as receive,
                        sum(a.money) as receiveMoney
                        from t_user_coupon_record a
                        left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
                        where a.activityType = 1
                        <if test="null != name and '' != name">
                            and b.`name` like CONCAT('%', #{name}, '%')
                        </if>
                        <if test="null != start and '' != start and null != end and '' != end">
                            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                        </if>
                        <if test="null != companyId">
                            and b.companyId = #{companyId}
                        </if>
                        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId
                    ) as aa GROUP BY aa.time
                    union all
                    select
                    aa.time,
                    0,
                    0,
                    0,
                    count(aa.userId) as usePeople,
                    sum(aa.receive) as `use`,
                    sum(aa.receiveMoney) as useMoney
                    from (
                        select
                        DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
                        a.userId,
                        count(a.id) as receive,
                        sum(a.money) as receiveMoney
                        from t_user_coupon_record a
                        left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
                        where a.activityType = 1 and a.state = 2
                        <if test="null != name and '' != name">
                            and b.`name` like CONCAT('%', #{name}, '%')
                        </if>
                        <if test="null != start and '' != start and null != end and '' != end">
                            and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
                        </if>
                        <if test="null != companyId">
                            and b.companyId = #{companyId}
                        </if>
                        GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
                    ) as aa GROUP BY aa.time
                </if>
            ) as da GROUP BY da.time
        ) as w
    </select>
    <select id="queryCouponRegisterInfo" resultType="map">
        select
        a.id as id,
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        d.nickName as userName,
        d.phone as phone,
        a.money as money,
        DATE_FORMAT(a.expirationTime, '%Y-%m-%d %H:%i:%s') as expirationTime,
        if(a.couponType = 1, '抵扣券', '满减券') as couponType,
        if(a.state = 1, '未使用', if(a.state = 2, '已使用', '已过期')) as state,
        DATE_FORMAT(a.endTime, '%Y-%m-%d %H:%i:%s') as endTime
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        left join t_user d on (a.userId = d.id)
        where a.activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        order by a.insertTime desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterInfoCount" resultType="int">
        select
        count(a.id)
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        left join t_user d on (a.userId = d.id)
        where a.activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
    </select>
    <select id="queryCouponRegisterInfo1" resultType="map">
        select
        aa.time,
        aa.userId,
        any_value(aa.userName) as userName,
        any_value(aa.phone) as phone,
        sum(aa.amount) as amount,
        sum(aa.tyNum) as tyNum,
        sum(aa.tyUseNum) as tyUseNum,
        sum(aa.tyUseMoney) as tyUseMoney,
        sum(aa.zcNum) as zcNum,
        sum(aa.zcUseNum) as zcUseNum,
        sum(aa.zcUseMoney) as zcUseMoney,
        sum(aa.czcNum) as czcNum,
        sum(aa.czcUseNum) as czcUseNum,
        sum(aa.czcUseMoney) as czcUseMoney,
        sum(aa.kcNum) as kcNum,
        sum(aa.kcUseNum) as kcUseNum,
        sum(aa.kcUseMoney) as kcUseMoney,
        sum(aa.xjNum) as xjNum,
        sum(aa.xjUseNum) as xjUseNum,
        sum(aa.xjUseMoney) as xjUseMoney
        from (
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            sum(e.amount) as amount,
            count(a.id) as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 0
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            count(a.id) as tyUseNum,
            sum(a.money) as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 0 and a.state = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            count(a.id) as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 1
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            count(a.id) as zcUseNum,
            sum(a.money) as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 1 and a.state = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            count(a.id) as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            count(a.id) as czcUseNum,
            sum(a.money) as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 2 and a.state = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            count(a.id) as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 3
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            count(a.id) as kcUseNum,
            sum(a.money) as kcUseMoney,
            0 as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 3 and a.state = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            count(a.id) as xjNum,
            0 as xjUseNum,
            0 as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 4
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            union all
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
            a.userId as userId,
            d.nickName as userName,
            d.phone as phone,
            0 as amount,
            0 as tyNum,
            0 as tyUseNum,
            0 as tyUseMoney,
            0 as zcNum,
            0 as zcUseNum,
            0 as zcUseMoney,
            0 as czcNum,
            0 as czcUseNum,
            0 as czcUseMoney,
            0 as kcNum,
            0 as kcUseNum,
            0 as kcUseMoney,
            0 as xjNum,
            count(a.id) as xjUseNum,
            sum(a.money) as xjUseMoney
            from t_user_coupon_record a
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
            left join t_user d on (a.userId = d.id)
            left join t_payment_record e on (a.paymentRecordId = e.id)
            where a.activityType = 4 and a.couponUseType = 4 and a.state = 2
            <if test="null != name and '' != name">
                and c.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and c.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        ) as aa GROUP BY aa.time,aa.userId order by aa.time desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterInfo1Count" resultType="int">
        select
        count(w.time)
        from (
            select
            aa.time as time
            from (
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                sum(e.amount) as amount,
                count(a.id) as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 0
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                count(a.id) as tyUseNum,
                sum(a.money) as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 0 and a.state = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                count(a.id) as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 1
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                count(a.id) as zcUseNum,
                sum(a.money) as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 1 and a.state = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                count(a.id) as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                count(a.id) as czcUseNum,
                sum(a.money) as czcUseMoney,
                0 as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 2 and a.state = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                count(a.id) as kcNum,
                0 as kcUseNum,
                0 as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 3
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
                union all
                select
                DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
                a.userId as userId,
                d.nickName as userName,
                d.phone as phone,
                0 as amount,
                0 as tyNum,
                0 as tyUseNum,
                0 as tyUseMoney,
                0 as zcNum,
                0 as zcUseNum,
                0 as zcUseMoney,
                0 as czcNum,
                0 as czcUseNum,
                0 as czcUseMoney,
                0 as kcNum,
                count(a.id) as kcUseNum,
                sum(a.money) as kcUseMoney
                from t_user_coupon_record a
                left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
                left join t_user_activity c on (b.userActivityId = c.id)
                left join t_user d on (a.userId = d.id)
                left join t_payment_record e on (a.paymentRecordId = e.id)
                where a.activityType = 4 and a.couponUseType = 3 and a.state = 2
                <if test="null != name and '' != name">
                    and c.`name` like CONCAT('%', #{name}, '%')
                </if>
                <if test="null != start and '' != start and null != end and '' != end">
                    and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
                </if>
                <if test="null != companyId">
                    and c.companyId = #{companyId}
                </if>
                GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
            ) as aa GROUP BY aa.time,aa.userId
        ) w
    </select>
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.UserCouponRecord">
        <id column="id" property="id"/>
        <result column="money" property="money"/>
        <result column="fullMoney" property="fullMoney"/>
        <result column="expirationTime" property="expirationTime"/>
        <result column="insertTime" property="insertTime"/>
        <result column="companyId" property="companyId"/>
        <result column="state" property="state"/>
        <result column="endTime" property="endTime"/>
        <result column="couponUseType" property="couponUseType"/>
        <result column="couponType" property="couponType"/>
        <result column="userId" property="userId"/>
        <result column="couponId" property="couponId"/>
        <result column="couponActivityId" property="couponActivityId"/>
        <result column="activityType" property="activityType"/>
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , money, fullMoney, expirationTime, insertTime, companyId, state, couponUseType, couponType, userId, couponId, couponActivityId, activityType
    </sql>
    <select id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
        c.id,
        c.money,
        c.fullMoney,
        c.expirationTime,
        c.insertTime,
        c.companyId,
        c.state,
        c.couponUseType,
        c.couponType,
        c.userId,
        c.couponId,
        c.couponActivityId,
        c.activityType,
        u.nickName,
        u.phone,
        if(a.id is null, if(b.id is null, if(d.id is null, if(e.id is null, '', e.endServiceTime), d.endServiceTime),
        b.endServiceTime), a.endServiceTime) as useTime
        FROM
        t_user_coupon_record c
        LEFT JOIN t_user u ON c.userId = u.id
        left join t_order_private_car a on (a.couponId = c.id)
        left join t_order_taxi b on (b.couponId = c.id)
        left join t_order_cross_city d on (d.couponId = c.id)
        left join t_order_logistics e on (e.couponId = c.id)
        WHERE 1=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (c.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        <if test="userName != null and userName !=''">
            and u.nickName like CONCAT('%',#{userName},'%')
        </if>
        <if test="activityType != null and activityType !=''">
            and c.activityType=#{activityType}
        </if>
        <if test="userPhone != null and userPhone !=''">
            and u.phone like CONCAT('%',#{userPhone},'%')
        </if>
        <if test="couponActivityId != null">
            and c.couponActivityId=#{couponActivityId}
        </if>
        <if test="state != null and state !=''">
            and c.state=#{state}
        </if>
    </select>
    <select id="getRedList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
        c.id,
        c.money,
        c.endTime as expirationTime,
        c.insertTime,
        c.companyId,
        c.state,
        c.userId,
        c.redPacketActivityId,
        u.nickName,
        u.phone,
        if(a.id is null, if(b.id is null, if(d.id is null, if(e.id is null, '', e.endServiceTime), d.endServiceTime),
        b.endServiceTime), a.endServiceTime) as useTime
        FROM
        t_user_red_packet_record c
        LEFT JOIN t_user u ON c.userId = u.id
        left join t_order_private_car a on (a.redPacketId = c.id)
        left join t_order_taxi b on (b.redPacketId = c.id)
        left join t_order_cross_city d on (d.redPacketId = c.id)
        left join t_order_logistics e on (e.redPacketId = c.id)
        WHERE 1=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (c.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        <if test="userName != null and userName !=''">
            and u.nickName like CONCAT('%',#{userName},'%')
        </if>
        <if test="userPhone != null and userPhone !=''">
            and u.phone like CONCAT('%',#{userPhone},'%')
        </if>
        <if test="couponActivityId != null and couponActivityId !=''">
            and c.redPacketActivityId=#{couponActivityId}
        </if>
        <if test="state != null and state !=''">
            and c.state=#{state}
        </if>
    </select>
    <select id="getCouponStatic" resultType="map">
        select
        IFNULL(SUM(aa.money), 0) money,
        IFNULL(SUM(aa.useMoney), 0) useMoney,
        COUNT(aa.userId) as number
        from (
        SELECT
        IFNULL(SUM(money), 0) money,
        IFNULL(SUM(CASE WHEN state = 2 THEN money ELSE 0 END), 0) useMoney,
        userId
        FROM t_user_coupon_record WHERE activityType = #{activityType} AND couponActivityId = #{activityId}
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        group by userId
        ) as aa
    </select>
    <select id="getRedStatic" resultType="map">
        SELECT
        IFNULL(SUM(aa.money), 0) money,
        IFNULL(SUM(aa.useMoney), 0) useMoney,
        COUNT(aa.userId) number
        FROM
        (
        SELECT
        IFNULL(SUM(money), 0) money,
        IFNULL(SUM(CASE WHEN state = 2 THEN money ELSE 0 END ), 0) useMoney,
        userId
        FROM
        t_user_red_packet_record
        WHERE redPacketActivityId = #{activityId}
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        group by userId
        ) as aa group by aa.userId
    </select>
    <select id="getDiscountStatic" resultType="map">
        SELECT IFNULL(SUM(aa.money), 0) money, COUNT(aa.userId) number
        FROM (select IFNULL(SUM(discountMoney), 0) money, userId
              from t_order_private_car
              WHERE activityId = #{activityId}
              group by userId) as aa
    </select>
    <select id="getDiscountStatic1" resultType="map">
        SELECT IFNULL(SUM(aa.money), 0) money, COUNT(aa.userId) number
        FROM (select IFNULL(SUM(discountMoney), 0) money, userId
              from t_order_logistics
              WHERE activityId = #{activityId}
              group by userId) as aa
    </select>
    <select id="getRegStatic" resultType="map">
        SELECT
        IFNULL(SUM(r.money), 0) money,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        r.money
        ELSE
        0
        END
        ),
        0
        ) useMoney,
        COUNT(r.id) number
        FROM
        t_user_coupon_record r
        LEFT JOIN t_user_activity_balance u ON u.id = r.couponActivityId
        WHERE
        u.userActivityId = #{activityId} and r.activityType =4
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
    </select>
    <select id="getBlanceList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT
        b.id,
        b.money,
        c1.number,c1.useMoney,c1.useNumber,
        c2.number speNumber,c2.useMoney speUserMoney,c2.useNumber speUseNumber,
        c3.number taxiNumber,c3.useMoney taxiUserMoney,c3.useNumber taxiUseNumber,
        c4.number intercityNumber,c4.useMoney intercityUserMoney,c4.useNumber intercityUseNumber
        FROM
        t_user_activity_balance b
        LEFT JOIN (
        SELECT
        couponActivityId,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        r.money
        ELSE
        0
        END
        ),
        0
        ) useMoney,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        1
        ELSE
        0
        END
        ),
        0
        ) useNumber,
        COUNT(r.id) number
        FROM
        t_user_coupon_record r
        WHERE
        r.activityType = 4 AND r.couponUseType=0
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c1 ON c1.couponActivityId=b.id
        LEFT JOIN (
        SELECT
        couponActivityId,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        r.money
        ELSE
        0
        END
        ),
        0
        ) useMoney,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        1
        ELSE
        0
        END
        ),
        0
        ) useNumber,
        COUNT(r.id) number
        FROM
        t_user_coupon_record r
        WHERE
        r.activityType = 4 AND r.couponUseType=1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c2 ON c2.couponActivityId=b.id
        LEFT JOIN (
        SELECT
        couponActivityId,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        r.money
        ELSE
        0
        END
        ),
        0
        ) useMoney,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        1
        ELSE
        0
        END
        ),
        0
        ) useNumber,
        COUNT(r.id) number
        FROM
        t_user_coupon_record r
        WHERE
        r.activityType = 4 AND r.couponUseType=2
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c3 ON c3.couponActivityId=b.id
        LEFT JOIN (
        SELECT
        couponActivityId,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        r.money
        ELSE
        0
        END
        ),
        0
        ) useMoney,
        IFNULL(
        SUM(
        CASE
        WHEN r.state = 2 THEN
        1
        ELSE
        0
        END
        ),
        0
        ) useNumber,
        COUNT(r.id) number
        FROM
        t_user_coupon_record r
        WHERE
        r.activityType = 4 AND r.couponUseType=4
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (r.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        GROUP BY couponActivityId
        ) c4 ON c4.couponActivityId=b.id
        WHERE
        b.userActivityId = #{activityId}
    </select>
    <select id="queryCouponRegister" resultType="map">
        select
        da.time,
        sum(da.receivePeople) as receivePeople,
        sum(da.giving) as giving,
        (sum(da.receivePeople) + sum(da.giving)) as receive,
        sum(da.receiveMoney) as receiveMoney,
        sum(da.usePeople) as usePeople,
        sum(da.`use`) as `use`,
        sum(da.useMoney) as useMoney
        from (
        select
        aa.time,
        count(aa.userId) as receivePeople,
        0 as giving,
        sum(aa.receiveMoney) as receiveMoney,
        0 as usePeople,
        0 as `use`,
        0 as useMoney
        from (
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
        a.userId,
        count(a.id) as receive,
        sum(a.money) as receiveMoney
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="4 == type">
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        where a.activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId
        ) as aa GROUP BY aa.time
        union all
        select
        aa.time,
        0,
        0,
        0,
        count(aa.userId) as usePeople,
        sum(aa.receive) as `use`,
        sum(aa.receiveMoney) as useMoney
        from (
        select
        DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
        a.userId,
        count(a.id) as receive,
        sum(a.money) as receiveMoney
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="4 == type">
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        where a.activityType = #{type} and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
        ) as aa GROUP BY aa.time
        <if test="2 == type">
            union all
            select
            aa.time,
            0,
            count(aa.userId) as giving,
            sum(aa.receiveMoney) as receiveMoney,
            0 as usePeople,
            0 as `use`,
            0 as useMoney
            from (
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
            a.userId,
            count(a.id) as receive,
            sum(a.money) as receiveMoney
            from t_user_coupon_record a
            left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
            where a.activityType = 1
            <if test="null != name and '' != name">
                and b.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and b.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
            union all
            select
            aa.time,
            0,
            0,
            0,
            count(aa.userId) as usePeople,
            sum(aa.receive) as `use`,
            sum(aa.receiveMoney) as useMoney
            from (
            select
            DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
            a.userId,
            count(a.id) as receive,
            sum(a.money) as receiveMoney
            from t_user_coupon_record a
            left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
            where a.activityType = 1 and a.state = 2
            <if test="null != name and '' != name">
                and b.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and b.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
        </if>
        ) as da GROUP BY da.time order by da.time desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterCount" resultType="int">
        select count(time) from (
        select
        count(da.time) as time
        from (
        select
        aa.time,
        count(aa.userId) as receivePeople,
        0 as giving,
        sum(aa.receiveMoney) as receiveMoney,
        0 as usePeople,
        0 as `use`,
        0 as useMoney
        from (
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
        a.userId,
        count(a.id) as receive,
        sum(a.money) as receiveMoney
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="4 == type">
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        where activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(insertTime, '%Y-%m-%d'),userId
        ) as aa GROUP BY aa.time
        union all
        select
        aa.time,
        0,
        0,
        0,
        count(aa.userId) as usePeople,
        sum(aa.receive) as `use`,
        sum(aa.receiveMoney) as useMoney
        from (
        select
        DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
        a.userId,
        count(a.id) as receive,
        sum(a.money) as receiveMoney
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="4 == type">
            left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        where a.activityType = #{type} and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(endTime, '%Y-%m-%d'),userId
        ) as aa GROUP BY aa.time
        <if test="2 == type">
            union all
            select
            aa.time,
            0,
            count(aa.userId) as giving,
            sum(aa.receiveMoney) as receiveMoney,
            0 as usePeople,
            0 as `use`,
            0 as useMoney
            from (
            select
            DATE_FORMAT(a.insertTime, '%Y-%m-%d') as time,
            a.userId,
            count(a.id) as receive,
            sum(a.money) as receiveMoney
            from t_user_coupon_record a
            left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
            where a.activityType = 1
            <if test="null != name and '' != name">
                and b.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and b.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
            union all
            select
            aa.time,
            0,
            0,
            0,
            count(aa.userId) as usePeople,
            sum(aa.receive) as `use`,
            sum(aa.receiveMoney) as useMoney
            from (
            select
            DATE_FORMAT(a.endTime, '%Y-%m-%d') as time,
            a.userId,
            count(a.id) as receive,
            sum(a.money) as receiveMoney
            from t_user_coupon_record a
            left join t_sys_coupon_record b on (a.couponActivityId = b.id and a.activityType = 1)
            where a.activityType = 1 and a.state = 2
            <if test="null != name and '' != name">
                and b.`name` like CONCAT('%', #{name}, '%')
            </if>
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(a.endTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            <if test="null != companyId">
                and b.companyId = #{companyId}
            </if>
            GROUP BY DATE_FORMAT(a.endTime, '%Y-%m-%d'),userId
            ) as aa GROUP BY aa.time
        </if>
        ) as da GROUP BY da.time
        ) as w
    </select>
    <select id="queryCouponRegisterInfo" resultType="map">
        select
        a.id as id,
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        d.nickName as userName,
        d.phone as phone,
        a.money as money,
        DATE_FORMAT(a.expirationTime, '%Y-%m-%d %H:%i:%s') as expirationTime,
        if(a.couponType = 1, '抵扣券', '满减券') as couponType,
        if(a.state = 1, '未使用', if(a.state = 2, '已使用', '已过期')) as state,
        DATE_FORMAT(a.endTime, '%Y-%m-%d %H:%i:%s') as endTime
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        left join t_user d on (a.userId = d.id)
        where a.activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        order by a.insertTime desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterInfoCount" resultType="int">
        select
        count(a.id)
        from t_user_coupon_record a
        <if test="2 == type">
            left join t_user_activity_registered b on (a.couponActivityId = b.id and a.activityType = 2)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        <if test="3 == type">
            left join t_user_activity_invite b on (a.couponActivityId = b.id and a.activityType = 3)
            left join t_user_activity c on (b.userActivityId = c.id)
        </if>
        left join t_user d on (a.userId = d.id)
        where a.activityType = #{type}
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
    </select>
    <select id="queryCouponRegisterInfo1" resultType="map">
        select
        aa.time,
        aa.userId,
        any_value(aa.userName) as userName,
        any_value(aa.phone) as phone,
        sum(aa.amount) as amount,
        sum(aa.tyNum) as tyNum,
        sum(aa.tyUseNum) as tyUseNum,
        sum(aa.tyUseMoney) as tyUseMoney,
        sum(aa.zcNum) as zcNum,
        sum(aa.zcUseNum) as zcUseNum,
        sum(aa.zcUseMoney) as zcUseMoney,
        sum(aa.czcNum) as czcNum,
        sum(aa.czcUseNum) as czcUseNum,
        sum(aa.czcUseMoney) as czcUseMoney,
        sum(aa.kcNum) as kcNum,
        sum(aa.kcUseNum) as kcUseNum,
        sum(aa.kcUseMoney) as kcUseMoney,
        sum(aa.xjNum) as xjNum,
        sum(aa.xjUseNum) as xjUseNum,
        sum(aa.xjUseMoney) as xjUseMoney
        from (
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        sum(e.amount) as amount,
        count(a.id) as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 0
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        count(a.id) as tyUseNum,
        sum(a.money) as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 0 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        count(a.id) as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 1
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        count(a.id) as zcUseNum,
        sum(a.money) as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 1 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        count(a.id) as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        count(a.id) as czcUseNum,
        sum(a.money) as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 2 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        count(a.id) as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 3
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        count(a.id) as kcUseNum,
        sum(a.money) as kcUseMoney,
        0 as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 3 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        count(a.id) as xjNum,
        0 as xjUseNum,
        0 as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 4
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney,
        0 as xjNum,
        count(a.id) as xjUseNum,
        sum(a.money) as xjUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 4 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        ) as aa GROUP BY aa.time,aa.userId order by aa.time desc
        <if test="null != offset and null != limit">
            limit #{offset}, #{limit}
        </if>
    </select>
    <select id="queryCouponRegisterInfo1Count" resultType="int">
        select
        count(w.time)
        from (
        select
        aa.time as time
        from (
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        sum(e.amount) as amount,
        count(a.id) as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 0
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        count(a.id) as tyUseNum,
        sum(a.money) as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 0 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        count(a.id) as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 1
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        count(a.id) as zcUseNum,
        sum(a.money) as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 1 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        count(a.id) as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        count(a.id) as czcUseNum,
        sum(a.money) as czcUseMoney,
        0 as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 2 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        count(a.id) as kcNum,
        0 as kcUseNum,
        0 as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 3
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        union all
        select
        DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s') as time,
        a.userId as userId,
        d.nickName as userName,
        d.phone as phone,
        0 as amount,
        0 as tyNum,
        0 as tyUseNum,
        0 as tyUseMoney,
        0 as zcNum,
        0 as zcUseNum,
        0 as zcUseMoney,
        0 as czcNum,
        0 as czcUseNum,
        0 as czcUseMoney,
        0 as kcNum,
        count(a.id) as kcUseNum,
        sum(a.money) as kcUseMoney
        from t_user_coupon_record a
        left join t_user_activity_balance b on (a.couponActivityId = b.id and a.activityType = 4)
        left join t_user_activity c on (b.userActivityId = c.id)
        left join t_user d on (a.userId = d.id)
        left join t_payment_record e on (a.paymentRecordId = e.id)
        where a.activityType = 4 and a.couponUseType = 3 and a.state = 2
        <if test="null != name and '' != name">
            and c.`name` like CONCAT('%', #{name}, '%')
        </if>
        <if test="null != start and '' != start and null != end and '' != end">
            and DATE_FORMAT(a.insertTime, '%Y-%m-%d') between #{start} and #{end}
        </if>
        <if test="null != companyId">
            and c.companyId = #{companyId}
        </if>
        GROUP BY DATE_FORMAT(a.insertTime, '%Y-%m-%d %H:%i:%s'),a.userId
        ) as aa GROUP BY aa.time,aa.userId
        ) w
    </select>
</mapper>
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/DriverActivityHistory.java
@@ -1,10 +1,14 @@
package com.stylefeng.guns.modular.system.model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
/**
@@ -17,124 +21,137 @@
 */
@TableName("t_driver_activity_history")
public class DriverActivityHistory extends Model<DriverActivityHistory> {
    private static final long serialVersionUID = 1L;
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 活动日期
     */
    private Date day;
    /**
     * 司机id
     */
    private Integer driverId;
    /**
     * 活动类型(1=邀请司机注册,2=邀请用户注册,3=累计在线,4=订单量)
     */
    private Integer type;
    /**
     * 活动id
     */
    private Integer activityId;
    /**
     * 是否完成(1=未完成,2=已完成)
     */
    private Integer carryOut;
    /**
     * 奖励金额
     */
    private Double money;
    /**
     * 添加时间
     */
    private Date insertTime;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Date getDay() {
        return day;
    }
    public void setDay(Date day) {
        this.day = day;
    }
    public Integer getDriverId() {
        return driverId;
    }
    public void setDriverId(Integer driverId) {
        this.driverId = driverId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public Integer getActivityId() {
        return activityId;
    }
    public void setActivityId(Integer activityId) {
        this.activityId = activityId;
    }
    public Integer getCarryOut() {
        return carryOut;
    }
    public void setCarryOut(Integer carryOut) {
        this.carryOut = carryOut;
    }
    public Double getMoney() {
        return money;
    }
    public void setMoney(Double money) {
        this.money = money;
    }
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    @Override
    protected Serializable pkVal() {
        return this.id;
    }
    @Override
    public String toString() {
        return "DriverActivityHistory{" +
        "id=" + id +
        ", day=" + day +
        ", driverId=" + driverId +
        ", type=" + type +
        ", activityId=" + activityId +
        ", carryOut=" + carryOut +
        ", money=" + money +
        ", insertTime=" + insertTime +
        "}";
    }
    private static final long serialVersionUID = 1L;
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 活动日期
     */
    private Date day;
    /**
     * 司机id
     */
    private Integer driverId;
    /**
     * 活动类型(1=邀请司机注册,2=邀请用户注册,3=累计在线,4=订单量)
     */
    private Integer type;
    /**
     * 活动id
     */
    private Integer activityId;
    /**
     * 是否完成(1=未完成,2=已完成)
     */
    private Integer carryOut;
    /**
     * 奖励金额
     */
    private Double money;
    /**
     * 添加时间
     */
    private Date insertTime;
    /**
     * 完成时间
     */
    @TableField("completionTime")
    private Date completionTime;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public Date getDay() {
        return day;
    }
    public void setDay(Date day) {
        this.day = day;
    }
    public Integer getDriverId() {
        return driverId;
    }
    public void setDriverId(Integer driverId) {
        this.driverId = driverId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public Integer getActivityId() {
        return activityId;
    }
    public void setActivityId(Integer activityId) {
        this.activityId = activityId;
    }
    public Integer getCarryOut() {
        return carryOut;
    }
    public void setCarryOut(Integer carryOut) {
        this.carryOut = carryOut;
    }
    public Double getMoney() {
        return money;
    }
    public void setMoney(Double money) {
        this.money = money;
    }
    public Date getInsertTime() {
        return insertTime;
    }
    public void setInsertTime(Date insertTime) {
        this.insertTime = insertTime;
    }
    public Date getCompletionTime() {
        return completionTime;
    }
    public void setCompletionTime(Date completionTime) {
        this.completionTime = completionTime;
    }
    @Override
    protected Serializable pkVal() {
        return this.id;
    }
    @Override
    public String toString() {
        return "DriverActivityHistory{" +
                "id=" + id +
                ", day=" + day +
                ", driverId=" + driverId +
                ", type=" + type +
                ", activityId=" + activityId +
                ", carryOut=" + carryOut +
                ", money=" + money +
                ", insertTime=" + insertTime +
                "}";
    }
}
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/ITReassignService.java
@@ -41,6 +41,7 @@
     */
    List<Map<String,Object>> getCanSelectPrivateCarDriverList(@Param("page") Page<Map<String, Object>> page,
                                                              @Param("companyId") Integer companyId,
                                                              @Param("driverId") Integer driverId,
                                                              @Param("name") String name,
                                                              @Param("phone") String phone);
@@ -51,6 +52,7 @@
     */
    List<Map<String,Object>> getCanSelectSmallDriverList(@Param("page") Page<Map<String, Object>> page,
                                                              @Param("companyId") Integer companyId,
                                                         @Param("driverId") Integer driverId,
                                                         @Param("type") Integer type,
                                                              @Param("name") String name,
                                                              @Param("phone") String phone);
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TReassignServiceImpl.java
@@ -28,13 +28,13 @@
    }
    @Override
    public List<Map<String, Object>> getCanSelectPrivateCarDriverList(Page<Map<String, Object>> page, Integer companyId, String name, String phone) {
        return this.baseMapper.getCanSelectPrivateCarDriverList(page, companyId, name, phone);
    public List<Map<String, Object>> getCanSelectPrivateCarDriverList(Page<Map<String, Object>> page, Integer companyId, Integer driverId, String name, String phone) {
        return this.baseMapper.getCanSelectPrivateCarDriverList(page, companyId, driverId, name, phone);
    }
    @Override
    public List<Map<String, Object>> getCanSelectSmallDriverList(Page<Map<String, Object>> page, Integer companyId, Integer type, String name, String phone) {
        return this.baseMapper.getCanSelectSmallDriverList(page, companyId, type, name, phone);
    public List<Map<String, Object>> getCanSelectSmallDriverList(Page<Map<String, Object>> page, Integer companyId, Integer driverId, Integer type, String name, String phone) {
        return this.baseMapper.getCanSelectSmallDriverList(page, companyId, driverId, type, name, phone);
    }
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/appWithdrawalRule/appWithdrawalRule.js
@@ -2,117 +2,118 @@
 * 管理初始化
 */
var AppWithdrawalRule = {
    id: "AppWithdrawalRuleTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
    id: "AppWithdrawalRuleTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
/**
 * 初始化表格的列
 */
AppWithdrawalRule.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: 'ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
            {title: '可提现日期', field: 'weeks', visible: true, align: 'center', valign: 'middle',
                formatter: function (value, row) {
                    var btn = "";
                    if(value==1) {
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期一" onfocus="TUser.tooltip()">星期一</p>']
                    }else if(value==2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期二" onfocus="TUser.tooltip()">星期二</p>']
                    }else if(value==3){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期三" onfocus="TUser.tooltip()">星期三</p>']
                    }else if(value==4){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期四" onfocus="TUser.tooltip()">星期四</p>']
                    }else if(value==5){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期五" onfocus="TUser.tooltip()">星期五</p>']
                    }else if(value==6){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期六" onfocus="TUser.tooltip()">星期六</p>']
                    }else if(value==7){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期日" onfocus="TUser.tooltip()">星期日</p>']
                    }
                    return btn;
                }
            }
    ];
    return [
        {field: 'selectItem', radio: true},
        {title: 'ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {
            title: '司机可提现日期(星期几)', field: 'weeks', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if (value == 1) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期一" onfocus="TUser.tooltip()">星期一</p>']
                } else if (value == 2) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期二" onfocus="TUser.tooltip()">星期二</p>']
                } else if (value == 3) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期三" onfocus="TUser.tooltip()">星期三</p>']
                } else if (value == 4) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期四" onfocus="TUser.tooltip()">星期四</p>']
                } else if (value == 5) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期五" onfocus="TUser.tooltip()">星期五</p>']
                } else if (value == 6) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期六" onfocus="TUser.tooltip()">星期六</p>']
                } else if (value == 7) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="星期日" onfocus="TUser.tooltip()">星期日</p>']
                }
                return btn;
            }
        }
    ];
};
/**
 * 检查是否选中
 */
AppWithdrawalRule.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        AppWithdrawalRule.seItem = selected[0];
        return true;
    }
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录!");
        return false;
    } else {
        AppWithdrawalRule.seItem = selected[0];
        return true;
    }
};
/**
 * 点击添加
 */
AppWithdrawalRule.openAddAppWithdrawalRule = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/appWithdrawalRule/appWithdrawalRule_add'
    });
    this.layerIndex = index;
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/appWithdrawalRule/appWithdrawalRule_add'
    });
    this.layerIndex = index;
};
/**
 * 打开查看详情
 */
AppWithdrawalRule.openAppWithdrawalRuleDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/appWithdrawalRule/appWithdrawalRule_update/' + AppWithdrawalRule.seItem.id
        });
        this.layerIndex = index;
    }
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/appWithdrawalRule/appWithdrawalRule_update/' + AppWithdrawalRule.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 删除
 */
AppWithdrawalRule.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/appWithdrawalRule/delete", function (data) {
            Feng.success("删除成功!");
            AppWithdrawalRule.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("appWithdrawalRuleId",this.seItem.id);
        ajax.start();
    }
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/appWithdrawalRule/delete", function (data) {
            Feng.success("删除成功!");
            AppWithdrawalRule.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("appWithdrawalRuleId", this.seItem.id);
        ajax.start();
    }
};
/**
 * 查询列表
 */
AppWithdrawalRule.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    AppWithdrawalRule.table.refresh({query: queryData});
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    AppWithdrawalRule.table.refresh({query: queryData});
};
$(function () {
    var defaultColunms = AppWithdrawalRule.initColumn();
    var table = new BSTable(AppWithdrawalRule.id, "/appWithdrawalRule/list", defaultColunms);
    table.setPaginationType("client");
    AppWithdrawalRule.table = table.init();
    var defaultColunms = AppWithdrawalRule.initColumn();
    var table = new BSTable(AppWithdrawalRule.id, "/appWithdrawalRule/list", defaultColunms);
    table.setPaginationType("client");
    AppWithdrawalRule.table = table.init();
});
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/tOrderLogistics/tOrderLogistics.js
@@ -258,7 +258,8 @@
        } else {
            nickname = "【" + nickname + "】";
        }
        if (TOrderLogistics.seItem.state == 9 || TOrderLogistics.seItem.state == 10 ) {
        if (TOrderLogistics.seItem.state == 6 || TOrderLogistics.seItem.state == 7 || TOrderLogistics.seItem.state == 8 ||
                TOrderLogistics.seItem.state == 9 || TOrderLogistics.seItem.state == 10 ) {
            swal("取消失败", "【已完成】【已取消】状态下不能执行此操作", "warning");
            return;
        }
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/tOrderPrivateCar/tOrderPrivateCar.js
@@ -386,8 +386,8 @@
        } else {
            nickname = "【" + nickname + "】";
        }
        if (TOrderPrivateCar.seItem.state == 7 || TOrderPrivateCar.seItem.state == 8 || TOrderPrivateCar.seItem.state == 9 || TOrderPrivateCar.seItem.state == 10 ) {
            swal("支付失败", "【待评价】【已完成】【已取消】状态下不能执行此操作", "warning");
        if (TOrderPrivateCar.seItem.state == 6 || TOrderPrivateCar.seItem.state == 7 || TOrderPrivateCar.seItem.state == 8 || TOrderPrivateCar.seItem.state == 9 || TOrderPrivateCar.seItem.state == 10 ) {
            swal("取消失败", "【待评价】【已完成】【已取消】状态下不能执行此操作", "warning");
            return;
        }
        swal({
ManagementIGOTravel/guns-admin/src/main/webapp/static/modular/system/userActivity/userActivity.js
@@ -2,214 +2,215 @@
 * 管理初始化
 */
var UserActivity = {
    id: "UserActivityTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
    id: "UserActivityTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
/**
 * 初始化表格的列
 */
UserActivity.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'},
        {title: '活动名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
        {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
        {title: '参与人次', field: 'number', visible: true, align: 'center', valign: 'middle'},
        {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'},
        {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if(value==1){
                    return "待审核";
                }else if(value==2){
                    return "已驳回";
                }else if(value==3){
                    // if(new Date()<new Date(row.startTime.replace(/-/g,"/"))){
                    //     return "未开始";
                    // }else if(new Date()>new Date(row.endTime.replace(/-/g,"/"))){
                    //     return "已结束";
                    // }else{
                    //     return "进行中";
                    // }
                }else if(value==4){
                    return "已暂停";
                }else if(value==5){
                    return "未开始";
                }else if(value==6){
                    return "进行中";
                }else if(value==7){
                    return "已结束";
                }
            }
        }
    ];
    return [
        {field: 'selectItem', radio: true},
        {title: '', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'},
        {title: '活动名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
        {title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
        {title: '参与人次', field: 'number', visible: true, align: 'center', valign: 'middle'},
        {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'},
        {
            title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if (value == 1) {
                    return "待审核";
                } else if (value == 2) {
                    return "已驳回";
                } else if (value == 3) {
                    // if(new Date()<new Date(row.startTime.replace(/-/g,"/"))){
                    //     return "未开始";
                    // }else if(new Date()>new Date(row.endTime.replace(/-/g,"/"))){
                    //     return "已结束";
                    // }else{
                    //     return "进行中";
                    // }
                } else if (value == 4) {
                    return "已暂停";
                } else if (value == 5) {
                    return "未开始";
                } else if (value == 6) {
                    return "进行中";
                } else if (value == 7) {
                    return "已结束";
                }
            }
        }
    ];
};
/**
 * 检查是否选中
 */
UserActivity.check = function (type) {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        //验证类型null删除,1=审核,2=编辑,3=启动/暂停
        if(type==null){
            UserActivity.seItem = selected[0];
            return true;
        }else if(type==3 && selected[0].status!=3 && selected[0].status!=4){
            Feng.info("当前状态不能暂停/启动!");
            return false;
        }else if(type==3 && selected[0].status==3 && (selected[0].startTime>new Date() || new Date()>selected[0].endTime)){
            Feng.info("当前状态不能暂停/启动!");
            return false;
        }else if(type==1 && selected[0].status!=1){
            Feng.info("当前状态不能审核!");
            return false;
        }else if(type==2 && selected[0].status!=2 && new Date()>=new Date(selected[0].startTime.replace(/-/g,"/"))){
            Feng.info("当前状态不能编辑!");
            return false;
        }
        UserActivity.seItem = selected[0];
        return true;
    }
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录!");
        return false;
    } else {
        //验证类型null删除,1=审核,2=编辑,3=启动/暂停
        if (type == null) {
            UserActivity.seItem = selected[0];
            return true;
        } else if (type == 3 && selected[0].status != 6 && selected[0].status != 7) {
            Feng.info("当前状态不能暂停/启动!");
            return false;
        } else if (type == 3 && selected[0].status == 6 && (selected[0].startTime > new Date() || new Date() > selected[0].endTime)) {
            Feng.info("当前状态不能暂停/启动!");
            return false;
        } else if (type == 1 && selected[0].status != 1) {
            Feng.info("当前状态不能审核!");
            return false;
        } else if (type == 2 && selected[0].status != 2 && new Date() >= new Date(selected[0].startTime.replace(/-/g, "/"))) {
            Feng.info("当前状态不能编辑!");
            return false;
        }
        UserActivity.seItem = selected[0];
        return true;
    }
};
/**
 * 点击添加
 */
UserActivity.openAddUserActivity = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/userActivity/userActivity_add'
    });
    this.layerIndex = index;
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/userActivity/userActivity_add'
    });
    this.layerIndex = index;
};
/**
 * 打开查看详情
 */
UserActivity.openUserActivityDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 打开编辑
 */
UserActivity.openUpdateUserActivity = function () {
    if (this.check(2)) {
        var index = layer.open({
            type: 2,
            title: '编辑',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
    if (this.check(2)) {
        var index = layer.open({
            type: 2,
            title: '编辑',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 删除
 */
UserActivity.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) {
            Feng.success("删除成功!");
            UserActivity.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("userActivityId",this.seItem.id);
        ajax.start();
    }
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) {
            Feng.success("删除成功!");
            UserActivity.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("userActivityId", this.seItem.id);
        ajax.start();
    }
};
/**
 * 启动/暂停
 */
UserActivity.updateStatus = function () {
    if (this.check(3)) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) {
            Feng.success("启动/暂停成功!");
            UserActivity.table.refresh();
        }, function (data) {
            Feng.error("动/暂停失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id",this.seItem.id);
        ajax.set("status",this.seItem.status==3?4:3);
        ajax.start();
    }
    if (this.check(3)) {
        var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) {
            Feng.success("启动/暂停成功!");
            UserActivity.table.refresh();
        }, function (data) {
            Feng.error("动/暂停失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id", this.seItem.id);
        ajax.set("status", this.seItem.status == 3 ? 4 : 3);
        ajax.start();
    }
};
/**
 * 打开立即处理页面
 */
UserActivity.immediately = function () {
    if (this.check(1)) {
        var index = layer.open({
            type: 2,
            title: '审核',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_immediately/' +  this.seItem.id
        });
        this.layerIndex = index;
    }
    if (this.check(1)) {
        var index = layer.open({
            type: 2,
            title: '审核',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/userActivity_immediately/' + this.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 领取记录
 */
UserActivity.receiveRecord= function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '领取记录',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/receiveRecord?activityId='+ UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
UserActivity.receiveRecord = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '领取记录',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/userActivity/receiveRecord?activityId=' + UserActivity.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 查询列表
 */
UserActivity.search = function () {
    var queryData = {};
    queryData['createTime'] = $("#createTime").val();
    queryData['name'] = $("#name").val();
    queryData['status'] = $("#status").val();
    UserActivity.table.refresh({query: queryData});
    var queryData = {};
    queryData['createTime'] = $("#createTime").val();
    queryData['name'] = $("#name").val();
    queryData['status'] = $("#status").val();
    UserActivity.table.refresh({query: queryData});
};
UserActivity.resetSearch = function () {
    $("#createTime").val("");
    $("#name").val("");
    $("#status").val("");
    DriverActivity.search();
    $("#createTime").val("");
    $("#name").val("");
    $("#status").val("");
    DriverActivity.search();
};
$(function () {
    var defaultColunms = UserActivity.initColumn();
    var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms);
    table.setPaginationType("server");
    UserActivity.table = table.init();
    var defaultColunms = UserActivity.initColumn();
    var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms);
    table.setPaginationType("server");
    UserActivity.table = table.init();
});