新增事务方案修复掉线问题导致的重复消费
This commit is contained in:
parent
ddd20b825e
commit
eb5ddd03df
@ -550,7 +550,7 @@ public class SxDataDao extends BaseDao{
|
|||||||
int[] remainingCounts = ps.executeBatch();
|
int[] remainingCounts = ps.executeBatch();
|
||||||
|
|
||||||
//todo 新增流水
|
//todo 新增流水
|
||||||
updateStoreSaleFlow(dataBaseInfo,rmSaleflowList,tRmPayflowList);
|
updateStoreSaleFlow(conn,rmSaleflowList,tRmPayflowList);
|
||||||
|
|
||||||
List<String> consumIds=productQuantityConsumptionDtoList
|
List<String> consumIds=productQuantityConsumptionDtoList
|
||||||
.stream()
|
.stream()
|
||||||
@ -566,7 +566,7 @@ public class SxDataDao extends BaseDao{
|
|||||||
if (!HttpUtils.SUCCESSCODE.equals(code)) {
|
if (!HttpUtils.SUCCESSCODE.equals(code)) {
|
||||||
throw new Exception("服务器异常");
|
throw new Exception("服务器异常");
|
||||||
}
|
}
|
||||||
log.info("剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
log.info("库存更新剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
||||||
conn.commit(); // 最终提交事务
|
conn.commit(); // 最终提交事务
|
||||||
log.info("批量更新完成,总记录数: {}" , count);
|
log.info("批量更新完成,总记录数: {}" , count);
|
||||||
//baseUpdateImBrancStock(dataBaseInfo);
|
//baseUpdateImBrancStock(dataBaseInfo);
|
||||||
@ -754,18 +754,18 @@ public class SxDataDao extends BaseDao{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增销售流水
|
* 批量新增销售流水
|
||||||
* @param dataBaseInfo
|
* @param conn
|
||||||
* @param rmSaleflowList
|
* @param rmSaleflowList
|
||||||
*/
|
*/
|
||||||
public void updateStoreSaleFlow(DataBaseInfo dataBaseInfo,List<RmSaleflow> rmSaleflowList,List<TRmPayflow> payflowList){
|
public void updateStoreSaleFlow(Connection conn,List<RmSaleflow> rmSaleflowList,List<TRmPayflow> payflowList){
|
||||||
if(CollectionUtil.isEmpty(rmSaleflowList)){
|
if(CollectionUtil.isEmpty(rmSaleflowList)){
|
||||||
log.info("销售流水记录为空");
|
log.info("销售流水记录为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Connection conn =getConnection(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),
|
// Connection conn =getConnection(dataBaseInfo.getIp(),dataBaseInfo.getUserName(),
|
||||||
dataBaseInfo.getPassword(), dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName());
|
// dataBaseInfo.getPassword(), dataBaseInfo.getDbPort(),dataBaseInfo.getDataBaseName());
|
||||||
try {
|
//try {
|
||||||
conn.setAutoCommit(false); // 关闭自动提交,开启事务
|
//conn.setAutoCommit(false); // 关闭自动提交,开启事务
|
||||||
String sql = "INSERT INTO t_rm_saleflow (" +
|
String sql = "INSERT INTO t_rm_saleflow (" +
|
||||||
"flow_id, flow_no, branch_no, item_no, source_price, sale_price, " +
|
"flow_id, flow_no, branch_no, item_no, source_price, sale_price, " +
|
||||||
"sale_qnty, sale_money, sell_way, oper_id, sale_man, counter_no, " +
|
"sale_qnty, sale_money, sell_way, oper_id, sale_man, counter_no, " +
|
||||||
@ -892,27 +892,18 @@ public class SxDataDao extends BaseDao{
|
|||||||
int[] remainingCounts2 = ps2.executeBatch();
|
int[] remainingCounts2 = ps2.executeBatch();
|
||||||
log.info("销售流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
log.info("销售流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts));
|
||||||
log.info("支付流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts2));
|
log.info("支付流水记录剩余批次更新数: {}", Arrays.toString(remainingCounts2));
|
||||||
conn.commit(); // 最终提交事务
|
//conn.commit(); // 最终提交事务
|
||||||
log.info("销售-支付-流水记录批量更新完成,总记录数: {}" , count);
|
log.info("销售-支付-流水记录批量更新完成,总记录数: {}" , count);
|
||||||
//baseUpdateImBrancStock(dataBaseInfo);
|
//baseUpdateImBrancStock(dataBaseInfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
conn.rollback(); // 出错时回滚整个事务
|
// conn.rollback(); // 出错时回滚整个事务
|
||||||
log.info("销售支付流水记录业务失败:: {}", e.getMessage());
|
log.info("销售支付流水记录业务失败:: {}", e.getMessage());
|
||||||
throw new RuntimeException("销售支付流水记录业务失败:: {}"+e.getMessage());
|
throw new RuntimeException("销售支付流水记录业务失败:: {}"+e.getMessage());
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
log.info("sql失败:: {}", e.getMessage());
|
// log.info("sql失败:: {}", e.getMessage());
|
||||||
throw new RuntimeException("sql失败:: {}"+e.getMessage());
|
// throw new RuntimeException("sql失败:: {}"+e.getMessage());
|
||||||
}finally {
|
// }
|
||||||
if(conn!=null){
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.info("最后sql失败:: {}", e.getMessage());
|
|
||||||
throw new RuntimeException("sql关闭失败:: {}"+e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -397,7 +397,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
+"&syncType="+DicEnum.MUAL_1.getCode()
|
+"&syncType="+DicEnum.MUAL_1.getCode()
|
||||||
+"&refreshDateStr="+refreshDate,
|
+"&refreshDateStr="+refreshDate,
|
||||||
JSONUtil.parseArray(folders));
|
JSONUtil.parseArray(folders));
|
||||||
log.info("商品分类总共有{}条数据,同步完成{}条",total,syncCount);
|
log.info("商品总共有{}条数据,同步完成{}条",total,syncCount);
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_GOODS_READ
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_GOODS_READ
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
+"&sign="+commentModel.getAppId()
|
+"&sign="+commentModel.getAppId()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user