Commit 9da628ea by guojuxing

卡券绑定修改:添加gic过期时间,用于查询

parent 758818b7
......@@ -8,6 +8,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.gic.enterprise.error.ErrorCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -317,6 +318,16 @@ public class WmMallStoreController {
@RequestMapping("/bind-coupon")
public RestResponse bindCoupon(WmStoreCouponConfigDTO dto) {
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
Map<String, CouponDTO> gicCouponMap = getGicCoupon(dto.getWmMallStoreId());
CouponDTO couponDTO = gicCouponMap.get(dto.getGicCouponId());
if (couponDTO == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "gic卡券不存在");
}
//计算过期时间
if (couponDTO.getCardEffectiveMode().intValue() == 0) {
//固定日期,需要给一个过期时间
dto.setGicCouponExpire(couponDTO.getExpireDate());
}
return OperationResultUtils
.operationResult(wmStoreApiService.saveCouponConfig(dto),
"绑定卡券"
......@@ -329,4 +340,20 @@ public class WmMallStoreController {
return ResultControllerUtils
.commonResult(wmStoreApiService.pageCouponConfig(params));
}
private Map<String, CouponDTO> getGicCoupon(Integer wmMallStoreId) {
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
//获取已配置的卡券ID
ServiceResponse<Long> mcuIdResponse = weimobMerchantService.getMcuAreaId(wmMallStoreId);
if (!mcuIdResponse.isSuccess()) {
return new HashMap<>(2);
}
ServiceResponse<List<CouponDTO>> gicCouponResponse = memberCouponApiService
.listGicCoupon(enterpriseId, mcuIdResponse.getResult(), "");
if (gicCouponResponse.isSuccess()) {
List<CouponDTO> list = gicCouponResponse.getResult();
return list.stream().collect(Collectors.toMap(e -> e.getCouponId().toString(), e -> e));
}
return new HashMap<>(2);
}
}
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