|
|
|
@@ -0,0 +1,99 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.dto.WxMerchantDto; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.WxMerchantVo; |
|
|
|
import com.iformall.enums.EnumMerchantPublic; |
|
|
|
import com.iformall.enums.EnumMerchantStatus; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.utils.HashUtil; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author Stormeye |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/merchant") |
|
|
|
public class WxMerchantController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@GetMapping("list") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
public ResultData list(@ModelAttribute WxMerchantDto wxMerchantDto, Integer pageNum, Integer pageSize) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); |
|
|
|
if (null == wxMerchantDto) wxMerchantDto = new WxMerchantDto(); |
|
|
|
wxMerchantDto.updateTenantInfo(getTenantInfo()); |
|
|
|
wxMerchantDto.setMerchantStatus(EnumMerchantStatus.VALID.getCode()); |
|
|
|
wxMerchantDto.setIsPublic(EnumMerchantPublic.PUBLIC.getCode()); |
|
|
|
return new ResultData(wxMerchantService.listAsPageCVo(wxMerchantDto, pageNum, pageSize)); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据code查询接口") |
|
|
|
@GetMapping("/findByCode") |
|
|
|
@ApiImplicitParam(name = "merchantCode", value = "merchantCode", dataType = "String", paramType = "query", required = true) |
|
|
|
public ResultData findByCode(String merchantCode) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxMerchantController::findByCode"); |
|
|
|
if(merchantCode == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); |
|
|
|
} |
|
|
|
String codeMD5 = HashUtil.DecodeByMD5(merchantCode); |
|
|
|
if(StringUtils.isBlank(codeMD5)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); |
|
|
|
} |
|
|
|
HashMap<String, String> params = new HashMap<String, String>(); |
|
|
|
TenantEntity tenantEntity = getTenantInfo(); |
|
|
|
params.put("tenantId", tenantEntity.getTenantId()); |
|
|
|
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { |
|
|
|
params.put("parentTenantId", tenantEntity.getParentTenantId()); |
|
|
|
} |
|
|
|
params.put("merchantCode", codeMD5); |
|
|
|
WxMerchantVo wxMerchant = wxMerchantService.getMerchantInfo(params); |
|
|
|
return new ResultData(wxMerchant); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("关注") |
|
|
|
@GetMapping("/collectCoupon") |
|
|
|
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) |
|
|
|
public ResultData collectCoupon(@RequestParam Long id) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxMerchantController::collectCoupon"); |
|
|
|
if (id == null) { |
|
|
|
return new ResultData(ResultData.ERROR, "缺少id"); |
|
|
|
} |
|
|
|
WxMerchant byId = wxMerchantService.getById(id); |
|
|
|
if(byId == null){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到数据"); |
|
|
|
} |
|
|
|
Long memberId; |
|
|
|
try { |
|
|
|
memberId = getMemberId(); |
|
|
|
} catch (MallinkException e) { |
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
wxMerchantService.collectCoupon(getTenantInfo(),memberId,byId.getId()); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
} |