diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java index 3f6e0cae..9d835901 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java @@ -789,8 +789,10 @@ public class LklTkServiceImpl { */ public JSONObject updateMerchantNotify(HttpServletRequest request) { try { + logger.info("开始处理拉卡拉商户增终异步通知"); // 解密请求参数 String requestBody = LakalaUtil.getBody(request); + logger.info("拉卡拉商户增终异步通知返回加密数据:{}", requestBody); if (StrUtil.isBlank(requestBody)) { return new JSONObject().set("code", "400").set("message", "返回参数为空"); @@ -812,6 +814,7 @@ public class LklTkServiceImpl { if (StrUtil.isBlank(lklNotifyResp)) { return new JSONObject().set("code", "400").set("message", "数据解密出错!"); } + logger.info("拉卡拉商户增终异步通知返回明文数据:{}", lklNotifyResp); // 逻辑处理 JSONObject dataJSON = JSONUtil.parseObj(lklNotifyResp); @@ -827,10 +830,32 @@ public class LklTkServiceImpl { StrUtil.isBlank(merCupNo) || StrUtil.isBlank(reviewRelatedId) || StrUtil.isBlank(termNo)) { - return new JSONObject().set("code", "500").set("message", "参数解析出错"); + return new JSONObject().set("code", "500").set("message", "返回参数缺少关键数据"); } - // 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据 + // 更新商户分店入驻表 + // status 状态:1-已成功;2-审核未通过;3-未处理;4-待审核; + Integer status = 4; + switch (reviewPass) { + case "PASS": + status = CommonConstant.Enable; + break; + case "UNPASS": + status = CommonConstant.Disable2; + break; + case "PASSING": + status = 3; + break; + case "PREPARE": + status = 4; + break; + default: + status = 4; + + } + shopMchEntryBranchService.updateByReviewRelatedId(reviewRelatedId, status, lklNotifyResp); + + // 给商家总店入驻表增加拉卡拉的商户号和拉卡拉返回的数据 ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo); if (shopMchEntry == null) { return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在"); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryBranchAdminController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryBranchAdminController.java new file mode 100644 index 00000000..c8be3184 --- /dev/null +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryBranchAdminController.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. + * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. + * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. + * Vestibulum commodo. Ut rhoncus gravida arcu. + */ + +package com.suisung.mall.shop.store.controller.admin; + +import cn.hutool.json.JSONObject; +import com.suisung.mall.common.api.CommonResult; +import com.suisung.mall.common.pojo.dto.MainStoreBranchReqDTO; +import com.suisung.mall.common.service.impl.BaseControllerImpl; +import com.suisung.mall.shop.store.service.ShopMchEntryBranchService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.util.Pair; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@Slf4j +@Api(tags = "商家入驻业务控制器") +@RestController +@RequestMapping("/admin/shop/merch/branch") +public class ShopMchEntryBranchAdminController extends BaseControllerImpl { + + + @Resource + private ShopMchEntryBranchService shopMchEntryBranchService; + + /** + * 商家申请入驻商城平台 + * + * @param mainStoreBranchReqJSON + * @return + */ + @ApiOperation(value = "后台-申请总店的分店", notes = "向拉卡拉申请总店的分店") + @RequestMapping(value = "/apply/store", method = RequestMethod.POST) + public CommonResult shopMerchEntryList(@RequestBody JSONObject mainStoreBranchReqJSON) { + MainStoreBranchReqDTO mainStoreBranchReq = mainStoreBranchReqJSON.toBean(MainStoreBranchReqDTO.class); + Pair result = shopMchEntryBranchService.applyMchEntryBranchStore(mainStoreBranchReq); + if (result.getFirst()) { + return CommonResult.success(); + } + + return CommonResult.failed(result.getSecond()); + } + + +} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryBranchService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryBranchService.java index 0e1cdb89..85de8680 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryBranchService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryBranchService.java @@ -22,6 +22,17 @@ public interface ShopMchEntryBranchService { */ Boolean saveShopMchEntryBranch(ShopMchEntryBranch shopMchEntryBranch); + + /** + * 更新商户终端入驻申请信息 + * + * @param reviewRelatedId 商户终端入驻申请ID + * @param status 商户终端入驻申请状态 + * @param notifyResp 商户终端入驻申请通知响应数据 + * @return 更新结果 + */ + Boolean updateByReviewRelatedId(String reviewRelatedId, Integer status, String notifyResp); + /** * 根据商户终端入驻申请ID查询商户终端入驻申请信息 * diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryBranchServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryBranchServiceImpl.java index f937abe2..5b5f80ea 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryBranchServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryBranchServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.feignService.AccountService; @@ -28,6 +29,7 @@ import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; import java.util.Arrays; +import java.util.Date; import java.util.Objects; @Slf4j @@ -101,6 +103,45 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId).set(ShopMchEntryBranch::getUpdated_at, new Date()); + + // 只有当状态值有效时才更新状态字段 + if (CheckUtil.isNotEmpty(status)) { + updateWrapper.set(ShopMchEntryBranch::getStatus, status); + log.debug("更新状态字段为: {}", status); + } + + // 更新通知响应内容 + if (StrUtil.isNotBlank(notifyResp)) { // 允许空字符串,但不能为null + updateWrapper.set(ShopMchEntryBranch::getLkl_notify_reps, notifyResp); + } + + boolean result = update(updateWrapper); + + if (result) { + log.info("成功更新分店入驻申请记录,审核关联号: {}", reviewRelatedId); + } else { + log.warn("更新分店入驻申请记录失败,审核关联号: {}", reviewRelatedId); + } + + return result; + } catch (Exception e) { + log.error("更新分店入驻申请记录时发生异常,审核关联号: {}", reviewRelatedId, e); + return false; + } + } + + /** * 根据商户终端入驻申请ID查询商户终端入驻申请信息 * @@ -159,8 +200,8 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl entryQueryWrapper = new LambdaQueryWrapper<>(); entryQueryWrapper.eq(ShopMchEntry::getStore_id, mainStoreBranchReq.getParent_store_id()) - .eq(ShopMchEntry::getApproval_status, CommonConstant.Enable) - .eq(ShopMchEntry::getParent_id, 0L); + .eq(ShopMchEntry::getApproval_status, CommonConstant.MCH_APPR_STA_PASS) + .eq(ShopMchEntry::getParent_id, 0L); // 总店记录 ShopMchEntry mchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper); if (mchEntry == null) {