Commit 636ec1d2 by Java-张振楠

①增加切换结算卡

parent e8164668
......@@ -18,6 +18,13 @@ import java.util.Map;
@Transactional(readOnly = true)
public class JuHeZhongPayService {
/**
* 注册子商户
*
* @param dto
* @return
* @throws Exception
*/
public JSONObject register(MerchantDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
......@@ -27,7 +34,14 @@ public class JuHeZhongPayService {
return JSONObject.parseObject(respStr);
}
public JSONObject updateSettle(MerchantDto dto) throws Exception {
/**
* 更新费率
*
* @param dto
* @return
* @throws Exception
*/
public JSONObject updateRate(MerchantDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
String sign = SignUtils.sign(signBefore, ComCode.MERCHANT_SECRET);
......@@ -35,4 +49,20 @@ public class JuHeZhongPayService {
String respStr = HttpUtil.post(ComCode.HOST + ComCode.RATE_UPDATE_URL, params);
return JSONObject.parseObject(respStr);
}
/**
* 更新结算信息
*
* @param dto
* @return
* @throws Exception
*/
public JSONObject updateSettle(MerchantDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
String sign = SignUtils.sign(signBefore, ComCode.MERCHANT_SECRET);
params.put("sign", sign);
String respStr = HttpUtil.post(ComCode.HOST + ComCode.SETTLE_UPDATE_URL, params);
return JSONObject.parseObject(respStr);
}
}
......@@ -493,5 +493,31 @@ public class UserApiController {
return resp;
}
/**
* 切换结算卡
*
* @param request
* @return
*/
@PostMapping("/changeDebit")
public Response changeDebit(UserRequest request) {
Response resp = new Response();
try {
// 判断业务入参是否为空
if (StringUtils.isBlank(request.getSubMerchantCode()) || StringUtils.isBlank(request.getDebitCardCode())) {
resp.setStatus(ComCode.STATUS_CODE_4001);
resp.setMessage(ComCode.STATUS_CODE_4001_DESC);
return resp;
}
userService.changeDebit(request);
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
resp.setError(e.getMessage());
}
return resp;
}
}
......@@ -31,6 +31,7 @@ public class UserRequest extends Request {
private String cardSrc; // 银行卡正面
private String type; // 省市类型 P省 C市
private String pid; // 父级id
private String debitCardCode; // 结算卡code
public String getMobile() {
return mobile;
......@@ -239,4 +240,12 @@ public class UserRequest extends Request {
public void setPid(String pid) {
this.pid = pid;
}
public String getDebitCardCode() {
return debitCardCode;
}
public void setDebitCardCode(String debitCardCode) {
this.debitCardCode = debitCardCode;
}
}
......@@ -59,11 +59,16 @@ public interface UserApiDao {
List<CardEntity> getRecommendCardsInfo(UserEntity recommendedUser);
void updateCardNoDebit(UserRequest request);
void updateCardDebit(UserRequest request);
CardEntity getDebitCard(CardEntity cardEntity);
List<ProvinceCityEntity> getProvince(UserRequest request);
List<ProvinceCityEntity> getCity(UserRequest request);
List<BelongBankEntity> getBelongBank(UserRequest request);
}
......@@ -38,6 +38,10 @@ public class CardEntity extends BaseEntity implements Serializable {
public CardEntity() {
}
public CardEntity(String code) {
this.setCode(code);
}
public CardEntity(String userCode, String isDebit) {
this.userCode = userCode;
this.isDebit = isDebit;
......
......@@ -198,7 +198,7 @@ public class UserApiService {
RateEntity rateEntity = userDao.getRateByLevel(rateEntityParam);
List<CardEntity> recommendCards = userDao.getRecommendCardsInfo(recommendedUser);
for (CardEntity entity : recommendCards) {
updateSettleJuHeZhongPay(entity, rateEntity);
updateRateJuHeZhongPay(entity, rateEntity);
}
}
}
......@@ -216,6 +216,18 @@ public class UserApiService {
public List<BelongBankEntity> getBelongBank(UserRequest request) {
return userDao.getBelongBank(request);
}
@Transactional(readOnly = false)
public void changeDebit(UserRequest request) throws MyException, Exception {
// 将该用户的所有卡类型置为非结算卡
userDao.updateCardNoDebit(request);
// 设置结算卡
userDao.updateCardDebit(request);
// 获取结算卡信息
CardEntity cardEntity = userDao.getDebitCard(new CardEntity(request.getDebitCardCode()));
// 修改用户的结算卡
updateSettleJuHeZhongPay(cardEntity);
}
/*
* 以下为类内使用方法
*/
......@@ -273,7 +285,7 @@ public class UserApiService {
* @throws MyException
* @throws Exception
*/
public void updateSettleJuHeZhongPay(CardEntity cardEntity, RateEntity rateEntity) throws MyException, Exception {
public void updateRateJuHeZhongPay(CardEntity cardEntity, RateEntity rateEntity) throws MyException, Exception {
// 修改费率
MerchantDto dto = new MerchantDto();
dto.setMerchantId(ComCode.MERCHANT_ID);
......@@ -283,6 +295,34 @@ public class UserApiService {
dto.setExtraRate(new BigDecimal(ComCode.EXTRA_RATE));
dto.setTimestamp(System.currentTimeMillis());
dto.setMerchantKey(ComCode.MERCHANT_KEY);
JSONObject jsonObject = juHeZhongPayService.updateRate(dto);
if (!"0000".equals(jsonObject.getString("code"))) {
throw new MyException(jsonObject.getString("msg"));
}
}
/**
* 修改JuHeZhong支付用户结算信息
*
* @param cardEntity
* @return
* @throws MyException
* @throws Exception
*/
public void updateSettleJuHeZhongPay(CardEntity cardEntity) throws Exception {
// 修改费率
MerchantDto dto = new MerchantDto();
dto.setMerchantId(ComCode.MERCHANT_ID);
dto.setSubMchId(cardEntity.getSubMerchantId());
dto.setOrderId(IdGen.uuid());//不会产生交易订单
dto.setAccType(Integer.parseInt(cardEntity.getType()));//1 对私 2对公
dto.setAccNo(cardEntity.getCardNo());
dto.setAccProvince(cardEntity.getProvince());
dto.setAccCity(cardEntity.getCity());
dto.setBankCode(cardEntity.getBelongBank());
dto.setMobile(cardEntity.getCardMobile());
dto.setTimestamp(System.currentTimeMillis());
dto.setMerchantKey(ComCode.MERCHANT_KEY);
JSONObject jsonObject = juHeZhongPayService.updateSettle(dto);
if (!"0000".equals(jsonObject.getString("code"))) {
throw new MyException(jsonObject.getString("msg"));
......
......@@ -474,6 +474,53 @@
AND yc.del_flag = '0'
</select>
<update id="updateCardNoDebit">
UPDATE
youka_cards
SET
is_debit = 'N'
WHERE
user_code = #{subMerchantCode}
</update>
<update id="updateCardDebit">
UPDATE
youka_cards
SET
is_debit = 'Y'
WHERE
code = #{debitCardCode}
</update>
<select id="getDebitCard" resultType="com.thinkgem.jeesite.modules.user.entity.CardEntity">
SELECT
yc.id,
yc.code,
yc.user_code AS userCode,
yc.card_type AS cardType,
yc.card_no AS cardNo,
yc.card_mobile AS cardMobile,
yc.belong_bank AS belongBank,
yc.card_bank AS cardBank,
yc.card_place AS cardPlace,
yc.is_debit AS isDebit,
yc.sub_merchant_id AS subMerchantId,
yc.card_src AS cardSrc,
yc.type,
yc.status,
yc.province,
yc.city,
yc.create_date AS created,
yc.create_by AS createdUser,
yc.update_date AS modified,
yc.update_by AS modifiedUser,
yc.del_flag AS delFlag
FROM
youka_cards yc
WHERE
yc.code = #{code}
</select>
<select id="getProvince" resultType="com.thinkgem.jeesite.modules.user.entity.ProvinceCityEntity">
SELECT
id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment