| | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.douyin.DouyinClient; |
| | | import com.doumee.core.douyin.dto.DouyinBaseResp; |
| | | import com.doumee.core.douyin.dto.DouyinBoundProduct; |
| | | import com.doumee.core.douyin.dto.DouyinPrepareParam; |
| | | import com.doumee.core.douyin.dto.DouyinPrepareResp; |
| | | import com.doumee.core.douyin.dto.DouyinShopPoiResp; |
| | |
| | | import com.doumee.service.business.DouyinVerifyLogService; |
| | | import com.doumee.service.business.DouyinVerifyService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | @PreventRepeat |
| | | @ApiOperation("扫码一步核销(验券准备 + 核销合并;前端只调此接口)") |
| | | @PostMapping("/scanVerify") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), |
| | | }) |
| | | public ApiResponse<DouyinVerifyRecord> scanVerify(@RequestBody DouyinPrepareParam param) { |
| | | String apiPath = "/web/douyin/scanVerify"; |
| | | String memberId = getMemberId(); |
| | |
| | | verifyParam.setSkuId(cert.getSku().getSkuId()); |
| | | verifyParam.setPayAmount(cert.getAmount() == null ? null : cert.getAmount().getPayAmount()); |
| | | |
| | | // ④ 核销 + 开套餐(单独记一条 VERIFY 日志) |
| | | // ④ 核销前校验:商品在库 + 已绑定有效套餐;失败直接拦截(券尚未核销,避免抖音已核销但本地未开卡) |
| | | DouyinBoundProduct boundProduct = douyinVerifyService.resolveBoundProduct(verifyParam.getSkuId()); |
| | | |
| | | // ⑤ 核销 + 开套餐(单独记一条 VERIFY 日志) |
| | | long verifyStart = System.currentTimeMillis(); |
| | | DouyinVerifyLog verifyLog = baseLog(Constants.DOUYIN_VERIFY_OPERATE_TYPE.VERIFY.getKey(), apiPath, verifyStart); |
| | | verifyLog.setRawRequest(JSON.toJSONString(verifyParam)); |
| | | verifyLog.setPoiId(verifyParam.getPoiId()); |
| | | try { |
| | | DouyinVerifyRecord rec = douyinVerifyService.verify(verifyParam, memberId); |
| | | // 透传核销前校验结果,verify 内不再重复查询商品/套餐 |
| | | DouyinVerifyRecord rec = douyinVerifyService.verify(verifyParam, memberId, boundProduct); |
| | | // 附带本次开通的套餐卡详情(供前端核销后展示套餐信息) |
| | | douyinVerifyService.fillPackageInfo(rec); |
| | | fillByRecord(verifyLog, rec); |
| | | return ApiResponse.success(rec); |
| | | } catch (Throwable e) { |
| | |
| | | @LoginRequired |
| | | @ApiOperation("核销记录分页") |
| | | @PostMapping("/page") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), |
| | | }) |
| | | public ApiResponse<PageData<DouyinVerifyRecord>> findPage(@RequestBody PageWrap<DouyinVerifyRecord> pageWrap) { |
| | | return ApiResponse.success(douyinVerifyService.findPage(pageWrap)); |
| | | } |
| | |
| | | @LoginRequired |
| | | @ApiOperation("核销记录详情") |
| | | @GetMapping("/{id}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), |
| | | }) |
| | | public ApiResponse<DouyinVerifyRecord> findById(@PathVariable String id) { |
| | | return ApiResponse.success(douyinVerifyService.findById(id)); |
| | | } |