v1.1 payermax ios第三方支付 h5接口
This commit is contained in:
@@ -1756,6 +1756,11 @@ public class Constant {
|
||||
*/
|
||||
public static final String H5_AREA_CHARGE_CONFIG = "h5_area_charge_config";
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
public static final String CHARGE_WAY_CONFIG = "charge_way_config";
|
||||
|
||||
}
|
||||
|
||||
public static class ActiveMq {
|
||||
|
@@ -13,6 +13,10 @@ public class ChargeProd {
|
||||
|
||||
private String localCurrencyCode;
|
||||
|
||||
private String payChannel;
|
||||
|
||||
private String paymentType;
|
||||
|
||||
private Long money;
|
||||
|
||||
private Integer changeGoldRate;
|
||||
@@ -75,6 +79,22 @@ public class ChargeProd {
|
||||
this.localCurrencyCode = localCurrencyCode;
|
||||
}
|
||||
|
||||
public String getPayChannel() {
|
||||
return payChannel;
|
||||
}
|
||||
|
||||
public void setPayChannel(String payChannel) {
|
||||
this.payChannel = payChannel;
|
||||
}
|
||||
|
||||
public String getPaymentType() {
|
||||
return paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(String paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
public Long getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
@@ -454,6 +454,26 @@ public class ChargeProdExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCountryEqualTo(String value) {
|
||||
addCriterion("country = ", value, "country");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPayChannelEqualTo(String value) {
|
||||
addCriterion("pay_channel = ", value, "pay_channel");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPaymentTypeEqualTo(String value) {
|
||||
addCriterion("payment_type = ", value, "payment_type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andPaymentTypeEqualIsNull() {
|
||||
addCriterion("payment_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andChangeGoldRateIsNull() {
|
||||
addCriterion("change_gold_rate is null");
|
||||
return (Criteria) this;
|
||||
|
@@ -3,10 +3,13 @@ package com.accompany.payment.service;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.vo.BaseRequestVO;
|
||||
import com.accompany.payment.mapper.ChargeProdMapper;
|
||||
import com.accompany.payment.model.ChargeProd;
|
||||
import com.accompany.payment.model.ChargeProdExample;
|
||||
import com.accompany.payment.vo.ChargeProdVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,10 +19,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -31,22 +33,6 @@ public class ChargeProdService {
|
||||
private JedisService jedisService;
|
||||
private Gson gson = new Gson();
|
||||
|
||||
public List<ChargeProd> getAllChargeProdList() {
|
||||
String chargeProdStr = jedisService.read(RedisKey.charge_prod.getKey());
|
||||
List<ChargeProd> chargeProdList = null;
|
||||
if (StringUtils.isEmpty(chargeProdStr)) {
|
||||
ChargeProdExample chargeProdExample = new ChargeProdExample();
|
||||
chargeProdExample.setOrderByClause(" seq_no asc");
|
||||
chargeProdList = chargeProdMapper.selectByExample(chargeProdExample);
|
||||
batchSaveChargeProdCache(chargeProdList);
|
||||
} else {
|
||||
Type typeJson = new TypeToken<List<ChargeProd>>() {
|
||||
}.getType();
|
||||
chargeProdList = gson.fromJson(chargeProdStr, typeJson);
|
||||
}
|
||||
return chargeProdList;
|
||||
}
|
||||
|
||||
public List<ChargeProd> query(int type, String appVersion, String os,String channel) {
|
||||
Map<String, String> chargeProdKeyMap = jedisService.hgetAllBykey(RedisKey.charge_prod.getKey());
|
||||
List<ChargeProd> chargeProdList = com.beust.jcommander.internal.Lists.newArrayList();
|
||||
@@ -139,9 +125,57 @@ public class ChargeProdService {
|
||||
chargeProdVo.setSeqNo(chargeProd.getSeqNo());
|
||||
chargeProdVo.setProdDesc(chargeProd.getProdDesc());
|
||||
chargeProdVo.setRate(chargeProd.getChangeGoldRate());
|
||||
chargeProdVo.setChargeGoldNum(chargeProd.getChargeGoldNum());
|
||||
chargeProdVoList.add(chargeProdVo);
|
||||
}
|
||||
Collections.sort(chargeProdVoList);
|
||||
return chargeProdVoList;
|
||||
}
|
||||
|
||||
public List<ChargeProdVo> getAllChargeProdVoList(String countryCode, String payChannel, String paymentType) {
|
||||
BaseRequestVO baseRequestVO = new BaseRequestVO();
|
||||
|
||||
ChargeProdExample chargeProdExample = new ChargeProdExample();
|
||||
chargeProdExample.createCriteria().andCountryEqualTo(countryCode)
|
||||
.andPayChannelEqualTo(payChannel)
|
||||
.andProdStatusIn(this.getAvailableChargeProdStatus());
|
||||
if (StringUtils.isBlank(paymentType)) {
|
||||
chargeProdExample.createCriteria().andPaymentTypeEqualIsNull();
|
||||
} else {
|
||||
chargeProdExample.createCriteria().andPaymentTypeEqualTo(paymentType);
|
||||
}
|
||||
|
||||
List<ChargeProd> chargeProds = chargeProdMapper.selectByExample(chargeProdExample);
|
||||
List<ChargeProd> chargeProdList = Lists.newArrayList();
|
||||
for (ChargeProd chargeProd : chargeProds) {
|
||||
|
||||
if (Constant.ChargeProdStatus.using.equals(chargeProd.getProdStatus())) {
|
||||
chargeProdList.add(chargeProd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Constant.ChargeProdStatus.audit.equals(chargeProd.getProdStatus())) {
|
||||
if (Constant.OsType.IOS.equalsIgnoreCase(baseRequestVO.getOs())) {
|
||||
chargeProdList.add(chargeProd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chargeProdList.stream()
|
||||
.map(chargeProd -> {
|
||||
ChargeProdVo chargeProdVo = new ChargeProdVo();
|
||||
chargeProdVo.setChannel(chargeProd.getChannel());
|
||||
chargeProdVo.setChargeProdId(chargeProd.getChargeProdId());
|
||||
chargeProdVo.setProdName(chargeProd.getProdName());
|
||||
chargeProdVo.setGiftGoldNum(chargeProd.getGiftGoldNum());
|
||||
chargeProdVo.setMoney(chargeProd.getMoney());
|
||||
chargeProdVo.setSeqNo(chargeProd.getSeqNo());
|
||||
chargeProdVo.setProdDesc(chargeProd.getProdDesc());
|
||||
chargeProdVo.setChargeGoldNum(chargeProd.getChargeGoldNum());
|
||||
return chargeProdVo;
|
||||
})
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,9 @@ public class ChargeProdVo implements Comparable<ChargeProdVo> {
|
||||
private Integer giftGoldNum;
|
||||
private Byte channel;
|
||||
private Byte seqNo;
|
||||
private Long chargeGoldNum;
|
||||
private Integer rate;
|
||||
private String currencySign;
|
||||
|
||||
public Integer getRate() {
|
||||
return rate;
|
||||
@@ -77,6 +79,22 @@ public class ChargeProdVo implements Comparable<ChargeProdVo> {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public Long getChargeGoldNum() {
|
||||
return chargeGoldNum;
|
||||
}
|
||||
|
||||
public void setChargeGoldNum(Long chargeGoldNum) {
|
||||
this.chargeGoldNum = chargeGoldNum;
|
||||
}
|
||||
|
||||
public String getCurrencySign() {
|
||||
return currencySign;
|
||||
}
|
||||
|
||||
public void setCurrencySign(String currencySign) {
|
||||
this.currencySign = currencySign;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ChargeProdVo chargeProdVo) {
|
||||
Byte seqNoVo = chargeProdVo.seqNo;
|
||||
|
@@ -8,6 +8,8 @@
|
||||
<result column="prod_status" property="prodStatus" jdbcType="TINYINT"/>
|
||||
<result column="country" property="country" jdbcType="VARCHAR"/>
|
||||
<result column="local_currency_code" property="localCurrencyCode" jdbcType="TINYINT"/>
|
||||
<result column="pay_channel" property="payChannel" jdbcType="VARCHAR"/>
|
||||
<result column="paymentType" property="paymentType" jdbcType="VARCHAR"/>
|
||||
<result column="money" property="money" jdbcType="BIGINT"/>
|
||||
<result column="change_gold_rate" property="changeGoldRate" jdbcType="INTEGER"/>
|
||||
<result column="gift_gold_num" property="giftGoldNum" jdbcType="INTEGER"/>
|
||||
@@ -77,7 +79,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
charge_prod_id, prod_name, prod_desc, prod_status, country, local_currency_code, money, change_gold_rate, gift_gold_num,
|
||||
charge_prod_id, prod_name, prod_desc, prod_status, country, local_currency_code, pay_channel, payment_type, money, change_gold_rate, gift_gold_num,
|
||||
first_gift_gold_num, channel, seq_no, charge_gold_num
|
||||
</sql>
|
||||
<select id="selectByExample" resultMap="BaseResultMap"
|
||||
|
@@ -5,8 +5,12 @@ import com.accompany.business.event.ChargeSuccessEvent;
|
||||
import com.accompany.business.message.PayFinishMessage;
|
||||
import com.accompany.business.model.BankCardSign;
|
||||
import com.accompany.business.model.payment.PaymentDTO;
|
||||
import com.accompany.common.utils.BeanUtil;
|
||||
import com.accompany.core.service.base.BaseService;
|
||||
import com.accompany.payment.vo.VipOpenParams;
|
||||
import com.accompany.payment.dto.AreaChargeConfigDTO;
|
||||
import com.accompany.payment.dto.ChargeWayConfigDTO;
|
||||
import com.accompany.payment.dto.ChargeWayDTO;
|
||||
import com.accompany.payment.vo.*;
|
||||
import com.accompany.business.service.charge.LuckyTarotChargeService;
|
||||
import com.accompany.business.service.charge.VipChargeService;
|
||||
import com.accompany.business.service.mq.ActiveMQService;
|
||||
@@ -38,8 +42,10 @@ import com.accompany.payment.model.*;
|
||||
import com.accompany.payment.service.*;
|
||||
import com.accompany.sms.service.AliyunSmsService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -54,6 +60,7 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by liuguofu on 2017/6/27.
|
||||
@@ -655,4 +662,150 @@ public class ChargeService extends BaseService {
|
||||
// 發送小秘書通知和頭飾
|
||||
luckyTarotChargeService.sendDrawResultToUsers(luckyTarotRecord);
|
||||
}
|
||||
|
||||
public ChargePageVO getChargePageInfo(String countryCode) {
|
||||
AreaChargeConfigDTO h5AreaChargeConfig = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.H5_AREA_CHARGE_CONFIG, "{}"), AreaChargeConfigDTO.class);
|
||||
Map<String, AreaChargeConfigDTO.AreaChargeConfigeItem> areaConfigMap = h5AreaChargeConfig.getAreaConfig();
|
||||
if (areaConfigMap == null) {
|
||||
areaConfigMap = new HashMap<>();
|
||||
}
|
||||
|
||||
AreaChargeConfigDTO.AreaChargeConfigeItem areaChargeConfig = areaConfigMap.get(countryCode);
|
||||
if (areaChargeConfig == null) {
|
||||
log.error("获取h5充值页信息错误:未知地区。 countryCode: {}", countryCode);
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
// TODO 后续版本下面2句可以去掉
|
||||
List<ChargeWayInfoVO> chargeWays = genChargeWayList(areaChargeConfig.getChargeWays());
|
||||
setChargeProdsInChargeWay(countryCode, areaChargeConfig, chargeWays);
|
||||
////////
|
||||
|
||||
List<ChargeWayGroupInfoVO> chargeWayGroups = genChargeWayGroups(areaChargeConfig.getChargeWayGroups(), countryCode, areaChargeConfig);
|
||||
|
||||
ChargePageVO pageVO = new ChargePageVO();
|
||||
pageVO.setChargeGroups(chargeWayGroups);
|
||||
return pageVO;
|
||||
}
|
||||
|
||||
private List<ChargeWayGroupInfoVO> genChargeWayGroups(List<AreaChargeConfigDTO.AreaChargeWayGroup> chargeWayGroups, String countryCode, AreaChargeConfigDTO.AreaChargeConfigeItem areaChargeConfig) {
|
||||
if (CollectionUtils.isEmpty(chargeWayGroups)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<String, ChargeWayDTO> chargeWayMap = getChargeWayMap();
|
||||
|
||||
List<ChargeWayGroupInfoVO> groupInfos = new ArrayList<>(chargeWayGroups.size());
|
||||
List<ChargeWayInfoVO> allChargeWays = new ArrayList<>();
|
||||
// 构造分组
|
||||
chargeWayGroups.forEach(group -> {
|
||||
ChargeWayGroupInfoVO info = new ChargeWayGroupInfoVO();
|
||||
info.setGroupName(group.getGroupName());
|
||||
List<ChargeWayInfoVO> chargeWays = genChargeWayList(group.getChargeWays(), chargeWayMap);
|
||||
info.setChargeWays(chargeWays);
|
||||
|
||||
allChargeWays.addAll(chargeWays);
|
||||
groupInfos.add(info);
|
||||
});
|
||||
|
||||
// 处理各种支付方式的产品列表
|
||||
Map<String, List<ChargeProdVo>> chargeWayProdMap = new HashMap<>(allChargeWays.size());
|
||||
allChargeWays.forEach(chargeWay -> {
|
||||
String mapKey = getChargeWayProdMap(chargeWay);
|
||||
List<ChargeProdVo> chargeProdVos = chargeWayProdMap.get(mapKey);
|
||||
if (chargeProdVos == null) {
|
||||
chargeProdVos = listChargeProdVos(countryCode, areaChargeConfig, chargeWay);
|
||||
chargeWayProdMap.put(mapKey, chargeProdVos);
|
||||
}
|
||||
|
||||
chargeWay.setChargeProds(chargeProdVos);
|
||||
});
|
||||
|
||||
return groupInfos;
|
||||
}
|
||||
|
||||
private String getChargeWayProdMap(ChargeWayInfoVO chargeWay) {
|
||||
StringBuilder sb = new StringBuilder(chargeWay.getPayChannel()).append("_").append(chargeWay.getPaymentType());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private List<ChargeWayInfoVO> genChargeWayList(List<String> chargeWayCodes) {
|
||||
Map<String, ChargeWayDTO> chargeWayMap = getChargeWayMap();
|
||||
|
||||
return genChargeWayList(chargeWayCodes, chargeWayMap);
|
||||
}
|
||||
|
||||
private List<ChargeWayInfoVO> genChargeWayList(List<String> chargeWayCodes, Map<String, ChargeWayDTO> chargeWayMap) {
|
||||
if (CollectionUtils.isEmpty(chargeWayCodes)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ChargeWayInfoVO> chargeWays = new ArrayList<>(chargeWayCodes.size());
|
||||
for (String chargeWayName : chargeWayCodes) {
|
||||
ChargeWayDTO chargeWay = chargeWayMap.get(chargeWayName);
|
||||
if (chargeWay != null) {
|
||||
ChargeWayInfoVO info = BeanUtil.map(chargeWay, ChargeWayInfoVO.class);
|
||||
chargeWays.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
return chargeWays;
|
||||
}
|
||||
|
||||
private Map<String, ChargeWayDTO> getChargeWayMap() {
|
||||
ChargeWayConfigDTO chargeWayConfig = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.CHARGE_WAY_CONFIG, "{}"), ChargeWayConfigDTO.class);
|
||||
Map<String, ChargeWayDTO> chargeWayMap = chargeWayConfig.getChargeWayConfig();
|
||||
if (chargeWayMap == null) {
|
||||
chargeWayMap = new HashMap<>();
|
||||
}
|
||||
return chargeWayMap;
|
||||
}
|
||||
|
||||
private void setChargeProdsInChargeWay(String countryCode, AreaChargeConfigDTO.AreaChargeConfigeItem areaChargeConfig, List<ChargeWayInfoVO> channelType) {
|
||||
for (ChargeWayInfoVO chargeWayInfoVO : channelType) {
|
||||
List<ChargeProdVo> chargeProds = listChargeProdVos(countryCode, areaChargeConfig, chargeWayInfoVO);
|
||||
chargeWayInfoVO.setChargeProds(chargeProds);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ChargeProdVo> listChargeProdVos(String countryCode, AreaChargeConfigDTO.AreaChargeConfigeItem areaChargeConfig, ChargeWayInfoVO chargeWayInfoVO) {
|
||||
List<ChargeProdVo> chargeProds = chargeProdService.getAllChargeProdVoList(countryCode, chargeWayInfoVO.getPayChannel(), chargeWayInfoVO.getPaymentType());
|
||||
for (ChargeProdVo chargeProd : chargeProds) {
|
||||
chargeProd.setCurrencySign(areaChargeConfig.getLocalCurrencySign());
|
||||
}
|
||||
return chargeProds;
|
||||
}
|
||||
|
||||
public List<ChargeAreaInfoVO> listChargeAreaInfo() {
|
||||
AreaChargeConfigDTO h5AreaChargeConfig = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.H5_AREA_CHARGE_CONFIG, "{}"), AreaChargeConfigDTO.class);
|
||||
Map<String, AreaChargeConfigDTO.AreaChargeConfigeItem> areaConfigMap = h5AreaChargeConfig.getAreaConfig();
|
||||
if (areaConfigMap == null) {
|
||||
areaConfigMap = new HashMap<>();
|
||||
}
|
||||
|
||||
List<ChargeAreaInfoVO> list = areaConfigMap.entrySet().stream().filter(item -> {
|
||||
// 过滤没有启用的地区
|
||||
AreaChargeConfigDTO.AreaChargeConfigeItem value = item.getValue();
|
||||
return value.getEnable() != null && value.getEnable();
|
||||
}).sorted((i1, i2) -> {
|
||||
// 使用seq配置尽心排序
|
||||
Integer seq1 = i1.getValue().getSeq();
|
||||
if (seq1 == null) {
|
||||
seq1 = Integer.MAX_VALUE;
|
||||
}
|
||||
Integer seq2 = i2.getValue().getSeq();
|
||||
if (seq2 == null) {
|
||||
seq2 = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return seq1.compareTo(seq2);
|
||||
}).map(item -> {
|
||||
ChargeAreaInfoVO areaInfoVO = new ChargeAreaInfoVO();
|
||||
areaInfoVO.setAreaCode(item.getKey());
|
||||
areaInfoVO.setAreaName(item.getValue().getDesc());
|
||||
return areaInfoVO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@@ -13,6 +13,9 @@ import com.accompany.common.utils.IPUitls;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
|
||||
import com.accompany.payment.vo.ChargeAreaInfoVO;
|
||||
import com.accompany.payment.vo.ChargePageVO;
|
||||
import com.accompany.payment.vo.WeChatMiniAppPayRequestVO;
|
||||
import com.accompany.payment.vo.WeXinPayTypeVO;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -45,6 +49,18 @@ public class ChargeController extends BaseController {
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
|
||||
@GetMapping(value = "/getChargePageInfoForH5")
|
||||
public BusiResult<ChargePageVO> getChargePageInfo(String countryCode) {
|
||||
ChargePageVO vo = chargeService.getChargePageInfo(countryCode);
|
||||
return new BusiResult<>(vo);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/listChargeAreaInfo")
|
||||
public BusiResult<List<ChargeAreaInfoVO>> listChargeAreaInfo() {
|
||||
List<ChargeAreaInfoVO> voList = chargeService.listChargeAreaInfo();
|
||||
return new BusiResult<>(voList);
|
||||
}
|
||||
|
||||
@PostMapping(value = "apply2New")
|
||||
public BusiResult<Object> applyH5ChargeNew(HttpServletRequest request,
|
||||
@NotBlank(message = "交易产品 id 不可为空") String chargeProdId,
|
||||
|
Reference in New Issue
Block a user