package cc.mrbird.febs.mall.controller;
|
|
import cc.mrbird.febs.common.entity.FebsConstant;
|
import cc.mrbird.febs.common.enumerates.AgentLevelEnum;
|
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
|
import cc.mrbird.febs.common.enumerates.GreenScoreEnum;
|
import cc.mrbird.febs.common.enumerates.OrderPayMethodEnum;
|
import cc.mrbird.febs.common.service.ValidateCodeService;
|
import cc.mrbird.febs.common.utils.FebsUtil;
|
import cc.mrbird.febs.common.utils.RedisUtils;
|
import cc.mrbird.febs.mall.dto.*;
|
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
|
import cc.mrbird.febs.mall.entity.MallMember;
|
import cc.mrbird.febs.mall.mapper.*;
|
import cc.mrbird.febs.monitor.service.ILoginLogService;
|
import cc.mrbird.febs.system.service.IUserService;
|
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import lombok.RequiredArgsConstructor;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import java.math.BigDecimal;
|
import java.util.*;
|
|
|
@Controller("mallSystemView")
|
@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/system")
|
@RequiredArgsConstructor
|
public class ViewSystemController {
|
|
private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
|
|
private final MallMemberMapper mallMemberMapper;
|
private final MallOrderInfoMapper mallOrderInfoMapper;
|
private final MallAchieveRecordMapper mallAchieveRecordMapper;
|
private final MallMemberWalletMapper mallMemberWalletMapper;
|
private final RedisUtils redisUtils;
|
|
@GetMapping("profitSetting")
|
public String profitSetting() {
|
return FebsUtil.view("modules/system/profitSetting");
|
}
|
@GetMapping("bonusSetting")
|
public String bonusSetting() {
|
return FebsUtil.view("modules/system/bonusSetting");
|
}
|
|
/**
|
* 积分设置
|
* @param model
|
* @return
|
*/
|
@GetMapping("hlmScoreSet")
|
@RequiresPermissions("hlmScoreSet:view")
|
public String hlmScoreSet(Model model) {
|
HlmScoreSetDto hlmScoreSetDto = new HlmScoreSetDto();
|
DataDictionaryCustom signScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SIGN_SCORE.getType(),
|
DataDictionaryEnum.SIGN_SCORE.getCode());
|
if (signScoreDic != null) {
|
String signScore = ObjectUtil.isEmpty(signScoreDic.getValue()) ? "0" : signScoreDic.getValue();
|
hlmScoreSetDto.setSignScore(signScore);
|
}
|
DataDictionaryCustom signScoreDaysDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SIGN_SCORE_DAYS.getType(),
|
DataDictionaryEnum.SIGN_SCORE_DAYS.getCode());
|
if (signScoreDaysDic != null) {
|
String signScoreDays = ObjectUtil.isEmpty(signScoreDaysDic.getValue()) ? "0" : signScoreDaysDic.getValue();
|
hlmScoreSetDto.setSignScoreDays(signScoreDays);
|
}
|
DataDictionaryCustom signScoreCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SIGN_SCORE_CNT.getType(),
|
DataDictionaryEnum.SIGN_SCORE_CNT.getCode());
|
if (signScoreCntDic != null) {
|
String signScoreCnt = ObjectUtil.isEmpty(signScoreCntDic.getValue()) ? "0" : signScoreCntDic.getValue();
|
hlmScoreSetDto.setSignScoreCnt(signScoreCnt);
|
}
|
DataDictionaryCustom scorePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SCORE_PERCENT.getType(),
|
DataDictionaryEnum.SCORE_PERCENT.getCode());
|
if (scorePercentDic != null) {
|
String scorePercent = ObjectUtil.isEmpty(scorePercentDic.getValue()) ? "0" : scorePercentDic.getValue();
|
hlmScoreSetDto.setScorePercent(scorePercent);
|
}
|
DataDictionaryCustom scoreChangeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SCORE_CHANGE.getType(),
|
DataDictionaryEnum.SCORE_CHANGE.getCode());
|
if (scoreChangeDic != null) {
|
String scoreChange = ObjectUtil.isEmpty(scoreChangeDic.getValue()) ? "0" : scoreChangeDic.getValue();
|
hlmScoreSetDto.setScoreChange(scoreChange);
|
}
|
DataDictionaryCustom starGetDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.STAR_GET.getType(),
|
DataDictionaryEnum.STAR_GET.getCode());
|
if (starGetDic != null) {
|
String starGet = ObjectUtil.isEmpty(starGetDic.getValue()) ? "0" : starGetDic.getValue();
|
hlmScoreSetDto.setStarGet(starGet);
|
}
|
model.addAttribute("hlmScoreSet", hlmScoreSetDto);
|
return FebsUtil.view("modules/system/hlmScoreSet");
|
}
|
|
@GetMapping("cashOutSetting")
|
@RequiresPermissions("cashOutSetting:update")
|
public String cashOutSetting(Model model) {
|
DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode());
|
if (dic != null) {
|
model.addAttribute("cashout", JSONObject.parseObject(dic.getValue(), CashOutSettingDto.class));
|
}
|
return FebsUtil.view("modules/system/cashOutSetting");
|
}
|
|
@GetMapping("scorePoorSetting")
|
@RequiresPermissions("scorePoorSetting:update")
|
public String scorePoor(Model model) {
|
DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SCORE_POOR_RADIO.getType(), DataDictionaryEnum.SCORE_POOR_RADIO.getCode());
|
if (dic != null) {
|
model.addAttribute("scorePoor", JSONObject.parseObject(dic.getValue(), ScorePoorDto.class));
|
}
|
return FebsUtil.view("modules/system/scorePoorSetting");
|
}
|
|
@GetMapping("indexData")
|
@RequiresPermissions("indexData:view")
|
public String indexData(Model model) {
|
Map<String, Object> data = new HashMap<>(5);
|
|
//积分池数据
|
data.put("scorePool",redisUtils.get("scorePool"));
|
//支付统计
|
List<Long> states = new ArrayList();
|
states.add(2L);
|
states.add(3L);
|
states.add(4L);
|
data.put("wechatPay",mallOrderInfoMapper.selectSumAmountByPayMethodAndSomeStatue(OrderPayMethodEnum.WECHAT.getName(), states));
|
data.put("alipayPay",mallOrderInfoMapper.selectSumAmountByPayMethodAndSomeStatue(OrderPayMethodEnum.ALIPAY.getName(), states));
|
data.put("scorePay",mallOrderInfoMapper.selectSumAmountByPayMethodAndSomeStatue(OrderPayMethodEnum.BANK.getName(), states));
|
data.put("balancePay",mallOrderInfoMapper.selectSumAmountByPayMethodAndSomeStatue(OrderPayMethodEnum.BALANCE.getName(), states));
|
|
|
data.put("lastDay", mallAchieveRecordMapper.selectAchieveTotal("D", DateUtil.offsetDay(new Date(), -1)));
|
data.put("today", mallAchieveRecordMapper.selectAchieveTotal("D", new Date()));
|
data.put("lastMonth", mallAchieveRecordMapper.selectAchieveTotal("M", DateUtil.offsetMonth(new Date(), -1)));
|
data.put("thisMonth", mallAchieveRecordMapper.selectAchieveTotal("M", new Date()));
|
|
data.put("totalBalance",mallMemberWalletMapper.selectSumBalance().setScale(2, BigDecimal.ROUND_DOWN));
|
data.put("totalScore",mallMemberWalletMapper.selectSumScore().setScale(2, BigDecimal.ROUND_DOWN));
|
data.put("totalPrizeScore",mallMemberWalletMapper.selectSumPrizeScore().setScale(2, BigDecimal.ROUND_DOWN));
|
data.put("totalCommission",mallMemberWalletMapper.selectSumCommission().setScale(2, BigDecimal.ROUND_DOWN));
|
|
//会员数据
|
data.put("totalMember",mallMemberMapper.selectCount(new QueryWrapper<>()) );
|
QueryWrapper<MallMember> formalMember = new QueryWrapper<>();
|
formalMember.ne("level", AgentLevelEnum.ZERO_LEVEL.name());
|
data.put("formalMember",mallMemberMapper.selectCount(formalMember));
|
|
QueryWrapper<MallMember> informalMember = new QueryWrapper<>();
|
informalMember.eq("level", AgentLevelEnum.ZERO_LEVEL.name());
|
data.put("informalMember",mallMemberMapper.selectCount(informalMember));
|
|
QueryWrapper<MallMember> todayMember = new QueryWrapper<>();
|
todayMember.like("CREATED_TIME", DateUtil.today());
|
data.put("todayMember",mallMemberMapper.selectCount(todayMember));
|
|
QueryWrapper<MallMember> thisMonthMember = new QueryWrapper<>();
|
thisMonthMember.like("CREATED_TIME", DateUtil.format(DateUtil.date(),"yyyy-MM"));
|
data.put("thisMonthMember",mallMemberMapper.selectCount(thisMonthMember));
|
|
QueryWrapper<MallMember> lastMonthMember = new QueryWrapper<>();
|
lastMonthMember.like("CREATED_TIME", DateUtil.format(DateUtil.offsetMonth(new Date(), -1),"yyyy-MM"));
|
data.put("lastMonthMember",mallMemberMapper.selectCount(lastMonthMember));
|
|
model.addAttribute("indexData", data);
|
return FebsUtil.view("modules/system/indexData");
|
}
|
|
@GetMapping("hlmBasicPerk")
|
@RequiresPermissions("hlmBasicPerk:view")
|
public String hlmBasicPerk(Model model) {
|
HlmBasicPerkDto hlmBasicPerkDto = new HlmBasicPerkDto();
|
DataDictionaryCustom sharePerkDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.SHARE_PERK.getType(),
|
DataDictionaryEnum.SHARE_PERK.getCode());
|
if (sharePerkDic != null) {
|
String sharePerk = ObjectUtil.isEmpty(sharePerkDic.getValue()) ? "0" : sharePerkDic.getValue();
|
hlmBasicPerkDto.setSharePerk(sharePerk);
|
}
|
DataDictionaryCustom teamPerkDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.TEAM_PERK.getType(),
|
DataDictionaryEnum.TEAM_PERK.getCode());
|
if (teamPerkDic != null) {
|
String teamPerk = ObjectUtil.isEmpty(teamPerkDic.getValue()) ? "0" : teamPerkDic.getValue();
|
hlmBasicPerkDto.setTeamPerk(teamPerk);
|
}
|
DataDictionaryCustom teamEqualsPerkDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.TEAM_EQUALS_PERK.getType(),
|
DataDictionaryEnum.TEAM_EQUALS_PERK.getCode());
|
if (teamEqualsPerkDic != null) {
|
String teamEqualsPerk = ObjectUtil.isEmpty(teamEqualsPerkDic.getValue()) ? "0" : teamEqualsPerkDic.getValue();
|
hlmBasicPerkDto.setTeamEqualsPerk(teamEqualsPerk);
|
}
|
DataDictionaryCustom offLinePerkDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.OFFLINE_PERK.getType(),
|
DataDictionaryEnum.OFFLINE_PERK.getCode());
|
if (offLinePerkDic != null) {
|
String offLinePerk = ObjectUtil.isEmpty(offLinePerkDic.getValue()) ? "0" : offLinePerkDic.getValue();
|
hlmBasicPerkDto.setOffLinePerk(offLinePerk);
|
}
|
DataDictionaryCustom agentPerkDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
DataDictionaryEnum.AGENT_PERK.getType(),
|
DataDictionaryEnum.AGENT_PERK.getCode());
|
if (agentPerkDic != null) {
|
String agentPerk = ObjectUtil.isEmpty(agentPerkDic.getValue()) ? "0" : agentPerkDic.getValue();
|
hlmBasicPerkDto.setAgentPerk(agentPerk);
|
}
|
model.addAttribute("hlmBasicPerk", hlmBasicPerkDto);
|
return FebsUtil.view("modules/system/hlmBasicPerk");
|
}
|
|
/**
|
* 积分凭证设置
|
* @param model
|
* @return
|
*/
|
@GetMapping("hlmVoucherSet")
|
@RequiresPermissions("hlmVoucherSet:view")
|
public String hlmVoucherSet(Model model) {
|
HlmVoucherSetDto hlmVoucherSetDto = new HlmVoucherSetDto();
|
DataDictionaryCustom totalCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.TOTAL_CNT.getType(),
|
GreenScoreEnum.TOTAL_CNT.getCode());
|
if (totalCntDic != null) {
|
String totalCnt = ObjectUtil.isEmpty(totalCntDic.getValue()) ? "0" : totalCntDic.getValue();
|
hlmVoucherSetDto.setTotalCnt(totalCnt);
|
}
|
DataDictionaryCustom surplusCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.SURPLUS_CNT.getType(),
|
GreenScoreEnum.SURPLUS_CNT.getCode());
|
if (surplusCntDic != null) {
|
String surplusCnt = ObjectUtil.isEmpty(surplusCntDic.getValue()) ? "0" : surplusCntDic.getValue();
|
hlmVoucherSetDto.setSurplusCnt(surplusCnt);
|
}
|
DataDictionaryCustom roleReleasePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ROLE_RELEASE_PERCENT.getType(),
|
GreenScoreEnum.ROLE_RELEASE_PERCENT.getCode());
|
if (roleReleasePercentDic != null) {
|
String roleReleasePercent = ObjectUtil.isEmpty(roleReleasePercentDic.getValue()) ? "0" : roleReleasePercentDic.getValue();
|
hlmVoucherSetDto.setRoleReleasePercent(roleReleasePercent);
|
}
|
DataDictionaryCustom achieveReleasePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ACHIEVE_RELEASE_PERCENT.getType(),
|
GreenScoreEnum.ACHIEVE_RELEASE_PERCENT.getCode());
|
if (achieveReleasePercentDic != null) {
|
String achieveReleasePercent = ObjectUtil.isEmpty(achieveReleasePercentDic.getValue()) ? "0" : achieveReleasePercentDic.getValue();
|
hlmVoucherSetDto.setAchieveReleasePercent(achieveReleasePercent);
|
}
|
DataDictionaryCustom achieveReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ACHIEVE_RELEASE.getType(),
|
GreenScoreEnum.ACHIEVE_RELEASE.getCode());
|
if (achieveReleaseDic != null) {
|
String achieveRelease = ObjectUtil.isEmpty(achieveReleaseDic.getValue()) ? "0" : achieveReleaseDic.getValue();
|
hlmVoucherSetDto.setAchieveRelease(achieveRelease);
|
}
|
DataDictionaryCustom achieveMaxDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ACHIEVE_MAX.getType(),
|
GreenScoreEnum.ACHIEVE_MAX.getCode());
|
if (achieveMaxDic != null) {
|
String achieveMax = ObjectUtil.isEmpty(achieveMaxDic.getValue()) ? "0" : achieveMaxDic.getValue();
|
hlmVoucherSetDto.setAchieveMax(achieveMax);
|
}
|
DataDictionaryCustom achieveMinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ACHIEVE_MIN.getType(),
|
GreenScoreEnum.ACHIEVE_MIN.getCode());
|
if (achieveMinDic != null) {
|
String achieveMin = ObjectUtil.isEmpty(achieveMinDic.getValue()) ? "0" : achieveMinDic.getValue();
|
hlmVoucherSetDto.setAchieveMin(achieveMin);
|
}
|
DataDictionaryCustom roleAchievePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.ROLE_ACHIEVE_PERCENT.getType(),
|
GreenScoreEnum.ROLE_ACHIEVE_PERCENT.getCode());
|
if (roleAchievePercentDic != null) {
|
String roleAchievePercent = ObjectUtil.isEmpty(roleAchievePercentDic.getValue()) ? "0" : roleAchievePercentDic.getValue();
|
hlmVoucherSetDto.setRoleAchievePercent(roleAchievePercent);
|
}
|
DataDictionaryCustom starAchievePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.STAR_ACHIEVE_PERCENT.getType(),
|
GreenScoreEnum.STAR_ACHIEVE_PERCENT.getCode());
|
if (starAchievePercentDic != null) {
|
String starAchievePercent = ObjectUtil.isEmpty(starAchievePercentDic.getValue()) ? "0" : starAchievePercentDic.getValue();
|
hlmVoucherSetDto.setStarAchievePercent(starAchievePercent);
|
}
|
DataDictionaryCustom levelAchievePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.LEVEL_ACHIEVE_PERCENT.getType(),
|
GreenScoreEnum.LEVEL_ACHIEVE_PERCENT.getCode());
|
if (levelAchievePercentDic != null) {
|
String levelAchievePercent = ObjectUtil.isEmpty(levelAchievePercentDic.getValue()) ? "0" : levelAchievePercentDic.getValue();
|
hlmVoucherSetDto.setLevelAchievePercent(levelAchievePercent);
|
}
|
DataDictionaryCustom scorePoolCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.SCORE_POOL_CNT.getType(),
|
GreenScoreEnum.SCORE_POOL_CNT.getCode());
|
if (scorePoolCntDic != null) {
|
String scorePoolCnt = ObjectUtil.isEmpty(scorePoolCntDic.getValue()) ? "0" : scorePoolCntDic.getValue();
|
hlmVoucherSetDto.setScorePoolCnt(scorePoolCnt);
|
}
|
model.addAttribute("hlmVoucherSetDto", hlmVoucherSetDto);
|
return FebsUtil.view("modules/system/hlmVoucherSet");
|
}
|
|
/**
|
* 一键卖出
|
* @param model
|
* @return
|
*/
|
@GetMapping("hlmVoucherButton")
|
@RequiresPermissions("hlmVoucherButton:view")
|
public String hlmVoucherButton(Model model) {
|
HlmVoucherButtonDto hlmVoucherButtonDto = new HlmVoucherButtonDto();
|
DataDictionaryCustom scorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.SCORE_PRICE.getType(),
|
GreenScoreEnum.SCORE_PRICE.getCode());
|
if (scorePriceDic != null) {
|
String scorePrice = ObjectUtil.isEmpty(scorePriceDic.getValue()) ? "0" : scorePriceDic.getValue();
|
hlmVoucherButtonDto.setScorePrice(scorePrice);
|
}
|
DataDictionaryCustom voucherOnOffDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.VOUCHER_ON_OFF.getType(),
|
GreenScoreEnum.VOUCHER_ON_OFF.getCode());
|
if (voucherOnOffDic != null) {
|
String voucherOnOff = ObjectUtil.isEmpty(voucherOnOffDic.getValue()) ? "0" : voucherOnOffDic.getValue();
|
hlmVoucherButtonDto.setVoucherOnOff(voucherOnOff);
|
}
|
DataDictionaryCustom voucherPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
|
GreenScoreEnum.VOUCHER_PERCENT.getType(),
|
GreenScoreEnum.VOUCHER_PERCENT.getCode());
|
if (voucherPercentDic != null) {
|
String voucherPercent = ObjectUtil.isEmpty(voucherPercentDic.getValue()) ? "0" : voucherPercentDic.getValue();
|
hlmVoucherButtonDto.setVoucherPercent(voucherPercent);
|
}
|
model.addAttribute("hlmVoucherButtonDto", hlmVoucherButtonDto);
|
return FebsUtil.view("modules/system/hlmVoucherButton");
|
}
|
}
|