| @@ -10,6 +10,7 @@ import com.iformall.enums.EnumMerchantBUserStatus; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.interceptor.AuthorizationInterceptor; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.IPUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -81,6 +82,15 @@ public class WxMerchantBUserController extends BaseController { | |||
| resultMap.put("service_phone", mall.getServicePhone()); | |||
| resultMap.put("tenant_id",merchant.getTenantId()); | |||
| resultMap.put("merchant_id",merchant.getId()); | |||
| String mid = null; | |||
| try { | |||
| mid = String.valueOf(merchant.getId()); | |||
| if(mid != null) { | |||
| resultMap.put("merchant_id_scan", HashUtil.EncoderByMd5(mid)); | |||
| } | |||
| }catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(resultMap); | |||
| } | |||
| @@ -45,22 +45,22 @@ public class WxCardPayController extends BaseController { | |||
| @Autowired | |||
| WxCardSpendService wxCardSpendService; | |||
| @ApiOperation(value = "C端扫B端储值卡支付订单", notes = "params:{\"cardId\":\"String\",\"merchantCode\":\"String\",\"totalFee\":\"String(元)\"}") | |||
| @ApiOperation(value = "C端扫B端储值卡支付订单", notes = "params:{\"cardId\":\"String\",\"merchantId\":\"String\",\"totalFee\":\"String(元)\"}") | |||
| @PostMapping("order_create") | |||
| public ResultData saveCardPayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("saveCardPayOrder: " + ipStr + " :" + paramMap.toString()); | |||
| String cardIdStr = paramMap.get("cardId"); | |||
| String merchantCode = paramMap.get("merchantCode"); | |||
| String merchantStr = paramMap.get("merchantId"); | |||
| String totalFeeStr = paramMap.get("totalFee"); | |||
| if (StringUtils.isBlank(cardIdStr)) { | |||
| logger.error("cardId不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "cardId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(merchantCode)) { | |||
| logger.error("merchantCode不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantCode不能为空"); | |||
| if (StringUtils.isBlank(merchantStr)) { | |||
| logger.error("merchantId不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(totalFeeStr)) { | |||
| logger.error("totalFee不能为空"); | |||
| @@ -76,10 +76,10 @@ public class WxCardPayController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "cardIdStr转换失败"); | |||
| } | |||
| try { | |||
| merchantId = Long.valueOf(merchantCode); | |||
| merchantId = Long.valueOf(merchantStr); | |||
| } catch (Exception e) { | |||
| logger.error("merchantCode convert failed:" + merchantCode); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantCode转换失败"); | |||
| logger.error("merchantCode convert failed:" + merchantStr); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId转换失败"); | |||
| } | |||
| BigDecimal totalFee = new BigDecimal(totalFeeStr); | |||
| @@ -5,7 +5,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantDiscountVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| @@ -123,7 +123,7 @@ public class WxMallController extends BaseController { | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.setTenantId(user.getTenantId()); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchantDiscountVo> list = wxMerchantService.getDisCountList(merchantQ); | |||
| List<WxMerchantVo> list = wxMerchantService.getDisCountList(merchantQ); | |||
| return new ResultData(Result.SUCCESS, "查询成功", list); | |||
| } | |||
| @@ -0,0 +1,43 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.service.WxMerchantService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| 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("wxMerchant") | |||
| public class WxMerchantController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @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); | |||
| } | |||
| HashMap<String, String> params = new HashMap<String, String>(); | |||
| params.put("tenantId", getTenantId()); | |||
| params.put("merchantCode", merchantCode); | |||
| WxMerchantVo wxMerchant = wxMerchantService.getMerchantInfo(params); | |||
| return new ResultData(wxMerchant); | |||
| } | |||
| } | |||
| @@ -1,38 +0,0 @@ | |||
| package com.iformall.domain.vo; | |||
| public class WxMerchantDiscountVo extends WxMerchantVo { | |||
| private static final long serialVersionUID = 6687964942922444531L; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率1",name="vipDiscountRate1") | |||
| private Integer vipDiscountRate1; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率2",name="vipDiscountRate2") | |||
| private Integer vipDiscountRate2; | |||
| @io.swagger.annotations.ApiModelProperty(value="VIP折扣率3",name="vipDiscountRate3") | |||
| private Integer vipDiscountRate3; | |||
| public Integer getVipDiscountRate1() { | |||
| return vipDiscountRate1; | |||
| } | |||
| public void setVipDiscountRate1(Integer vipDiscountRate1) { | |||
| this.vipDiscountRate1 = vipDiscountRate1; | |||
| } | |||
| public Integer getVipDiscountRate2() { | |||
| return vipDiscountRate2; | |||
| } | |||
| public void setVipDiscountRate2(Integer vipDiscountRate2) { | |||
| this.vipDiscountRate2 = vipDiscountRate2; | |||
| } | |||
| public Integer getVipDiscountRate3() { | |||
| return vipDiscountRate3; | |||
| } | |||
| public void setVipDiscountRate3(Integer vipDiscountRate3) { | |||
| this.vipDiscountRate3 = vipDiscountRate3; | |||
| } | |||
| } | |||
| @@ -3,13 +3,15 @@ package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.vo.WxMerchantDiscountVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> { | |||
| List<WxMerchant> findList(WxMerchant wxMerchant); | |||
| List<WxMerchantDiscountVo> findDiscountList(WxMerchant wxMerchant); | |||
| List<WxMerchantVo> findDiscountList(WxMerchant wxMerchant); | |||
| WxMerchantVo getMerchantByCode(HashMap<String, String> params); | |||
| @@ -3,8 +3,9 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.vo.WxMerchantDiscountVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| /** | |||
| @@ -28,7 +29,15 @@ public interface WxMerchantService { | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxMerchantDiscountVo> getDisCountList(WxMerchant record); | |||
| List<WxMerchantVo> getDisCountList(WxMerchant record); | |||
| /** | |||
| * 根据code查询 | |||
| * | |||
| * @param params | |||
| * @return | |||
| */ | |||
| WxMerchantVo getMerchantInfo(HashMap<String, String> params); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| @@ -7,7 +7,6 @@ import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantDiscountVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| @@ -102,10 +101,15 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| } | |||
| @Override | |||
| public List<WxMerchantDiscountVo> getDisCountList(WxMerchant record) { | |||
| public List<WxMerchantVo> getDisCountList(WxMerchant record) { | |||
| return wxMerchantMapper.findDiscountList(record); | |||
| } | |||
| @Override | |||
| public WxMerchantVo getMerchantInfo(HashMap<String, String> params) { | |||
| return wxMerchantMapper.getMerchantByCode(params); | |||
| } | |||
| @Override | |||
| public List<WxMerchant> etcpList(WxMerchant record) { | |||
| record.setCarVendorType(EnumCarVendor.CAR_ETCP.getCode()); | |||
| @@ -1,6 +1,8 @@ | |||
| package com.iformall.utils; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.security.MessageDigest; | |||
| import java.util.Base64; | |||
| /** | |||
| * @author Stormeye | |||
| @@ -82,4 +84,25 @@ public class HashUtil { | |||
| } | |||
| return diff == 0; | |||
| } | |||
| public static String EncoderByMd5(String str) { | |||
| if (str == null) { | |||
| return null; | |||
| } | |||
| try { | |||
| String enc = hash("md5", str); | |||
| enc = new String(Base64.getUrlEncoder().encode(enc.getBytes("utf-8"))); | |||
| return enc; | |||
| } catch (UnsupportedEncodingException e) { | |||
| return null; | |||
| } | |||
| } | |||
| public static String DecodeByMD5(String str) { | |||
| if (str == null) { | |||
| return null; | |||
| } | |||
| String dec = new String(Base64.getUrlDecoder().decode(str)); | |||
| return dec; | |||
| } | |||
| } | |||
| @@ -98,7 +98,7 @@ | |||
| m.vip_discount_rate1, m.vip_discount_rate2, m.vip_discount_rate3 | |||
| </sql> | |||
| <resultMap id="MerchantDiscountVoResultMap" type="com.iformall.domain.vo.WxMerchantDiscountVo"> | |||
| <resultMap id="MerchantDiscountVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/> | |||
| <result column="name" jdbcType="VARCHAR" property="merchantName"/> | |||
| @@ -135,5 +135,26 @@ | |||
| </where> | |||
| </select> | |||
| <select id="getMerchantByCode" parameterType="java.util.Map" resultMap="MerchantDiscountVoResultMap"> | |||
| select | |||
| <include refid="allMerchantDiscountVoColumns"/> | |||
| FROM wx_merchant m | |||
| left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 | |||
| left join wx_shop s on ms.shop_id = s.id | |||
| left join wx_mall_building mb on s.building = mb.id | |||
| left join wx_mall_floor mf on s.floor = mf.id | |||
| <where> | |||
| <if test=" null != tenantId "> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != status "> | |||
| and m.`status` = #{status} | |||
| </if> | |||
| <if test=" null != merchantCode "> | |||
| and md5(m.`id`) = #{merchantCode} | |||
| </if> | |||
| </where> | |||
| </select> | |||
| </mapper> | |||