mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update huifu
This commit is contained in:
@@ -6,14 +6,12 @@ import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.dto.GetPayModeDTO;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.PaymentScenarioDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.pile.vo.uniapp.PayModeVO;
|
||||
import com.jsowell.service.MemberService;
|
||||
@@ -71,15 +69,47 @@ public class PayController extends BaseController {
|
||||
}
|
||||
dto.setOpenId(openId);
|
||||
// 充值余额 附加参数
|
||||
PaymentScenarioDTO paymentScenarioDTO = new PaymentScenarioDTO();
|
||||
paymentScenarioDTO.setType(ScenarioEnum.BALANCE.getValue());
|
||||
paymentScenarioDTO.setMemberId(memberId);
|
||||
dto.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
dto.setDescription("会员充值余额");
|
||||
Map<String, Object> weixinMap = orderService.weixinPayV3(dto);
|
||||
Map<String, Object> weixinMap = memberService.rechargeBalance(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("weixinMap", weixinMap));
|
||||
} catch (Exception e) {
|
||||
response = new RestApiResponse<>();
|
||||
logger.error("会员充值余额 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_MEMBER_RECHARGE_BALANCE_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员充值余额
|
||||
* http://localhost:8080/uniapp/pay/rechargeBalance
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/rechargeBalance")
|
||||
public RestApiResponse<?> rechargeBalance(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("会员充值余额 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getCode()) || StringUtils.isBlank(dto.getAmount())) {
|
||||
return new RestApiResponse<>(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 鉴权
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(openId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
dto.setOpenId(openId);
|
||||
// 充值余额 附加参数
|
||||
Map<String, Object> weixinMap = memberService.rechargeBalanceWithAdapay(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("weixinMap", weixinMap));
|
||||
} catch (Exception e) {
|
||||
logger.error("会员充值余额 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_MEMBER_RECHARGE_BALANCE_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.huifu.adapay.model.Payment;
|
||||
import com.jsowell.adapay.common.CreateAdaPaymentParam;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
@@ -9,7 +15,9 @@ import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.TitleTypeEnum;
|
||||
import com.jsowell.common.enums.uniapp.BalanceChangesEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.AdapayUtil;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
@@ -23,8 +31,10 @@ import com.jsowell.pile.dto.BindingCardDTO;
|
||||
import com.jsowell.pile.dto.CreateInvoiceTitleDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterDTO;
|
||||
import com.jsowell.pile.dto.PaymentScenarioDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.dto.WechatLoginDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.service.IMemberInvoiceTitleService;
|
||||
import com.jsowell.pile.service.IMemberPlateNumberRelationService;
|
||||
@@ -42,10 +52,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cglib.beans.BeanMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@@ -76,6 +88,9 @@ public class MemberService {
|
||||
@Autowired
|
||||
private IMemberInvoiceTitleService memberInvoiceTitleService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 校验短信验证码
|
||||
* @param dto
|
||||
@@ -381,4 +396,39 @@ public class MemberService {
|
||||
int i = memberInvoiceTitleService.insertMemberInvoiceTitle(title);
|
||||
log.info("新增{}条发票抬头", i);
|
||||
}
|
||||
|
||||
public Map<String, Object> rechargeBalance(WeixinPayDTO dto) throws Exception {
|
||||
PaymentScenarioDTO paymentScenarioDTO = new PaymentScenarioDTO();
|
||||
paymentScenarioDTO.setType(ScenarioEnum.BALANCE.getValue());
|
||||
paymentScenarioDTO.setMemberId(dto.getMemberId());
|
||||
dto.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
dto.setDescription("会员充值余额");
|
||||
return orderService.weixinPayV3(dto);
|
||||
}
|
||||
|
||||
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) throws Exception {
|
||||
// 封装对象
|
||||
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
||||
createAdaPaymentParam.setOrder_no(IdUtils.fastSimpleUUID());
|
||||
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getAmount()));
|
||||
createAdaPaymentParam.setApp_id("app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"); // todo 后面移动到配置文件中
|
||||
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
|
||||
createAdaPaymentParam.setGoods_title("充电费用1");
|
||||
createAdaPaymentParam.setGoods_desc("充电费用2");
|
||||
createAdaPaymentParam.setDescription("充电费用3");
|
||||
createAdaPaymentParam.setExpend(JSONObject.toJSONString( ImmutableMap.of("open_id", dto.getOpenId())));
|
||||
try {
|
||||
log.info("创建汇付支付参数:{}", JSONObject.toJSONString(createAdaPaymentParam));
|
||||
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam));
|
||||
if (response != null && !response.isEmpty()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());
|
||||
JSONObject pay_info = jsonObject.getJSONObject("pay_info");
|
||||
Map<String, Object> resultMap = JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {});
|
||||
return resultMap;
|
||||
}
|
||||
} catch (BaseAdaPayException e) {
|
||||
log.error("汇付-获取支付对象发生异常", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.enums.ykc.StartTypeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.AdapayUtil;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -92,7 +93,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -291,7 +291,8 @@ public class OrderService {
|
||||
// 封装对象
|
||||
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
||||
createAdaPaymentParam.setOrder_no(orderInfo.getOrderCode());
|
||||
createAdaPaymentParam.setPay_amt(new DecimalFormat("#.00").format(dto.getPayAmount()));
|
||||
// createAdaPaymentParam.setPay_amt(new DecimalFormat("#.00").format(dto.getPayAmount()));
|
||||
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getPayAmount()));
|
||||
createAdaPaymentParam.setApp_id("app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa"); // todo 后面移动到配置文件中
|
||||
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
|
||||
createAdaPaymentParam.setGoods_title("充电费用1");
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.jsowell.pile.domain.WxpayCallbackRecord;
|
||||
import com.jsowell.pile.dto.BasicPileDTO;
|
||||
import com.jsowell.pile.dto.BatchCreatePileDTO;
|
||||
import com.jsowell.pile.dto.ImportBillingTemplateDTO;
|
||||
import com.jsowell.pile.dto.LianLianGetTokenDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryPileDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
@@ -228,29 +227,29 @@ public class SpringBootTestController {
|
||||
System.out.println(pileAuthCard);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLianLian(){
|
||||
// 获取令牌
|
||||
LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||
dto.setOperatorId("987654321");
|
||||
dto.setOperatorSecret("1234567890abcdef");
|
||||
String token = lianLianService.getToken(dto);
|
||||
System.out.println("token:" + token);
|
||||
|
||||
|
||||
LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
|
||||
.OperatorID("987654321")
|
||||
.DataSecret("1234567890abcdef")
|
||||
.DataSecretIV("1234567890abcdef")
|
||||
.SigSecret("1234567890abcdef")
|
||||
.token(token)
|
||||
.stationId(2L)
|
||||
|
||||
.build();
|
||||
lianLianService.pushStationInfo(dto1);
|
||||
|
||||
|
||||
}
|
||||
// @Test
|
||||
// public void testLianLian(){
|
||||
// // 获取令牌
|
||||
// LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||
// dto.setOperatorId("987654321");
|
||||
// dto.setOperatorSecret("1234567890abcdef");
|
||||
// String token = lianLianService.getToken(dto);
|
||||
// System.out.println("token:" + token);
|
||||
//
|
||||
//
|
||||
// LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
|
||||
// .OperatorID("987654321")
|
||||
// .DataSecret("1234567890abcdef")
|
||||
// .DataSecretIV("1234567890abcdef")
|
||||
// .SigSecret("1234567890abcdef")
|
||||
// .token(token)
|
||||
// .stationId(2L)
|
||||
//
|
||||
// .build();
|
||||
// lianLianService.pushStationInfo(dto1);
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user