耗材流水中添加订单信息

This commit is contained in:
牛叉闪闪 2024-07-17 11:19:45 +08:00
parent 35057b4ee7
commit 56d66097c7
3 changed files with 43 additions and 4 deletions

View File

@ -25,6 +25,12 @@ public class TbConsInfoFlow implements Serializable {
private String bizType;
private Integer orderId;
private String orderNo;
private Date createTime;
private Date updateTime;
@ -126,4 +132,20 @@ public class TbConsInfoFlow implements Serializable {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getOrderId() {
return orderId;
}
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
}

View File

@ -35,6 +35,9 @@ public class ConsService {
@Autowired
TbOrderDetailMapper tbOrderDetailMapper;
@Autowired
TbOrderInfoMapper tbOrderInfoMapper;
@Transactional(rollbackFor = Exception.class)
public void exect(String message) throws Exception {
log.info("耗材信息更新开始:{}",message);
@ -47,7 +50,11 @@ public class ConsService {
Thread.sleep(1000L);
TbOrderInfo tbOrderInfo=tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
if(Objects.isNull(tbOrderInfo)){
log.info("订单信息不存在");
return;
}
List<TbOrderDetail> orderDetails= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
if(Objects.isNull(orderDetails)||orderDetails.size()<=0){
@ -102,10 +109,18 @@ public class ConsService {
// ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
// consInfoPOS.add(consInfoPO);
flow.setOrderId(tbOrderInfo.getId());
flow.setOrderNo(tbOrderInfo.getOrderNo());
flow.setCreateTime(new Date());
// flow.setUpdateTime(new Date());
// consInfoFlows.add(flow);
if(amount.equals(BigDecimal.ZERO)){
log.info("变动金额为 0:{}",amount);
continue;
}
tbConsInfoMapper.updateByPrimaryKey(tbConsInfo);
tbConsInfoFlowMapper.insert(flow);

View File

@ -14,10 +14,12 @@
<result column="biz_type" jdbcType="VARCHAR" property="bizType" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="order_no" jdbcType="VARCHAR" property="orderNo" />
</resultMap>
<sql id="Base_Column_List">
id, shop_id, cons_id, con_name, amount, balance, biz_code, biz_name, biz_type, create_time,
update_time
update_time,order_id,order_no
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -33,11 +35,11 @@
insert into tb_cons_info_flow (id, shop_id, cons_id, pro_sku_id,
con_name, amount, balance,
biz_code, biz_name, biz_type,
create_time, update_time)
create_time, update_time,order_id,order_no)
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{consId,jdbcType=INTEGER}, #{proSkuId,jdbcType=INTEGER},
#{conName,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{balance,jdbcType=DECIMAL},
#{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, #{bizType,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},#{orderId,jdbcType=INTEGER},#{orderNo,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbConsInfoFlow">
insert into tb_cons_info_flow