first commit

This commit is contained in:
2025-02-20 15:14:38 +08:00
commit 70e3764011
1113 changed files with 107789 additions and 0 deletions
@@ -0,0 +1,677 @@
package lingtao.net.service;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import lingtao.net.bean.CustomerAward;
import lingtao.net.bean.Msg;
import lingtao.net.bean.SysUser;
import lingtao.net.dao.CustomerAwardMapper;
import lingtao.net.util.DateFormatUtils;
import lingtao.net.util.ExcelUtils;
@Service
public class CustomerAwardService {
@Autowired
private CustomerAwardMapper customerAwardMapper;
public List<CustomerAward> getCustomerAward(CustomerAward customerAward) {
customerAward.setCreateTimeEnd(new DateFormatUtils().formatEndTime(customerAward.getCreateTimeBegin()));
customerAward.setCreateTimeBegin(new DateFormatUtils().formatBeginTime(customerAward.getCreateTimeBegin()));
return customerAwardMapper.getCustomerAward(customerAward);
}
// 批量删除
public Msg deleteBatch(int[] ints) {
try {
customerAwardMapper.deleteBatch(ints);
return Msg.success();
} catch (Exception e) {
return Msg.fail();
}
}
public List<String> getArardShopname() {
return customerAwardMapper.getArardShopname();
}
public Msg ajaxUploadExcel(MultipartFile file) throws Exception {
if (file.isEmpty()) {
throw new Exception("文件不存在!");
}
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
InputStream in = null;
List<List<Object>> listob = null;
String awardDate = "";
List<String> matches = null;
List<CustomerAward> list = new ArrayList<CustomerAward>(1000);
try {
in = file.getInputStream();
listob = new ExcelUtils().getBankListByExcel(in, file.getOriginalFilename());
} catch (IOException e) {
e.printStackTrace();
}
String filename = file.getOriginalFilename();
// 获取字符串中的日期正则
Pattern p = Pattern.compile("(\\d{1,4}[-|\\/]\\d{1,2}[-|\\/]\\d{1,2})",
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher matcher = p.matcher(listob.get(0).toString().trim());
if (matcher.find() && matcher.groupCount() >= 1) {
matches = new ArrayList<String>();
for (int i = 1; i <= matcher.groupCount(); i++) {
String temp = matcher.group(i);
matches.add(temp);
}
}
if (matches.size() > 0) {
awardDate = ((String) matches.get(0)).trim();
}
filename = filename.substring(0, filename.indexOf("."));
System.out.println(filename);
for (int i = 0; i < listob.size(); i++) {
synchronized (this) {
CustomerAward vo = new CustomerAward();
List<Object> lo = listob.get(i);
if (lo.size() == 0 || lo.size() == 1) {
System.out.println("++++++++++++++");
continue;
}
String nickname = String.valueOf(lo.get(0)).trim();
String payPercent2 = (String.valueOf(lo.get(1)).trim());
String askNumber2 = (String.valueOf(lo.get(2)).trim());
String customerPrice2 = (String.valueOf(lo.get(3)).trim());
payPercent2 = payPercent2.replaceAll("%", " ");
Double payPercent = 0.0;
Double askNumber = 0.0;
Double customerPrice = 0.0;
try {
payPercent = Double.valueOf(payPercent2);
askNumber = Double.valueOf(askNumber2);
customerPrice = Double.valueOf(customerPrice2);
} catch (NumberFormatException e) {
continue;
}
if (payPercent == 1) {
payPercent = 100.0;
}
int award = 0;
switch (filename) {
case "菇凉":
award = guliang(nickname, payPercent, askNumber, customerPrice);
break;
case "榆家":
award = yujia(nickname, payPercent, askNumber, customerPrice);
break;
case "奥丽芙":
award = aolifu(nickname, payPercent, askNumber, customerPrice);
break;
case "翊喜":
award = yixi(nickname, payPercent, askNumber, customerPrice);
break;
case "航和":
award = hanghe(nickname, payPercent, askNumber, customerPrice);
break;
case "卓胜":
award = zhuosheng(nickname, payPercent, askNumber, customerPrice);
break;
case "欣克利":
award = xinkeli(nickname, payPercent, askNumber, customerPrice);
break;
case "米笛儿":
award = midier(nickname, payPercent, askNumber, customerPrice);
break;
case "阳光猫":
award = yangguangmao(nickname, payPercent, askNumber, customerPrice);
break;
default:
break;
}
vo.setNickname(nickname);
vo.setPayPercent(payPercent);
vo.setAskNumber(askNumber);
vo.setCustomerPrice(customerPrice);
vo.setAward(award);
vo.setShopname(filename);
vo.setAwardDate(awardDate);
vo.setCreator(user.getRealname());
list.add(vo);
}
}
if (list.size() > 0) {
customerAwardMapper.insertForeach(list);
}
in.close();
return Msg.success();
}
// 菇凉店客服日奖励
private int guliang(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=46,"奖励档80元",IF(C4>=44,"奖励档60元",IF(C4>=43,"奖励档50元",IF(C4>=42,"奖励档40元",
// IF(C4>=41,"奖励档30元",IF(C4>=40,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 46) {
payPercentPrice = 80;
} else if (payPercent >= 44) {
payPercentPrice = 60;
} else if (payPercent >= 43) {
payPercentPrice = 50;
} else if (payPercent >= 42) {
payPercentPrice = 40;
} else if (payPercent >= 41) {
payPercentPrice = 30;
} else if (payPercent >= 40) {
payPercentPrice = 20;
}
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 70) {
askNumberPrice = 80;
} else if (askNumber >= 50) {
askNumberPrice = 60;
}
}
// =IF(E4>=240,"客单档80元",IF(E4>=220,"客单档60元",IF(E4>=200,"客单档50元",IF(E4>=190,"客单档40元",
// IF(E4>=180,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 240) {
customerPricePrice = 80;
} else if (customerPrice >= 220) {
customerPricePrice = 60;
} else if (customerPrice >= 200) {
customerPricePrice = 50;
} else if (customerPrice >= 190) {
customerPricePrice = 40;
} else if (customerPrice >= 180) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 榆家店客服日奖励
private int yujia(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=43,"奖励档80元",IF(C4>=42,"奖励档60元",IF(C4>=41,"奖励档50元",IF(C4>=40,"奖励档40元",
// IF(C4>=39,"奖励档30元",IF(C4>=38,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 43) {
payPercentPrice = 80;
} else if (payPercent >= 42) {
payPercentPrice = 60;
} else if (payPercent >= 41) {
payPercentPrice = 50;
} else if (payPercent >= 40) {
payPercentPrice = 40;
} else if (payPercent >= 39) {
payPercentPrice = 30;
} else if (payPercent >= 38) {
payPercentPrice = 20;
}
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 70) {
askNumberPrice = 80;
} else if (askNumber >= 50) {
askNumberPrice = 60;
}
}
// =IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 190) {
customerPricePrice = 80;
} else if (customerPrice >= 180) {
customerPricePrice = 60;
} else if (customerPrice >= 170) {
customerPricePrice = 50;
} else if (customerPrice >= 160) {
customerPricePrice = 40;
} else if (customerPrice >= 150) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 奥丽芙店客服日奖励
private int aolifu(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=43,"奖励档80元",IF(C4>=42,"奖励档60元",IF(C4>=41,"奖励档50元",IF(C4>=40,"奖励档40元",
// IF(C4>=39,"奖励档30元",IF(C4>=38,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 43) {
payPercentPrice = 80;
} else if (payPercent >= 42) {
payPercentPrice = 60;
} else if (payPercent >= 41) {
payPercentPrice = 50;
} else if (payPercent >= 40) {
payPercentPrice = 40;
} else if (payPercent >= 39) {
payPercentPrice = 30;
} else if (payPercent >= 38) {
payPercentPrice = 20;
}
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 70) {
askNumberPrice = 80;
} else if (askNumber >= 50) {
askNumberPrice = 60;
}
}
// =IF(E4>=240,"客单档80元",IF(E4>=220,"客单档60元",IF(E4>=200,"客单档50元",IF(E4>=190,"客单档40元",
// IF(E4>=180,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 240) {
customerPricePrice = 80;
} else if (customerPrice >= 220) {
customerPricePrice = 60;
} else if (customerPrice >= 200) {
customerPricePrice = 50;
} else if (customerPrice >= 190) {
customerPricePrice = 40;
} else if (customerPrice >= 180) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 翊喜店客服日奖励
private int yixi(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=42,"奖励档80元",IF(C4>=41,"奖励档60元",IF(C4>=40,"奖励档50元",IF(C4>=39,"奖励档40元",
// IF(C4>=38,"奖励档30元",IF(C4>=37,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 42) {
payPercentPrice = 80;
} else if (payPercent >= 41) {
payPercentPrice = 60;
} else if (payPercent >= 40) {
payPercentPrice = 50;
} else if (payPercent >= 39) {
payPercentPrice = 40;
} else if (payPercent >= 38) {
payPercentPrice = 30;
} else if (payPercent >= 37) {
payPercentPrice = 20;
}
// IF(D4>=75,"询单人数档80元",IF(D4>=55,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 75) {
askNumberPrice = 80;
} else if (askNumber >= 55) {
askNumberPrice = 60;
}
}
// =IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 190) {
customerPricePrice = 80;
} else if (customerPrice >= 180) {
customerPricePrice = 60;
} else if (customerPrice >= 170) {
customerPricePrice = 50;
} else if (customerPrice >= 160) {
customerPricePrice = 40;
} else if (customerPrice >= 150) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 航和店客服日奖励
private int hanghe(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=40,"奖励档80元",IF(C4>=38,"奖励档60元",IF(C4>=37,"奖励档50元",IF(C4>=36,"奖励档40元",
// IF(C4>=35,"奖励档30元",IF(C4>=34,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 40) {
payPercentPrice = 80;
} else if (payPercent >= 38) {
payPercentPrice = 60;
} else if (payPercent >= 37) {
payPercentPrice = 50;
} else if (payPercent >= 36) {
payPercentPrice = 40;
} else if (payPercent >= 35) {
payPercentPrice = 30;
} else if (payPercent >= 34) {
payPercentPrice = 20;
}
// IF(D4>=80,"询单人数档80元",IF(D4>=60,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
// 航和没有这个,写个大数字
askNumberPrice = 100;
} else {
if (askNumber >= 80) {
askNumberPrice = 80;
} else if (askNumber >= 60) {
askNumberPrice = 60;
}
}
// =IF(E4>=195,"客单档80元",IF(E4>=185,"客单档60元",IF(E4>=175,"客单档50元",IF(E4>=165,"客单档40元",
// IF(E4>=155,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 195) {
customerPricePrice = 80;
} else if (customerPrice >= 185) {
customerPricePrice = 60;
} else if (customerPrice >= 175) {
customerPricePrice = 50;
} else if (customerPrice >= 165) {
customerPricePrice = 40;
} else if (customerPrice >= 155) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 卓胜店客服日奖励
private int zhuosheng(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=38,"奖励档80元",IF(C4>=37,"奖励档60元",IF(C4>=36,"奖励档50元",IF(C4>=35,"奖励档40元",
// IF(C4>=34,"奖励档30元",IF(C4>=33,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 38) {
payPercentPrice = 80;
} else if (payPercent >= 37) {
payPercentPrice = 60;
} else if (payPercent >= 36) {
payPercentPrice = 50;
} else if (payPercent >= 35) {
payPercentPrice = 40;
} else if (payPercent >= 34) {
payPercentPrice = 30;
} else if (payPercent >= 33) {
payPercentPrice = 20;
}
// IF(D4>=65,"询单人数档80元",IF(D4>=45,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 65) {
askNumberPrice = 80;
} else if (askNumber >= 45) {
askNumberPrice = 60;
}
}
// IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 190) {
customerPricePrice = 80;
} else if (customerPrice >= 180) {
customerPricePrice = 60;
} else if (customerPrice >= 170) {
customerPricePrice = 50;
} else if (customerPrice >= 160) {
customerPricePrice = 40;
} else if (customerPrice >= 150) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 欣克利店客服日奖励
private int xinkeli(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=37,"奖励档80元",IF(C4>=36,"奖励档60元",IF(C4>=35,"奖励档50元",IF(C4>=34,"奖励档40元",
// IF(C4>=33,"奖励档30元",IF(C4>=32,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 37) {
payPercentPrice = 80;
} else if (payPercent >= 36) {
payPercentPrice = 60;
} else if (payPercent >= 35) {
payPercentPrice = 50;
} else if (payPercent >= 34) {
payPercentPrice = 40;
} else if (payPercent >= 33) {
payPercentPrice = 30;
} else if (payPercent >= 32) {
payPercentPrice = 20;
}
// IF(D4>=50,"询单人数档80元",IF(D4>=30,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 50) {
askNumberPrice = 80;
} else if (askNumber >= 30) {
askNumberPrice = 60;
}
}
// IF(E4>=165,"客单档80元",IF(E4>=155,"客单档60元",IF(E4>=145,"客单档50元",IF(E4>=135,"客单档40元",
// IF(E4>=125,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 165) {
customerPricePrice = 80;
} else if (customerPrice >= 155) {
customerPricePrice = 60;
} else if (customerPrice >= 145) {
customerPricePrice = 50;
} else if (customerPrice >= 135) {
customerPricePrice = 40;
} else if (customerPrice >= 125) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 米笛儿店客服日奖励
private int midier(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=35,"奖励档80元",IF(C4>=34,"奖励档60元",IF(C4>=33,"奖励档50元",IF(C4>=32,"奖励档40元",
// IF(C4>=31,"奖励档30元",IF(C4>=30,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 35) {
payPercentPrice = 80;
} else if (payPercent >= 34) {
payPercentPrice = 60;
} else if (payPercent >= 33) {
payPercentPrice = 50;
} else if (payPercent >= 32) {
payPercentPrice = 40;
} else if (payPercent >= 31) {
payPercentPrice = 30;
} else if (payPercent >= 30) {
payPercentPrice = 20;
}
// IF(D4>=55,"询单人数档80元",IF(D4>=35,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 55) {
askNumberPrice = 80;
} else if (askNumber >= 35) {
askNumberPrice = 60;
}
}
// IF(E4>=210,"客单档80元",IF(E4>=195,"客单档60元",IF(E4>=185,"客单档50元",IF(E4>=175,"客单档40元",
// IF(E4>=165,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 210) {
customerPricePrice = 80;
} else if (customerPrice >= 195) {
customerPricePrice = 60;
} else if (customerPrice >= 185) {
customerPricePrice = 50;
} else if (customerPrice >= 175) {
customerPricePrice = 40;
} else if (customerPrice >= 165) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
// 阳光猫店客服日奖励
private int yangguangmao(String nickname, Double payPercent, Double askNumber, Double customerPrice) {
// IF(C4>=40,"奖励档80元",IF(C4>=38,"奖励档60元",IF(C4>=37,"奖励档50元",IF(C4>=36,"奖励档40元",
// IF(C4>=35,"奖励档30元",IF(C4>=34,"奖励档20元"))))))
int payPercentPrice = 0;
if (payPercent >= 40) {
payPercentPrice = 80;
} else if (payPercent >= 38) {
payPercentPrice = 60;
} else if (payPercent >= 37) {
payPercentPrice = 50;
} else if (payPercent >= 36) {
payPercentPrice = 40;
} else if (payPercent >= 35) {
payPercentPrice = 30;
} else if (payPercent >= 34) {
payPercentPrice = 20;
}
// IF(D4>=70,"询单人数档80元",IF(D4>=50,"询单人数档60元")))
int askNumberPrice = 0;
if ("平均".equals(nickname)) {
// IF(D4>=50%,"询单人数档80元",IF(D4>=30%,"询单人数档60元")))
if (askNumber >= 0.5) {
askNumberPrice = 80;
} else if (askNumber >= 0.3) {
askNumberPrice = 60;
}
} else {
if (askNumber >= 70) {
askNumberPrice = 80;
} else if (askNumber >= 50) {
askNumberPrice = 60;
}
}
// IF(E4>=190,"客单档80元",IF(E4>=180,"客单档60元",IF(E4>=170,"客单档50元",IF(E4>=160,"客单档40元",
// IF(E4>=150,"客单档30元",IF(E4>=0,"客单档20元"))))))
int customerPricePrice = 0;
if (customerPrice >= 190) {
customerPricePrice = 80;
} else if (customerPrice >= 180) {
customerPricePrice = 60;
} else if (customerPrice >= 170) {
customerPricePrice = 50;
} else if (customerPrice >= 160) {
customerPricePrice = 40;
} else if (customerPrice >= 150) {
customerPricePrice = 30;
} else if (customerPrice >= 0) {
customerPricePrice = 20;
}
double award = Math.min(Math.min(payPercentPrice, askNumberPrice), customerPricePrice);
return (int) award;
}
}