Przeglądaj źródła

[停车券每日限领检查][新增]

release_toaliyun_real
Stormeye.Wu 7 lat temu
rodzic
commit
5685f5789e
3 zmienionych plików z 53 dodań i 32 usunięć
  1. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java
  2. +34
    -21
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  3. +18
    -11
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 1
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java Wyświetl plik

@@ -14,6 +14,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {


List<WxCouponOrder> findList(WxCouponOrder wxCouponOrder); List<WxCouponOrder> findList(WxCouponOrder wxCouponOrder);
Integer countList(WxCouponOrder wxCouponOrder); Integer countList(WxCouponOrder wxCouponOrder);
Integer countCarList(Map params);


List<WxCouponOrder> findListOfOrderedByDate(Map dateMap); List<WxCouponOrder> findListOfOrderedByDate(Map dateMap);
List<WxCouponOrder> findListOfVerifiedByDate(Map dateMap); List<WxCouponOrder> findListOfVerifiedByDate(Map dateMap);


+ 34
- 21
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Wyświetl plik

@@ -23,9 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;


@Service @Service
public class WxOrderServiceImpl implements WxOrderService { public class WxOrderServiceImpl implements WxOrderService {
@@ -83,6 +81,7 @@ public class WxOrderServiceImpl implements WxOrderService {
// + couponOrder ---待使用 // + couponOrder ---待使用
int countOrder = 0, countCouponOrder = 0; int countOrder = 0, countCouponOrder = 0;
WxOrder orderQ = new WxOrder(); WxOrder orderQ = new WxOrder();
orderQ.setTenantId(user.getTenantId());
orderQ.setCouponId(counpon.getId()); orderQ.setCouponId(counpon.getId());
orderQ.setCUserId(user.getId()); orderQ.setCUserId(user.getId());
orderQ.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); orderQ.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode());
@@ -93,12 +92,21 @@ public class WxOrderServiceImpl implements WxOrderService {
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
} }


WxCouponOrder couponOrderQ = new WxCouponOrder();
couponOrderQ.setCouponId(counpon.getId());
couponOrderQ.setCUserId(user.getId());
//////couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode());
try { try {
countCouponOrder = wxCouponOrderMapper.countList(couponOrderQ);
if (counpon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode())) {
// 停车券 每日限领1张
Map params = new HashMap<String, Object>();
params.put("couponId", counpon.getId());
params.put("cUserId", user.getId());
countCouponOrder = wxCouponOrderMapper.countCarList(params);
} else {
WxCouponOrder couponOrderQ = new WxCouponOrder();
couponOrderQ.setTenantId(user.getTenantId());
couponOrderQ.setCouponId(counpon.getId());
couponOrderQ.setCUserId(user.getId());
//////couponOrderQ.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode());
countCouponOrder = wxCouponOrderMapper.countList(couponOrderQ);
}
} catch (Exception e) { } catch (Exception e) {
logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage()); logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
@@ -125,22 +133,27 @@ public class WxOrderServiceImpl implements WxOrderService {
} }


// check 购买是否超限 // check 购买是否超限
int count = 0;
try {
count = getUserCouponOrderCount(user, coupon);
} catch (Exception e) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
throw new MallinkException(ErrorCode.DB_FAIL);
}
if (coupon.getType().equals(EnumCouponType.COUPON_TINGCHE.getCode())) {


if (count >= coupon.getUseLimitQuantity()) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
logger.error("此券购买数量已超限, couponId: " + couponIdStr + ", count: " + count);
throw new MallinkException(ErrorCode.ORDER_IS_LIMITED);
} else {
int count = 0;
try {
count = getUserCouponOrderCount(user, coupon);
} catch (Exception e) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
throw new MallinkException(ErrorCode.DB_FAIL);
}

if (count >= coupon.getUseLimitQuantity()) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
logger.error("此券购买数量已超限, couponId: " + couponIdStr + ", count: " + count);
throw new MallinkException(ErrorCode.ORDER_IS_LIMITED);
}
} }



try { try {
// 减库存 // 减库存
coupon.setRemainInventory(coupon.getRemainInventory() - 1); coupon.setRemainInventory(coupon.getRemainInventory() - 1);


+ 18
- 11
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Wyświetl plik

@@ -24,57 +24,46 @@


<if test=" null != id "> <if test=" null != id ">
and `id` = #{id} and `id` = #{id}

</if> </if>


<if test=" null != tenantId "> <if test=" null != tenantId ">
and `tenant_id` = #{tenantId} and `tenant_id` = #{tenantId}

</if> </if>


<if test=" null != couponId "> <if test=" null != couponId ">
and `coupon_id` = #{couponId} and `coupon_id` = #{couponId}

</if> </if>


<if test=" null != cUserId "> <if test=" null != cUserId ">
and `c_user_id` = #{cUserId} and `c_user_id` = #{cUserId}

</if> </if>


<if test=" null != bUserId "> <if test=" null != bUserId ">
and `b_user_id` = #{bUserId} and `b_user_id` = #{bUserId}

</if> </if>


<if test=" null != orderId "> <if test=" null != orderId ">
and `order_id` = #{orderId} and `order_id` = #{orderId}

</if> </if>


<if test=" null != expiredTime "> <if test=" null != expiredTime ">
and `expired_time` = #{expiredTime} and `expired_time` = #{expiredTime}

</if> </if>


<if test=" null != couponOrderStatus "> <if test=" null != couponOrderStatus ">
and `coupon_order_status` = #{couponOrderStatus} and `coupon_order_status` = #{couponOrderStatus}

</if> </if>


<if test=" null != createDate "> <if test=" null != createDate ">
and `create_date` = #{createDate} and `create_date` = #{createDate}

</if> </if>


<if test=" null != updateDate "> <if test=" null != updateDate ">
and `update_date` = #{updateDate} and `update_date` = #{updateDate}

</if> </if>


<if test=" null != couponPrice "> <if test=" null != couponPrice ">
and `coupon_price` = #{couponPrice} and `coupon_price` = #{couponPrice}

</if> </if>
<if test=" null != ids "> <if test=" null != ids ">
and id in and id in
@@ -95,6 +84,24 @@
<include refid="dynamicWhereConditions" /> <include refid="dynamicWhereConditions" />
</select> </select>


<select id="countCarList" parameterType="hashmap" resultType="java.lang.Integer">
select count(*) from wx_coupon_order
<where>
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
</if>

<if test=" null != couponId ">
and `coupon_id` = #{couponId}
</if>

<if test=" null != cUserId ">
and `c_user_id` = #{cUserId}
</if>
and `create_date` between date_sub(now(),interval 1 day) and now()
</where>
</select>





<resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo"> <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo">


Ładowanie…
Anuluj
Zapisz