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

Commit 4010df5c authored by 张国柄's avatar 张国柄

~API:商城:POS机相关;

parent 4aafb739
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class GoblinPosGoodsVo implements Serializable, Cloneable {
private static final long serialVersionUID = 9108226197069813814L;
private String skuId;
private String name;
private BigDecimal price;
private String spuId;
private String spuName;
private static final GoblinPosGoodsVo obj = new GoblinPosGoodsVo();
public static GoblinPosGoodsVo getNew() {
try {
return (GoblinPosGoodsVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinPosGoodsVo();
}
}
}
......@@ -3,14 +3,10 @@ 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.dto.vo.*;
import com.liquidnet.service.goblin.service.GoblinCouponService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
......@@ -21,7 +17,6 @@ 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)
......@@ -36,13 +31,13 @@ public class GoblinPosController {
GoblinCouponService goblinCouponService;
@PostMapping("coupon/receive")
@ApiOperation("领券")
@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,
public ResponseDto<GoblinUserCouponVo> checkOrderResult(@NotBlank(message = "参数无效:storeCouponId") @RequestParam("storeCouponId") String storeCouponId,
@NotBlank(message = "参数无效:uid") @RequestParam("uid") String uid) {
String currentUid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVoByUid(currentUid);
......@@ -59,6 +54,7 @@ public class GoblinPosController {
} else if (!storeCouponVo.getState().equals("1")) {
return ResponseDto.failure(ErrorMapping.get("140051"));
}
// TODO: 2022/2/24 zhanggb==暂不进行UID真实校验
List<GoblinUserCouponVo> userCouponVos = goblinRedisUtils.getUserCouponVos(uid);
if (!CollectionUtils.isEmpty(userCouponVos)) {
int beforeSize = userCouponVos.size();
......@@ -69,15 +65,18 @@ public class GoblinPosController {
}
if (storeCouponVo.getStock().equals(0) || goblinRedisUtils.getStoreCouponStock(storeCouponId) > 0) {
Boolean resultFlg = goblinCouponService.receiveCoupon(uid, userCouponVos, storeCouponVo);
return resultFlg ? ResponseDto.success() : ResponseDto.failure();
return resultFlg ? ResponseDto.success(userCouponVos.stream().filter(r -> r.getStoreCouponId().equals(storeCouponId)).findFirst().get()) : 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) {
@ApiOperation(value = "商品信息")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "skuids", value = "多个skuId以,分隔"),
})
@PostMapping("goods/skuinfo")
public ResponseDto<List<GoblinPosGoodsVo>> skuInfoList(@NotBlank(message = "参数无效:skuIds") @RequestBody String skuids) {
log.info("商城:POS机相关:SKU列表[skuIds={}]", skuids);
String currentUid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVoByUid(currentUid);
......@@ -87,13 +86,23 @@ public class GoblinPosController {
}
String storeId = storeInfoVo.getStoreId();
String[] skuIdArr = skuids.split(",");
ArrayList<Object> skuVoList = CollectionUtil.arrayListObject();
List<GoblinPosGoodsVo> posGoodsVoList = ObjectUtil.getGoblinPosGoodsVoArrayList();
for (String skuId : skuIdArr) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
if (storeId.equals(skuInfoVo.getStoreId())) {
skuVoList.add(skuInfoVo);
GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
if (null != goodsSkuInfoVo && storeId.equals(goodsSkuInfoVo.getStoreId())) {
String spuId = goodsSkuInfoVo.getSpuId();
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getGoodsInfoVo(spuId);
GoblinPosGoodsVo posGoodsVo = GoblinPosGoodsVo.getNew();
posGoodsVo.setSkuId(skuId);
posGoodsVo.setName(goodsSkuInfoVo.getName());
posGoodsVo.setPrice(goodsSkuInfoVo.getPrice());
posGoodsVo.setSpuId(spuId);
posGoodsVo.setSpuName(goodsInfoVo.getName());
posGoodsVoList.add(posGoodsVo);
}
}
return ResponseDto.success(skuVoList);
return ResponseDto.success(posGoodsVoList);
}
}
......@@ -75,8 +75,9 @@ public class ObjectUtil {
private static final ArrayList<GoblinStoreCouponVo> goblinStoreCouponVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinStoreMgtCouponListVoExcel> goblinStoreMgtCouponListVoExcelArrayList = new ArrayList<>();
private static final ArrayList<GoblinUserCouponVo> goblinUserCouponVo = new ArrayList<>();
private static final ArrayList<BackCouponParam> backCouponParam = new ArrayList<>();
private static final ArrayList<GoblinMailVo> goblinMailVo = new ArrayList<>();
private static final ArrayList<BackCouponParam> backCouponParam = new ArrayList<>();
private static final ArrayList<GoblinMailVo> goblinMailVo = new ArrayList<>();
private static final ArrayList<GoblinPosGoodsVo> goblinPosGoodsVoArrayList = new ArrayList<>();
private static final BasicDBObject basicDBObject = new BasicDBObject();
......@@ -289,6 +290,10 @@ public class ObjectUtil {
return (ArrayList<GoblinStoreMgtCouponListVoExcel>) goblinStoreMgtCouponListVoExcelArrayList.clone();
}
public static ArrayList<GoblinPosGoodsVo> getGoblinPosGoodsVoArrayList() {
return (ArrayList<GoblinPosGoodsVo>) goblinPosGoodsVoArrayList.clone();
}
public static BasicDBObject cloneBasicDBObject() {
return (BasicDBObject) basicDBObject.clone();
}
......
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