mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 15:28:41 +08:00
订单实时数据保存到数据库
This commit is contained in:
@@ -26,6 +26,11 @@ public class OrderMonitorData {
|
|||||||
*/
|
*/
|
||||||
private String orderCode;
|
private String orderCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易流水号
|
||||||
|
*/
|
||||||
|
private String transactionCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时监控数据
|
* 实时监控数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -31,17 +31,7 @@ public interface OrderMonitorDataMapper {
|
|||||||
*/
|
*/
|
||||||
OrderMonitorData selectByPrimaryKey(Integer id);
|
OrderMonitorData selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
/**
|
OrderMonitorData selectByOrderCode(String orderCode);
|
||||||
* update record selective
|
|
||||||
* @param record the updated record
|
|
||||||
* @return update count
|
|
||||||
*/
|
|
||||||
int updateByPrimaryKeySelective(OrderMonitorData record);
|
|
||||||
|
|
||||||
/**
|
OrderMonitorData selectByTransactionCode(String transactionCode);
|
||||||
* update record
|
|
||||||
* @param record the updated record
|
|
||||||
* @return update count
|
|
||||||
*/
|
|
||||||
int updateByPrimaryKey(OrderMonitorData record);
|
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,7 @@ public interface OrderMonitorDataService{
|
|||||||
|
|
||||||
OrderMonitorData selectByPrimaryKey(Integer id);
|
OrderMonitorData selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(OrderMonitorData record);
|
OrderMonitorData selectByOrderCode(String orderCode);
|
||||||
|
|
||||||
int updateByPrimaryKey(OrderMonitorData record);
|
|
||||||
|
|
||||||
|
OrderMonitorData selectByTransactionCode(String transactionCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.jsowell.common.util.id.SnowflakeIdWorker;
|
|||||||
import com.jsowell.pile.domain.OrderAbnormalRecord;
|
import com.jsowell.pile.domain.OrderAbnormalRecord;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.domain.OrderDetail;
|
import com.jsowell.pile.domain.OrderDetail;
|
||||||
|
import com.jsowell.pile.domain.OrderMonitorData;
|
||||||
import com.jsowell.pile.domain.OrderPayRecord;
|
import com.jsowell.pile.domain.OrderPayRecord;
|
||||||
import com.jsowell.pile.domain.PileAuthCard;
|
import com.jsowell.pile.domain.PileAuthCard;
|
||||||
import com.jsowell.pile.domain.PileBasicInfo;
|
import com.jsowell.pile.domain.PileBasicInfo;
|
||||||
@@ -53,6 +54,7 @@ import com.jsowell.pile.service.IPileAuthCardService;
|
|||||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||||
|
import com.jsowell.pile.service.OrderMonitorDataService;
|
||||||
import com.jsowell.pile.service.WechatPayService;
|
import com.jsowell.pile.service.WechatPayService;
|
||||||
import com.jsowell.pile.service.WxpayCallbackRecordService;
|
import com.jsowell.pile.service.WxpayCallbackRecordService;
|
||||||
import com.jsowell.pile.service.WxpayRefundCallbackService;
|
import com.jsowell.pile.service.WxpayRefundCallbackService;
|
||||||
@@ -151,6 +153,9 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IPileAuthCardService pileAuthCardService;
|
private IPileAuthCardService pileAuthCardService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderMonitorDataService orderMonitorDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 条件查询订单基本信息
|
* 条件查询订单基本信息
|
||||||
*
|
*
|
||||||
@@ -694,14 +699,14 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
logger.error("小程序发送充电停止推送消息 error", e);
|
logger.error("小程序发送充电停止推送消息 error", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode());
|
realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderBasicInfo.getOrderCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从redis中取出实时记录保存到表中
|
* 从redis中取出实时记录保存到表中
|
||||||
* 当订单完成的时候调用
|
* 当订单完成的时候调用
|
||||||
*/
|
*/
|
||||||
private void realTimeMonitorDataRedis2DB(String transactionCode) {
|
private void realTimeMonitorDataRedis2DB(String transactionCode, String orderCode) {
|
||||||
if (StringUtils.isBlank(transactionCode)) {
|
if (StringUtils.isBlank(transactionCode)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -728,11 +733,18 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
list.add(build);
|
list.add(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrderMonitorData record = new OrderMonitorData();
|
||||||
|
record.setOrderCode(orderCode);
|
||||||
|
record.setTransactionCode(transactionCode);
|
||||||
|
record.setMonitorData(JSONObject.toJSONString(list));
|
||||||
|
int insert = orderMonitorDataService.insert(record);
|
||||||
|
if (insert > 0) {
|
||||||
|
// 删除redis中缓存
|
||||||
|
String pileConnectorCode = transactionCode.substring(0, 16);
|
||||||
|
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode;
|
||||||
|
redisCache.deleteObject(redisKey);
|
||||||
|
}
|
||||||
|
|
||||||
// 删除redis中缓存
|
|
||||||
String pileConnectorCode = transactionCode.substring(0, 16);
|
|
||||||
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + pileConnectorCode + "_" + transactionCode;
|
|
||||||
redisCache.deleteObject(redisKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,40 +6,41 @@ import com.jsowell.pile.service.OrderMonitorDataService;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderMonitorDataServiceImpl implements OrderMonitorDataService {
|
public class OrderMonitorDataServiceImpl implements OrderMonitorDataService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OrderMonitorDataMapper orderMonitorDataMapper;
|
private OrderMonitorDataMapper orderMonitorDataMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
public int deleteByPrimaryKey(Integer id) {
|
public int deleteByPrimaryKey(Integer id) {
|
||||||
return orderMonitorDataMapper.deleteByPrimaryKey(id);
|
return orderMonitorDataMapper.deleteByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int insert(OrderMonitorData record) {
|
public int insert(OrderMonitorData record) {
|
||||||
return orderMonitorDataMapper.insert(record);
|
return orderMonitorDataMapper.insert(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int insertSelective(OrderMonitorData record) {
|
public int insertSelective(OrderMonitorData record) {
|
||||||
return orderMonitorDataMapper.insertSelective(record);
|
return orderMonitorDataMapper.insertSelective(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public OrderMonitorData selectByPrimaryKey(Integer id) {
|
public OrderMonitorData selectByPrimaryKey(Integer id) {
|
||||||
return orderMonitorDataMapper.selectByPrimaryKey(id);
|
return orderMonitorDataMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int updateByPrimaryKeySelective(OrderMonitorData record) {
|
public OrderMonitorData selectByOrderCode(String orderCode) {
|
||||||
return orderMonitorDataMapper.updateByPrimaryKeySelective(record);
|
return orderMonitorDataMapper.selectByOrderCode(orderCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int updateByPrimaryKey(OrderMonitorData record) {
|
public OrderMonitorData selectByTransactionCode(String transactionCode) {
|
||||||
return orderMonitorDataMapper.updateByPrimaryKey(record);
|
return orderMonitorDataMapper.selectByTransactionCode(transactionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
<!--@Table order_monitor_data-->
|
<!--@Table order_monitor_data-->
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
<result column="order_code" jdbcType="VARCHAR" property="orderCode" />
|
<result column="order_code" jdbcType="VARCHAR" property="orderCode" />
|
||||||
|
<result column="transaction_code" jdbcType="VARCHAR" property="transactionCode" />
|
||||||
<result column="monitor_data" jdbcType="VARCHAR" property="monitorData" />
|
<result column="monitor_data" jdbcType="VARCHAR" property="monitorData" />
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, order_code, monitor_data, create_time
|
id, order_code, transaction_code, monitor_data, create_time
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
@@ -27,9 +28,9 @@
|
|||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
<insert id="insert" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into order_monitor_data (id, order_code, monitor_data,
|
insert into order_monitor_data (id, order_code, transaction_code, monitor_data,
|
||||||
create_time)
|
create_time)
|
||||||
values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{monitorData,jdbcType=VARCHAR},
|
values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{transactionCode,jdbcType=VARCHAR}, #{monitorData,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=TIMESTAMP})
|
#{createTime,jdbcType=TIMESTAMP})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
<insert id="insertSelective" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
||||||
@@ -42,6 +43,9 @@
|
|||||||
<if test="orderCode != null and orderCode != ''">
|
<if test="orderCode != null and orderCode != ''">
|
||||||
order_code,
|
order_code,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="transactionCode != null and transactionCode != ''">
|
||||||
|
transaction_code,
|
||||||
|
</if>
|
||||||
<if test="monitorData != null and monitorData != ''">
|
<if test="monitorData != null and monitorData != ''">
|
||||||
monitor_data,
|
monitor_data,
|
||||||
</if>
|
</if>
|
||||||
@@ -56,6 +60,9 @@
|
|||||||
<if test="orderCode != null and orderCode != ''">
|
<if test="orderCode != null and orderCode != ''">
|
||||||
#{orderCode,jdbcType=VARCHAR},
|
#{orderCode,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="transactionCode != null and transactionCode != ''">
|
||||||
|
#{transactionCode,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
<if test="monitorData != null and monitorData != ''">
|
<if test="monitorData != null and monitorData != ''">
|
||||||
#{monitorData,jdbcType=VARCHAR},
|
#{monitorData,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
@@ -64,28 +71,18 @@
|
|||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
|
||||||
<!--@mbg.generated-->
|
<select id="selectByOrderCode" resultMap="BaseResultMap">
|
||||||
update order_monitor_data
|
select
|
||||||
<set>
|
<include refid="Base_Column_List" />
|
||||||
<if test="orderCode != null and orderCode != ''">
|
from order_monitor_data
|
||||||
order_code = #{orderCode,jdbcType=VARCHAR},
|
where order_code = #{orderCode,jdbcType=VARCHAR}
|
||||||
</if>
|
</select>
|
||||||
<if test="monitorData != null and monitorData != ''">
|
|
||||||
monitor_data = #{monitorData,jdbcType=VARCHAR},
|
<select id="selectByTransactionCode" resultMap="BaseResultMap">
|
||||||
</if>
|
select
|
||||||
<if test="createTime != null">
|
<include refid="Base_Column_List" />
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
from order_monitor_data
|
||||||
</if>
|
where transaction_code = #{transactionCode,jdbcType=VARCHAR}
|
||||||
</set>
|
</select>
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
<update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.OrderMonitorData">
|
|
||||||
<!--@mbg.generated-->
|
|
||||||
update order_monitor_data
|
|
||||||
set order_code = #{orderCode,jdbcType=VARCHAR},
|
|
||||||
monitor_data = #{monitorData,jdbcType=VARCHAR},
|
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user