Commit 0ee57361 by Java-聂换换

修改支付得bug

parent f3a8b5b5
......@@ -58,7 +58,7 @@ public class ComCode {
*/
public static final String HUANQIUHUIJU_PAYURL = "http://pay.huanqiuhuiju.com/authsys/api/pay/shanglv/qpay/execute.do";
public static final String HUANQIUHUIJU_MERCHANT_ID = Global.getConfig("huanqiuhuiju.merchant.id");
public static final String HUANQIUHUIJU_MERCHANT_KEY = Global.getConfig("c7dadd0a");
public static final String HUANQIUHUIJU_MERCHANT_KEY = Global.getConfig("huanqiuhuiju.merchant.key");
/**
* duolabao相关参数
*
......
......@@ -46,7 +46,7 @@ public class PayApiController {
private UserApiService userApiService;
/**
* 快捷支付
* 快捷支付 分不同得通道 根据payChannel来判断支付通道
*
* @param request
* @return
......@@ -83,7 +83,7 @@ public class PayApiController {
/**
* 支付宝支付
* 支付宝支付 目前仅仅用来用户升级支付
*
* @param request
* @return
......@@ -118,7 +118,7 @@ public class PayApiController {
return resp;
}
/**
* 开卡
* 开卡 目前仅仅jfen通道需要请求这个接口 如果还有其他通道开卡请加上通道另外的判断
*
* @param request
* @return
......@@ -126,7 +126,7 @@ public class PayApiController {
@PostMapping("/openCard")
public Response openCard(UserRequest request) {
Response resp = new Response();
if(ComCode.PAYCHANNEL_HL2.equals(request.getPayChannel())){
if(ComCode.PAYCHANNEL_HL2.equals(request.getPayChannel())){ // 目前仅仅jfen通道需要请求这个接口 如果还有其他通道开卡请加上通道的判断
return payService.openCardJFen(request);
}
resp.setMessage("没有该渠道");
......@@ -135,7 +135,7 @@ public class PayApiController {
}
/**
* 发送验证码
* 发送验证码 目前仅仅jfen通道需要请求这个接口 如果还有其他通道发送验证码请加上另外通道的判断
*
* @param request
* @return
......@@ -143,7 +143,7 @@ public class PayApiController {
@PostMapping("/sendMessagePay")
public Response sendMessagePay(JuHeZhongPayRequest request) {
Response resp = new Response();
if(ComCode.PAYCHANNEL_HL2.equals(request.getPayChannel())){
if(ComCode.PAYCHANNEL_HL2.equals(request.getPayChannel())){ // 目前仅仅jfen通道需要请求这个接口 如果还有其他通道发送验证码请加上通道的判断
return payService.sendMessageJFen(request);
}
resp.setMessage("没有该渠道");
......@@ -152,7 +152,7 @@ public class PayApiController {
}
/**
* 回调
* juhezhong快捷支付的回调
* @param request
* @param response
*/
......@@ -219,7 +219,7 @@ public class PayApiController {
}
/**
* 回调
* Huanqiuhuiju快捷支付的回调
* @param request
* @param response
*/
......@@ -287,7 +287,7 @@ public class PayApiController {
/**
* 回调
* 开卡的回调
* @param request
* @param response
*/
......@@ -354,7 +354,7 @@ public class PayApiController {
/**
* 回调
* 支付宝支付的回调
* @param request
* @param response
*/
......@@ -469,6 +469,11 @@ public class PayApiController {
}
/**
* 获取支付通道
* @param dict
* @return
*/
@RequestMapping("/getDict")
public Response getDict(Dict dict){
Response response = new Response();
......
......@@ -15,7 +15,7 @@ public interface PayApiDao {
List<UserRateEntity> getCDEUsers(String[] pathIds);
List<UserRateEntity> getSABUsers(String[] pathIds,String payChannel);
List<UserRateEntity> getSABUsers(UserRateEntity userRateEntity);
void saveBenefitInfo(BenefitEntity benefitEntity);
......
......@@ -7,6 +7,9 @@ public class UserRateEntity implements Serializable {
private String userLevel; // 支付方式
private String rate; // 费率
private String[] pathIds;
private String payChannel;
public String getUserCode() {
return userCode;
}
......@@ -28,6 +31,24 @@ public class UserRateEntity implements Serializable {
}
public void setRate(String rate) {
System.out.println("rate:"+rate);
this.rate = rate;
}
public String[] getPathIds() {
return pathIds;
}
public void setPathIds(String[] pathIds) {
this.pathIds = pathIds;
}
public String getPayChannel() {
return payChannel;
}
public void setPayChannel(String payChannel) {
this.payChannel = payChannel;
}
}
......@@ -13,10 +13,19 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.SortedMap;
/**
* 也是一种快捷支付的方式 接口文档:快捷支付接口说明V1.1.2
*/
@Transactional
@Service
public class HuanqiuhuijuService {
/**
* 支付
* @param dto
* @return
* @throws Exception
*/
public JSONObject huanqiuhuijuPay(JSONObject dto) throws Exception {
SortedMap map = Bean2Map.JSONObject2SortedMap(dto);
String sign = SignUtils.createSign(map, ComCode.HUANQIUHUIJU_MERCHANT_KEY);
......
......@@ -326,6 +326,7 @@ public class HttpUtil {
String result = "";
try {
URL httpUrl = new URL(url);
param = URLEncoder.encode(param, "utf-8");
HttpURLConnection conn = (HttpURLConnection)httpUrl.openConnection();
conn.setRequestMethod("POST");
......@@ -333,6 +334,8 @@ public class HttpUtil {
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8");
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
......@@ -341,7 +344,7 @@ public class HttpUtil {
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
......
......@@ -18,7 +18,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
* 积分快捷支付 接口文档:https://github.com/juhezhong/JfQuickDemo
*/
@Service
@Lazy(false)
@Transactional
......@@ -47,6 +49,12 @@ public class JuHeZhongPayIntegralService {
}
/**
* 支付、商户进件、商户入驻
* @param dto
* @return
* @throws Exception
*/
public JSONObject quickPayHandle(JSONObject dto)throws Exception {
dto.put("merchantId",ComCode.INTEGRAL_MERCHANT_ID);
dto.put("timestamp",System.currentTimeMillis());
......
......@@ -46,6 +46,12 @@ public class JuHeZhongPayJFenService {
return JSONObject.parseObject(respStr);
}
/**
* 商户入驻
* @param dto
* @return
* @throws Exception
*/
public JSONObject merchantIn(JSONObject dto) throws Exception {
dto.put("merchantId",ComCode.JFEN_MERCHANT_ID);
dto.put("merchantKey",ComCode.JFEN_MERCHANT_KEY);
......@@ -57,6 +63,12 @@ public class JuHeZhongPayJFenService {
return JSONObject.parseObject(respStr);
}
/**
* 添加费率
* @param dto
* @return
* @throws Exception
*/
public JSONObject merchantAddFeel(JSONObject dto) throws Exception {
dto.put("timestamp",System.currentTimeMillis());
dto.put("serviceType","6");
......@@ -64,6 +76,12 @@ public class JuHeZhongPayJFenService {
return merchantIn(dto);
}
/**
* 修改费率
* @param dto
* @return
* @throws Exception
*/
public JSONObject merchantModifyFeel(JSONObject dto)throws Exception {
dto.put("timestamp",System.currentTimeMillis());
dto.put("serviceType","7");
......@@ -71,6 +89,12 @@ public class JuHeZhongPayJFenService {
return merchantIn(dto);
}
/**
* 开卡
* @param dto
* @return
* @throws Exception
*/
public JSONObject openCard(JSONObject dto)throws Exception {
String signBefore = SignUtils.signBefore(dto);
logger.info("signBefore:{}", signBefore);
......@@ -80,6 +104,12 @@ public class JuHeZhongPayJFenService {
return JSONObject.parseObject(respStr);
}
/**
*
* @param dto
* @return
* @throws Exception
*/
public JSONObject unionQrCodePay(QrCodeDto dto) throws Exception {
Map<String, Object> params = Bean2Map.Entity2Map(dto);
String signBefore = SignUtils.signBefore(params);
......
......@@ -25,6 +25,7 @@ import com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayJFenServic
import com.thinkgem.jeesite.modules.pay.juhezhong.service.JuHeZhongPayService;
import com.thinkgem.jeesite.modules.pay.juhezhong.utils.MakeOrderNum;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.user.bean.JuHeZhongPayRequest;
import com.thinkgem.jeesite.modules.user.bean.UserRequest;
......@@ -331,7 +332,16 @@ public class PayApiService {
}
public Map<String, String> getUserBenefit(UserEntity userEntity, JuHeZhongPayRequest request) {
Map<String, String> userBenefit = new HashMap<>();
String[] pathIds = (userEntity.getRecommendedPath() + userEntity.getId() + ",").split(",");
String recommendedPath = "";
if(userEntity.getRecommendedPath()!=null && userEntity.getRecommendedPath().length()>0){
recommendedPath = userEntity.getRecommendedPath().substring(1);
}
String[] pathIds = (recommendedPath + userEntity.getId() + ",").split(",");
System.out.println("recommendedPath:"+recommendedPath);
System.out.println("pathIds:"+pathIds);
// 获取三级的会员
List<UserRateEntity> pathCDEUsers = payDao.getCDEUsers(pathIds);
int countLevelC = 0;
......@@ -359,12 +369,25 @@ public class PayApiService {
userBenefit.put(entity.getUserCode(), String.valueOf((minRate - Double.parseDouble(entity.getRate())) > 0 ? (minRate - Double.parseDouble(entity.getRate())) * Double.parseDouble(request.getAmount()) * percent : "0"));
}
}
// 获取顶级管理员
List<UserRateEntity> pathSABUsers = payDao.getSABUsers(pathIds,request.getPayChannel());
for (UserRateEntity entity : pathSABUsers) {
userBenefit.put(entity.getUserCode(), String.valueOf((minRate - Double.parseDouble(entity.getRate())) * Double.parseDouble(request.getAmount())));
minRate = Double.valueOf(entity.getRate());
UserRateEntity userRateEntity = new UserRateEntity();
userRateEntity.setPathIds(pathIds);
userRateEntity.setPayChannel(request.getPayChannel());
List<UserRateEntity> pathSABUsers = payDao.getSABUsers(userRateEntity);
if(pathSABUsers!=null && pathSABUsers.size()>0){
for (UserRateEntity entity : pathSABUsers) {
System.out.println(entity.getRate());
System.out.println(entity.getUserCode());
System.out.println(entity.getUserLevel());
System.out.println(request.getAmount());
userBenefit.put(entity.getUserCode(), String.valueOf((minRate - Double.parseDouble(entity.getRate())) * Double.parseDouble(request.getAmount())));
minRate = Double.valueOf(entity.getRate());
}
}
return userBenefit;
}
......@@ -712,7 +735,7 @@ public class PayApiService {
dto.put("merchno",ComCode.HUANQIUHUIJU_MERCHANT_ID); // 商户号
dto.put("dsorderid", orderId); // 订单号 唯一
dto.put("txnAmt",request.getAmount()); // 交易金额
dto.put("txnRate",Double.valueOf(rateEntity.getRate())*100);// 费率
dto.put("txnRate",String.valueOf(Double.valueOf(rateEntity.getRate())*100));// 费率
dto.put("siglePrice",rateEntity.getSiglePrice() ); // 单笔价格
dto.put("merchno",ComCode.HUANQIUHUIJU_MERCHANT_ID); // 商户号
......
......@@ -57,17 +57,17 @@
<select id="getSABUsers" resultType="com.thinkgem.jeesite.modules.pay.entity.UserRateEntity">
SELECT
yu.code AS userCode,
yu.level AS userLevel,
yr.rate AS rate
yu.code AS "userCode",
yu.level AS "userLevel",
yr.rate AS "rate"
FROM
youka_users yu
LEFT JOIN youka_rate yr ON yu.level = yr.user_level AND yr.pay_method = 'quick' AND yr.pay_channel = #{payChannel}
WHERE
yu.id IN
<foreach collection="array" item="pathIds" index="index"
<foreach collection="pathIds" item="pathId" index="index"
open="(" close=")" separator=",">
#{pathIds}
#{pathId}
</foreach>
AND yu.level IN ('S', 'A', 'B')
ORDER BY recommended_path DESC
......
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