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

Commit bb0152b2 authored by 张国柄's avatar 张国柄

~API:商城活动:优惠券领取;

parent ca69e8f6
......@@ -14,7 +14,7 @@ public interface GoblinCouponService {
ArrayList<GoblinStoreCouponVo> getSpuByType(String spuId, String storeId, String type);
//领取券
Boolean receiveCoupon(String uid, List<GoblinUserCouponVo> userCouponVoList, GoblinStoreCouponVo storeCouponVo, Integer number);
Boolean receiveCoupon(String uid, List<GoblinUserCouponVo> userCouponVoList, GoblinStoreCouponVo storeCouponVo);
//我的券列表 [类型 1可用 2过期/已使用]
......
......@@ -61,10 +61,11 @@ public class GoblinCouponController {
@ApiResponse(code = 200, message = "接口返回对象参数")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeCouponId", value = "平台券id"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "number", value = "数量"),
// @ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "number", value = "数量"),
})
public ResponseDto<Boolean> checkOrderResult(@RequestParam("storeCouponId") @Valid String storeCouponId,
@RequestParam("number") @Valid Integer number) {
public ResponseDto<Boolean> checkOrderResult(@RequestParam("storeCouponId") @Valid String storeCouponId) {
// public ResponseDto<Boolean> checkOrderResult(@RequestParam("storeCouponId") @Valid String storeCouponId,
// @RequestParam("number") @Valid Integer number) {
String currentUid = CurrentUtil.getCurrentUid();
GoblinStoreCouponVo storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId);
if (null == storeCouponVo) {
......@@ -83,7 +84,7 @@ public class GoblinCouponController {
}
}
if (goblinRedisUtils.getStoreCouponStock(storeCouponId) > 0) {
Boolean resultFlg = goblinCouponService.receiveCoupon(currentUid, userCouponVos, storeCouponVo, number);
Boolean resultFlg = goblinCouponService.receiveCoupon(currentUid, userCouponVos, storeCouponVo);
return resultFlg ? ResponseDto.success() : ResponseDto.failure();
}
return ResponseDto.failure(ErrorMapping.get("140053"));
......
......@@ -6,6 +6,7 @@ import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo;
import com.liquidnet.service.goblin.dto.vo.GoblinUserCouponBasicVo;
import com.liquidnet.service.goblin.dto.vo.GoblinUserCouponVo;
import com.liquidnet.service.goblin.service.GoblinCouponService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -22,6 +23,8 @@ public class GoblinCouponImpl implements GoblinCouponService {
@Autowired
GoblinRedisUtils goblinRedisUtils;
@Autowired
GoblinMongoUtils goblinMongoUtils;
@Override
public ArrayList<String> getSpuType(String spuId, String storeId) {
......@@ -57,7 +60,8 @@ public class GoblinCouponImpl implements GoblinCouponService {
}
@Override
public Boolean receiveCoupon(String uid, List<GoblinUserCouponVo> userCouponVoList, GoblinStoreCouponVo storeCouponVo, Integer number) {
public Boolean receiveCoupon(String uid, List<GoblinUserCouponVo> userCouponVoList, GoblinStoreCouponVo storeCouponVo) {
String storeCouponId = storeCouponVo.getStoreCouponId();
LocalDateTime now = LocalDateTime.now();
GoblinUserCouponBasicVo receiveUserCouponBasicVo = GoblinUserCouponBasicVo.getNew().initByStoreCouponVo(storeCouponVo);
......@@ -66,10 +70,16 @@ public class GoblinCouponImpl implements GoblinCouponService {
receiveUserCouponBasicVo.setOperator(uid);
receiveUserCouponBasicVo.setCreatedAt(now);
GoblinUserCouponVo receiveUserCouponVo = GoblinUserCouponVo.getNew().copy(receiveUserCouponBasicVo);
userCouponVoList.add(GoblinUserCouponVo.getNew().copy(receiveUserCouponBasicVo));
if (goblinRedisUtils.decrStoreCouponStock(storeCouponId, 1) >= 0) {
goblinMongoUtils.insertUserCouponVo(receiveUserCouponBasicVo);
goblinRedisUtils.setUserCouponVos(uid, userCouponVoList);
// toMqSqls
return null;
return true;
}
goblinRedisUtils.incrStoreCouponStock(storeCouponId, 1);
return false;
}
}
......@@ -1051,6 +1051,10 @@ public class GoblinMongoUtils {
GoblinUserCouponVo.class, GoblinUserCouponBasicVo.class.getSimpleName());
}
public GoblinUserCouponBasicVo insertUserCouponVo(GoblinUserCouponBasicVo vo) {
return mongoTemplate.insert(vo, GoblinUserCouponBasicVo.class.getSimpleName());
}
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
}
......@@ -1108,6 +1108,13 @@ public class GoblinRedisUtils {
return vos;
}
public boolean addUserCouponVos(String uid, GoblinUserCouponVo vo) {
if (null == vo) return false;
List<GoblinUserCouponVo> vos = this.getUserCouponVos(uid);
vos.add(vo);
return redisUtil.set(GoblinRedisConst.USER_COUPON.concat(uid), JsonUtils.toJson(vos));
}
/* ---------------------------------------- ---------------------------------------- */
}
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