|
@@ -9,6 +9,7 @@ import com.charging.chargingparking.dto.AccessToken;
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
import com.charging.chargingparking.dto.MessageResult;
|
|
import com.charging.chargingparking.dto.ParkingCostDTO;
|
|
import com.charging.chargingparking.dto.ParkingCostDTO;
|
|
import com.charging.chargingparking.dto.UserInfo;
|
|
import com.charging.chargingparking.dto.UserInfo;
|
|
|
|
+import com.charging.chargingparking.entity.ParkingInfo;
|
|
import com.charging.chargingparking.entity.ParkingMerchant;
|
|
import com.charging.chargingparking.entity.ParkingMerchant;
|
|
import com.charging.chargingparking.entity.ParkingPay;
|
|
import com.charging.chargingparking.entity.ParkingPay;
|
|
import com.charging.chargingparking.entity.ParkingRecord;
|
|
import com.charging.chargingparking.entity.ParkingRecord;
|
|
@@ -57,6 +58,9 @@ public class WxPayController {
|
|
@Autowired
|
|
@Autowired
|
|
private WxPayProperties wxPayProperties;
|
|
private WxPayProperties wxPayProperties;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkingInfoService parkingInfoService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ParkingPayService parkingPayService;
|
|
private ParkingPayService parkingPayService;
|
|
|
|
|
|
@@ -91,6 +95,14 @@ public class WxPayController {
|
|
throw new Exception("记录不存在");
|
|
throw new Exception("记录不存在");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //停车场
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.getById(parkingRecord.getParkId());
|
|
|
|
+ //商户
|
|
|
|
+ ParkingMerchant parkingMerchant = parkingMerchantService.getById(parkingInfo.getMerchantId());
|
|
|
|
+ if (parkingMerchant == null || StrUtil.isBlank(parkingMerchant.getSubMchId())){
|
|
|
|
+ throw new Exception("商户信息错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
//记录总应缴
|
|
//记录总应缴
|
|
ParkingCostDTO parkingCostDTO = parkingFeeService.parkingCost(parkingRecord);
|
|
ParkingCostDTO parkingCostDTO = parkingFeeService.parkingCost(parkingRecord);
|
|
@@ -104,6 +116,8 @@ public class WxPayController {
|
|
throw new Exception("请直接离场");
|
|
throw new Exception("请直接离场");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//金额处理
|
|
//金额处理
|
|
int wxTotalTee = parkCost.subtract(parkingRecord.getPayAmount()).multiply(new BigDecimal(100)).intValue();
|
|
int wxTotalTee = parkCost.subtract(parkingRecord.getPayAmount()).multiply(new BigDecimal(100)).intValue();
|
|
|
|
|
|
@@ -116,7 +130,7 @@ public class WxPayController {
|
|
parkingPay.setCodePayType(codePayType);
|
|
parkingPay.setCodePayType(codePayType);
|
|
parkingPayService.save(parkingPay);
|
|
parkingPayService.save(parkingPay);
|
|
|
|
|
|
- ProfitVo profitVo = parkingPayProfitService.getProfitVo(parkingPay);
|
|
|
|
|
|
+ ProfitVo profitVo = parkingPayProfitService.getProfitVo(parkingPay,parkCost.subtract(parkingRecord.getPayAmount()));
|
|
String profitSharing = "N";
|
|
String profitSharing = "N";
|
|
if (profitVo.getProfitFlag()){
|
|
if (profitVo.getProfitFlag()){
|
|
parkingPay.setProfitNeedFlag(true);
|
|
parkingPay.setProfitNeedFlag(true);
|
|
@@ -130,7 +144,7 @@ public class WxPayController {
|
|
// .appid(companyPaymentInfo.getSubAppId())
|
|
// .appid(companyPaymentInfo.getSubAppId())
|
|
// .mch_id(companyPaymentInfo.getSubMchId())
|
|
// .mch_id(companyPaymentInfo.getSubMchId())
|
|
.mch_id(wxPayProperties.getMchId())
|
|
.mch_id(wxPayProperties.getMchId())
|
|
- .sub_mch_id(wxPayProperties.getSubMchId())
|
|
|
|
|
|
+ .sub_mch_id(profitVo.getSubMchId())
|
|
// .sub_appid(companyPaymentInfo.getSubAppId())
|
|
// .sub_appid(companyPaymentInfo.getSubAppId())
|
|
.nonce_str(WxPayKit.generateStr())
|
|
.nonce_str(WxPayKit.generateStr())
|
|
.body(parkingRecord.getProductTheme())
|
|
.body(parkingRecord.getProductTheme())
|
|
@@ -342,7 +356,7 @@ public class WxPayController {
|
|
.out_refund_no(WxPayKit.generateStr())
|
|
.out_refund_no(WxPayKit.generateStr())
|
|
.total_fee(totalFee)
|
|
.total_fee(totalFee)
|
|
.refund_fee(totalFee)
|
|
.refund_fee(totalFee)
|
|
- .notify_url(wxPayProperties.getRefundUrl())
|
|
|
|
|
|
+ // .notify_url(wxPayProperties.getRefundUrl())
|
|
.build()
|
|
.build()
|
|
.createSign(wxPayProperties.getMchKey(), SignType.HMACSHA256);
|
|
.createSign(wxPayProperties.getMchKey(), SignType.HMACSHA256);
|
|
String result = WxPayApi.orderRefund(false, params, wxPayProperties.getCertPath(), wxPayProperties.getMchId());
|
|
String result = WxPayApi.orderRefund(false, params, wxPayProperties.getCertPath(), wxPayProperties.getMchId());
|
|
@@ -369,13 +383,14 @@ public class WxPayController {
|
|
|
|
|
|
@RequestMapping(value = "/wxJsapiRefundNotify", method = {RequestMethod.POST, RequestMethod.GET})
|
|
@RequestMapping(value = "/wxJsapiRefundNotify", method = {RequestMethod.POST, RequestMethod.GET})
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- public MessageResult wxJsapiRefundNotify(HttpServletRequest request){
|
|
|
|
- MessageResult msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public String wxJsapiRefundNotify(HttpServletRequest request){
|
|
|
|
|
|
String xmlMsg = HttpKit.readData(request);
|
|
String xmlMsg = HttpKit.readData(request);
|
|
log.warn("微信退款回调:"+xmlMsg);
|
|
log.warn("微信退款回调:"+xmlMsg);
|
|
-
|
|
|
|
- return msgResult;
|
|
|
|
|
|
+ Map<String,String> resultMap = new HashMap<>();
|
|
|
|
+ resultMap.put("code","SUCCESS");
|
|
|
|
+ resultMap.put("message","成功");
|
|
|
|
+ return WxPayKit.toXml(resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|