Sfoglia il codice sorgente

[库存退回][修改]:库存退回修改

release_toaliyun_real
Stormeye Wu 7 anni fa
parent
commit
7ffe5ee48b
3 ha cambiato i file con 12 aggiunte e 11 eliminazioni
  1. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java
  2. +6
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  3. +4
    -0
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml

+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java Vedi File

@@ -21,6 +21,8 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> {

void reduceInventory(@Param("id")Long id,@Param("number")Integer number);

void backInventory(@Param("id")Long id,@Param("remainInventory")Integer remainInventory, @Param("number")Integer number);

void offExpiriedCouponByValidDate();

void offExpiriedCouponByMerchantStatus();


+ 6
- 11
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Vedi File

@@ -360,13 +360,8 @@ public class WxOrderServiceImpl implements WxOrderService {
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY);
}

WxCoupon updateRecord = new WxCoupon();
updateRecord.setId(coupon.getId());
updateRecord.setRemainInventory(coupon.getRemainInventory() + 1);
updateRecord.setUpdateDate(new Date());

try {
wxCouponMapper.updateByPrimaryKeySelective(updateRecord);
wxCouponMapper.backInventory(coupon.getId(), coupon.getRemainInventory(), 1);
} catch (Exception e) {
logger.error("数据库更新失败,库存+1失败, e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "库存恢复失败");
@@ -839,8 +834,8 @@ public class WxOrderServiceImpl implements WxOrderService {
public int updateOrderStatus(WxOrder updateOrder, EnumOrderStatus enumOrderStatus) {
Date currentDate = new Date();
switch (enumOrderStatus) {
case ORDER_STATUS_OVERTIME_CANCEL:
case ORDER_STATUS_REFUND_SUCCESS: {
case ORDER_STATUS_OVERTIME_CANCEL: // 支付取消,库存退回
case ORDER_STATUS_REFUND_SUCCESS: { // 退款成功,库存退回
try {
stockBack(updateOrder);
} catch (Exception e) {
@@ -849,7 +844,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}
break;
}
case ORDER_STATUS_COOPERATING_OVERTIME: {
case ORDER_STATUS_COOPERATING_OVERTIME: { // 拼团超时,退库存
try {
stockBack(updateOrder);
} catch (Exception e) {
@@ -858,7 +853,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}
break;
}
case ORDER_STATUS_COOPERATING_CANCEL: {
case ORDER_STATUS_COOPERATING_CANCEL: { // 拼团取消,退库存
try {
stockBack(updateOrder);
} catch (Exception e) {
@@ -867,7 +862,7 @@ public class WxOrderServiceImpl implements WxOrderService {
}
break;
}
case ORDER_STATUS_COOPERATING_COMPLETE: {
case ORDER_STATUS_COOPERATING_COMPLETE: { // 拼团完成,退库存
try {
stockBack(updateOrder);
} catch (Exception e) {


+ 4
- 0
mallinkService/src/main/resources/mapper/WxCouponMapper.xml Vedi File

@@ -487,6 +487,10 @@
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
</update>

<update id="backInventory">
update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and remain_inventory>= #{remainInventory}
</update>

<update id="offExpiriedCouponByValidDate">
update wx_coupon SET status = 1, update_date = now()
where status = 0 and valid_type = 1 and valid_end_date &lt; now()


Caricamento…
Annulla
Salva