记得上下班打卡 | git大法好,push需谨慎

Commit afbbebfc authored by zhangguobing's avatar zhangguobing

~api:券商品业务-完善申请退款处理;

parent 846e5747
...@@ -9,6 +9,8 @@ import com.liquidnet.service.base.ErrorMapping; ...@@ -9,6 +9,8 @@ import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.candy.constant.CandyRedisConst;
import com.liquidnet.service.candy.dto.CandyUserCouponBasicDto;
import com.liquidnet.service.goblin.constant.GoblinStatusConst; import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinBackOrder; import com.liquidnet.service.goblin.entity.GoblinBackOrder;
...@@ -28,6 +30,7 @@ import java.time.LocalDateTime; ...@@ -28,6 +30,7 @@ import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.IntStream;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS; import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
import static com.liquidnet.commons.lang.util.DateUtil.DTFYMDHMS; import static com.liquidnet.commons.lang.util.DateUtil.DTFYMDHMS;
...@@ -207,11 +210,13 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService { ...@@ -207,11 +210,13 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
sqls.add(SqlMapping.get("goblin_order.store.orderStatus")); sqls.add(SqlMapping.get("goblin_order.store.orderStatus"));
sqls.add(SqlMapping.get("goblin_order.store.orderSkuStatus")); sqls.add(SqlMapping.get("goblin_order.store.orderSkuStatus"));
sqls.add(SqlMapping.get("goblin_order.store.refundLog")); sqls.add(SqlMapping.get("goblin_order.store.refundLog"));
sqls.add(SqlMapping.get("candy_user_coupon.update_by_apply_refund"));
LinkedList<Object[]> applyRefund = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> applyRefund = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> orderStatus = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> orderStatus = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> orderSkuStatus = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> orderSkuStatus = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> refundLog = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> refundLog = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> updateCandyUserCouponObjs = CollectionUtil.linkedListObjectArr();
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
...@@ -332,10 +337,22 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService { ...@@ -332,10 +337,22 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
if (param.getOrderSkuId() != null) { if (param.getOrderSkuId() != null) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(param.getOrderSkuId()); GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(param.getOrderSkuId());
if (2 == orderSkuVo.getSkuType()) {// 券类商品-校验发放的券是否已使用 if (2 == orderSkuVo.getSkuType()) {// 券类商品-校验发放的券是否已使用
List<GoblinUserCouponVo> userCouponVos = redisUtils.getUserCouponVos(orderVo.getUserId());// 券类商品默认一个商品对应一个券,下单只可购买一张 // 券类商品默认一个商品对应一个券,下单只可购买一张
GoblinUserCouponVo userCouponVo = userCouponVos.stream().filter(c -> c.getUcouponId().equals(orderSkuVo.getOrderSkuId())).findAny().orElse(null); String ucKey = CandyRedisConst.BASIC_USER_COUPON.concat(orderVo.getUserId());
if (null != userCouponVo && 5 == userCouponVo.getState()) {// 券状态为'5-已使用',则不可申请退款 List<CandyUserCouponBasicDto> vos = (List<CandyUserCouponBasicDto>) redisUtils.get(ucKey);
return ResponseDto.failure("券已使用,不可申请"); int idx = IntStream.range(0, vos.size())
.filter(i -> vos.get(i).getUcouponId().equals(orderSkuVo.getOrderSkuId())).findFirst().orElse(-1);
if (-1 != idx) {
CandyUserCouponBasicDto basicDto = vos.get(idx);
if (5 == basicDto.getState()) {// 券状态为'5-已使用',则不可退款
return ResponseDto.failure("券已使用,不可申请");
}
basicDto.setState(2);// 置为'2-无效',防止用户在后台审核过程中使用券,造成券已使用,订单也退款
vos.set(idx, basicDto);
redisUtils.redisUtil.set(ucKey, vos);
updateCandyUserCouponObjs.add(new Object[]{basicDto.getState(), orderVo.getUserId(), now, basicDto.getUcouponId()});
} else {
log.warn("券类商品订单申请退款,未找到对应券[orderSkuId={},uid={}]", orderSkuVo.getOrderSkuId(), orderVo.getUserId());
} }
} }
//订单款式状态修改 //订单款式状态修改
...@@ -366,10 +383,21 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService { ...@@ -366,10 +383,21 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
//订单款式状态修改 //订单款式状态修改
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuId); GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuId);
if (2 == orderSkuVo.getSkuType()) {// 券类商品-校验发放的券是否已使用 if (2 == orderSkuVo.getSkuType()) {// 券类商品-校验发放的券是否已使用
List<GoblinUserCouponVo> userCouponVos = redisUtils.getUserCouponVos(orderVo.getUserId());// 券类商品默认一个商品对应一个券,下单只可购买一张 // 券类商品默认一个商品对应一个券,下单只可购买一张
GoblinUserCouponVo userCouponVo = userCouponVos.stream().filter(c -> c.getUcouponId().equals(orderSkuVo.getOrderSkuId())).findAny().orElse(null); String ucKey = CandyRedisConst.BASIC_USER_COUPON.concat(orderVo.getUserId());
if (null != userCouponVo && 5 == userCouponVo.getState()) {// 券状态为'5-已使用',则不可申请退款 List<CandyUserCouponBasicDto> vos = (List<CandyUserCouponBasicDto>) redisUtils.get(ucKey);
return ResponseDto.failure("券已使用,不可申请"); int idx = IntStream.range(0, vos.size()).filter(i -> vos.get(i).getUcouponId().equals(orderSkuVo.getOrderSkuId())).findFirst().orElse(-1);
if (-1 != idx) {
CandyUserCouponBasicDto basicDto = vos.get(idx);
if (5 == basicDto.getState()) {// 券状态为'5-已使用',则不可退款
return ResponseDto.failure("券已使用,不可申请");
}
basicDto.setState(2);// 置为'2-无效',防止用户在后台审核过程中使用券,造成券已使用,订单也退款
vos.set(idx, basicDto);
redisUtils.redisUtil.set(ucKey, vos);
updateCandyUserCouponObjs.add(new Object[]{basicDto.getState(), orderVo.getUserId(), now, basicDto.getUcouponId()});
} else {
log.warn("券类商品订单申请退款,未找到对应券[orderSkuId={},uid={}]", orderSkuVo.getOrderSkuId(), orderVo.getUserId());
} }
} }
orderSkuVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_61.getValue()); orderSkuVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_61.getValue());
...@@ -425,7 +453,7 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService { ...@@ -425,7 +453,7 @@ public class GoblinOrderAppServiceImpl implements IGoblinOrderAppService {
backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(), backOrderLog.getBackOrderLogId(), backOrderLog.getBackOrderId(), backOrderLog.getOperationType(),
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
}); });
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_USER_ORDER_OPERA.getKey(), SqlMapping.gets(sqls, applyRefund, orderStatus, orderSkuStatus, refundLog)); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_USER_ORDER_OPERA.getKey(), SqlMapping.gets(sqls, applyRefund, orderStatus, orderSkuStatus, refundLog, updateCandyUserCouponObjs));
return ResponseDto.success(); return ResponseDto.success();
} }
......
...@@ -162,18 +162,6 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer ...@@ -162,18 +162,6 @@ public class GoblinStoreBackOrderServiceImpl implements IGoblinStoreBackOrderSer
if(backOrderVo.getStatus().equals(GoblinStatusConst.Status.ORDER_BACK_STATUS_0.getValue())){ if(backOrderVo.getStatus().equals(GoblinStatusConst.Status.ORDER_BACK_STATUS_0.getValue())){
return ResponseDto.failure("已经发起"); return ResponseDto.failure("已经发起");
} }
{// 券类商品-校验发放的券是否已使用
List<GoblinBackOrderSkuVo> backOrderSkuVos = backOrderVo.getBackOrderSkuVos();
for (GoblinBackOrderSkuVo backOrderSkuVo : backOrderSkuVos) {
if (2 == backOrderSkuVo.getSkuType()) {
List<GoblinUserCouponVo> userCouponVos = redisUtils.getUserCouponVos(backOrderVo.getUserId());// 券类商品默认一个商品对应一个券,下单只可购买一张
GoblinUserCouponVo userCouponVo = userCouponVos.stream().filter(c -> c.getUcouponId().equals(backOrderSkuVo.getOrderSkuId())).findAny().orElse(null);
if (null != userCouponVo && 5 == userCouponVo.getState()) {// 券状态为'5-已使用',则不可退款
return ResponseDto.failure("券已使用,不可退款");
}
}
}
}
backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_0.getValue()); backOrderVo.setStatus(GoblinStatusConst.Status.ORDER_BACK_STATUS_0.getValue());
backOrderVo.setAuditAt(nowStr); backOrderVo.setAuditAt(nowStr);
//添加日志 //添加日志
......
...@@ -189,5 +189,6 @@ goblin_nft_order.update_artwork=UPDATE goblin_nft_order SET artwork_id=? WHERE o ...@@ -189,5 +189,6 @@ goblin_nft_order.update_artwork=UPDATE goblin_nft_order SET artwork_id=? WHERE o
#---- #----
goblin_sku.stock=UPDATE goblin_goods_sku SET sku_stock = ? , stock = ?, updated_at = ? WHERE sku_erp_code = ? and erp_warehouse_no = ? goblin_sku.stock=UPDATE goblin_goods_sku SET sku_stock = ? , stock = ?, updated_at = ? WHERE sku_erp_code = ? and erp_warehouse_no = ?
#---- #----
candy_user_coupon.update_by_apply_refund=UPDATE candy_user_coupon SET state=?,operator=?,updated_at=? WHERE ucoupon_id=?
#---- #----
#---- #----
\ No newline at end of file
...@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils; ...@@ -26,6 +26,7 @@ import org.springframework.util.CollectionUtils;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -387,11 +388,12 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C ...@@ -387,11 +388,12 @@ public class PlatformCandyCouponService extends ServiceImpl<CandyCouponMapper, C
AbstractRedisUtil redisCandyUtil = redisDataSourceUtil.getRedisCandyUtil(); AbstractRedisUtil redisCandyUtil = redisDataSourceUtil.getRedisCandyUtil();
if (!initUserCouponList.isEmpty()) { if (!initUserCouponList.isEmpty()) {
if (platformCandyUserCouponService.saveBatch(initUserCouponList)) { if (platformCandyUserCouponService.saveBatch(initUserCouponList)) {
if (!initUserCouponAssocList.isEmpty()) { if (!initUserCouponAssocList.isEmpty()) {// 券类商品默认一个商品对应一个券,下单只可购买一张
boolean assocSaveFlg = platformCandyUserCouponAssocService.saveBatch(initUserCouponAssocList); boolean assocSaveFlg = platformCandyUserCouponAssocService.saveBatch(initUserCouponAssocList);
initUserCouponAssocList.forEach(c -> { initUserCouponAssocList.forEach(c -> {
CandyUserCouponAssocDto assocDto = CandyUserCouponAssocDto.getNew().copy(c); CandyUserCouponAssocDto assocDto = CandyUserCouponAssocDto.getNew().copy(c);
boolean assocRdsSetFlg = redisCandyUtil.set(CandyRedisConst.BASIC_USER_COUPON_ASSOC.concat(c.getUcouponId()), assocDto); long l = ChronoUnit.SECONDS.between(now, couponExpireAt);
boolean assocRdsSetFlg = redisCandyUtil.set(CandyRedisConst.BASIC_USER_COUPON_ASSOC.concat(c.getUcouponId()), assocDto, l);
log.info("发放券-券类商品-记录关联人信息:[mcouponId={}, ucouponId={},assocSaveFlg={},assocRdsSetFlg={}]", mcouponId, c.getUcouponId(), assocSaveFlg, assocRdsSetFlg); log.info("发放券-券类商品-记录关联人信息:[mcouponId={}, ucouponId={},assocSaveFlg={},assocRdsSetFlg={}]", mcouponId, c.getUcouponId(), assocSaveFlg, assocRdsSetFlg);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment