|
|
@@ -1125,19 +1125,44 @@ public class TsfGoodsController extends TsfBaseController {
|
|
|
*/
|
|
|
@PostMapping(value = "/coupon/download")
|
|
|
@ResponseBody
|
|
|
- public GagaMap createGoodsCoupon(@RequestBody Goods goods) throws Exception {
|
|
|
+ public GagaMap createGoodsCoupon(@RequestBody Goods paramsGoods) throws Exception {
|
|
|
|
|
|
GagaMap result = new GagaMap();
|
|
|
|
|
|
// 상품관련 기본값 설정(회원 등급, 앱, PC/모바일 등)
|
|
|
- setGoods(goods);
|
|
|
+ setGoods(paramsGoods);
|
|
|
+ log.info("createGoodsCoupon paramsGoods {}", paramsGoods);
|
|
|
+
|
|
|
+ // 일반상품과 딜상품 구분
|
|
|
+ Goods goods = goodsService.getGoodsInfo(paramsGoods);
|
|
|
+ if (goods == null || StringUtils.isBlank(goods.getGoodsCd())) {
|
|
|
+ result.set("message", "발급가능 쿠폰이 없습니다.");
|
|
|
+ result.set("status", "200");
|
|
|
+ result.set("params", paramsGoods);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
log.info("createGoodsCoupon goods {}", goods);
|
|
|
+ if (TscConstants.GoodsType.DEAL.value().equals(goods.getGoodsType())) {
|
|
|
+ Collection<Goods> goodsDealComposeList = goodsService.getGoodsDealComposeList(paramsGoods);
|
|
|
+ // 상품쿠폰
|
|
|
+ if (goodsDealComposeList != null && !goodsDealComposeList.isEmpty()) {
|
|
|
|
|
|
+ ArrayList<String> arrGoodsList = new ArrayList<>();
|
|
|
+ for (Goods goodsCompose : goodsDealComposeList) {
|
|
|
+ arrGoodsList.add(goodsCompose.getCompsGoodsCd());
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] arrGoodsCd = arrGoodsList.stream().toArray(String[]::new);
|
|
|
+ paramsGoods.setArrGoodsCd(arrGoodsCd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 쿠폰발급
|
|
|
// ERROR_10: 발급가능 쿠폰없음, 20: 발급완료 쿠폰, 30: 발급받은 쿠폰
|
|
|
//죄송합니다. 쿠폰이 모두 소진되었습니다
|
|
|
//죄송합니다. 해당 쿠폰은 다운로드가 불가합니다.
|
|
|
- String couponResult = goodsService.createGoodsCoupon(goods);
|
|
|
+ String couponResult = goodsService.createGoodsCoupon(paramsGoods);
|
|
|
|
|
|
result.set("status", GagaResponseStatus.SUCCESS.getCode());
|
|
|
|
|
|
@@ -1156,8 +1181,8 @@ public class TsfGoodsController extends TsfBaseController {
|
|
|
|
|
|
}
|
|
|
result.set("status", "200");
|
|
|
- result.set("params", goods);
|
|
|
- result.set("goodsCouponList", couponService.getGoodsCouponList(goods));
|
|
|
+ result.set("params", paramsGoods);
|
|
|
+ result.set("goodsCouponList", couponService.getGoodsCouponList(paramsGoods));
|
|
|
return result;
|
|
|
}
|
|
|
|