Commit 35262cd2 by huluobin

业绩

parent 7f08605f
...@@ -42,7 +42,7 @@ import com.gogirl.infrastructure.mapper.product.serve.ProducePromotionTimeMapper ...@@ -42,7 +42,7 @@ import com.gogirl.infrastructure.mapper.product.serve.ProducePromotionTimeMapper
import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper; import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMessageMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerMessageMapper;
import com.gogirl.infrastructure.service.subscribe.PushMsgService; import com.gogirl.infrastructure.service.push.PushMsgService;
import com.gogirl.infrastructure.util.SessionUtils; import com.gogirl.infrastructure.util.SessionUtils;
import com.gogirl.shared.member.order.command.CreateCommentCommand; import com.gogirl.shared.member.order.command.CreateCommentCommand;
import com.gogirl.shared.member.order.command.OrderCommentCommand; import com.gogirl.shared.member.order.command.OrderCommentCommand;
......
...@@ -32,14 +32,9 @@ public class RRExceptionHandler { ...@@ -32,14 +32,9 @@ public class RRExceptionHandler {
result.setCode(e.getCode()); result.setCode(e.getCode());
result.setMessage(e.getMessage()); result.setMessage(e.getMessage());
if (e.getCode() ==500 && e.getMessage().equals("业务异常")) { if (e.getCode() == 500 && e.getMessage().equals("业务异常")) {
//
// log.error("Params : {}", getParamString(request.getParameterMap()) + "\n");
// log.error("URI : {}", request.getRequestURI() + "\n");
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} else { } else {
// log.error("Params : {}", getParamString(request.getParameterMap()) + "\n");
// log.error("URI : {}", request.getRequestURI() + "\n");
log.error(e.getMessage()); log.error(e.getMessage());
} }
return result; return result;
......
package com.gogirl.infrastructure.interceptor; package com.gogirl.infrastructure.interceptor;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson; import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.common.util.JsonUtilByJackson;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -76,13 +74,6 @@ public class LogAspect { ...@@ -76,13 +74,6 @@ public class LogAspect {
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
// 会打印出一个对象,想打印出具体内容需要在定义模型处加上toString() // 会打印出一个对象,想打印出具体内容需要在定义模型处加上toString()
//logger.info( "result:{}", object.toString() ); //logger.info( "result:{}", object.toString() );
try {
JsonResult jsonResult = JsonUtilByJackson.readValue(JsonUtilByJackson.writeValueAsString(object), JsonResult.class);
jsonResult.setData("hidden data");
logger.info("result:{}", JsonUtilByJackson.writeValueAsString(jsonResult));
} catch (Exception ignore) {
}
} }
/** /**
...@@ -98,11 +89,16 @@ public class LogAspect { ...@@ -98,11 +89,16 @@ public class LogAspect {
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
//时间差 //时间差
long timeDiff = (end - begin); long timeDiff = (end - begin);
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
String uri = request.getRequestURI();
String msg = "方法性能分析: 执行耗时 {}毫秒,来自Dream PWJ的表情"; String msg = "方法性能分析: 执行耗时 {}毫秒,来自Dream PWJ的表情";
if (timeDiff < 200) { if (timeDiff < 200) {
logger.info("方法性能分析: 执行耗时 {}毫秒," + "\uD83D\uDE02", timeDiff); logger.info("{}:方法性能分析: 执行耗时 {}毫秒," + "\uD83D\uDE02", uri, timeDiff);
} else { } else {
logger.warn("方法性能分析: 执行耗时 {}毫秒," + "\uD83D\uDE31", timeDiff); logger.warn("{}:方法性能分析: 执行耗时 {}毫秒," + "\uD83D\uDE31", uri, timeDiff);
} }
return obj; return obj;
} }
......
...@@ -43,7 +43,7 @@ import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper; ...@@ -43,7 +43,7 @@ import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper;
import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper; import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper; import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper;
import com.gogirl.infrastructure.service.subscribe.PushMsgService; import com.gogirl.infrastructure.service.push.PushMsgService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.gogirl.infrastructure.service.mail;
public interface MailService {
/**
* 发送纯文本的简单邮件
*
* @param to
* @param subject
* @param content
*/
public void sendSimpleMail(String to, String subject, String content);
/**
* 发送html格式的邮件
*
* @param to
* @param subject
* @param content
*/
public void sendHtmlMail(String to, String subject, String content);
/**
* 发送带附件的邮件
*
* @param to
* @param subject
* @param content
* @param filePath
*/
public void sendAttachmentsMail(String to, String subject, String content, String filePath);
/**
* 发送嵌入静态资源(一般是图片)的邮件
*
* @param to
* @param subject
* @param content 邮件内容,需要包括一个静态资源的id,比如:<img src=\"cid:rscId01\" >
* @param rscPath 静态资源路径和文件名
* @param rscId 静态资源id
*/
public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId);
}
package com.gogirl.infrastructure.service.mail.impl;
import com.gogirl.infrastructure.service.mail.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
@Service
@Slf4j
public class MailServiceImpl implements MailService {
@Resource
JavaMailSender sender;
@Value("${spring.mail.username}")
private String from;
/**
* 发送纯文本的简单邮件
*
* @param to
* @param subject
* @param content
*/
public void sendSimpleMail(String to, String subject, String content) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(content);
try {
sender.send(message);
log.info("简单邮件已经发送。");
} catch (Exception e) {
log.error("发送简单邮件时发生异常!", e);
}
}
/**
* 发送html格式的邮件
*
* @param to
* @param subject
* @param content
*/
public void sendHtmlMail(String to, String subject, String content) {
MimeMessage message = sender.createMimeMessage();
try {
//true表示需要创建一个multipart message
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(content, true);
sender.send(message);
log.info("html邮件已经发送。");
} catch (MessagingException e) {
log.error("发送html邮件时发生异常!", e);
}
}
/**
* 发送带附件的邮件
*
* @param to
* @param subject
* @param content
* @param filePath
*/
public void sendAttachmentsMail(String to, String subject, String content, String filePath) {
MimeMessage message = sender.createMimeMessage();
try {
//true表示需要创建一个multipart message
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(content, true);
FileSystemResource file = new FileSystemResource(new File(filePath));
String fileName = filePath.substring(filePath.lastIndexOf(File.separator));
helper.addAttachment(fileName, file);
sender.send(message);
log.info("带附件的邮件已经发送。");
} catch (MessagingException e) {
log.error("发送带附件的邮件时发生异常!", e);
}
}
/**
* 发送嵌入静态资源(一般是图片)的邮件
*
* @param to
* @param subject
* @param content 邮件内容,需要包括一个静态资源的id,比如:<img src=\"cid:rscId01\" >
* @param rscPath 静态资源路径和文件名
* @param rscId 静态资源id
*/
public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId) {
MimeMessage message = sender.createMimeMessage();
try {
//true表示需要创建一个multipart message
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(content, true);
FileSystemResource res = new FileSystemResource(new File(rscPath));
helper.addInline(rscId, res);
sender.send(message);
log.info("嵌入静态资源的邮件已经发送。");
} catch (MessagingException e) {
log.error("发送嵌入静态资源的邮件时发生异常!", e);
}
}
}
package com.gogirl.infrastructure.service.subscribe; package com.gogirl.infrastructure.service.push;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
......
package com.gogirl.infrastructure.service.subscribe.impl; package com.gogirl.infrastructure.service.push.impl;
import com.gogirl.application.xcx.impl.AccessTokenService; import com.gogirl.application.xcx.impl.AccessTokenService;
import com.gogirl.infrastructure.common.base.JsonResult; import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson; import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.config.property.WxProperties; import com.gogirl.infrastructure.config.property.WxProperties;
import com.gogirl.infrastructure.service.subscribe.PushMsgService; import com.gogirl.infrastructure.service.push.PushMsgService;
import com.gogirl.shared.wx.*; import com.gogirl.shared.wx.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
...@@ -40,7 +40,17 @@ spring: ...@@ -40,7 +40,17 @@ spring:
username: root username: root
password: "#7kfnymAM$Y9-Ntf" password: "#7kfnymAM$Y9-Ntf"
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
mail:
host: smtp.qq.com
username: robbendev@qq.com
password: hccmfwhgcrnccagh
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
#redis配置 #redis配置
redis: redis:
host: 127.0.0.1 host: 127.0.0.1
...@@ -90,4 +100,5 @@ wx: ...@@ -90,4 +100,5 @@ wx:
keyPath: "/usr/local/src/gogirl/gogirl-payment/apiclient_cert.p12" keyPath: "/usr/local/src/gogirl/gogirl-payment/apiclient_cert.p12"
server: server:
port: 5444 port: 5444
\ No newline at end of file
spring: spring:
profiles: profiles:
active: pre active: prod
servlet: servlet:
#文件上传最大容量 #文件上传最大容量
multipart: multipart:
......
...@@ -142,12 +142,12 @@ ...@@ -142,12 +142,12 @@
FROM ( FROM (
SELECT a.id, SELECT a.id,
a.achievement / (char_length(a.technician_id) - char_length(REPLACE(a.technician_id, ',', '')) + a.achievement / (char_length(a.technician_id) - char_length(REPLACE(a.technician_id, ',', '')) +
1) as achievement, 1) as achievement,
a.serve_type, a.serve_type,
substring_index(substring_index(a.technician_id, ',', b.help_topic_id + 1), ',', substring_index(substring_index(a.technician_id, ',', b.help_topic_id + 1), ',',
-1) as technician_id, -1) as technician_id,
t2.`name` technician_name, t2.`name` technician_name,
t2.picture_path technician_picture, t2.picture_path technician_picture,
c.department_id c.department_id
FROM order_serve a FROM order_serve a
JOIN mysql.help_topic AS b ON b.help_topic_id &lt; (char_length(a.technician_id) - JOIN mysql.help_topic AS b ON b.help_topic_id &lt; (char_length(a.technician_id) -
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
and a.start_time LIKE concat(#{month}, '%') and a.start_time LIKE concat(#{month}, '%')
and (c.`status` = 4 or c.`status` = 3) and (c.`status` = 4 or c.`status` = 3)
) t1 ) t1
GROUP BY t1.serve_type, t1.technician_id GROUP BY t1.serve_type, t1.technician_id, t1.department_id
</select> </select>
<select id="chargeAchieve" resultType="java.math.BigDecimal"> <select id="chargeAchieve" resultType="java.math.BigDecimal">
......
...@@ -3,11 +3,13 @@ package com.gogirl; ...@@ -3,11 +3,13 @@ package com.gogirl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gogirl.application.market.coupon.CouponCustomerRelevanceService; import com.gogirl.application.market.coupon.CouponCustomerRelevanceService;
import com.gogirl.application.market.coupon.CouponService;
import com.gogirl.application.market.timescard.TimesCardCustomerRelevanceService; import com.gogirl.application.market.timescard.TimesCardCustomerRelevanceService;
import com.gogirl.application.market.timescard.TimesCardUsedRecordService; import com.gogirl.application.market.timescard.TimesCardUsedRecordService;
import com.gogirl.application.store.store.StoreTechnicianService; import com.gogirl.application.store.store.StoreTechnicianService;
import com.gogirl.application.xcx.GogirlTokenService; import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.domain.market.coupon.CouponCustomerRelevance; import com.gogirl.domain.market.coupon.CouponCustomerRelevance;
import com.gogirl.domain.market.discount.DiscountConfig;
import com.gogirl.domain.order.pay.OrderPay; import com.gogirl.domain.order.pay.OrderPay;
import com.gogirl.domain.order.serve.MultiPaymentType; import com.gogirl.domain.order.serve.MultiPaymentType;
import com.gogirl.domain.order.serve.OrderManage; import com.gogirl.domain.order.serve.OrderManage;
...@@ -19,12 +21,15 @@ import com.gogirl.domain.store.complaint.ComplaintDetailedTechnician; ...@@ -19,12 +21,15 @@ import com.gogirl.domain.store.complaint.ComplaintDetailedTechnician;
import com.gogirl.domain.store.complaint.ComplaintMain; import com.gogirl.domain.store.complaint.ComplaintMain;
import com.gogirl.domain.store.store.StoreTechnician; import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.user.customer.Customer; import com.gogirl.domain.user.customer.Customer;
import com.gogirl.domain.user.customer.CustomerBalance;
import com.gogirl.domain.user.customer.CustomerBalanceRecord; import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import com.gogirl.domain.xcx.GogirlToken; import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.domain.xcx.TimeNode; import com.gogirl.domain.xcx.TimeNode;
import com.gogirl.domain.xcx.WeekConfig; import com.gogirl.domain.xcx.WeekConfig;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson; import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.mapper.market.coupon.CouponCustomerRelevanceMapper; import com.gogirl.infrastructure.mapper.market.coupon.CouponCustomerRelevanceMapper;
import com.gogirl.infrastructure.mapper.market.discount.DiscountConfigMapper;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigWeekMapper; import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigWeekMapper;
import com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper; import com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper;
import com.gogirl.infrastructure.mapper.order.pay.OrderPayMapper; import com.gogirl.infrastructure.mapper.order.pay.OrderPayMapper;
...@@ -35,6 +40,7 @@ import com.gogirl.infrastructure.mapper.product.purchase.PurchaseStockRecordMapp ...@@ -35,6 +40,7 @@ import com.gogirl.infrastructure.mapper.product.purchase.PurchaseStockRecordMapp
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedTechnicianMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedTechnicianMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintMainMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintMainMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper;
import com.gogirl.infrastructure.mapper.xcx.TimeNodeMapper; import com.gogirl.infrastructure.mapper.xcx.TimeNodeMapper;
...@@ -52,10 +58,7 @@ import java.text.SimpleDateFormat; ...@@ -52,10 +58,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
...@@ -355,4 +358,117 @@ public class Test { ...@@ -355,4 +358,117 @@ public class Test {
}); });
} }
@Resource
CustomerBalanceMapper customerBalanceMapper;
@Resource
DiscountConfigMapper discountConfigMapper;
@Resource
CouponService couponService;
@org.junit.Test
public void notifyChargeOrder() {
int totalFee = 100000;
String openid = "ot_nm5VbDqBbl6trcHKL0LM_AiNA";
Customer customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, openid));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(
new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
DiscountConfig discountConfig = discountConfigMapper.selectList(new LambdaQueryWrapper<>())
.stream().filter(config -> config.getChargeAmount() <= totalFee)
.max(Comparator.comparing(DiscountConfig::getChargeAmount)).orElseThrow(RRException::new);
couponService.sendCoupon(discountConfig.getCouponId(), customer.getId());
//首次充值
if (customerBalance == null || customerBalance.getBalance() == 0) {
if (customerBalance == null) {
customerBalance = CustomerBalance.builder()
//充值金额+赠送金额
.balance(totalFee)
.customerId(customer.getId())
.currentDiscount(1.00)
.discountRate(0.00)
.firstChargeTime(new Date())
.level(discountConfig.getLevel())
//赠送金额
.totalBestow(0)
//总充值金额
.totalCharge(totalFee)
.totalExpenditure(0)
.updateTime(new Date())
.version(5)
.build();
} else {
customerBalance.setBalance(totalFee);
customerBalance.setCurrentDiscount(1.00);
customerBalance.setDiscountRate(0.00);
customerBalance.setFirstChargeTime(new Date());
customerBalance.setLevel(discountConfig.getLevel());
customerBalance.setTotalBestow(0);
customerBalance.setTotalCharge(totalFee);
customerBalance.setTotalExpenditure(0);
customerBalance.setUpdateTime(new Date());
customerBalance.setVersion(5);
}
//会员卡不存在
if (customerBalance.getId() == null) {
customerBalanceMapper.insert(customerBalance);
}
//会员卡存在
else {
customerBalanceMapper.updateById(customerBalance);
}
CustomerBalanceRecord customerBalanceRecord = CustomerBalanceRecord.builder()
.time(new Date())
.orderId(IdWorker.getIdStr())
.orderAmount(totalFee)
.discount(1.00)
.currentBalance(customerBalance.getBalance())
.bestowAmount(0)
//首次充值
.type(1)
.customerId(customer.getId())
//微信支付
.source(1)
.build();
customerBalanceRecordMapper.insert(customerBalanceRecord);
}
//充值
else {
//更新用户余额
customerBalance.setBalance(customerBalance.getBalance() + totalFee);
customerBalance.setLevel(discountConfig.getLevel());
customerBalance.setUpdateTime(new Date());
//总送
customerBalance.setTotalCharge(customerBalance.getTotalCharge() + totalFee);
customerBalanceMapper.updateById(customerBalance);
//
CustomerBalanceRecord customerBalanceRecord = CustomerBalanceRecord.builder()
.time(new Date())
.orderId(IdWorker.getIdStr())
.orderAmount(totalFee)
.discount(1.00)
.currentBalance(customerBalance.getBalance())
.bestowAmount(0)
//首次充值
.type(1)
.customerId(customer.getId())
//微信支付
.source(1)
.build();
customerBalanceRecordMapper.insert(customerBalanceRecord);
}
}
} }
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