|
@@ -22,6 +22,7 @@ import com.caimei.modules.user.entity.UserBeansHistory;
|
|
import com.caimei.modules.user.service.CmUserBalanceRecordService;
|
|
import com.caimei.modules.user.service.CmUserBalanceRecordService;
|
|
import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.MathUtil;
|
|
import com.caimei.utils.MathUtil;
|
|
|
|
+import com.google.common.util.concurrent.AtomicDouble;
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.config.Global;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.persistence.Page;
|
|
import com.thinkgem.jeesite.common.service.CrudService;
|
|
import com.thinkgem.jeesite.common.service.CrudService;
|
|
@@ -38,6 +39,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
import org.apache.commons.httpclient.HttpStatus;
|
|
import org.apache.commons.httpclient.HttpStatus;
|
|
|
|
+
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -468,7 +470,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
return newOrder;
|
|
return newOrder;
|
|
}
|
|
}
|
|
|
|
|
|
- @Transactional(readOnly = false,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(readOnly = false, rollbackFor = Exception.class)
|
|
public void confirmApply(CmReturnedPurchase cmReturnedPurchase, HttpServletRequest request) throws Exception {
|
|
public void confirmApply(CmReturnedPurchase cmReturnedPurchase, HttpServletRequest request) throws Exception {
|
|
CmReturnedPurchase returnedPurchase = cmReturnedPurchaseDao.get(cmReturnedPurchase);
|
|
CmReturnedPurchase returnedPurchase = cmReturnedPurchaseDao.get(cmReturnedPurchase);
|
|
if (returnedPurchase == null) {
|
|
if (returnedPurchase == null) {
|
|
@@ -604,9 +606,9 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
|
|
|
|
//判断是否有线上退款
|
|
//判断是否有线上退款
|
|
if (returnedPurchase.getReturnedWay().equals("1") && returnedPurchase.getRefundOnlineFee() > 0) {
|
|
if (returnedPurchase.getReturnedWay().equals("1") && returnedPurchase.getRefundOnlineFee() > 0) {
|
|
- List<Integer> shopOrderIds=cmReturnedPurchaseDao.findReturnedShopOrder(returnedPurchase.getOrderID());
|
|
|
|
- if(null==shopOrderIds||0==shopOrderIds.size()){
|
|
|
|
- throw new Exception("子订单信息错误!");
|
|
|
|
|
|
+ List<Integer> shopOrderIds = cmReturnedPurchaseDao.findReturnedShopOrder(returnedPurchase.getOrderID());
|
|
|
|
+ if (null == shopOrderIds || 0 == shopOrderIds.size()) {
|
|
|
|
+ throw new Exception("退款子订单信息错误!");
|
|
}
|
|
}
|
|
theOnlineRefund(shopOrderIds);
|
|
theOnlineRefund(shopOrderIds);
|
|
}
|
|
}
|
|
@@ -750,8 +752,10 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
*
|
|
*
|
|
* @param shopOrderIds
|
|
* @param shopOrderIds
|
|
*/
|
|
*/
|
|
- private void theOnlineRefund(List<Integer> shopOrderIds) throws Exception {
|
|
|
|
|
|
+ private void theOnlineRefund(List<Integer> shopOrderIds) {
|
|
List<CmReceiptOrderRelation> relationList = cmReceiptOrderRelationDao.findByShopOrderIds(shopOrderIds);
|
|
List<CmReceiptOrderRelation> relationList = cmReceiptOrderRelationDao.findByShopOrderIds(shopOrderIds);
|
|
|
|
+// AtomicDouble allRefund = new AtomicDouble(0);
|
|
|
|
+// relationList.forEach(r -> allRefund.getAndSet(Double.parseDouble(r.getAssociateAmount())));
|
|
if (null != relationList && relationList.size() > 0) {
|
|
if (null != relationList && relationList.size() > 0) {
|
|
for (CmReceiptOrderRelation orderRelation : relationList) {
|
|
for (CmReceiptOrderRelation orderRelation : relationList) {
|
|
//cdr表payway为1纯线上收款
|
|
//cdr表payway为1纯线上收款
|
|
@@ -769,22 +773,22 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void onlinePay(String orderRequestNo, String money, Integer shopOrderId) throws Exception {
|
|
|
|
|
|
+ void onlinePay(String orderRequestNo, String money, Integer shopOrderId) {
|
|
AppPayRefundOrderVo orderVo = new AppPayRefundOrderVo();
|
|
AppPayRefundOrderVo orderVo = new AppPayRefundOrderVo();
|
|
orderVo.setP1_bizType("AppPayRefund");
|
|
orderVo.setP1_bizType("AppPayRefund");
|
|
- String splitCode=cmReturnedPurchaseDao.findSplitCode(shopOrderId);
|
|
|
|
|
|
+ String splitCode = cmReturnedPurchaseDao.findSplitCode(shopOrderId);
|
|
orderVo.setP3_customerNumber(splitCode);
|
|
orderVo.setP3_customerNumber(splitCode);
|
|
//退款原单号
|
|
//退款原单号
|
|
orderVo.setP2_orderId(orderRequestNo);
|
|
orderVo.setP2_orderId(orderRequestNo);
|
|
//自定义退款单号
|
|
//自定义退款单号
|
|
String tk = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
String tk = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
- orderVo.setP4_refundOrderId("TK" + tk +orderRequestNo);
|
|
|
|
|
|
+ orderVo.setP4_refundOrderId("TK" + tk + orderRequestNo);
|
|
//退款金额
|
|
//退款金额
|
|
orderVo.setP5_amount(money);
|
|
orderVo.setP5_amount(money);
|
|
try {
|
|
try {
|
|
Map<String, String> map = MyBeanUtils.convertBean(orderVo, new LinkedHashMap());
|
|
Map<String, String> map = MyBeanUtils.convertBean(orderVo, new LinkedHashMap());
|
|
String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayRefundOrderVo.NEED_SIGN_PARAMS);
|
|
String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayRefundOrderVo.NEED_SIGN_PARAMS);
|
|
- oriMessage+=Constant.SAOMA;
|
|
|
|
|
|
+ oriMessage += Constant.SAOMA;
|
|
String sign = Disguiser.disguiseMD5(oriMessage.trim());
|
|
String sign = Disguiser.disguiseMD5(oriMessage.trim());
|
|
logger.info("签名串:" + sign);
|
|
logger.info("签名串:" + sign);
|
|
map.put("sign", sign);
|
|
map.put("sign", sign);
|
|
@@ -796,7 +800,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
AppPayRefundOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayRefundOrderResponseVo.class);
|
|
AppPayRefundOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayRefundOrderResponseVo.class);
|
|
//String[] excludes = {"rt3_retMsg"};
|
|
//String[] excludes = {"rt3_retMsg"};
|
|
String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayRefundOrderResponseVo.NEED_SIGN_PARAMS);
|
|
String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayRefundOrderResponseVo.NEED_SIGN_PARAMS);
|
|
- assemblyRespOriSign+=Constant.SAOMA;
|
|
|
|
|
|
+ assemblyRespOriSign += Constant.SAOMA;
|
|
logger.info("组装返回结果签名串:" + assemblyRespOriSign);
|
|
logger.info("组装返回结果签名串:" + assemblyRespOriSign);
|
|
String responseSign = orderResponseVo.getSign();
|
|
String responseSign = orderResponseVo.getSign();
|
|
logger.info("响应签名:" + responseSign);
|
|
logger.info("响应签名:" + responseSign);
|
|
@@ -820,23 +824,24 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//todo 网银退款不退手续费,
|
|
//todo 网银退款不退手续费,
|
|
//1.本方法内转账手续费等待到账再发起退款请求
|
|
//1.本方法内转账手续费等待到账再发起退款请求
|
|
//2.异步
|
|
//2.异步
|
|
//3.回调
|
|
//3.回调
|
|
- void unionRefund(String orderRequestNo,String money,Integer shopOrderId) throws Exception{
|
|
|
|
|
|
+ void unionRefund(String orderRequestNo, String money, Integer shopOrderId) {
|
|
Map<String, String> sPara = new HashMap<String, String>();
|
|
Map<String, String> sPara = new HashMap<String, String>();
|
|
sPara.put("P1_bizType", "OnlineRefund");
|
|
sPara.put("P1_bizType", "OnlineRefund");
|
|
sPara.put("P2_orderId", orderRequestNo);
|
|
sPara.put("P2_orderId", orderRequestNo);
|
|
- String splitCode=cmReturnedPurchaseDao.findSplitCode(shopOrderId);
|
|
|
|
|
|
+ String splitCode = cmReturnedPurchaseDao.findSplitCode(shopOrderId);
|
|
sPara.put("P3_customerNumber", splitCode);
|
|
sPara.put("P3_customerNumber", splitCode);
|
|
- sPara.put("P4_refundAmount",money);
|
|
|
|
- sPara.put("P5_refundOrderId","TK" +orderRequestNo);
|
|
|
|
- sPara.put("P6_desc","无");
|
|
|
|
- sPara.put("P7_serverCallbackUrl","");
|
|
|
|
|
|
+ sPara.put("P4_refundAmount", money);
|
|
|
|
+ sPara.put("P5_refundOrderId", "TK" + orderRequestNo);
|
|
|
|
+ sPara.put("P6_desc", "无");
|
|
|
|
+ sPara.put("P7_serverCallbackUrl", "");
|
|
StringBuffer sb = new StringBuffer();
|
|
StringBuffer sb = new StringBuffer();
|
|
sb.append("&").append("OnlineRefund").append("&").append(orderRequestNo).append("&").append(splitCode).append("&").
|
|
sb.append("&").append("OnlineRefund").append("&").append(orderRequestNo).append("&").append(splitCode).append("&").
|
|
- append(money).append("&").append("TK" +orderRequestNo).append("&").append("无").append("&").append("&").append(Constant.WANGYIN);
|
|
|
|
|
|
+ append(money).append("&").append("TK" + orderRequestNo).append("&").append("无").append("&").append("&").append(Constant.WANGYIN);
|
|
String sign = Disguiser.disguiseMD5(sb.toString());
|
|
String sign = Disguiser.disguiseMD5(sb.toString());
|
|
sPara.put("sign", sign);
|
|
sPara.put("sign", sign);
|
|
try {
|
|
try {
|
|
@@ -851,7 +856,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
assemblyRespOriSign += Constant.SPLIT + Constant.WANGYIN;
|
|
assemblyRespOriSign += Constant.SPLIT + Constant.WANGYIN;
|
|
String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
|
|
String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
|
|
if (!checkSign.equals(on.getSign())) {
|
|
if (!checkSign.equals(on.getSign())) {
|
|
- logger.error("验签失败========================" +on.getRt3_retMsg());
|
|
|
|
|
|
+ logger.error("验签失败========================" + on.getRt3_retMsg());
|
|
throw new Exception("第三方退款失败!");
|
|
throw new Exception("第三方退款失败!");
|
|
} else {
|
|
} else {
|
|
logger.info("第三方退款成功");
|
|
logger.info("第三方退款成功");
|
|
@@ -898,7 +903,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
|
|
}
|
|
}
|
|
JSONObject res = JSON.parseObject(content);
|
|
JSONObject res = JSON.parseObject(content);
|
|
if ("0000".equals(res.getString("rt2_retCode"))) {
|
|
if ("0000".equals(res.getString("rt2_retCode"))) {
|
|
- logger.info("退款申请发起成功------->"+res.toString());
|
|
|
|
|
|
+ logger.info("退款申请发起成功------->" + res.toString());
|
|
}
|
|
}
|
|
/** rt4_success 为 true,需验签 **/
|
|
/** rt4_success 为 true,需验签 **/
|
|
return res.toJavaObject(clazz);
|
|
return res.toJavaObject(clazz);
|