代码完善
This commit is contained in:
parent
a0ab50c656
commit
9d6cc08560
9
pom.xml
9
pom.xml
@ -44,6 +44,15 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-easysdk -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
<version>4.9.28.ALL</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- SpringBoot Websocket -->
|
<!-- SpringBoot Websocket -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -43,15 +43,16 @@ public class RyTask
|
|||||||
|
|
||||||
//定时任务,每15s对设备进行一次检测,超过30s未运行,返回异常信息给前端,同时将该设备运行状态改为停用
|
//定时任务,每15s对设备进行一次检测,超过30s未运行,返回异常信息给前端,同时将该设备运行状态改为停用
|
||||||
public void reportCurrentTime1() {
|
public void reportCurrentTime1() {
|
||||||
// System.out.println("11");
|
|
||||||
long l = System.currentTimeMillis();
|
long l = System.currentTimeMillis();
|
||||||
Map<Integer, Long> upsMap = Util1.upsMap;
|
Map<Integer, Long> upsMap = Util1.upsMap;
|
||||||
for (Map.Entry<Integer, Long> entry : upsMap.entrySet()) {
|
for (Map.Entry<Integer, Long> entry : upsMap.entrySet()) {
|
||||||
if(l-entry.getValue()>=30000){
|
if(l-entry.getValue()>=30000){
|
||||||
System.out.println(entry.getKey());
|
System.out.println(entry.getKey());
|
||||||
|
//更新设备状态
|
||||||
pupuEquipmentService.updateEquipmentStatus(entry.getKey(),1);
|
pupuEquipmentService.updateEquipmentStatus(entry.getKey(),1);
|
||||||
WsServerEndpoint wsServerEndpoint=new WsServerEndpoint();
|
// WsServerEndpoint wsServerEndpoint=new WsServerEndpoint();
|
||||||
try {
|
try {
|
||||||
|
//向前端传输异常信息
|
||||||
wsServerEndpoint.sendAllUser("id"+entry.getKey()+"设备异常");
|
wsServerEndpoint.sendAllUser("id"+entry.getKey()+"设备异常");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -15,16 +15,37 @@ public class PupuEquipmentController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PupuEquipmentService pupuEquipmentService;
|
private PupuEquipmentService pupuEquipmentService;
|
||||||
|
|
||||||
@PutMapping("/add")
|
/**
|
||||||
public AjaxResult add(@RequestBody PupuEquipment pupuEquipment){
|
* 设备新增
|
||||||
return toAjax(pupuEquipmentService.add(pupuEquipment));
|
* @param pupuEquipment
|
||||||
|
* @param userId 用户id(用于日志生成时记录操作人员)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/add/{userId}")
|
||||||
|
public AjaxResult add(
|
||||||
|
@RequestBody PupuEquipment pupuEquipment,
|
||||||
|
@PathVariable(value = "userId") Integer userId){
|
||||||
|
return toAjax(pupuEquipmentService.add(pupuEquipment,userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/del/{equipmentId}")
|
/**
|
||||||
public AjaxResult del(@PathVariable(value = "equipmentId") Integer equipmentId){
|
* 设备删除
|
||||||
return toAjax(pupuEquipmentService.del(equipmentId));
|
* @param equipmentId
|
||||||
|
* @param userId 用户id(用于记录执行删除操作的用户id)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/del/{equipmentId}/{userId}")
|
||||||
|
public AjaxResult del(
|
||||||
|
@PathVariable(value = "equipmentId") Integer equipmentId,
|
||||||
|
@PathVariable(value = "userId")Integer userId){
|
||||||
|
return toAjax(pupuEquipmentService.del(equipmentId,userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前门店的设备信息
|
||||||
|
* @param storeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/selectByStoreId/{storeId}")
|
@GetMapping("/selectByStoreId/{storeId}")
|
||||||
public AjaxResult selectByStoreId(@PathVariable(value = "storeId") Integer storeId){
|
public AjaxResult selectByStoreId(@PathVariable(value = "storeId") Integer storeId){
|
||||||
List<PupuEquipment> pupuEquipments = pupuEquipmentService.selectByStoreId(storeId);
|
List<PupuEquipment> pupuEquipments = pupuEquipmentService.selectByStoreId(storeId);
|
||||||
|
@ -20,23 +20,29 @@ public class PupuStoreController extends BaseController {
|
|||||||
private PupuStoreService pupuStoreService;
|
private PupuStoreService pupuStoreService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增门店
|
* 门店新增
|
||||||
* @param pupuStore
|
* @param pupuStore
|
||||||
|
* @param userId(执行新增操作的用户id)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PutMapping("/add")
|
@PutMapping("/add/{userId}")
|
||||||
public AjaxResult add(@Validated @RequestBody PupuStore pupuStore){
|
public AjaxResult add(
|
||||||
return toAjax(pupuStoreService.add(pupuStore));
|
@Validated @RequestBody PupuStore pupuStore,
|
||||||
|
@PathVariable(value = "userId") Integer userId){
|
||||||
|
return toAjax(pupuStoreService.add(pupuStore,userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除门店
|
* 删除门店
|
||||||
* @param storeId
|
* @param storeId
|
||||||
|
* @param userId (执行删除操作的用户id)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/del/{storeId}")
|
@DeleteMapping("/del/{storeId}/{userId}")
|
||||||
public AjaxResult del(@PathVariable(value = "storeId")Integer storeId){
|
public AjaxResult del(
|
||||||
return toAjax(pupuStoreService.del(storeId));
|
@PathVariable(value = "storeId")Integer storeId,
|
||||||
|
@PathVariable(value = "userId")Integer userId){
|
||||||
|
return toAjax(pupuStoreService.del(storeId,userId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hit/user")
|
@RequestMapping("/hit/user")
|
||||||
@ -39,8 +39,9 @@ public class PupuUserController extends BaseController {
|
|||||||
String token = JwtUtil.generateToken(userLoginVO.getUserName());
|
String token = JwtUtil.generateToken(userLoginVO.getUserName());
|
||||||
// System.out.println("登录token:"+token);
|
// System.out.println("登录token:"+token);
|
||||||
// redisTemplate.opsForValue().set(token,loginer.toString(),60,TimeUnit.MINUTES);
|
// redisTemplate.opsForValue().set(token,loginer.toString(),60,TimeUnit.MINUTES);
|
||||||
Map<String,String> map=new HashMap<>();
|
Map<String,Object> map=new HashMap<>();
|
||||||
map.put("Token",token);
|
map.put("Token",token);
|
||||||
|
map.put("userId",loginer.getUserId());
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(map);
|
||||||
}else {
|
}else {
|
||||||
return AjaxResult.error("账号或密码错误");
|
return AjaxResult.error("账号或密码错误");
|
||||||
|
@ -22,6 +22,8 @@ public class PupuLog implements Serializable {
|
|||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date time;
|
private Date time;
|
||||||
|
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public PupuLog(String logEvent, Integer logSort, Date time) {
|
public PupuLog(String logEvent, Integer logSort, Date time) {
|
||||||
@ -29,4 +31,11 @@ public class PupuLog implements Serializable {
|
|||||||
this.logSort = logSort;
|
this.logSort = logSort;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PupuLog(String logEvent, Integer logSort, Date time, Integer userId) {
|
||||||
|
this.logEvent = logEvent;
|
||||||
|
this.logSort = logSort;
|
||||||
|
this.time = time;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package com.ruoyi.project.hit.mapper;
|
|||||||
|
|
||||||
import com.ruoyi.project.hit.domain.PupuEquipment;
|
import com.ruoyi.project.hit.domain.PupuEquipment;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HP
|
* @author HP
|
||||||
@ -9,8 +10,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* @createDate 2024-09-05 16:50:18
|
* @createDate 2024-09-05 16:50:18
|
||||||
* @Entity com.ruoyi.project.hit.domain.PupuEquipment
|
* @Entity com.ruoyi.project.hit.domain.PupuEquipment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface PupuEquipmentMapper extends BaseMapper<PupuEquipment> {
|
public interface PupuEquipmentMapper extends BaseMapper<PupuEquipment> {
|
||||||
|
|
||||||
|
@Options(useGeneratedKeys = true, keyProperty = "equipmentId")
|
||||||
|
int insertAndReturnId(PupuEquipment pupuEquipment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* @Entity com.ruoyi.project.hit.domain.PupuStore
|
* @Entity com.ruoyi.project.hit.domain.PupuStore
|
||||||
*/
|
*/
|
||||||
public interface PupuStoreMapper extends BaseMapper<PupuStore> {
|
public interface PupuStoreMapper extends BaseMapper<PupuStore> {
|
||||||
|
int insertReturnId(PupuStore pupuStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface PupuEquipmentService extends IService<PupuEquipment> {
|
public interface PupuEquipmentService extends IService<PupuEquipment> {
|
||||||
|
|
||||||
int add(PupuEquipment pupuEquipment);
|
int add(PupuEquipment pupuEquipment, Integer userId);
|
||||||
|
|
||||||
int del(Integer equipmentId);
|
int del(Integer equipmentId, Integer userId);
|
||||||
|
|
||||||
List<PupuEquipment> selectByStoreId(Integer storeId);
|
List<PupuEquipment> selectByStoreId(Integer storeId);
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface PupuStoreService extends IService<PupuStore> {
|
public interface PupuStoreService extends IService<PupuStore> {
|
||||||
|
|
||||||
int add(PupuStore pupuStore);
|
int add(PupuStore pupuStore, Integer userId);
|
||||||
|
|
||||||
int del(Integer storeId);
|
int del(Integer storeId, Integer userId);
|
||||||
|
|
||||||
List<Map<String, Object>> select();
|
List<Map<String, Object>> select();
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.ruoyi.common.exception.CustomException;
|
import com.ruoyi.common.exception.CustomException;
|
||||||
import com.ruoyi.project.hit.domain.PupuEquipment;
|
import com.ruoyi.project.hit.domain.PupuEquipment;
|
||||||
import com.ruoyi.project.hit.domain.PupuLog;
|
import com.ruoyi.project.hit.domain.PupuLog;
|
||||||
import com.ruoyi.project.hit.domain.PupuStore;
|
|
||||||
import com.ruoyi.project.hit.mapper.PupuStoreMapper;
|
import com.ruoyi.project.hit.mapper.PupuStoreMapper;
|
||||||
import com.ruoyi.project.hit.service.PupuEquipmentService;
|
import com.ruoyi.project.hit.service.PupuEquipmentService;
|
||||||
import com.ruoyi.project.hit.mapper.PupuEquipmentMapper;
|
import com.ruoyi.project.hit.mapper.PupuEquipmentMapper;
|
||||||
import com.ruoyi.project.hit.service.PupuLogService;
|
import com.ruoyi.project.hit.service.PupuLogService;
|
||||||
import com.ruoyi.project.hit.service.PupuStoreService;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -34,7 +32,7 @@ public class PupuEquipmentServiceImpl extends ServiceImpl<PupuEquipmentMapper, P
|
|||||||
private PupuStoreMapper pupuStoreMapper;
|
private PupuStoreMapper pupuStoreMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int add(PupuEquipment pupuEquipment) {
|
public int add(PupuEquipment pupuEquipment, Integer userId) {
|
||||||
if(pupuStoreMapper.selectById(pupuEquipment.getStoreId())==null){
|
if(pupuStoreMapper.selectById(pupuEquipment.getStoreId())==null){
|
||||||
throw new CustomException("该门店不存在");
|
throw new CustomException("该门店不存在");
|
||||||
}
|
}
|
||||||
@ -43,16 +41,20 @@ public class PupuEquipmentServiceImpl extends ServiceImpl<PupuEquipmentMapper, P
|
|||||||
if(pupuEquipmentMapper.selectOne(wrapper)!=null){
|
if(pupuEquipmentMapper.selectOne(wrapper)!=null){
|
||||||
throw new CustomException("标识码重复");
|
throw new CustomException("标识码重复");
|
||||||
};
|
};
|
||||||
pupuLogService.add(new PupuLog("设备新增",1,new Date()));
|
int i=0;
|
||||||
return pupuEquipmentMapper.insert(pupuEquipment);
|
i = pupuEquipmentMapper.insertAndReturnId(pupuEquipment);
|
||||||
|
if(i>0){
|
||||||
|
pupuLogService.add(new PupuLog("设备"+pupuEquipment.getEquipmentId()+"新增",1,new Date(),userId));
|
||||||
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int del(Integer equipmentId) {
|
public int del(Integer equipmentId, Integer userId) {
|
||||||
if(pupuEquipmentMapper.selectById(equipmentId)==null){
|
if(pupuEquipmentMapper.selectById(equipmentId)==null){
|
||||||
throw new CustomException("该设备不存在");
|
throw new CustomException("该设备不存在");
|
||||||
}
|
}
|
||||||
pupuLogService.add(new PupuLog("设备删除",2,new Date()));
|
pupuLogService.add(new PupuLog("设备"+equipmentId+"删除",2,new Date(),userId));
|
||||||
return pupuEquipmentMapper.deleteById(equipmentId);
|
return pupuEquipmentMapper.deleteById(equipmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.project.hit.service.impl;
|
package com.ruoyi.project.hit.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
import com.ruoyi.project.hit.domain.PupuLog;
|
import com.ruoyi.project.hit.domain.PupuLog;
|
||||||
import com.ruoyi.project.hit.domain.vo.SelectLogVO;
|
import com.ruoyi.project.hit.domain.vo.SelectLogVO;
|
||||||
import com.ruoyi.project.hit.service.PupuLogService;
|
import com.ruoyi.project.hit.service.PupuLogService;
|
||||||
@ -24,6 +25,9 @@ public class PupuLogServiceImpl extends ServiceImpl<PupuLogMapper, PupuLog>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int add(PupuLog pupuLog) {
|
public int add(PupuLog pupuLog) {
|
||||||
|
if(pupuLog.getUserId()==0){
|
||||||
|
throw new CustomException("日志生成异常,未捕获操作用户的id");
|
||||||
|
}
|
||||||
return pupuLogMapper.insert(pupuLog);
|
return pupuLogMapper.insert(pupuLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,11 @@ package com.ruoyi.project.hit.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
|
import com.ruoyi.project.hit.domain.PupuEquipment;
|
||||||
import com.ruoyi.project.hit.domain.PupuLog;
|
import com.ruoyi.project.hit.domain.PupuLog;
|
||||||
import com.ruoyi.project.hit.domain.PupuStore;
|
import com.ruoyi.project.hit.domain.PupuStore;
|
||||||
|
import com.ruoyi.project.hit.mapper.PupuEquipmentMapper;
|
||||||
import com.ruoyi.project.hit.service.PupuLogService;
|
import com.ruoyi.project.hit.service.PupuLogService;
|
||||||
import com.ruoyi.project.hit.service.PupuStoreService;
|
import com.ruoyi.project.hit.service.PupuStoreService;
|
||||||
import com.ruoyi.project.hit.mapper.PupuStoreMapper;
|
import com.ruoyi.project.hit.mapper.PupuStoreMapper;
|
||||||
@ -25,17 +28,39 @@ public class PupuStoreServiceImpl extends ServiceImpl<PupuStoreMapper, PupuStore
|
|||||||
private PupuStoreMapper pupuStoreMapper;
|
private PupuStoreMapper pupuStoreMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PupuLogService pupuLogService;
|
private PupuLogService pupuLogService;
|
||||||
|
@Resource
|
||||||
|
private PupuEquipmentMapper pupuEquipmentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int add(PupuStore pupuStore) {
|
public int add(PupuStore pupuStore, Integer userId) {
|
||||||
pupuLogService.add(new PupuLog("门店新增",1,new Date()));
|
int i=0;
|
||||||
return pupuStoreMapper.insert(pupuStore);
|
i = pupuStoreMapper.insertReturnId(pupuStore);
|
||||||
|
if(i>0){
|
||||||
|
pupuLogService.add(new PupuLog("门店"+pupuStore.getStoreId()+"新增",1,new Date(),userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int del(Integer storeId) {
|
public int del(Integer storeId, Integer userId) {
|
||||||
pupuLogService.add(new PupuLog("门店删除",2,new Date()));
|
LambdaQueryWrapper<PupuEquipment> wrapper=new LambdaQueryWrapper<>();
|
||||||
return pupuStoreMapper.deleteById(storeId);
|
wrapper.eq(PupuEquipment::getStoreId,storeId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
pupuEquipmentMapper.delete(wrapper);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new CustomException("门店设备删除异常");
|
||||||
|
}
|
||||||
|
int i=pupuStoreMapper.deleteById(storeId);
|
||||||
|
if(i>0){
|
||||||
|
pupuLogService.add(new PupuLog("门店"+storeId+"删除",2,new Date(),userId));
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.ruoyi.project.hit.test;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//import com.alipay.easysdk.factory.Factory;
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝接口
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/alipay")
|
||||||
|
public class AliPayController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AlipayTemplate alipayTemplate;
|
||||||
|
|
||||||
|
@GetMapping(value = "/pay", produces = "text/html")
|
||||||
|
@ResponseBody
|
||||||
|
public String pay(@RequestParam long id) throws AlipayApiException {
|
||||||
|
Order order = new Order();
|
||||||
|
order.setId(120948748372234L);
|
||||||
|
order.setUserId(129904058947L);
|
||||||
|
order.setInterfaceInfoId(294389472934L);
|
||||||
|
order.setMoney(10.0);
|
||||||
|
order.setPaymentMethod("支付宝");
|
||||||
|
return alipayTemplate.pay(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||||
|
public String payNotify(HttpServletRequest request) throws Exception {
|
||||||
|
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||||
|
System.out.println("=========支付宝异步回调========");
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
|
for (String name : requestParams.keySet()) {
|
||||||
|
params.put(name, request.getParameter(name));
|
||||||
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
String tradeNo = params.get("out_trade_no");
|
||||||
|
String gmtPayment = params.get("gmt_payment");
|
||||||
|
String alipayTradeNo = params.get("trade_no");
|
||||||
|
// 支付宝验签
|
||||||
|
// if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
|
// // 验签通过
|
||||||
|
// System.out.println("交易名称: " + params.get("subject"));
|
||||||
|
// System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
|
// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
|
// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
|
// System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
|
// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
|
// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
|
// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
|
// // 更新订单状态
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
85
src/main/java/com/ruoyi/project/hit/test/AlipayTemplate.java
Normal file
85
src/main/java/com/ruoyi/project/hit/test/AlipayTemplate.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package com.ruoyi.project.hit.test;
|
||||||
|
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import com.alipay.api.AlipayClient;
|
||||||
|
import com.alipay.api.DefaultAlipayClient;
|
||||||
|
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "alipay")
|
||||||
|
@Component
|
||||||
|
@Data
|
||||||
|
public class AlipayTemplate {
|
||||||
|
// 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
|
||||||
|
@Value("{alipay.appId}")
|
||||||
|
|
||||||
|
public String appId;
|
||||||
|
|
||||||
|
// 应用私钥,就是工具生成的应用私钥
|
||||||
|
@Value("{alipay.merchantPrivateKey}")
|
||||||
|
public String merchantPrivateKey;
|
||||||
|
// 支付宝公钥,对应APPID下的支付宝公钥。
|
||||||
|
@Value("{alipay.alipayPublicKey}")
|
||||||
|
public String alipayPublicKey;
|
||||||
|
|
||||||
|
// 支付宝会悄悄的给我们发送一个请求,告诉我们支付成功的信息
|
||||||
|
@Value("{alipay.notifyUrl}")
|
||||||
|
public String notifyUrl;
|
||||||
|
//同步通知,支付成功,一般跳转到成功页
|
||||||
|
@Value("{alipay.returnUrl}")
|
||||||
|
public String returnUrl;
|
||||||
|
|
||||||
|
// 签名方式
|
||||||
|
@Value("{alipay.signType}")
|
||||||
|
private String signType;
|
||||||
|
|
||||||
|
// 字符编码格式
|
||||||
|
@Value("{alipay.charset}")
|
||||||
|
private String charset;
|
||||||
|
|
||||||
|
//订单超时时间
|
||||||
|
private String timeout = "1m";
|
||||||
|
// 支付宝网关;https://openapi-sandbox.dl.alipaydev.com/gateway.do
|
||||||
|
@Value("{alipay.gatewayUrl}")
|
||||||
|
public String gatewayUrl;
|
||||||
|
|
||||||
|
public String pay(Order order) throws
|
||||||
|
AlipayApiException {
|
||||||
|
|
||||||
|
//1、根据支付宝的配置生成一个支付客户端
|
||||||
|
AlipayClient alipayClient = new
|
||||||
|
DefaultAlipayClient(gatewayUrl, appId, merchantPrivateKey,
|
||||||
|
"json", charset, alipayPublicKey, signType);
|
||||||
|
|
||||||
|
//2、创建一个支付请求,并设置请求参数
|
||||||
|
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
|
||||||
|
alipayRequest.setReturnUrl(returnUrl);
|
||||||
|
alipayRequest.setNotifyUrl(notifyUrl);
|
||||||
|
|
||||||
|
Long id = order.getId();
|
||||||
|
Long interfaceInfoId = order.getInterfaceInfoId();
|
||||||
|
Double money = order.getMoney();
|
||||||
|
String paymentMethod = order.getPaymentMethod();
|
||||||
|
|
||||||
|
|
||||||
|
alipayRequest.setBizContent(" {\"out_trade_no\":\"" + id + "\","
|
||||||
|
+ "\"total_amount\":\"" + money + "\","
|
||||||
|
+ "\"subject\":\"" + interfaceInfoId
|
||||||
|
+ "\","
|
||||||
|
+ "\"body\":\"" + paymentMethod + "\","
|
||||||
|
+
|
||||||
|
"\"timeout_express\":\"" + timeout + "\","
|
||||||
|
+
|
||||||
|
"\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
|
||||||
|
String result = alipayClient.pageExecute(alipayRequest).getBody();
|
||||||
|
//会收到支付宝的响应,响应的是一个页面,只要浏览器显示这个页面,就会自动来到支付宝的收银台页面
|
||||||
|
System.out.println("支付宝的响应:" + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
69
src/main/java/com/ruoyi/project/hit/test/Order.java
Normal file
69
src/main/java/com/ruoyi/project/hit/test/Order.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package com.ruoyi.project.hit.test;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口次数订单表
|
||||||
|
* @TableName order
|
||||||
|
*/
|
||||||
|
@TableName(value ="`order`")
|
||||||
|
@Data
|
||||||
|
public class Order implements Serializable {
|
||||||
|
/**
|
||||||
|
* 订单Id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户Id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口Id
|
||||||
|
*/
|
||||||
|
private Long interfaceInfoId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付金额
|
||||||
|
*/
|
||||||
|
private Double money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
*/
|
||||||
|
private String paymentMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0 - 未支付 1 - 已支付
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
@ -18,7 +18,6 @@ public class AESUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成AES密钥
|
* 生成AES密钥
|
||||||
*
|
|
||||||
* @return SecretKey AES密钥
|
* @return SecretKey AES密钥
|
||||||
* @throws NoSuchAlgorithmException 当AES算法不可用时抛出
|
* @throws NoSuchAlgorithmException 当AES算法不可用时抛出
|
||||||
*/
|
*/
|
||||||
@ -37,7 +36,6 @@ public class AESUtil {
|
|||||||
public static SecretKey generateFixAESKey(){
|
public static SecretKey generateFixAESKey(){
|
||||||
// 定义一个16字节字符串key
|
// 定义一个16字节字符串key
|
||||||
String fixedKey = "gpnknbndfdgzgwhh";
|
String fixedKey = "gpnknbndfdgzgwhh";
|
||||||
|
|
||||||
// 使用固定的字节数组(128位)创建DES密钥
|
// 使用固定的字节数组(128位)创建DES密钥
|
||||||
return new SecretKeySpec(fixedKey.getBytes(StandardCharsets.UTF_8), "AES");
|
return new SecretKeySpec(fixedKey.getBytes(StandardCharsets.UTF_8), "AES");
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class HitInterceptor implements HandlerInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
String path = request.getRequestURI();
|
String path = request.getRequestURI();
|
||||||
if (path.startsWith("/hit/log/select") && !"/hit/user/register".equals(path) && !"/hit/user/login".equals(path)) {
|
if (path.startsWith("/hit") && !"/hit/user/register".equals(path) && !"/hit/user/login".equals(path)) {
|
||||||
System.out.println("拦截");
|
System.out.println("拦截");
|
||||||
String token = request.getHeader("Token");
|
String token = request.getHeader("Token");
|
||||||
System.out.println(token);
|
System.out.println(token);
|
||||||
|
@ -11,11 +11,11 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private HitInterceptor hitInterceptor;
|
private HitInterceptor hitInterceptor;
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
// public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(hitInterceptor)
|
// registry.addInterceptor(hitInterceptor)
|
||||||
.addPathPatterns("/hit/log/select") // 拦截所有/hit开头的请求
|
// .addPathPatterns("/hit") // 拦截所有/hit开头的请求
|
||||||
.excludePathPatterns("/hit/user/register")
|
// .excludePathPatterns("/hit/user/register")
|
||||||
.excludePathPatterns("/hit/user/login"); // 但不拦截/hit/user
|
// .excludePathPatterns("/hit/user/login"); // 但不拦截/hit/user
|
||||||
}
|
// }
|
||||||
}
|
}
|
@ -148,3 +148,14 @@ minio:
|
|||||||
accessKey: minioadmin
|
accessKey: minioadmin
|
||||||
secretKey: minioadmin
|
secretKey: minioadmin
|
||||||
bucketName: meiyanshe
|
bucketName: meiyanshe
|
||||||
|
|
||||||
|
alipay:
|
||||||
|
appId: 9021000140665155
|
||||||
|
merchantPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCeszWzeW3hcNTgJCPisg3AEDTfgSulgg6g5ui/s9eKgeC53zYm8XNyOwEJZoHRz1dk1ekxSHOUYmQbdOVyfqRvdOd5V5xMY3ihvtOIsY1EjrIgU1VzJOpuiWJ1egxsUyc4nDUA00+5YXfeXyTI60Ro5+mQukq4MS6Q3FConQwa8LxLJhWOVuIT/laQpKu6hskldUcgYcWS1pYMo2Z+mnnt1qLkKMRmiFnpo+p4tx3XuN8Uy5o/ZhTxD0WZC+SPqgJ0osfcp/KDFMtUklOefuHlCGc1dBvo2TTnsLl54bGXHQ8HvgN4W4HXRWvPfLbyXsg3ULWaYMmuOkTgQgbZK3NjAgMBAAECggEAfnPVilhrUYMSXDbv0SaHBk7jkmPeX1auSU80jevDBz5Nzk0pXQZvMsoJHXBsaL2JqXM5CGfukIGFusr+OKjoZVcFSg6hH8zyxg7DhtvS8JmzHUbJg6IamlEl/u1tELOBQP5WzX2SvOgJF0tAiEfOjribxxJpjzLBI/Qo4PGiP6PhFiT/A6Dm3U6Qz8G4s168hRsIqXwrpmtYG4vc2acLeUg1Dc3jD4wHZFN0WQbYhKcY7e1xoKiIsYG/MJVKNemMRMPQxmPVLJ4Q3scMRNCYcrEDfj78QryTCUOVKY0Vo7Wx2T6H1CEgjeXHzBjE4zsdqFPE4gSVZ6t43AXQIpTHwQKBgQD9CTYUHaTfnk4zIfLKV5nTEIREV4q0g6b6JDO6uyxrLhnT5Dz2mMFvNtA+Oso65vzc6mxi8uhXCD5SmmmJzPtJ6VBsT4V3A6gg5dpZHassKXlEEWZZ58zE4aCWBbaL8w5GqWcR8X83/ijuSjSpnzQaAWS0D4Kd4F/I4gA1XBtVawKBgQCgjxwU7cilbBKMHYT0Aoxnxw4pS3Qw1Vfk0ij/Np2f1kAo/ylaeWcIRIep5/E7cJbXS2HnmJqjroZ4MISc8ihs5k8EOFdF3S4z4850nH3VmfEJOI2PKxE7smqVoik6sohfYqHYjRJtMFyGsEgvOrvEBNox3ugEkIfeGemsbMhf6QKBgG+b34GR7cZAwkdlgvzjFNN3JpAqeODUbRNKYpLLunTwGa5PruAqUq/mYoYAUnEWr5QVxocCk57H4Q14VHLWukRIqBOOI9VyBHe2StAh+P16saVnc1jWmIiC6N0jWfhy1eovEGpmtfGRpqYsjvv+X/HUiYGukbNnY3hszyC6JshPAoGATQR49v0dC2Ts/LNITHhQe5N7kol0QdyE3emF6u566+otOr0zTAgCSW/+F52AFQAsCzhIzXxhaXTVYh/77QEoLRzI+IBCNOwlNpTnOv66SdUfT0oGdY+2I4mxIPf5iQOM8RxyAFujZCcXqzAyYB1vZlbhh5yidVYTJpINij1gXMkCgYEA7kP3hmFOXqbPcMwWL5FEBc1u+NK/v4dj1FURNj19IkRw15d53pY8/orPHfIFt05NYCyl4jXJhozuEihGw5YwJLi8t2kPAwHX3u2yxrSeI5MrqVhyWD1Nf2HD4VBt1iuGgGj6xoiISc83cKw5ZiJT4I2plq5UIPHRiEM9wcuOeYE=
|
||||||
|
alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnrM1s3lt4XDU4CQj4rINwBA034ErpYIOoObov7PXioHgud82JvFzcjsBCWaB0c9XZNXpMUhzlGJkG3Tlcn6kb3TneVecTGN4ob7TiLGNRI6yIFNVcyTqbolidXoMbFMnOJw1ANNPuWF33l8kyOtEaOfpkLpKuDEukNxQqJ0MGvC8SyYVjlbiE/5WkKSruobJJXVHIGHFktaWDKNmfpp57dai5CjEZohZ6aPqeLcd17jfFMuaP2YU8Q9FmQvkj6oCdKLH3KfygxTLVJJTnn7h5QhnNXQb6Nk057C5eeGxlx0PB74DeFuB10Vrz3y28l7IN1C1mmDJrjpE4EIG2StzYwIDAQAB
|
||||||
|
notifyUrl: http://内网穿透地址/api/alipay/notify
|
||||||
|
returnUrl: http://member.zyz.com/memberOrder.html
|
||||||
|
signType: RSA2
|
||||||
|
charset: utf-8
|
||||||
|
# 我的支付宝网关地址
|
||||||
|
gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do
|
||||||
|
@ -17,4 +17,10 @@
|
|||||||
equipment_id,serial_number,create_time,
|
equipment_id,serial_number,create_time,
|
||||||
status
|
status
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<insert id="insertAndReturnId" useGeneratedKeys="true" keyProperty="equipmentId">
|
||||||
|
INSERT INTO `ry-vue`.`pupu_equipment` ( `equipment_id`, `serial_number`, `store_id`, `create_time`, `update_time`,`status` )
|
||||||
|
VALUES
|
||||||
|
( DEFAULT, #{serialNumber}, #{storeId},#{createTime},#{updateTime}, DEFAULT );
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<id property="logId" column="log_id" jdbcType="INTEGER"/>
|
<id property="logId" column="log_id" jdbcType="INTEGER"/>
|
||||||
<result property="logEvent" column="log_event" jdbcType="VARCHAR"/>
|
<result property="logEvent" column="log_event" jdbcType="VARCHAR"/>
|
||||||
<result property="logSort" column="log_sort" jdbcType="INTEGER"/>
|
<result property="logSort" column="log_sort" jdbcType="INTEGER"/>
|
||||||
|
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
||||||
<result property="time" column="time" jdbcType="TIMESTAMP"/>
|
<result property="time" column="time" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -17,16 +18,22 @@
|
|||||||
</sql>
|
</sql>
|
||||||
<select id="select" resultType="java.util.HashMap">
|
<select id="select" resultType="java.util.HashMap">
|
||||||
SELECT
|
SELECT
|
||||||
|
pupu_log_sort.sort_name AS sortName,
|
||||||
pupu_log.log_id AS logId,
|
pupu_log.log_id AS logId,
|
||||||
pupu_log.log_event AS logEvent,
|
pupu_log.log_event AS logEvent,
|
||||||
|
pupu_log.user_id AS userId,
|
||||||
pupu_log.time,
|
pupu_log.time,
|
||||||
pupu_log_sort.sort_name AS sortName
|
pupu_user.user_name AS userName
|
||||||
FROM
|
FROM
|
||||||
pupu_log_sort
|
|
||||||
INNER JOIN
|
|
||||||
pupu_log
|
pupu_log
|
||||||
|
INNER JOIN
|
||||||
|
pupu_log_sort
|
||||||
ON
|
ON
|
||||||
pupu_log_sort.sort_id = pupu_log.log_sort
|
pupu_log.log_sort = pupu_log_sort.sort_id
|
||||||
|
INNER JOIN
|
||||||
|
pupu_user
|
||||||
|
ON
|
||||||
|
pupu_log.user_id = pupu_user.user_id
|
||||||
<where>
|
<where>
|
||||||
<if test="sortId!=null">
|
<if test="sortId!=null">
|
||||||
pupu_log.log_sort = #{sortId}
|
pupu_log.log_sort = #{sortId}
|
||||||
|
@ -19,4 +19,10 @@
|
|||||||
store_id,store_name,longitude,
|
store_id,store_name,longitude,
|
||||||
dimensionality,status
|
dimensionality,status
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<insert id="insertReturnId" useGeneratedKeys="true" keyProperty="storeId">
|
||||||
|
INSERT INTO `ry-vue`.`pupu_store` ( `store_id`, `store_name`, `longitude`, `latitude`, `province`, `city`, `district`, `status` )
|
||||||
|
VALUES
|
||||||
|
( default , #{storeName}, #{longitude}, #{latitude}, #{province}, #{city}, #{district}, default );
|
||||||
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user