Commit ef9226df by kangxiaoshan

大后台更新

parent 93dbab6b
......@@ -120,11 +120,13 @@
<io.username>root</io.username>
<io.password>reyun.123</io.password>
<mail.host>smtp.exmail.qq.com</mail.host>
<mail.username>manxiaang@reyun.com</mail.username>
<mail.password>Mxq123</mail.password>
<mail.host>smtp.263.net</mail.host>
<mail.username>manager@reyun.com</mail.username>
<mail.password>rym@123</mail.password>
<mail.content_type>text/plain;charset\=GBK</mail.content_type>
<mail.list>zhangliang</mail.list>
<mail.list>muchunyu@reyun.com</mail.list>
<mail.prod>true</mail.prod>
<mail.test>kangxiaoshan,muchunyu</mail.test>
<!-- 单位是分钟-->
<mail.valid_time>3</mail.valid_time>
......@@ -207,11 +209,13 @@
<io.username>reyun</io.username>
<io.password>Reyun123</io.password>
<mail.host>smtp.exmail.qq.com</mail.host>
<mail.host>smtp.263.net</mail.host>
<mail.username>manager@reyun.com</mail.username>
<mail.password>Reyun123</mail.password>
<mail.password>rym@123</mail.password>
<mail.content_type>text/plain;charset\=GBK</mail.content_type>
<mail.list>zhangliang</mail.list>
<mail.list>muchunyu@reyun.com</mail.list>
<mail.prod>true</mail.prod>
<mail.test>kangxiaoshan@reyun.com</mail.test>
<!-- 单位是分钟-->
<mail.valid_time>3</mail.valid_time>
......
package common.controller;
import com.google.common.collect.ImmutableList;
import common.model.*;
import common.model.Contract;
import common.model.ContractChange;
import common.model.ContractMoney;
import common.model.User;
import common.service.ContractService;
import common.service.MenuService;
import common.task.ContractSendEmailThread;
import dic.ContractStatusEnum;
import dic.OperateObjectTypeEnum;
import exception.TipException;
import org.apache.commons.io.IOUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,20 +21,13 @@ import org.springframework.web.bind.annotation.*;
import security.annotation.CurrentAccount;
import util.NewUserLogThread;
import util.ResultModel;
import util.UserLogThread;
import util.ValidateUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -47,6 +40,19 @@ import java.util.Map;
@RequestMapping("{platform}/contract")
public class ContractController {
private static final Logger logger = LoggerFactory.getLogger(ContractController.class);
private static final Map<String, String> CONTRACT_STATUS = new HashMap<String, String>() {{
put(ContractStatusEnum.WAIT.getKey(), ContractStatusEnum.WAIT.getValue());
put(ContractStatusEnum.EXECUTING.getKey(), ContractStatusEnum.EXECUTING.getValue());
put(ContractStatusEnum.END.getKey(), ContractStatusEnum.END.getValue());
put(ContractStatusEnum.CANCEL.getKey(), ContractStatusEnum.CANCEL.getValue());
put(ContractStatusEnum.MONEY_BACK_ALL.getKey(), ContractStatusEnum.MONEY_BACK_ALL.getValue());
put(ContractStatusEnum.MONEY_BACK_PART.getKey(), ContractStatusEnum.MONEY_BACK_PART.getValue());
put(ContractStatusEnum.MONEY_BACK_NONE.getKey(), ContractStatusEnum.MONEY_BACK_NONE.getValue());
put(ContractStatusEnum.DELETE.getKey(), ContractStatusEnum.DELETE.getValue());
}};
@Autowired
private ContractService service;
......@@ -63,20 +69,16 @@ public class ContractController {
public ResponseEntity<byte[]> export(@CurrentAccount User loginAccount, @PathVariable String platform, @RequestParam String startDate
, @RequestParam String endDate, HttpServletRequest request, HttpServletResponse response) {
List<Contract> contractList = service.findAll(loginAccount, startDate, endDate, platform,null);
Map<String, String> map = new HashMap<>();
map.put("wait", "未执行");
map.put("executing", "执行中");
map.put("end", "已结束");
map.put("cancel", "作废");
byte[] content = new byte[0];
StringBuilder sb = new StringBuilder();
sb.append("时间,合同编号,客户账号,签约方,销售,开始日期,结束日期,套餐类型,合同金额,折扣,收款金额,合同状态\r\n");
sb.append("时间,合同编号,客户账号,签约方,销售,开始日期,结束日期,套餐类型,合同金额,收款金额,合同状态\r\n");
if(ValidateUtil.isValid(contractList)){
for (Contract c : contractList){
sb.append(c.getDs()).append(",").append(c.getContractCode()).append(",").append(c.getEmail()).append(",").append(c.getCustomerBody()).append(",").append(c.getSaleName()).append(",")
.append(c.getStartDate()).append(",").append(c.getEndDate()).append(",").append(c.getPriceLevelName()).append(",").append(c.getMoney()).append(",").append(c.getRebate()).append(",").append(c.getPayMoney()).append(",")
.append(map.get(c.getStatus())).append("\r\n");
.append(c.getStartDate()).append(",").append(c.getEndDate()).append(",").append(c.getPriceLevelName()).append(",").append(c.getMoney()).append(",").append(c.getRebateMoney()).append(",")
.append(CONTRACT_STATUS.get(c.getStatus())).append("\r\n");
}
}
InputStream in = new ByteArrayInputStream(sb.toString().getBytes());
......
......@@ -37,7 +37,7 @@ public class Contract {
private Long payMoney;
private Long invoice; // 开票次数
private String invoiceMoney; // 发票金额
private BigDecimal invoiceMoney; // 发票金额
private String createName; // 创建人NAME
//合同类型 主套餐 or 增值套餐
private String type;
......@@ -57,16 +57,13 @@ public class Contract {
*/
private Long discountFlow; // 优惠流量
private Long discountTimeLong; // 优惠时长
private Double rebateMoney; //回款金额
private BigDecimal rebateMoney; //回款金额
private String customerShort;// 客户简称
private String customerThird;// 三方客户
private int tradeType; // 行业id
private Long relationContract;// 关联合同id
private String createrName; // 录入人
// private String createrName; // 录入人
private String relationCode;// 关联合同编号
private String hasDiscount;// 是否有优惠
......@@ -262,14 +259,22 @@ public class Contract {
return invoice;
}
public String getInvoiceMoney() {
public BigDecimal getRebateMoney() {
return rebateMoney;
}
public BigDecimal getInvoiceMoney() {
return invoiceMoney;
}
public void setInvoiceMoney(String invoiceMoney) {
public void setInvoiceMoney(BigDecimal invoiceMoney) {
this.invoiceMoney = invoiceMoney;
}
public void setRebateMoney(BigDecimal rebateMoney) {
this.rebateMoney = rebateMoney;
}
public void setInvoice(Long invoice) {
this.invoice = invoice;
}
......@@ -366,14 +371,6 @@ public class Contract {
this.discountTimeLong = discountTimeLong;
}
public Double getRebateMoney() {
return rebateMoney;
}
public void setRebateMoney(Double rebateMoney) {
this.rebateMoney = rebateMoney;
}
public String getCustomerShort() {
return customerShort;
}
......@@ -406,13 +403,13 @@ public class Contract {
this.relationContract = relationContract;
}
public String getCreaterName() {
return createrName;
}
public void setCreaterName(String createrName) {
this.createrName = createrName;
}
// public String getCreaterName() {
// return createrName;
// }
//
// public void setCreaterName(String createrName) {
// this.createrName = createrName;
// }
@Override
public String toString() {
......
......@@ -12,6 +12,6 @@ import java.util.List;
*/
public interface ContractRelationRepository extends JpaRepository<ContractRelation, Long> {
@Query(value = "select main_contract from contract_relation where relation_id = ?1",nativeQuery = true)
@Query(value = "select relation_id from contract_relation where main_contract = ?1",nativeQuery = true)
List<Long> findRelationIds(String contractId);
}
......@@ -22,7 +22,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 order by ds desc",nativeQuery=true)
List<Contract> findByDs(String startDate, String endDate, String platfrom);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and sale in ?4 order by ds desc",nativeQuery=true)
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoile(String startDate, String endDate, String platfrom, List<Long> userids);
@Query(value="select * from contract where contract_code = ?1",nativeQuery=true)
......@@ -49,7 +49,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="SELECT * from contract where end_date <= ?1 and (status <> 'end' or status <> 'cancel')",nativeQuery=true)
List<Contract> findByEndDate(String endDate);
@Query(value = "select count(*) from contract where platform = ?1",nativeQuery = true)
@Query(value = "select count(*) from contract where my_body_code = ?1",nativeQuery = true)
BigInteger findcountContract(String platform);
@Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform = ?1 and c.contractCode is not null and c.contractCode <> 'null'")
......@@ -61,6 +61,6 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and id in ?4 order by ds desc",nativeQuery=true)
List<Contract> findByDsRelation(String startDate, String endDate, String platform, List<Long> contractIds);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and sale in ?4 and id in ?5 order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoileRelation(String startDate, String endDate, String platform, List<Long> idList, List<Long> contractIds);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform = ?3 and create_account in ?4 and id in ?5 order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoileRelation(String startDate, String endDate, String platform, List<Long> create_account, List<Long> contractIds);
}
......@@ -16,6 +16,8 @@ public class Constant {
public static String mailPassword = mailBundle.getString("mail.password");
public static String mailContentType = mailBundle.getString("mail.content_type");
public static String mailList = mailBundle.getString("mail.list");
public static String mailprod = mailBundle.getString("mail.prod");
public static String mailtestUser = mailBundle.getString("mail.test");
public static List<String> mlist = Arrays.asList(mailList.split(","));
public static String mailValidTime = mailBundle.getString("mail.valid_time");
......
......@@ -14,6 +14,7 @@ import org.xbill.DNS.Type;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -36,10 +37,21 @@ public class MailUtils {
SimpleEmail email = new SimpleEmail();
email.setHostName(Constant.mailHost);
email.setAuthentication(FROM_EMAIL_ADDRESS,Constant.mailPassword);
if(!Boolean.getBoolean(Constant.mailprod)){
//测试环境
userEmailAddress = new ArrayList<>();
List<String> users = Arrays.asList(Constant.mailtestUser.split(","));
for(String u :users){
userEmailAddress.add(u+"@reyun.com");
}
}
// 发送给多个人
for (int i = 0; i < userEmailAddress.size(); i++) {
email.addTo(userEmailAddress.get(i), userEmailAddress.get(i));
}
email.setFrom(FROM_EMAIL_ADDRESS, FROM_EMAIL_ADDRESS);
email.setSubject(subject);
email.setContent(contents, CONTENT_TYPE);
......@@ -89,6 +101,17 @@ public class MailUtils {
MultiPartEmail email = new MultiPartEmail();
email.setHostName(Constant.mailHost);
email.setAuthentication(Constant.mailUsername,Constant.mailPassword);
if(!Boolean.getBoolean(Constant.mailprod)){
//测试环境
userEmailAddress = new ArrayList<>();
List<String> users = Arrays.asList(Constant.mailtestUser.split(","));
for(String u :users){
userEmailAddress.add(u+"@reyun.com");
}
}
// 发送给多个人
for (int i = 0; i < userEmailAddress.size(); i++) {
email.addTo(userEmailAddress.get(i), userEmailAddress.get(i));
......@@ -124,6 +147,16 @@ public class MailUtils {
HtmlEmail email = new HtmlEmail();
email.setHostName(Constant.mailHost);
email.setAuthentication(Constant.mailUsername,Constant.mailPassword);
if(!Boolean.getBoolean(Constant.mailprod)){
//测试环境
userEmailAddress = new ArrayList<>();
List<String> users = Arrays.asList(Constant.mailtestUser.split(","));
for(String u :users){
userEmailAddress.add(u+"@reyun.com");
}
}
// 发送给多个人
for (int i = 0; i < userEmailAddress.size(); i++) {
email.addTo(userEmailAddress.get(i), userEmailAddress.get(i));
......
......@@ -4,3 +4,5 @@ mail.password=${mail.password}
mail.content_type=${mail.content_type}
mail.list=${mail.list}
mail.valid_time=${mail.valid_time}
mail.prod=${mail.prod}
mail.test=${mail.test}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment