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

Commit 8d1a01ab authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev_goblin' into dev_goblin

parents 8316a705 4aafb739
......@@ -57,7 +57,7 @@ public class GoblinCouponController {
}
@PostMapping("receive")
@ApiOperation("订单状态")
@ApiOperation("领取券")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeCouponId", value = "平台券id"),
......
package com.liquidnet.service.goblin.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo;
import com.liquidnet.service.goblin.service.GoblinCouponService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
@ApiSupport(order = 145001)
@Api(tags = "商城:POS机相关")
@Slf4j
@RestController
@RequestMapping("store/pos")
public class GoblinPosController {
@Autowired
GoblinRedisUtils goblinRedisUtils;
@Autowired
GoblinCouponService goblinCouponService;
@PostMapping("coupon/receive")
@ApiOperation("领取券")
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeCouponId", value = "平台券id"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "uid", value = "UID"),
})
public ResponseDto<Boolean> checkOrderResult(@NotBlank(message = "参数无效:storeCouponId") @RequestParam("storeCouponId") String storeCouponId,
@NotBlank(message = "参数无效:uid") @RequestParam("uid") String uid) {
String currentUid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVoByUid(currentUid);
GoblinStoreCouponVo storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId);
if (null == storeCouponVo) {
log.warn("商城:POS机相关:领取券:优惠券不存在:[uid={},storeCouponId={}]", uid, storeCouponId);
return ResponseDto.failure(ErrorMapping.get("140050"));
} else if (null == storeInfoVo) {
log.warn("商城:POS机相关:领取券:未创建店铺不可领取优惠券:[uid={},storeCouponId={}]", uid, storeCouponId);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "店铺不存在");
} else if (!storeCouponVo.getStoreId().equals(storeInfoVo.getStoreId())) {
log.warn("商城:POS机相关:领取券:非本店铺优惠券不可领取:[uid={},storeId={},storeCouponId={}]", uid, storeInfoVo.getStoreId(), storeCouponId);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "非本店铺优惠券不可领取");
} else if (!storeCouponVo.getState().equals("1")) {
return ResponseDto.failure(ErrorMapping.get("140051"));
}
List<GoblinUserCouponVo> userCouponVos = goblinRedisUtils.getUserCouponVos(uid);
if (!CollectionUtils.isEmpty(userCouponVos)) {
int beforeSize = userCouponVos.size();
userCouponVos.removeIf(vo -> vo.getStoreCouponId().equals(storeCouponId));
if ((beforeSize - userCouponVos.size()) >= storeCouponVo.getReceiveLimit()) {
return ResponseDto.failure(ErrorMapping.get("140052"));
}
}
if (storeCouponVo.getStock().equals(0) || goblinRedisUtils.getStoreCouponStock(storeCouponId) > 0) {
Boolean resultFlg = goblinCouponService.receiveCoupon(uid, userCouponVos, storeCouponVo);
return resultFlg ? ResponseDto.success() : ResponseDto.failure();
}
return ResponseDto.failure(ErrorMapping.get("140053"));
}
@ApiOperationSupport(order = 1)
@ApiOperation(value = "SKU明细")
@PostMapping("goods/skus")
public ResponseDto<List<Object>> list(@NotBlank(message = "参数无效:skuIds") @RequestBody String skuids) {
log.info("商城:POS机相关:SKU列表[skuIds={}]", skuids);
String currentUid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVoByUid(currentUid);
if (null == storeInfoVo) {
log.warn("商城:POS机相关:SKU明细:店铺不存在[uid={},skuIds={}]", currentUid, skuids);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "店铺不存在");
}
String storeId = storeInfoVo.getStoreId();
String[] skuIdArr = skuids.split(",");
ArrayList<Object> skuVoList = CollectionUtil.arrayListObject();
for (String skuId : skuIdArr) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
if (storeId.equals(skuInfoVo.getStoreId())) {
skuVoList.add(skuInfoVo);
}
}
return ResponseDto.success(skuVoList);
}
}
......@@ -138,6 +138,9 @@ public class GoblinStoreMgtCouponController {
if (null == storeCouponVo) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在");
}
if (storeCouponVo.getState().equals("1")) {// 该优惠券活动中
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "该优惠券活动中不可停用");
}
if (storeCouponVo.getState().equals("3")) {// 该优惠券已停用
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "该优惠券已停用");
}
......
......@@ -699,8 +699,17 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
goodsSkuInfoVo.setUpdatedAt(now);
goodsSkuInfoVo.setDeletedBy(uid);
goodsSkuInfoVo.setDeletedAt(now);
if (goblinMongoUtils.delGoodsSkuInfoVo(goodsSkuInfoVo)) {
goblinRedisUtils.delGoodsSkuInfoVo(delSkuId);
List<String> skuReList = goblinRedisUtils.getSkuRe(delSkuId);
skuReList = null == skuReList ? CollectionUtil.arrayListString() : skuReList;
skuReList.add(delSkuId);
if (goblinMongoUtils.delGoodsSkuInfoVo(goodsSkuInfoVo, skuReList)) {
// goblinRedisUtils.delGoodsSkuInfoVo(delSkuId);
// goblinRedisUtils.delGoodsSkuInfoVoByUnShelves(delSkuId);
skuReList.forEach(skuRe -> {
goblinRedisUtils.delGoodsSkuInfoVo(skuRe);
goblinRedisUtils.delGoodsSkuInfoVoByUnShelves(skuRe);
});
BigDecimal priceGe = BigDecimal.ZERO, priceLe = BigDecimal.ZERO;
for (String skuId : mgtGoodsInfoVo.getSkuIdList()) {
......
......@@ -498,9 +498,9 @@ public class GoblinMongoUtils {
return (List<GoblinGoodsSkuInfoVo>) mongoTemplate.insert(vos, GoblinGoodsSkuInfoVo.class.getSimpleName());
}
public boolean delGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo) {
public boolean delGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo, List<String> skuIdList) {
return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("skuId").is(vo.getSkuId()).and("delFlg").is("0")).getQueryObject(),
Query.query(Criteria.where("skuId").is(skuIdList).and("delFlg").is("0")).getQueryObject(),
Update.update("updatedBy", vo.getUpdatedBy()).set("updatedAt", vo.getUpdatedAt())
.set("deletedBy", vo.getDeletedBy()).set("deletedAt", vo.getDeletedAt()).getUpdateObject()
).getModifiedCount() > 0;
......@@ -1075,21 +1075,20 @@ public class GoblinMongoUtils {
criteria.and("state").is(filterParam.getState());
}
if (StringUtils.isNotBlank(filterParam.getStartTime())) {
LocalDateTime startTime = DateUtil.Formatter.yyyy_MM_dd.parse(filterParam.getStartTime());
LocalDateTime startTime = DateUtil.Formatter.yyyyMMddHHmmss.parse(filterParam.getStartTime());
LocalDateTime startTimeBegin = startTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
criteria.and("startTime").gte(startTimeBegin);
}
if (StringUtils.isNotBlank(filterParam.getEndTime())) {
LocalDateTime endTime = DateUtil.Formatter.yyyy_MM_dd.parse(filterParam.getEndTime());
LocalDateTime endTime = DateUtil.Formatter.yyyyMMddHHmmss.parse(filterParam.getEndTime());
LocalDateTime endTimeEnd = endTime.withHour(23).withMinute(59).withSecond(59).withNano(999);
criteria.and("endTime").gte(endTimeEnd);
}
if (StringUtils.isNotBlank(filterParam.getCreatedDt())) {
LocalDateTime createDt = DateUtil.Formatter.yyyy_MM_dd.parse(filterParam.getCreatedDt());
LocalDateTime createdAtBegin = createDt.withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime createdAtEnd = createDt.withHour(23).withMinute(59).withSecond(59).withNano(999);
LocalDateTime createdAtBegin = DateUtil.Formatter.yyyyMMddHHmmss.parse(filterParam.getCreatedDt() + " 00:00:00");
LocalDateTime createdAtEnd = createdAtBegin.withHour(23).withMinute(59).withSecond(59).withNano(999);
criteria.and("createdAt").gte(createdAtBegin).lte(createdAtEnd);
}
......
......@@ -97,7 +97,7 @@ public class GoblinRedisUtils {
String rk = GoblinRedisConst.SKU_RELATION.concat(skuId);
Object obj = redisUtil.get(rk);
if (obj == null) {
return new ArrayList();
return CollectionUtil.arrayListString();
} else {
return (List<String>) obj;
}
......
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