Commit 4b403421 authored by liaoanyuan's avatar liaoanyuan

添加支付宝service层和发送短信验证码签名修改

parent 2b174d40
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.dto.PayPageDto;
import cn.wisenergy.model.dto.PayQueryDto;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface AliPayService {
/**
* 支付宝支付接口
* @param payPageDto
* @param request
* @param httpResponse
* @return 支付结果
*/
R<String> doPost(PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse httpResponse);
/**
* 支付宝交易查询
* @param payQueryDto 查询参数
* @return 查询结果
*/
R<String> query(PayQueryDto payQueryDto);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.dto.PayPageDto;
import cn.wisenergy.model.dto.PayQueryDto;
import cn.wisenergy.service.app.AliPayService;
import cn.wisenergy.service.common.Common;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Slf4j
@Service
public class AliPayServiceImpl implements AliPayService {
private static final String CHARSET = "UTF-8";
@Override
public R<String> doPost(PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse httpResponse) {
if (null == payPageDto || null == payPageDto.getTotal()) {
return R.error("人参不能为空!");
}
AlipayClient alipayClient = new DefaultAlipayClient(Common.PAY_URL_CS, Common.APP_ID_CS, Common.PRIVATE_KEY_CS, "json", "GBK", Common.ALIPAY_PUBLIC_KEY_CS, "RSA2");
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
String tradeNo = "21" + System.currentTimeMillis();
//创建API对应的request
alipayRequest.setReturnUrl("http://domain.com/CallBack/return_url.jsp");
//在公共参数中设置回跳和通知地址
alipayRequest.setNotifyUrl("http://domain.com/CallBack/notify_url.jsp");
alipayRequest.setBizContent("{" +
"\"out_trade_no\":\"" + tradeNo + "\"," +
"\"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
"\"total_amount\":" + payPageDto.getTotal() + "," +
"\"subject\":\"充值\"," +
"\"body\":\"充值\"," +
"\"time_expire\":\"2021-01-30 10:05:01\"," +
" \"goods_detail\":[{" +
" \"goods_id\":\"apple-01\"," +
"\"alipay_goods_id\":\"20010001\"," +
"\"goods_name\":\"ipad\"," +
"\"quantity\":1," +
"\"price\":2000," +
"\"goods_category\":\"34543238\"," +
"\"categories_tree\":\"124868003|126232002|126252004\"," +
"\"body\":\"特价手机\"," +
"\"show_url\":\"http://www.alipay.com/xxx.jpg\"" +
" }]," +
"\"passback_params\":\"merchantBizType%3d3C%26merchantBizNo%3d2016010101111\"," +
"\"extend_params\":{" +
"\"sys_service_provider_id\":\"2088511833207846\"," +
"\"hb_fq_num\":\"3\"," +
"\"hb_fq_seller_percent\":\"100\"," +
"\"industry_reflux_info\":\"{\\\\\\\"scene_code\\\\\\\":\\\\\\\"metro_tradeorder\\\\\\\",\\\\\\\"channel\\\\\\\":\\\\\\\"xxxx\\\\\\\",\\\\\\\"scene_data\\\\\\\":{\\\\\\\"asset_name\\\\\\\":\\\\\\\"ALIPAY\\\\\\\"}}\"," +
"\"card_type\":\"S0JP0000\"" +
" }," +
"\"goods_type\":\"0\"," +
"\"timeout_express\":\"90m\"," +
"\"promo_params\":\"{\\\"storeIdType\\\":\\\"1\\\"}\"," +
"\"royalty_info\":{" +
"\"royalty_type\":\"ROYALTY\"," +
" \"royalty_detail_infos\":[{" +
" \"serial_no\":1," +
"\"trans_in_type\":\"userId\"," +
"\"batch_no\":\"123\"," +
"\"out_relation_id\":\"20131124001\"," +
"\"trans_out_type\":\"userId\"," +
"\"trans_out\":\"2088101126765726\"," +
"\"trans_in\":\"2088101126708402\"," +
"\"amount\":0.1," +
"\"desc\":\"分账测试1\"," +
"\"amount_percentage\":\"100\"" +
" }]" +
" }," +
"\"sub_merchant\":{" +
"\"merchant_id\":\"2088000603999128\"," +
"\"merchant_type\":\"alipay: 支付宝分配的间连商户编号, merchant: 商户端的间连商户编号\"" +
" }," +
"\"merchant_order_no\":\"20161008001\"," +
"\"enable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
"\"store_id\":\"NJ_001\"," +
"\"disable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
"\"qr_pay_mode\":\"1\"," +
"\"qrcode_width\":100," +
"\"settle_info\":{" +
" \"settle_detail_infos\":[{" +
" \"trans_in_type\":\"cardAliasNo\"," +
"\"trans_in\":\"A0001\"," +
"\"summary_dimension\":\"A0001\"," +
"\"settle_entity_id\":\"2088xxxxx;ST_0001\"," +
"\"settle_entity_type\":\"SecondMerchant、Store\"," +
"\"amount\":0.1" +
" }]," +
"\"settle_period_time\":\"7d\"" +
" }," +
"\"invoice_info\":{" +
"\"key_info\":{" +
"\"is_support_invoice\":true," +
"\"invoice_merchant_name\":\"ABC|003\"," +
"\"tax_num\":\"1464888883494\"" +
" }," +
"\"details\":\"[{\\\"code\\\":\\\"100294400\\\",\\\"name\\\":\\\"服饰\\\",\\\"num\\\":\\\"2\\\",\\\"sumPrice\\\":\\\"200.00\\\",\\\"taxRate\\\":\\\"6%\\\"}]\"" +
" }," +
"\"agreement_sign_params\":{" +
"\"personal_product_code\":\"GENERAL_WITHHOLDING_P\"," +
"\"sign_scene\":\"INDUSTRY|CARRENTAL\"," +
"\"external_agreement_no\":\"test\"," +
"\"external_logon_id\":\"13852852877\"," +
"\"sign_validity_period\":\"2m\"," +
"\"third_party_type\":\"PARTNER\"," +
"\"buckle_app_id\":\"1001164\"," +
"\"buckle_merchant_id\":\"268820000000414397785\"," +
"\"promo_params\":\"{\\\"key\\\",\\\"value\\\"}\"" +
" }," +
"\"integration_type\":\"PCWEB\"," +
"\"request_from_url\":\"https://\"," +
"\"business_params\":\"{\\\"data\\\":\\\"123\\\"}\"," +
"\"ext_user_info\":{" +
"\"name\":\"李明\"," +
"\"mobile\":\"16587658765\"," +
"\"cert_type\":\"IDENTITY_CARD\"," +
"\"cert_no\":\"362334768769238881\"," +
"\"min_age\":\"18\"," +
"\"fix_buyer\":\"F\"," +
"\"need_check_info\":\"F\"" +
" }" +
" }");
String form = "";
//调用SDK生成表单
try {
form = alipayClient.pageExecute(alipayRequest).getBody();
httpResponse.setContentType("text/html;charset=" + CHARSET);
//直接将完整的表单html输出到页面
httpResponse.getWriter().write(form);
httpResponse.getWriter().flush();
httpResponse.getWriter().close();
return R.ok();
} catch (Exception e) {
e.printStackTrace();
}
return R.ok();
}
@Override
public R<String> query(PayQueryDto payQueryDto) {
return null;
}
}
......@@ -413,6 +413,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
//计算综合成绩
double total = major * 750 / 300 * 0.7 + culture * 0.3;
Map<String, Object> map = new HashMap<>(16);
map.put("number", firstRule.getNumber());
map.put("classNames", classNames);
......@@ -452,7 +453,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
if (secondCulture > firstRule.getCultureMin() && secondMajor < firstRule.getProfessionMin()) {
List<Volunteer> volunteers = new ArrayList<>();
volunteers = volunteerMapper.getVolunteerByType(SchemeTypeEnums.JUNIOR_COLLEGE_LITERATURE.getCode());
secondRuleTotal=Double.valueOf(volunteers.get(0).getLowestMark());
secondRuleTotal=Double.valueOf(volunteers.get(0).getLowestMark())-secondRule.getUpMark()+1;
}
//2、考生是否能报取美术专科
......@@ -531,9 +532,10 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
if (cultureSecond > firstRule.getCultureMin() && majorSecond < firstRule.getProfessionMin()) {
List<Volunteer> volunteers = new ArrayList<>();
volunteers = volunteerMapper.getVolunteerByType(SchemeTypeEnums.JUNIOR_COLLEGE_LITERATURE.getCode());
totalSecond=Double.valueOf(volunteers.get(0).getLowestMark());
totalSecond=Double.valueOf(volunteers.get(0).getLowestMark())-secondRule.getUpMark()+1;
}
log.info(classNames.toString());
//2、考生是否能报取美术专科
if (cultureSecond >= secondRule.getCultureMin() && majorSecond >= secondRule.getProfessionMin()) {
//浮动分数
......@@ -544,6 +546,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
map.put("type", SchemeTypeEnums.JUNIOR_COLLEGE_LITERATURE.getCode());
list = volunteerMapper.getVolunteerList(map);
log.info(Integer.toString(list.size()));
//如果数据不满足最大数量,取不限专业最低分补充
if (list.size() < secondRule.getNumber()) {
List<Volunteer> fillList = fillUpVolunteer(list, secondRule.getNumber(), upGrade, downGrade,
......
......@@ -73,7 +73,7 @@ public class SendSmsSerViceImpl implements SendSmsSerVice {
String scene = SceneType.getNameByCode(sendSmsVo.getScene());
boolean bool = redisService.set(CachePrefix.SMS_CODE.getPrefix() + scene + "_" +
source + "_" + sendSmsVo.getPhone(), code, Common.SMS_TIMEOUT);
log.info(CachePrefix.SMS_CODE.getPrefix());
if (!bool) {
return R.error("缓存验证码失败!");
}
......@@ -81,7 +81,7 @@ public class SendSmsSerViceImpl implements SendSmsSerVice {
map.put("code", code);
request.putQueryParameter("RegionId", "cn-hangzhou");
request.putQueryParameter("PhoneNumbers", sendSmsVo.getPhone());
request.putQueryParameter("SignName", "遵义群智科技有限公司");
request.putQueryParameter("SignName", "山东宇嘉雪教育科技有限公司");
if (sendSmsVo.getScene()==1) {
request.putQueryParameter("TemplateCode", "SMS_211755494");
}
......
......@@ -3,6 +3,7 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.dto.PayPageDto;
import cn.wisenergy.model.dto.PayQueryDto;
import cn.wisenergy.service.app.AliPayService;
import cn.wisenergy.service.app.WxPayService;
import cn.wisenergy.service.common.Common;
import com.alipay.api.AlipayApiException;
......@@ -43,135 +44,19 @@ import java.security.spec.InvalidKeySpecException;
@RequestMapping("/pay")
@Slf4j
public class PayController {
private static final String CHARSET = "UTF-8";
@Autowired
private WxPayService wxPayService;
@Autowired
private AliPayService aliPayService;
@ApiOperation(value = "PC支付宝-支付接口", notes = "PC支付宝-支付接口", httpMethod = "POST")
@ApiImplicitParam(name = "payPageDto", value = "参数", dataType = "PayPageDto")
@PostMapping("/page")
public R<String> doPost(@RequestBody PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse httpResponse) throws IOException, AlipayApiException {
if (null == payPageDto || null == payPageDto.getTotal()) {
return R.error("人参不能为空!");
}
AlipayClient alipayClient = new DefaultAlipayClient(Common.PAY_URL_CS, Common.APP_ID_CS, Common.PRIVATE_KEY_CS, "json", "GBK", Common.ALIPAY_PUBLIC_KEY_CS, "RSA2");
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
String tradeNo = "21" + System.currentTimeMillis();
//创建API对应的request
alipayRequest.setReturnUrl("http://domain.com/CallBack/return_url.jsp");
//在公共参数中设置回跳和通知地址
alipayRequest.setNotifyUrl("http://domain.com/CallBack/notify_url.jsp");
alipayRequest.setBizContent("{" +
"\"out_trade_no\":\"" + tradeNo + "\"," +
"\"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
"\"total_amount\":" + payPageDto.getTotal() + "," +
"\"subject\":\"充值\"," +
"\"body\":\"充值\"," +
"\"time_expire\":\"2021-01-30 10:05:01\"," +
" \"goods_detail\":[{" +
" \"goods_id\":\"apple-01\"," +
"\"alipay_goods_id\":\"20010001\"," +
"\"goods_name\":\"ipad\"," +
"\"quantity\":1," +
"\"price\":2000," +
"\"goods_category\":\"34543238\"," +
"\"categories_tree\":\"124868003|126232002|126252004\"," +
"\"body\":\"特价手机\"," +
"\"show_url\":\"http://www.alipay.com/xxx.jpg\"" +
" }]," +
"\"passback_params\":\"merchantBizType%3d3C%26merchantBizNo%3d2016010101111\"," +
"\"extend_params\":{" +
"\"sys_service_provider_id\":\"2088511833207846\"," +
"\"hb_fq_num\":\"3\"," +
"\"hb_fq_seller_percent\":\"100\"," +
"\"industry_reflux_info\":\"{\\\\\\\"scene_code\\\\\\\":\\\\\\\"metro_tradeorder\\\\\\\",\\\\\\\"channel\\\\\\\":\\\\\\\"xxxx\\\\\\\",\\\\\\\"scene_data\\\\\\\":{\\\\\\\"asset_name\\\\\\\":\\\\\\\"ALIPAY\\\\\\\"}}\"," +
"\"card_type\":\"S0JP0000\"" +
" }," +
"\"goods_type\":\"0\"," +
"\"timeout_express\":\"90m\"," +
"\"promo_params\":\"{\\\"storeIdType\\\":\\\"1\\\"}\"," +
"\"royalty_info\":{" +
"\"royalty_type\":\"ROYALTY\"," +
" \"royalty_detail_infos\":[{" +
" \"serial_no\":1," +
"\"trans_in_type\":\"userId\"," +
"\"batch_no\":\"123\"," +
"\"out_relation_id\":\"20131124001\"," +
"\"trans_out_type\":\"userId\"," +
"\"trans_out\":\"2088101126765726\"," +
"\"trans_in\":\"2088101126708402\"," +
"\"amount\":0.1," +
"\"desc\":\"分账测试1\"," +
"\"amount_percentage\":\"100\"" +
" }]" +
" }," +
"\"sub_merchant\":{" +
"\"merchant_id\":\"2088000603999128\"," +
"\"merchant_type\":\"alipay: 支付宝分配的间连商户编号, merchant: 商户端的间连商户编号\"" +
" }," +
"\"merchant_order_no\":\"20161008001\"," +
"\"enable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
"\"store_id\":\"NJ_001\"," +
"\"disable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," +
"\"qr_pay_mode\":\"1\"," +
"\"qrcode_width\":100," +
"\"settle_info\":{" +
" \"settle_detail_infos\":[{" +
" \"trans_in_type\":\"cardAliasNo\"," +
"\"trans_in\":\"A0001\"," +
"\"summary_dimension\":\"A0001\"," +
"\"settle_entity_id\":\"2088xxxxx;ST_0001\"," +
"\"settle_entity_type\":\"SecondMerchant、Store\"," +
"\"amount\":0.1" +
" }]," +
"\"settle_period_time\":\"7d\"" +
" }," +
"\"invoice_info\":{" +
"\"key_info\":{" +
"\"is_support_invoice\":true," +
"\"invoice_merchant_name\":\"ABC|003\"," +
"\"tax_num\":\"1464888883494\"" +
" }," +
"\"details\":\"[{\\\"code\\\":\\\"100294400\\\",\\\"name\\\":\\\"服饰\\\",\\\"num\\\":\\\"2\\\",\\\"sumPrice\\\":\\\"200.00\\\",\\\"taxRate\\\":\\\"6%\\\"}]\"" +
" }," +
"\"agreement_sign_params\":{" +
"\"personal_product_code\":\"GENERAL_WITHHOLDING_P\"," +
"\"sign_scene\":\"INDUSTRY|CARRENTAL\"," +
"\"external_agreement_no\":\"test\"," +
"\"external_logon_id\":\"13852852877\"," +
"\"sign_validity_period\":\"2m\"," +
"\"third_party_type\":\"PARTNER\"," +
"\"buckle_app_id\":\"1001164\"," +
"\"buckle_merchant_id\":\"268820000000414397785\"," +
"\"promo_params\":\"{\\\"key\\\",\\\"value\\\"}\"" +
" }," +
"\"integration_type\":\"PCWEB\"," +
"\"request_from_url\":\"https://\"," +
"\"business_params\":\"{\\\"data\\\":\\\"123\\\"}\"," +
"\"ext_user_info\":{" +
"\"name\":\"李明\"," +
"\"mobile\":\"16587658765\"," +
"\"cert_type\":\"IDENTITY_CARD\"," +
"\"cert_no\":\"362334768769238881\"," +
"\"min_age\":\"18\"," +
"\"fix_buyer\":\"F\"," +
"\"need_check_info\":\"F\"" +
" }" +
" }");
String form = "";
//调用SDK生成表单
form = alipayClient.pageExecute(alipayRequest).getBody();
public R<String> doPost(@RequestBody PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse httpResponse) {
return aliPayService.doPost(payPageDto,request,httpResponse);
httpResponse.setContentType("text/html;charset=" + CHARSET);
//直接将完整的表单html输出到页面
httpResponse.getWriter().write(form);
httpResponse.getWriter().flush();
httpResponse.getWriter().close();
return R.ok();
}
@ApiOperation(value = "PC支付宝-交易查询", notes = "PC支付宝-交易查询", httpMethod = "POST")
......
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