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