Merge remote-tracking branch 'origin/hph' into dev
# Conflicts: # src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
This commit is contained in:
commit
7e911d37b8
|
|
@ -28,9 +28,7 @@ public interface TbProskuConMapper {
|
||||||
|
|
||||||
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
|
List<Integer> selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId);
|
||||||
|
|
||||||
|
List<TbProskuCon> selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
|
||||||
TbProskuCon selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ public class TbConsInfoFlow implements Serializable {
|
||||||
|
|
||||||
private Integer consId;
|
private Integer consId;
|
||||||
|
|
||||||
|
private Integer proSkuId;
|
||||||
|
|
||||||
private String conName;
|
private String conName;
|
||||||
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
@ -53,6 +55,14 @@ public class TbConsInfoFlow implements Serializable {
|
||||||
this.consId = consId;
|
this.consId = consId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getProSkuId() {
|
||||||
|
return proSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProSkuId(Integer proSkuId) {
|
||||||
|
this.proSkuId = proSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getConName() {
|
public String getConName() {
|
||||||
return conName;
|
return conName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,53 +57,50 @@ public class ConsService {
|
||||||
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
|
List<TbConsInfoFlow> consInfoFlows=new ArrayList<>();
|
||||||
|
|
||||||
for (TbOrderDetail orderDetail : orderDetails) {
|
for (TbOrderDetail orderDetail : orderDetails) {
|
||||||
TbProskuCon proskuCon= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
|
List<TbProskuCon> proskuCons= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
|
||||||
if(Objects.isNull(proskuCon)){
|
if(Objects.isNull(proskuCons)||proskuCons.size()<=0){
|
||||||
log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
|
log.info("不存在的耗材信息配置:orderId:{},skuId:{},shopId:{},productId:{}",orderDetail.getOrderId(),orderDetail.getProductSkuId(),orderDetail.getShopId(),orderDetail.getProductId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
for (TbProskuCon proskuCon : proskuCons) {
|
||||||
|
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
|
||||||
|
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){
|
||||||
|
BigDecimal amount=BigDecimal.ZERO;
|
||||||
|
TbConsInfoFlow flow=new TbConsInfoFlow();
|
||||||
|
flow.setConsId(tbConsInfo.getId());
|
||||||
|
flow.setShopId(tbConsInfo.getShopId());
|
||||||
|
flow.setConName(tbConsInfo.getConName());
|
||||||
|
flow.setProSkuId(proskuCon.getProductSkuId());
|
||||||
|
if("create".equals(type)){
|
||||||
|
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
|
||||||
|
|
||||||
TbConsInfo tbConsInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
|
flow.setAmount(amount);
|
||||||
if(Objects.nonNull(tbConsInfo)&&"1".equals(tbConsInfo.getStatus())){
|
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
|
||||||
BigDecimal amount=BigDecimal.ZERO;
|
flow.setBizCode("createCart");
|
||||||
TbConsInfoFlow flow=new TbConsInfoFlow();
|
flow.setBizName("销售扣除");
|
||||||
flow.setConsId(tbConsInfo.getId());
|
flow.setBizType("-");
|
||||||
flow.setShopId(tbConsInfo.getShopId());
|
}else if("delete".equals(type)){
|
||||||
flow.setConName(tbConsInfo.getConName());
|
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
|
||||||
if("create".equals(type)){
|
|
||||||
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum()));
|
|
||||||
|
|
||||||
flow.setAmount(amount);
|
flow.setAmount(amount.abs());
|
||||||
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
|
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
|
||||||
flow.setBizCode("createCart");
|
flow.setBizCode("cancelCart");
|
||||||
flow.setBizName("销售扣除");
|
flow.setBizName("退单返还");
|
||||||
flow.setBizType("-");
|
flow.setBizType("+");
|
||||||
}else if("delete".equals(type)){
|
}
|
||||||
amount=proskuCon.getSurplusStock().multiply(new BigDecimal(orderDetail.getNum())).negate();
|
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
|
||||||
|
consInfoPOS.add(consInfoPO);
|
||||||
|
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
flow.setUpdateTime(new Date());
|
||||||
|
consInfoFlows.add(flow);
|
||||||
|
|
||||||
flow.setAmount(amount.abs());
|
|
||||||
flow.setBalance(tbConsInfo.getStockNumber().subtract(amount).subtract(tbConsInfo.getStockConsume()));
|
|
||||||
flow.setBizCode("cancelCart");
|
|
||||||
flow.setBizName("退单返还");
|
|
||||||
flow.setBizType("+");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConsInfoPO consInfoPO=new ConsInfoPO(tbConsInfo.getId(),amount);
|
|
||||||
consInfoPOS.add(consInfoPO);
|
|
||||||
|
|
||||||
flow.setCreateTime(new Date());
|
|
||||||
flow.setUpdateTime(new Date());
|
|
||||||
consInfoFlows.add(flow);
|
|
||||||
|
|
||||||
|
|
||||||
//更新耗材信息
|
|
||||||
tbConsInfoMapper.batchStock(consInfoPOS);
|
|
||||||
//记录更新日志
|
|
||||||
tbConsInfoFlowMapper.insertBatch(consInfoFlows);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//更新耗材信息
|
||||||
|
tbConsInfoMapper.batchStock(consInfoPOS);
|
||||||
|
//记录更新日志
|
||||||
|
tbConsInfoFlowMapper.insertBatch(consInfoFlows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||||
<result column="cons_id" jdbcType="INTEGER" property="consId" />
|
<result column="cons_id" jdbcType="INTEGER" property="consId" />
|
||||||
|
<result column="pro_sku_id" jdbcType="INTEGER" property="proSkuId" />
|
||||||
<result column="con_name" jdbcType="VARCHAR" property="conName" />
|
<result column="con_name" jdbcType="VARCHAR" property="conName" />
|
||||||
<result column="amount" jdbcType="DECIMAL" property="amount" />
|
<result column="amount" jdbcType="DECIMAL" property="amount" />
|
||||||
<result column="balance" jdbcType="DECIMAL" property="balance" />
|
<result column="balance" jdbcType="DECIMAL" property="balance" />
|
||||||
|
|
@ -29,11 +30,11 @@
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbConsInfoFlow">
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbConsInfoFlow">
|
||||||
insert into tb_cons_info_flow (id, shop_id, cons_id,
|
insert into tb_cons_info_flow (id, shop_id, cons_id, pro_sku_id,
|
||||||
con_name, amount, balance,
|
con_name, amount, balance,
|
||||||
biz_code, biz_name, biz_type,
|
biz_code, biz_name, biz_type,
|
||||||
create_time, update_time)
|
create_time, update_time)
|
||||||
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{consId,jdbcType=INTEGER},
|
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{consId,jdbcType=INTEGER}, #{proSkuId,jdbcType=INTEGER},
|
||||||
#{conName,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{balance,jdbcType=DECIMAL},
|
#{conName,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{balance,jdbcType=DECIMAL},
|
||||||
#{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, #{bizType,jdbcType=VARCHAR},
|
#{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR}, #{bizType,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap">
|
<select id="selectByShopIdAndSkuIdAndProductId" resultMap="BaseResultMap">
|
||||||
|
|
||||||
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1
|
select * from tb_prosku_con where product_sku_id=#{skuId} and shop_id=#{shopId} and product_id=#{productId} and status=1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue