remove monitor 增加充值管理 修复拼团等轮播不能修改的问题

This commit is contained in:
hupeng
2020-03-02 23:46:12 +08:00
parent 7bfdc8ad76
commit d38a482173
54 changed files with 668 additions and 737 deletions

View File

@ -14,7 +14,6 @@
<module>yshop-logging</module>
<module>yshop-system</module>
<module>yshop-tools</module>
<module>yshop-monitor</module>
<module>yshop-generator</module>
<module>yshop-api</module>
<module>yshop-mp</module>

View File

@ -18,6 +18,7 @@ import co.yixiang.common.web.vo.Paging;
import co.yixiang.constant.ShopConstants;
import co.yixiang.domain.AlipayConfig;
import co.yixiang.domain.vo.TradeVo;
import co.yixiang.enums.BillDetailEnum;
import co.yixiang.enums.BillEnum;
import co.yixiang.enums.OrderInfoEnum;
import co.yixiang.exception.ErrorRequestException;
@ -62,13 +63,10 @@ import co.yixiang.modules.user.service.YxWechatUserService;
import co.yixiang.modules.user.web.vo.YxUserAddressQueryVo;
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
import co.yixiang.modules.user.web.vo.YxWechatUserQueryVo;
import co.yixiang.modules.wechat.entity.YxWechatTemplate;
import co.yixiang.modules.wechat.service.YxWechatTemplateService;
import co.yixiang.mp.service.WxMpTemplateMessageService;
import co.yixiang.mp.service.YxPayService;
import co.yixiang.mp.service.YxTemplateService;
import co.yixiang.service.AlipayService;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -128,8 +126,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
private YxUserBillService billService;
@Autowired
private YxStoreProductReplyService storeProductReplyService;
// @Autowired
//private WxPayService wxPayService;
@Autowired
private YxWechatUserService wechatUserService;
@Autowired
@ -149,10 +145,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
@Autowired
private YxStoreBargainService storeBargainService;
@Autowired
private WxMpTemplateMessageService templateMessageService;
@Autowired
private YxWechatTemplateService yxWechatTemplateService;
@Autowired
private YxExpressService expressService;
@Autowired
private AlipayService alipayService;
@ -168,6 +160,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
@Autowired
private YxPayService payService;
@Autowired
private YxTemplateService templateService;
@ -233,21 +227,12 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
}
//模板消息通知
String siteUrl = RedisUtil.get("site_url");
YxWechatUserQueryVo wechatUser = wechatUserService.getYxWechatUserById(orderQueryVo.getUid());
if(ObjectUtil.isNotNull(wechatUser)){
if(StrUtil.isNotBlank(wechatUser.getOpenid())){
YxWechatTemplate WechatTemplate = yxWechatTemplateService.getOne(
new QueryWrapper<YxWechatTemplate>().eq("tempkey","OPENTM410119152"));
Map<String,String> map = new HashMap<>();
map.put("first","您在yshop的订单退款申请被通过钱款将很快还至您的支付账户。");
map.put("keyword1",orderQueryVo.getOrderId());//订单号
map.put("keyword2",orderQueryVo.getPayPrice().toString());
map.put("keyword3",OrderUtil.stampToDate(orderQueryVo.getAddTime().toString()));
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( wechatUser.getOpenid()
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderQueryVo.getOrderId(),map);
templateService.refundSuccessNotice(orderQueryVo.getOrderId(),
orderQueryVo.getPayPrice().toString(),wechatUser.getOpenid(),
OrderUtil.stampToDate(orderQueryVo.getAddTime().toString()));
}else if(StrUtil.isNotBlank(wechatUser.getRoutineOpenid())){
//todo 小程序通知
}
@ -290,22 +275,11 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
"已发货 快递公司:"+expressQueryVo.getName()+"快递单号:" +param.getDeliveryId());
//模板消息通知
String siteUrl = RedisUtil.get("site_url");
YxWechatUserQueryVo wechatUser = wechatUserService.getYxWechatUserById(orderQueryVo.getUid());
if(ObjectUtil.isNotNull(wechatUser)){
if(StrUtil.isNotBlank(wechatUser.getOpenid())){
YxWechatTemplate WechatTemplate = yxWechatTemplateService.getOne(
new QueryWrapper<YxWechatTemplate>().eq("tempkey","OPENTM200565259"));
//付款成功微信模板通知用户
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword1",storeOrder.getOrderId());//订单号
map.put("keyword2",expressQueryVo.getName());
map.put("keyword3",param.getDeliveryId());
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( wechatUser.getOpenid()
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderQueryVo.getOrderId(),map);
templateService.deliverySuccessNotice(storeOrder.getOrderId(),
expressQueryVo.getName(),param.getDeliveryId(),wechatUser.getOpenid());
}else if(StrUtil.isNotBlank(wechatUser.getRoutineOpenid())){
//todo 小程序通知
}
@ -979,23 +953,12 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
orderInfo.getUid());
}
//模板消息推送
//读取redis配置
String siteUrl = RedisUtil.get("site_url");
YxWechatUserQueryVo wechatUser = wechatUserService.getYxWechatUserById(orderInfo.getUid());
if(ObjectUtil.isNotNull(wechatUser)){
//公众号模板通知
if(StrUtil.isNotBlank(wechatUser.getOpenid())){
YxWechatTemplate WechatTemplate = yxWechatTemplateService.getOne(
new QueryWrapper<YxWechatTemplate>().eq("tempkey","OPENTM207791277"));
//付款成功微信模板通知用户
Map<String,String> map = new HashMap<>();
map.put("first","您的订单已支付成功,我们会尽快为您发货。");
map.put("keyword1",orderInfo.getOrderId());//订单号
map.put("keyword2",orderInfo.getPayPrice().toString());
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( wechatUser.getOpenid()
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderInfo.getOrderId(),map);
templateService.paySuccessNotice(orderInfo.getOrderId(),
orderInfo.getPayPrice().toString(),wechatUser.getOpenid());
}else if(StrUtil.isNotBlank(wechatUser.getRoutineOpenid())){
//todo 小程序模板通知
@ -1049,7 +1012,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
BigDecimal bigDecimal = new BigDecimal(100);
return payService.wxH5Pay(orderId,"H5商品购买",
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),1);
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),
BillDetailEnum.TYPE_3.getValue());
}
@ -1077,7 +1041,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
BigDecimal bigDecimal = new BigDecimal(100);
return payService.wxPay(orderId,wechatUser.getRoutineOpenid(),"小程序商品购买",
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),1);
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),
BillDetailEnum.TYPE_3.getValue());
}
@ -1101,7 +1066,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
BigDecimal bigDecimal = new BigDecimal(100);
return payService.wxPay(orderId,wechatUser.getOpenid(),"公众号商品购买",
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),1);
bigDecimal.multiply(orderInfo.getPayPrice()).intValue(),
BillDetailEnum.TYPE_3.getValue());
}

View File

@ -31,6 +31,9 @@ public class YxUserRecharge extends BaseEntity {
@ApiModelProperty(value = "充值用户UID")
private Integer uid;
@ApiModelProperty(value = "充值用户")
private String nickname;
@ApiModelProperty(value = "订单号")
private String orderId;

View File

@ -27,8 +27,13 @@ import java.io.Serializable;
*/
public interface YxUserRechargeService extends BaseService<YxUserRecharge> {
void updateRecharge(YxUserRecharge userRecharge);
YxUserRecharge getInfoByOrderId(String orderId);
void addRecharge(RechargeParam param,int uid);
/**
* 根据ID获取查询对象
* @param id

View File

@ -8,10 +8,19 @@
*/
package co.yixiang.modules.user.service.impl;
import cn.hutool.core.util.NumberUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.web.vo.Paging;
import co.yixiang.enums.AppFromEnum;
import co.yixiang.enums.BillEnum;
import co.yixiang.enums.OrderInfoEnum;
import co.yixiang.enums.PayTypeEnum;
import co.yixiang.modules.user.entity.YxUser;
import co.yixiang.modules.user.entity.YxUserBill;
import co.yixiang.modules.user.entity.YxUserRecharge;
import co.yixiang.modules.user.mapper.YxUserMapper;
import co.yixiang.modules.user.mapper.YxUserRechargeMapper;
import co.yixiang.modules.user.service.YxUserBillService;
import co.yixiang.modules.user.service.YxUserRechargeService;
import co.yixiang.modules.user.web.param.RechargeParam;
import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam;
@ -19,6 +28,7 @@ import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo;
import co.yixiang.utils.OrderUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -35,7 +45,7 @@ import java.math.BigDecimal;
* </p>
*
* @author hupeng
* @since 2019-12-08
* @since 2020-03-02
*/
@Slf4j
@Service
@ -44,21 +54,60 @@ import java.math.BigDecimal;
public class YxUserRechargeServiceImpl extends BaseServiceImpl<YxUserRechargeMapper, YxUserRecharge> implements YxUserRechargeService {
private final YxUserRechargeMapper yxUserRechargeMapper;
private final YxUserBillService billService;
private final YxUserMapper yxUserMapper;
@Override
public void updateRecharge(YxUserRecharge userRecharge) {
YxUser user = yxUserMapper.selectById(userRecharge.getUid());
//修改状态
userRecharge.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue());
userRecharge.setPayTime(OrderUtil.getSecondTimestampTwo());
userRecharge.setNickname(user.getNickname());
yxUserRechargeMapper.updateById(userRecharge);
//增加流水
YxUserBill userBill = new YxUserBill();
userBill.setUid(userRecharge.getUid());
userBill.setTitle("用户余额充值");
userBill.setLinkId(userRecharge.getId().toString());
userBill.setCategory("now_money");
userBill.setType("recharge");
userBill.setNumber(userRecharge.getPrice());
userBill.setBalance(NumberUtil.add(userRecharge.getPrice(),user.getNowMoney()));
userBill.setMark("成功充值余额"+userRecharge.getPrice());
userBill.setStatus(BillEnum.STATUS_1.getValue());
userBill.setPm(BillEnum.PM_1.getValue());
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
billService.save(userBill);
//update 余额
user.setNowMoney(NumberUtil.add(userRecharge.getPrice(),user.getNowMoney()));
yxUserMapper.updateById(user);
}
@Override
public YxUserRecharge getInfoByOrderId(String orderId) {
YxUserRecharge userRecharge = new YxUserRecharge();
userRecharge.setOrderId(orderId);
return yxUserRechargeMapper.selectOne(Wrappers.query(userRecharge));
}
/**
* 充值(废弃掉)
* 充值
* @param param
*/
@Override
public void addRecharge(RechargeParam param,int uid) {
YxUserRecharge yxUserRecharge = new YxUserRecharge();
String orderId = "re_"+OrderUtil.orderSn();
yxUserRecharge.setOrderId(orderId);
yxUserRecharge.setOrderId(param.getOrderSn());
yxUserRecharge.setUid(uid);
yxUserRecharge.setPrice(BigDecimal.valueOf(param.getPrice()));
yxUserRecharge.setRechargeType("weixin");
yxUserRecharge.setPaid(0);
yxUserRecharge.setRechargeType(PayTypeEnum.WEIXIN.getValue());
yxUserRecharge.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue());
yxUserRecharge.setAddTime(OrderUtil.getSecondTimestampTwo());
yxUserRechargeMapper.insert(yxUserRecharge);

View File

@ -14,6 +14,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.common.api.ApiResult;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.enums.BillDetailEnum;
import co.yixiang.exception.ErrorRequestException;
import co.yixiang.modules.shop.service.YxSystemConfigService;
import co.yixiang.modules.user.entity.YxUser;
@ -48,7 +49,7 @@ import java.util.Map;
* </p>
*
* @author hupeng
* @since 2019-03-01
* @since 2020-03-01
*/
@Slf4j
@RestController
@ -78,17 +79,22 @@ public class UserRechargeController extends BaseController {
//生成分布式唯一值
String orderSn = IdUtil.getSnowflake(0,0).nextIdStr();
param.setOrderSn(orderSn);
userRechargeService.addRecharge(param,uid);
BigDecimal bigDecimal = new BigDecimal(100);
int price = bigDecimal.multiply(BigDecimal.valueOf(param.getPrice())).intValue();
try{
if(param.getFrom().equals("weixinh5")){
WxPayMwebOrderResult result = payService.wxH5Pay(orderSn,"H5充值", price,2);
WxPayMwebOrderResult result = payService.wxH5Pay(orderSn,"H5充值", price,
BillDetailEnum.TYPE_1.getValue());
map.put("data",result.getMwebUrl());
}else{
YxWechatUser wechatUser = wechatUserService.getById(uid);
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
WxPayMpOrderResult result = payService.wxPay(orderSn,wechatUser.getOpenid(),
"H5充值", price,2);
"公众号充值", price,BillDetailEnum.TYPE_1.getValue());
Map<String,String> jsConfig = new HashMap<>();
jsConfig.put("appId",result.getAppId());
jsConfig.put("timeStamp",result.getTimeStamp());

View File

@ -18,4 +18,6 @@ public class RechargeParam implements Serializable {
@NotNull(message = "金额必填")
@Min(value = 1,message = "充值金额不能低于1")
private Double price;
private String orderSn;
}

View File

@ -12,11 +12,16 @@ import cn.hutool.core.util.StrUtil;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.common.api.ApiResult;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.enums.BillDetailEnum;
import co.yixiang.enums.OrderInfoEnum;
import co.yixiang.modules.order.entity.YxStoreOrder;
import co.yixiang.modules.order.service.YxStoreOrderService;
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
import co.yixiang.modules.shop.service.YxSystemConfigService;
import co.yixiang.modules.user.entity.YxUserRecharge;
import co.yixiang.modules.user.service.YxUserRechargeService;
import co.yixiang.mp.config.WxMpConfiguration;
import co.yixiang.mp.config.WxPayConfiguration;
import co.yixiang.utils.RedisUtil;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
@ -53,9 +58,9 @@ import java.util.Map;
@Api(value = "微信模块", tags = "微信:微信模块", description = "微信模块")
public class WechatController extends BaseController {
private final WxPayService wxPayService;
private final YxStoreOrderService orderService;
private final YxSystemConfigService systemConfigService;
private final YxUserRechargeService userRechargeService;
/**
@ -95,6 +100,7 @@ public class WechatController extends BaseController {
@ApiOperation(value = "微信支付回调",notes = "微信支付回调")
public String notify(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
String orderId = notifyResult.getOutTradeNo();
YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,0);
@ -112,6 +118,44 @@ public class WechatController extends BaseController {
}
/**
* 微信支付充值回调
*/
@AnonymousAccess
@PostMapping("/wechat/renotify")
@ApiOperation(value = "微信支付充值回调",notes = "微信支付充值回调")
public String renotify(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
String orderId = notifyResult.getOutTradeNo();
String attach = notifyResult.getAttach();
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,0);
if(orderInfo == null) return WxPayNotifyResponse.success("处理成功!");
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
orderService.paySuccess(orderInfo.getOrderId(),"weixin");
}else if(BillDetailEnum.TYPE_1.getValue().equals(attach)){
//处理充值
YxUserRecharge userRecharge = userRechargeService.getInfoByOrderId(orderId);
if(userRecharge == null) return WxPayNotifyResponse.success("处理成功!");
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(userRecharge.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
userRechargeService.updateRecharge(userRecharge);
}
return WxPayNotifyResponse.success("处理成功!");
} catch (WxPayException e) {
log.error(e.getMessage());
return WxPayNotifyResponse.fail(e.getMessage());
}
}
/**
* 微信退款回调
* @param xmlData
@ -123,6 +167,7 @@ public class WechatController extends BaseController {
@PostMapping("/notify/refund")
public String parseRefundNotifyResult(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayRefundNotifyResult result = wxPayService.parseRefundNotifyResult(xmlData);
String orderId = result.getReqInfo().getOutTradeNo();
Integer refundFee = result.getReqInfo().getRefundFee()/100;

View File

@ -0,0 +1,31 @@
package co.yixiang.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 账单明细相关枚举
*/
@Getter
@AllArgsConstructor
public enum BillDetailEnum {
TYPE_1("recharge","充值"),
TYPE_2("brokerage","返佣"),
TYPE_3("pay_product","消费"),
TYPE_4("extract","提现"),
TYPE_5("pay_product_refund","退款"),
TYPE_6("system_add","系统添加"),
TYPE_7("system_sub","系统减少"),
CATEGORY_1("now_money","金额"),
CATEGORY_2("integral","积分");
private String value;
private String desc;
}

View File

@ -18,6 +18,7 @@ public enum BillEnum {
STATUS_2(2,"无效");
private Integer value;
private String desc;

View File

@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yshop-monitor</artifactId>
<version>2.0</version>
<name>客户端监控模块</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hyperic/sigar -->
<dependency>
<groupId>org.hyperic</groupId>
<artifactId>sigar</artifactId>
<version>1.6.5.132</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
<excludes>
</excludes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<excludes>
<exclude>sigar-lib/**</exclude>
</excludes>
</resource>
</resources>
</build>
</project>

View File

@ -1,21 +0,0 @@
package co.yixiang;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
/**
*
* @author: Zhang houying
* @date: 2019/11/3
*/
@EnableAsync
@SpringBootApplication
public class MonitorRun {
public static void main(String[] args) {
SpringApplication.run(MonitorRun.class, args);
System.out.println("javapath:"+System.getProperty("java.library.path"));
}
}

View File

@ -1,61 +0,0 @@
package co.yixiang.res;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.FileSystemUsage;
import org.hyperic.sigar.Sigar;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @author Zhang houying
* @date 2019-11-03
*/
@RestController
@RequestMapping("/api/serverMonitor")
public class ServerMonitorController {
private Sigar sigar = new Sigar();
private static final double GB = 1024*1024*1024.00;
@GetMapping
public ResponseEntity<Object> getServerInfo(){
Map<String,Object> resultMap = new HashMap<>(8);
try {
CpuInfo[] infoList = sigar.getCpuInfoList();
resultMap.put("cpuRate",sigar.getCpuPerc().getCombined());
resultMap.put("cpuCore",infoList.length);
resultMap.put("memTotal",sigar.getMem().getTotal()/GB);
resultMap.put("memUsed",sigar.getMem().getUsed()/GB);
FileSystem[] fsArray = sigar.getFileSystemList();
double diskTotal = 0;
double diskUsed = 0;
for (FileSystem fileSystem : fsArray) {
try {
FileSystemUsage usage = null;
usage = sigar.getFileSystemUsage(fileSystem.getDirName());
// 本地硬盘
if (fileSystem.getType() == 2) {
diskTotal += usage.getTotal() / GB * 1024;
diskUsed += usage.getUsed() / GB * 1024;
}
} catch (Exception ignored) {
}
}
resultMap.put("diskTotal",diskTotal);
resultMap.put("diskUsed",diskUsed);
resultMap.put("swapTotal",sigar.getSwap().getTotal()/GB);
resultMap.put("swapUsed",sigar.getSwap().getUsed()/GB);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(resultMap, HttpStatus.OK);
}
}

View File

@ -1,279 +0,0 @@
package co.yixiang.utils;
import org.hyperic.sigar.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Properties;
/**
* @author ZhangHouYing
* @date 2019-11-03 15:04
*/
public class SigarUtil {
public static void main(String[] args) {
try {
// System信息从jvm获取
property();
System.out.println("----------------------------------");
// cpu信息
cpu();
System.out.println("----------------------------------");
// 内存信息
memory();
System.out.println("----------------------------------");
// 操作系统信息
os();
System.out.println("----------------------------------");
// 用户信息
who();
System.out.println("----------------------------------");
// 文件系统信息
file();
System.out.println("----------------------------------");
// 网络信息
net();
System.out.println("----------------------------------");
// 以太网信息
ethernet();
System.out.println("----------------------------------");
} catch (Exception e1) {
e1.printStackTrace();
}
}
private static void property() throws UnknownHostException {
Runtime r = Runtime.getRuntime();
Properties props = System.getProperties();
InetAddress addr;
addr = InetAddress.getLocalHost();
String ip = addr.getHostAddress();
Map<String, String> map = System.getenv();
// 获取用户名
String userName = map.get("USERNAME");
// 获取计算机名
String computerName = map.get("COMPUTERNAME");
// 获取计算机域名
String userDomain = map.get("USERDOMAIN");
System.out.println("用户名: " + userName);
System.out.println("计算机名: " + computerName);
System.out.println("计算机域名: " + userDomain);
System.out.println("本地ip地址: " + ip);
System.out.println("本地主机名: " + addr.getHostName());
System.out.println("JVM可以使用的总内存: " + r.totalMemory());
System.out.println("JVM可以使用的剩余内存: " + r.freeMemory());
System.out.println("JVM可以使用的处理器个数: " + r.availableProcessors());
System.out.println("Java的运行环境版本 " + props.getProperty("java.version"));
System.out.println("Java的运行环境供应商 " + props.getProperty("java.vendor"));
System.out.println("Java供应商的URL " + props.getProperty("java.vendor.url"));
System.out.println("Java的安装路径 " + props.getProperty("java.home"));
System.out.println("Java的虚拟机规范版本 " + props.getProperty("java.vm.specification.version"));
System.out.println("Java的虚拟机规范供应商 " + props.getProperty("java.vm.specification.vendor"));
System.out.println("Java的虚拟机规范名称 " + props.getProperty("java.vm.specification.name"));
System.out.println("Java的虚拟机实现版本 " + props.getProperty("java.vm.version"));
System.out.println("Java的虚拟机实现供应商 " + props.getProperty("java.vm.vendor"));
System.out.println("Java的虚拟机实现名称 " + props.getProperty("java.vm.name"));
System.out.println("Java运行时环境规范版本 " + props.getProperty("java.specification.version"));
System.out.println("Java运行时环境规范供应商 " + props.getProperty("java.specification.vender"));
System.out.println("Java运行时环境规范名称 " + props.getProperty("java.specification.name"));
System.out.println("Java的类格式版本号 " + props.getProperty("java.class.version"));
System.out.println("Java的类路径 " + props.getProperty("java.class.path"));
System.out.println("加载库时搜索的路径列表: " + props.getProperty("java.library.path"));
System.out.println("默认的临时文件路径: " + props.getProperty("java.io.tmpdir"));
System.out.println("一个或多个扩展目录的路径: " + props.getProperty("java.ext.dirs"));
System.out.println("操作系统的名称: " + props.getProperty("os.name"));
System.out.println("操作系统的构架: " + props.getProperty("os.arch"));
System.out.println("操作系统的版本: " + props.getProperty("os.version"));
System.out.println("文件分隔符: " + props.getProperty("file.separator"));
System.out.println("路径分隔符: " + props.getProperty("path.separator"));
System.out.println("行分隔符: " + props.getProperty("line.separator"));
System.out.println("用户的账户名称: " + props.getProperty("user.name"));
System.out.println("用户的主目录: " + props.getProperty("user.home"));
System.out.println("用户的当前工作目录: " + props.getProperty("user.dir"));
}
private static void memory() throws SigarException {
Sigar sigar = new Sigar();
Mem mem = sigar.getMem();
// 内存总量
System.out.println("内存总量: " + mem.getTotal() / 1024L + "K av");
// 当前内存使用量
System.out.println("当前内存使用量: " + mem.getUsed() / 1024L + "K used");
// 当前内存剩余量
System.out.println("当前内存剩余量: " + mem.getFree() / 1024L + "K free");
Swap swap = sigar.getSwap();
// 交换区总量
System.out.println("交换区总量: " + swap.getTotal() / 1024L + "K av");
// 当前交换区使用量
System.out.println("当前交换区使用量: " + swap.getUsed() / 1024L + "K used");
// 当前交换区剩余量
System.out.println("当前交换区剩余量: " + swap.getFree() / 1024L + "K free");
}
private static void cpu() throws SigarException {
Sigar sigar = new Sigar();
CpuInfo[] infos = sigar.getCpuInfoList();
CpuPerc[] cpuList;
System.out.println("cpu 总量参数情况:" + sigar.getCpu());
System.out.println("cpu 总百分比情况:" + sigar.getCpuPerc());
cpuList = sigar.getCpuPercList();
// 不管是单块CPU还是多CPU都适用
for (int i = 0; i < infos.length; i++) {
CpuInfo info = infos[i];
System.out.println("" + (i + 1) + "块CPU信息");
// CPU的总量MHz
System.out.println("CPU的总量MHz: " + info.getMhz());
// 获得CPU的卖主Intel
System.out.println("CPU生产商: " + info.getVendor());
// 获得CPU的类别
System.out.println("CPU类别: " + info.getModel());
// 缓冲存储器数量
System.out.println("CPU缓存数量: " + info.getCacheSize());
printCpuPerc(cpuList[i]);
}
}
private static void printCpuPerc(CpuPerc cpu) {
System.out.println("CPU用户使用率: " + CpuPerc.format(cpu.getUser()));
System.out.println("CPU系统使用率: " + CpuPerc.format(cpu.getSys()));
System.out.println("CPU当前等待率: " + CpuPerc.format(cpu.getWait()));
System.out.println("CPU当前错误率: " + CpuPerc.format(cpu.getNice()));
System.out.println("CPU当前空闲率: " + CpuPerc.format(cpu.getIdle()));
System.out.println("CPU总的使用率: " + CpuPerc.format(cpu.getCombined()));
}
private static void os() {
OperatingSystem os = OperatingSystem.getInstance();
// 操作系统内核类型如: 386、486、586等x86
System.out.println("操作系统: " + os.getArch());
System.out.println("操作系统CpuEndian(): " + os.getCpuEndian());
System.out.println("操作系统DataModel(): " + os.getDataModel());
// 系统描述
System.out.println("操作系统的描述: " + os.getDescription());
// 操作系统类型
System.out.println("OS.getName(): " + os.getName());
System.out.println("OS.getPatchLevel(): " + os.getPatchLevel());
// 操作系统的卖主
System.out.println("操作系统的卖主: " + os.getVendor());
// 卖主名称
System.out.println("操作系统的卖主名: " + os.getVendorCodeName());
// 操作系统名称
System.out.println("操作系统名称: " + os.getVendorName());
// 操作系统卖主类型
System.out.println("操作系统卖主类型: " + os.getVendorVersion());
// 操作系统的版本号
System.out.println("操作系统的版本号: " + os.getVersion());
}
private static void who() throws SigarException {
Sigar sigar = new Sigar();
Who[] whos = sigar.getWhoList();
if (whos != null && whos.length > 0) {
for (Who who : whos) {
System.out.println("用户控制台: " + who.getDevice());
System.out.println("用户host: " + who.getHost());
// 当前系统进程表中的用户名
System.out.println("当前系统进程表中的用户名: " + who.getUser());
}
}
}
private static void file() throws Exception {
Sigar sigar = new Sigar();
FileSystem[] fsList = sigar.getFileSystemList();
for (int i = 0; i < fsList.length; i++) {
System.out.println("分区的盘符名称" + i);
FileSystem fs = fsList[i];
// 分区的盘符名称
System.out.println("盘符名称: " + fs.getDevName());
// 分区的盘符名称
System.out.println("盘符路径: " + fs.getDirName());
System.out.println("盘符标志: " + fs.getFlags());
// 文件系统类型,比如 FAT32、NTFS
System.out.println("盘符类型: " + fs.getSysTypeName());
// 文件系统类型名,比如本地硬盘、光驱、网络文件系统等
System.out.println("盘符类型名: " + fs.getTypeName());
// 文件系统类型
System.out.println("盘符文件系统类型: " + fs.getType());
FileSystemUsage usage;
usage = sigar.getFileSystemUsage(fs.getDirName());
switch (fs.getType()) {
// TYPE_UNKNOWN :未知
case 0: break;
// TYPE_NONE
case 1: break;
// TYPE_LOCAL_DISK : 本地硬盘
case 2:
// 文件系统总大小
System.out.println(fs.getDevName() + "总大小: " + usage.getTotal() + "KB");
// 文件系统剩余大小
System.out.println(fs.getDevName() + "剩余大小: " + usage.getFree() + "KB");
// 文件系统可用大小
System.out.println(fs.getDevName() + "可用大小: " + usage.getAvail() + "KB");
// 文件系统已经使用量
System.out.println(fs.getDevName() + "已经使用量: " + usage.getUsed() + "KB");
double usePercent = usage.getUsePercent() * 100D;
// 文件系统资源的利用率
System.out.println(fs.getDevName() + "资源的利用率: " + usePercent + "%");
break;
// TYPE_NETWORK :网络
case 3: break;
// TYPE_RAM_DISK :闪存
case 4: break;
// TYPE_CD_ROM :光驱
case 5: break;
// TYPE_SWAP :页面交换
case 6: break;
default: break;
}
System.out.println(fs.getDevName() + "读出:" + usage.getDiskReads());
System.out.println(fs.getDevName() + "写入:" + usage.getDiskWrites());
}
}
private static void net() throws Exception {
Sigar sigar = new Sigar();
String[] ifNames = sigar.getNetInterfaceList();
for (String name : ifNames) {
NetInterfaceConfig ifconfig = sigar.getNetInterfaceConfig(name);
System.out.println("网络设备名: " + name);
System.out.println("IP地址: " + ifconfig.getAddress());
System.out.println("子网掩码: " + ifconfig.getNetmask());
if ((ifconfig.getFlags() & 1L) <= 0L) {
System.out.println("!IFF_UP...skipping getNetInterfaceStat");
continue;
}
NetInterfaceStat ifstat = sigar.getNetInterfaceStat(name);
System.out.println(name + "接收的总包裹数:" + ifstat.getRxPackets());
System.out.println(name + "发送的总包裹数:" + ifstat.getTxPackets());
System.out.println(name + "接收到的总字节数:" + ifstat.getRxBytes());
System.out.println(name + "发送的总字节数:" + ifstat.getTxBytes());
System.out.println(name + "接收到的错误包数:" + ifstat.getRxErrors());
System.out.println(name + "发送数据包时的错误数:" + ifstat.getTxErrors());
System.out.println(name + "接收时丢弃的包数:" + ifstat.getRxDropped());
System.out.println(name + "发送时丢弃的包数:" + ifstat.getTxDropped());
}
}
private static void ethernet() throws SigarException {
Sigar sigar;
sigar = new Sigar();
String[] ifAces = sigar.getNetInterfaceList();
for (String ifAce : ifAces) {
NetInterfaceConfig cfg = sigar.getNetInterfaceConfig(ifAce);
if (NetFlags.LOOPBACK_ADDRESS.equals(cfg.getAddress()) || (cfg.getFlags() & NetFlags.IFF_LOOPBACK) != 0
|| NetFlags.NULL_HWADDR.equals(cfg.getHwaddr())) {
continue;
}
System.out.println(cfg.getName() + "IP地址:" + cfg.getAddress());
System.out.println(cfg.getName() + "网关广播地址:" + cfg.getBroadcast());
System.out.println(cfg.getName() + "网卡MAC地址:" + cfg.getHwaddr());
System.out.println(cfg.getName() + "子网掩码:" + cfg.getNetmask());
System.out.println(cfg.getName() + "网卡描述信息:" + cfg.getDescription());
System.out.println(cfg.getName() + "网卡类型" + cfg.getType());
}
}
}

View File

@ -1,15 +0,0 @@
__ __ ___ _ _ ___ _ __
\ \ / // __|| | | | / _ \ | '_ \
\ \/ / \__ \| |--| || (_) || |_) |
\/ / |___/|_| |_| \___/ | .__/
/ / | |
/_/ |_|
:: Spring Boot :: (v2.1.0.RELEASE)

View File

@ -1,2 +0,0 @@
server:
port: 8777

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>yshop Monitor</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<!--普通日志输出到控制台-->
<root level="info">
<appender-ref ref="console" />
</root>
</configuration>

View File

@ -40,7 +40,7 @@ public class YxPayService {
* @throws WxPayException
*/
public WxPayMpOrderResult wxPay(String orderId, String openId, String body,
Integer totalFee,int type) throws WxPayException {
Integer totalFee,String attach) throws WxPayException {
String apiUrl = redisHandler.getVal("api_url");
if (StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
@ -54,11 +54,8 @@ public class YxPayService {
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
if(type == 2){
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/renotify");
}else{
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
}
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
@ -78,7 +75,7 @@ public class YxPayService {
* @throws WxPayException
*/
public WxPayMwebOrderResult wxH5Pay(String orderId, String body,
Integer totalFee,int type) throws WxPayException {
Integer totalFee,String attach) throws WxPayException {
String apiUrl = redisHandler.getVal("api_url");
if (StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
@ -91,11 +88,8 @@ public class YxPayService {
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
if(type == 2){
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/renotify");
}else{
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
}
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMwebOrderResult orderResult = wxPayService.createOrder(orderRequest);

View File

@ -0,0 +1,90 @@
package co.yixiang.mp.service;
import co.yixiang.mp.domain.YxWechatTemplate;
import co.yixiang.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName 微信公众号模板通知
* @Author hupeng <610796224@qq.com>
* @Date 2020/3/2
**/
@Service
public class YxTemplateService {
private final String PAY_SUCCESS_KEY = "OPENTM207791277"; //pay
private final String DELIVERY_SUCCESS_KEY = "OPENTM200565259"; //Delivery
private final String REFUND_SUCCESS_KEY = "OPENTM410119152"; //Refund
@Autowired
private YxWechatTemplateService templateService;
@Autowired
private WxMpTemplateMessageService templateMessageService;
/**
* 支付成功通知
* @param orderId
* @param price
* @param openid
*/
public void paySuccessNotice(String orderId,String price,String openid){
String siteUrl = RedisUtil.get("site_url");
YxWechatTemplate WechatTemplate = templateService.findByTempkey(PAY_SUCCESS_KEY);
Map<String,String> map = new HashMap<>();
map.put("first","您的订单已支付成功,我们会尽快为您发货。");
map.put("keyword1",orderId);//订单号
map.put("keyword2",price);
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( openid
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderId,map);
}
/**
* 退款成功通知
* @param orderId
* @param price
* @param openid
* @param time
*/
public void refundSuccessNotice(String orderId,String price,String openid,String time){
String siteUrl = RedisUtil.get("site_url");
YxWechatTemplate WechatTemplate = templateService.findByTempkey(REFUND_SUCCESS_KEY);
Map<String,String> map = new HashMap<>();
map.put("first","您在yshop的订单退款申请被通过钱款将很快还至您的支付账户。");
map.put("keyword1",orderId);//订单号
map.put("keyword2",price);
map.put("keyword3", time);
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( openid
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderId,map);
}
/**
* 发货成功通知
* @param orderId
* @param deliveryName
* @param deliveryId
* @param openid
*/
public void deliverySuccessNotice(String orderId,String deliveryName,String deliveryId,String openid){
String siteUrl = RedisUtil.get("site_url");
YxWechatTemplate WechatTemplate = templateService.findByTempkey(DELIVERY_SUCCESS_KEY);
Map<String,String> map = new HashMap<>();
map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword1",orderId);//订单号
map.put("keyword2",deliveryName);
map.put("keyword3",deliveryId);
map.put("remark","yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage( openid
,WechatTemplate.getTempid(),
siteUrl+"/order/detail/"+orderId,map);
}
}

View File

@ -0,0 +1,64 @@
package co.yixiang.modules.shop.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-03-02
*/
@Entity
@Data
@Table(name="yx_user_recharge")
public class YxUserRecharge implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
/** 充值用户UID */
@Column(name = "uid")
private Integer uid;
/** 订单号 */
@Column(name = "order_id",unique = true)
private String orderId;
/** 充值金额 */
@Column(name = "price")
private BigDecimal price;
/** 充值类型 */
@Column(name = "recharge_type")
private String rechargeType;
/** 是否充值 */
@Column(name = "paid")
private Integer paid;
/** 充值支付时间 */
@Column(name = "pay_time")
private Integer payTime;
/** 充值时间 */
@Column(name = "add_time")
private Integer addTime;
/** 退款金额 */
@Column(name = "refund_price")
private BigDecimal refundPrice;
/** 昵称 */
@Column(name = "nickname")
private String nickname;
public void copy(YxUserRecharge source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,18 @@
package co.yixiang.modules.shop.repository;
import co.yixiang.modules.shop.domain.YxUserRecharge;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author hupeng
* @date 2020-03-02
*/
public interface YxUserRechargeRepository extends JpaRepository<YxUserRecharge, Integer>, JpaSpecificationExecutor<YxUserRecharge> {
/**
* 根据 OrderId 查询
* @param order_id /
* @return /
*/
YxUserRecharge findByOrderId(String order_id);
}

View File

@ -20,6 +20,7 @@ import co.yixiang.modules.shop.service.YxWechatUserService;
import co.yixiang.modules.shop.service.dto.YxWechatUserDTO;
import co.yixiang.mp.domain.YxWechatTemplate;
import co.yixiang.mp.service.WxMpTemplateMessageService;
import co.yixiang.mp.service.YxTemplateService;
import co.yixiang.mp.service.YxWechatTemplateService;
import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.RedisUtil;
@ -56,11 +57,13 @@ public class StoreOrderController {
private final WxMpTemplateMessageService templateMessageService;
private final YxWechatTemplateService yxWechatTemplateService;
private final RedisTemplate<String, String> redisTemplate;
private YxTemplateService templateService;
public StoreOrderController(YxStoreOrderService yxStoreOrderService, YxStoreOrderStatusService yxStoreOrderStatusService,
YxExpressService yxExpressService, YxWechatUserService wechatUserService, WxMpTemplateMessageService templateMessageService,
YxWechatTemplateService yxWechatTemplateService,
RedisTemplate<String, String> redisTemplate) {
RedisTemplate<String, String> redisTemplate,
YxTemplateService templateService) {
this.yxStoreOrderService = yxStoreOrderService;
this.yxStoreOrderStatusService = yxStoreOrderStatusService;
this.yxExpressService = yxExpressService;
@ -68,6 +71,7 @@ public class StoreOrderController {
this.templateMessageService = templateMessageService;
this.yxWechatTemplateService = yxWechatTemplateService;
this.redisTemplate = redisTemplate;
this.templateService = templateService;
}
@GetMapping(value = "/data/count")
@ -192,26 +196,15 @@ public class StoreOrderController {
yxStoreOrderStatusService.create(storeOrderStatus);
//模板消息通知
String siteUrl = RedisUtil.get("site_url");
try {
YxWechatUserDTO wechatUser = wechatUserService.findById(resources.getUid());
if (ObjectUtil.isNotNull(wechatUser)) {
if (StrUtil.isNotBlank(wechatUser.getOpenid())) {
YxWechatTemplate WechatTemplate = yxWechatTemplateService
.findByTempkey("OPENTM200565259");
Map<String, String> map = new HashMap<>();
map.put("first", "亲,宝贝已经启程了,好想快点来到你身边。");
map.put("keyword1", resources.getOrderId());//订单号
map.put("keyword2", expressDTO.getName());
map.put("keyword3", resources.getDeliveryId());
map.put("remark", "yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage(wechatUser.getOpenid()
, WechatTemplate.getTempid(),
siteUrl + "/order/detail/" + resources.getOrderId(), map);
templateService.deliverySuccessNotice(resources.getOrderId(),
expressDTO.getName(),resources.getDeliveryId(),wechatUser.getOpenid());
} else if (StrUtil.isNotBlank(wechatUser.getRoutineOpenid())) {
//todo 小程序通知
}
}
} catch (Exception e) {
log.info("当前用户不是微信用户不能发送模板消息哦!");
@ -235,26 +228,16 @@ public class StoreOrderController {
yxStoreOrderService.refund(resources);
//模板消息通知
String siteUrl = RedisUtil.get("site_url");
try {
YxWechatUserDTO wechatUser = wechatUserService.findById(resources.getUid());
if (ObjectUtil.isNotNull(wechatUser)) {
if (StrUtil.isNotBlank(wechatUser.getOpenid())) {
YxWechatTemplate WechatTemplate = yxWechatTemplateService
.findByTempkey("OPENTM410119152");
Map<String, String> map = new HashMap<>();
map.put("first", "您在yshop的订单退款申请被通过钱款将很快还至您的支付账户。");
map.put("keyword1", resources.getOrderId());//订单号
map.put("keyword2", resources.getPayPrice().toString());
map.put("keyword3", OrderUtil.stampToDate(resources.getAddTime().toString()));
map.put("remark", "yshop电商系统为你服务");
templateMessageService.sendWxMpTemplateMessage(wechatUser.getOpenid()
, WechatTemplate.getTempid(),
siteUrl + "/order/detail/" + resources.getOrderId(), map);
templateService.refundSuccessNotice(resources.getOrderId(),
resources.getPayPrice().toString(),wechatUser.getOpenid(),
OrderUtil.stampToDate(resources.getAddTime().toString()));
} else if (StrUtil.isNotBlank(wechatUser.getRoutineOpenid())) {
//todo 小程序通知
}
}
} catch (Exception e) {
log.info("当前用户不是微信用户不能发送模板消息哦!");

View File

@ -0,0 +1,68 @@
package co.yixiang.modules.shop.rest;
import co.yixiang.aop.log.Log;
import co.yixiang.modules.shop.domain.YxUserRecharge;
import co.yixiang.modules.shop.service.YxUserRechargeService;
import co.yixiang.modules.shop.service.dto.YxUserRechargeQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author hupeng
* @date 2020-03-02
*/
@Api(tags = "充值管理管理")
@RestController
@RequestMapping("/api/yxUserRecharge")
public class UserRechargeController {
private final YxUserRechargeService yxUserRechargeService;
public UserRechargeController(YxUserRechargeService yxUserRechargeService) {
this.yxUserRechargeService = yxUserRechargeService;
}
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('yxUserRecharge:list')")
public void download(HttpServletResponse response, YxUserRechargeQueryCriteria criteria) throws IOException {
yxUserRechargeService.download(yxUserRechargeService.queryAll(criteria), response);
}
@GetMapping
@Log("查询充值管理")
@ApiOperation("查询充值管理")
@PreAuthorize("@el.check('yxUserRecharge:list')")
public ResponseEntity<Object> getYxUserRecharges(YxUserRechargeQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(yxUserRechargeService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增充值管理")
@ApiOperation("新增充值管理")
@PreAuthorize("@el.check('yxUserRecharge:add')")
public ResponseEntity<Object> create(@Validated @RequestBody YxUserRecharge resources){
return new ResponseEntity<>(yxUserRechargeService.create(resources),HttpStatus.CREATED);
}
@Log("删除充值管理")
@ApiOperation("删除充值管理")
@PreAuthorize("@el.check('yxUserRecharge:del')")
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Integer[] ids) {
yxUserRechargeService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/service.iml" filepath="$PROJECT_DIR$/.idea/service.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../../../../../../.." vcs="Git" />
</component>
</project>

View File

@ -1,139 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d0d75b53-cfec-4785-adc2-d809f10f6a57" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../../../../../../../.." />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="D:/apache-maven-3.6.1-bin/apache-maven-3.6.1" />
<option name="userSettingsFile" value="D:\apache-maven-3.6.1-bin\apache-maven-3.6.1\conf\settings.xml" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-12" />
<option name="y" value="-12" />
<option name="width" value="1890" />
<option name="height" value="960" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="service" type="b2602c69:ProjectViewProjectNode" />
<item name="service" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="E:/oldwww/www/mp-ma/joolun" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="MavenSettings" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d0d75b53-cfec-4785-adc2-d809f10f6a57" name="Default Changelist" comment="" />
<created>1582537625774</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1582537625774</updated>
<workItem from="1582537627217" duration="52000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="52000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1295" height="695" extended-state="6" />
<layout>
<window_info id="Image Layers" />
<window_info id="Designer" />
<window_info id="UI Designer" />
<window_info id="Capture Tool" />
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2497979" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Statistic" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Palette" />
<window_info anchor="right" id="Theme Preview" />
<window_info anchor="right" id="Maven" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="right" id="Palette&#9;" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

View File

@ -0,0 +1,62 @@
package co.yixiang.modules.shop.service;
import co.yixiang.modules.shop.domain.YxUserRecharge;
import co.yixiang.modules.shop.service.dto.YxUserRechargeDto;
import co.yixiang.modules.shop.service.dto.YxUserRechargeQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author hupeng
* @date 2020-03-02
*/
public interface YxUserRechargeService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxUserRechargeQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxUserRechargeDto>
*/
List<YxUserRechargeDto> queryAll(YxUserRechargeQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return YxUserRechargeDto
*/
YxUserRechargeDto findById(Integer id);
/**
* 创建
* @param resources /
* @return YxUserRechargeDto
*/
YxUserRechargeDto create(YxUserRecharge resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxUserRechargeDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,42 @@
package co.yixiang.modules.shop.service.dto;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author hupeng
* @date 2020-03-02
*/
@Data
public class YxUserRechargeDto implements Serializable {
private Integer id;
/** 充值用户UID */
private Integer uid;
/** 订单号 */
private String orderId;
/** 充值金额 */
private BigDecimal price;
/** 充值类型 */
private String rechargeType;
/** 是否充值 */
private Integer paid;
/** 充值支付时间 */
private Integer payTime;
/** 充值时间 */
private Integer addTime;
/** 退款金额 */
private BigDecimal refundPrice;
/** 昵称 */
private String nickname;
}

View File

@ -0,0 +1,17 @@
package co.yixiang.modules.shop.service.dto;
import lombok.Data;
import java.util.List;
import co.yixiang.annotation.Query;
/**
* @author hupeng
* @date 2020-03-02
*/
@Data
public class YxUserRechargeQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String nickname;
}

View File

@ -0,0 +1,106 @@
package co.yixiang.modules.shop.service.impl;
import co.yixiang.modules.shop.domain.YxUserRecharge;
import co.yixiang.utils.ValidationUtil;
import co.yixiang.utils.FileUtil;
import co.yixiang.modules.shop.repository.YxUserRechargeRepository;
import co.yixiang.modules.shop.service.YxUserRechargeService;
import co.yixiang.modules.shop.service.dto.YxUserRechargeDto;
import co.yixiang.modules.shop.service.dto.YxUserRechargeQueryCriteria;
import co.yixiang.modules.shop.service.mapper.YxUserRechargeMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import co.yixiang.exception.EntityExistException;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import co.yixiang.utils.PageUtil;
import co.yixiang.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @author hupeng
* @date 2020-03-02
*/
@Service
//@CacheConfig(cacheNames = "yxUserRecharge")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxUserRechargeServiceImpl implements YxUserRechargeService {
private final YxUserRechargeRepository yxUserRechargeRepository;
private final YxUserRechargeMapper yxUserRechargeMapper;
public YxUserRechargeServiceImpl(YxUserRechargeRepository yxUserRechargeRepository, YxUserRechargeMapper yxUserRechargeMapper) {
this.yxUserRechargeRepository = yxUserRechargeRepository;
this.yxUserRechargeMapper = yxUserRechargeMapper;
}
@Override
//@Cacheable
public Map<String,Object> queryAll(YxUserRechargeQueryCriteria criteria, Pageable pageable){
Page<YxUserRecharge> page = yxUserRechargeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(yxUserRechargeMapper::toDto));
}
@Override
//@Cacheable
public List<YxUserRechargeDto> queryAll(YxUserRechargeQueryCriteria criteria){
return yxUserRechargeMapper.toDto(yxUserRechargeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
//@Cacheable(key = "#p0")
public YxUserRechargeDto findById(Integer id) {
YxUserRecharge yxUserRecharge = yxUserRechargeRepository.findById(id).orElseGet(YxUserRecharge::new);
ValidationUtil.isNull(yxUserRecharge.getId(),"YxUserRecharge","id",id);
return yxUserRechargeMapper.toDto(yxUserRecharge);
}
@Override
//@CacheEvict(allEntries = true)
@Transactional(rollbackFor = Exception.class)
public YxUserRechargeDto create(YxUserRecharge resources) {
if(yxUserRechargeRepository.findByOrderId(resources.getOrderId()) != null){
throw new EntityExistException(YxUserRecharge.class,"order_id",resources.getOrderId());
}
return yxUserRechargeMapper.toDto(yxUserRechargeRepository.save(resources));
}
@Override
//@CacheEvict(allEntries = true)
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
yxUserRechargeRepository.deleteById(id);
}
}
@Override
public void download(List<YxUserRechargeDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxUserRechargeDto yxUserRecharge : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("充值用户UID", yxUserRecharge.getUid());
map.put("订单号", yxUserRecharge.getOrderId());
map.put("充值金额", yxUserRecharge.getPrice());
map.put("充值类型", yxUserRecharge.getRechargeType());
map.put("是否充值", yxUserRecharge.getPaid());
map.put("充值支付时间", yxUserRecharge.getPayTime());
map.put("充值时间", yxUserRecharge.getAddTime());
map.put("退款金额", yxUserRecharge.getRefundPrice());
map.put("昵称", yxUserRecharge.getNickname());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,16 @@
package co.yixiang.modules.shop.service.mapper;
import co.yixiang.base.BaseMapper;
import co.yixiang.modules.shop.domain.YxUserRecharge;
import co.yixiang.modules.shop.service.dto.YxUserRechargeDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author hupeng
* @date 2020-03-02
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface YxUserRechargeMapper extends BaseMapper<YxUserRechargeDto, YxUserRecharge> {
}