|
@@ -24,10 +24,12 @@ import com.wechat.pay.java.service.refund.model.AmountReq;
|
|
|
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
|
|
import com.wechat.pay.java.service.refund.model.Refund;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
@@ -46,6 +48,7 @@ import static com.wechat.pay.java.service.refund.model.Status.PROCESSING;
|
|
|
* @author wuhs
|
|
|
* @since 2024-03-07
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/wechatPay")
|
|
|
public class TWechatPayConfigController {
|
|
@@ -62,6 +65,9 @@ public class TWechatPayConfigController {
|
|
|
@Autowired
|
|
|
TWechatPayConfigService wechatPayConfigService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TAlipayConfigService alipayConfigService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TEquipmentService equipmentService;
|
|
|
|
|
@@ -70,263 +76,9 @@ public class TWechatPayConfigController {
|
|
|
|
|
|
@ApiOperation(value = "购物车 请求在线支付 ")
|
|
|
@PostMapping("/carsPay")
|
|
|
- public Object carsPay(String clientId, @RequestBody Map<String,String> productNameMap, HttpServletRequest request) {
|
|
|
- JsonMessage jsonMessage = wechatPayConfigService.carsPay(clientId, productNameMap, request);
|
|
|
+ public Object carsPay(String clientId, @RequestBody Map<String,String> productNameMap, String frpCode, HttpServletRequest request) {
|
|
|
+ JsonMessage jsonMessage = wechatPayConfigService.carsPay(clientId, productNameMap, frpCode, request);
|
|
|
return jsonMessage;
|
|
|
-// if(productNameMap==null){
|
|
|
-// return JsonMessage.error("数据出错");
|
|
|
-// }
|
|
|
-// StringBuffer note = new StringBuffer();
|
|
|
-// StringBuffer productName = new StringBuffer();
|
|
|
-// String productNo = "";
|
|
|
-// Map<String, Integer> productMap = new HashMap<>();
|
|
|
-// Integer productNumber = 0;
|
|
|
-//
|
|
|
-// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
-// if(equipment==null||equipment.getId()==null){
|
|
|
-// return JsonMessage.error("找不到设备");
|
|
|
-// }
|
|
|
-// BigDecimal price = new BigDecimal("0.00");
|
|
|
-// TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
-// if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
-// for (String key : productNameMap.keySet()) {
|
|
|
-// String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
-// List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
-// List<TPromoCode> promoCodeList = new ArrayList<>();
|
|
|
-// //1,校验优惠码
|
|
|
-// if(value.size()>0){
|
|
|
-// for(String code:value){
|
|
|
-// if(!code.equals("0")){
|
|
|
-// TPromoCode promoCode = new TPromoCode();
|
|
|
-// ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
-// TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
-// promoCode = tPromoCode;
|
|
|
-// if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
-// //不存在
|
|
|
-// return JsonMessage.success("1");
|
|
|
-// }
|
|
|
-// Date lastUseDate = null;
|
|
|
-// if (promoCode != null) {
|
|
|
-// lastUseDate = promoCode.getLastUseDate();
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
-// promoCode.setIsUse("2");
|
|
|
-// szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
-// //过期
|
|
|
-// return JsonMessage.success("4");
|
|
|
-// }
|
|
|
-// if (promoCode.getId() == null) {
|
|
|
-// //不存在
|
|
|
-// return JsonMessage.success("1");
|
|
|
-// }
|
|
|
-// if (promoCode.getIsUse().equals("1")) {
|
|
|
-// //被使用
|
|
|
-// return JsonMessage.success("2");
|
|
|
-// }
|
|
|
-// if(!promoCode.getAdminId().equals("1")){
|
|
|
-// if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
-//
|
|
|
-// } else {
|
|
|
-// //不是本机
|
|
|
-// return JsonMessage.success("3");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (promoCode.getDiscount() == null) {
|
|
|
-// //旧优惠码
|
|
|
-// return JsonMessage.success("0");
|
|
|
-// }
|
|
|
-// if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
-// //0折
|
|
|
-// return JsonMessage.success("0");
|
|
|
-// }
|
|
|
-// promoCodeList.add(promoCode);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// String[] productNum = key.split("-");
|
|
|
-// String productNamea = productNum[0];
|
|
|
-// String num = productNum[1];
|
|
|
-// productMap.put(productNamea,Integer.valueOf(num));
|
|
|
-// productNumber += Integer.valueOf(num);
|
|
|
-// productName.append(productNamea).append("x").append(num).append(",");
|
|
|
-// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
-// if (product == null) {
|
|
|
-// return JsonMessage.error("找不到商品");
|
|
|
-// }
|
|
|
-// note.append(productNamea).append("-").append(product.getNo()).append(":");
|
|
|
-// BigDecimal productPrice = product.getRmbPrice();
|
|
|
-// productNo = product.getNo();
|
|
|
-// if(promoCodeList.size()>0){
|
|
|
-// //有优惠码
|
|
|
-// BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
-// int i;
|
|
|
-// for( i = 0;i<promoCodeList.size();i++){
|
|
|
-// BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// price = price.add(price1);
|
|
|
-// onePrice = onePrice.add(price1);
|
|
|
-// }
|
|
|
-// if(i<Integer.valueOf(num)){
|
|
|
-// int a = Integer.valueOf(num)-i;
|
|
|
-// BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// price =price.add(price2);
|
|
|
-// onePrice = onePrice.add(price2);
|
|
|
-// }
|
|
|
-// note.append(onePrice).append("-").append(num).append(",");
|
|
|
-// }else {
|
|
|
-// //1,type=0,原始设定,没有第二件半价
|
|
|
-// int a = Integer.valueOf(num);
|
|
|
-// BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// price =price.add(price2);
|
|
|
-// note.append(price2).append("-").append(num).append(",");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-//
|
|
|
-// for (String key : productNameMap.keySet()) {
|
|
|
-// String[] productNum = key.split("-");
|
|
|
-// String productNamea = productNum[0];
|
|
|
-// String num = productNum[1];
|
|
|
-// productMap.put(productNamea,Integer.valueOf(num));
|
|
|
-// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
-// productNo = product.getNo();
|
|
|
-// BigDecimal productPrice = product.getRmbPrice();
|
|
|
-// productName.append(productNamea).append("x").append(num).append(",");
|
|
|
-// note.append(productNamea).append("-").append(product.getNo()).append(":");
|
|
|
-// switch (num) {
|
|
|
-// case "1":
|
|
|
-// //1个 0个半价
|
|
|
-// price =price.add(productPrice);
|
|
|
-// note.append(price).append("-").append(num).append(",");
|
|
|
-// break;
|
|
|
-// case "2":
|
|
|
-// //2个 1个半价
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// note.append(price).append("-").append(num).append(",");
|
|
|
-// break;
|
|
|
-// case "3":
|
|
|
-// //3个 1个半价
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// price =price.add(productPrice);
|
|
|
-// note.append(price).append("-").append(num).append(",");
|
|
|
-// break;
|
|
|
-// case "4":
|
|
|
-// //4个 2个半价
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// note.append(price).append("-").append(num).append(",");
|
|
|
-// break;
|
|
|
-// case "5":
|
|
|
-// //5个 2个半价
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// price =price.add(productPrice);
|
|
|
-// price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
-// price =price.add(productPrice);
|
|
|
-// note.append(price).append("-").append(num).append(",");
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (equipment == null) {
|
|
|
-// return JsonMessage.error("找不到设备");
|
|
|
-// }
|
|
|
-//
|
|
|
-// Long equipmentId = equipment.getId();
|
|
|
-// //查找商品
|
|
|
-// if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
-// return JsonMessage.error("商品价格异常");
|
|
|
-// }
|
|
|
-// Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
|
-// String sn = orderService.initSn(client6);
|
|
|
-// //获取分销 关联设备
|
|
|
-// TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
-// String companyType = admin.getCompanyType();
|
|
|
-// if (admin == null) {
|
|
|
-// return JsonMessage.error("找不到设备商家");
|
|
|
-// }
|
|
|
-// JSONArray altInfo = new JSONArray();
|
|
|
-// BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// amount = amount.multiply(new BigDecimal(100));
|
|
|
-// String notifyUrl = JoinpayConstant.WECHAT_NOTIFY_URL;
|
|
|
-// String frpCode = "WEIXIN_NATIVE";
|
|
|
-// TOrder order = new TOrder();
|
|
|
-// order.setId(IDGenerator.orderID());
|
|
|
-// order.setCreateDate(new Date());
|
|
|
-// order.setModifyDate(new Date());
|
|
|
-// order.setAdminId(admin.getId());
|
|
|
-// order.setSn(sn);
|
|
|
-// if(productNumber == 1) {
|
|
|
-// productName.delete(productName.length() - 3, productName.length());
|
|
|
-// } else {
|
|
|
-// productName.deleteCharAt(productName.length() - 1);
|
|
|
-// }
|
|
|
-// order.setProductName(productName.toString());
|
|
|
-// order.setPrice(price);
|
|
|
-// order.setClientId(equipment.getClientId());
|
|
|
-// order.setEquipmentId(equipmentId);
|
|
|
-// order.setFrpCode(frpCode);
|
|
|
-// order.setProductNumber(productNumber);
|
|
|
-// order.setAltInfo(altInfo.toString());
|
|
|
-// order.setStatus(0);
|
|
|
-// String payPlatform = "3";
|
|
|
-// order.setPayPlatform(payPlatform);
|
|
|
-// order.setCompanyType(companyType);
|
|
|
-// order.setMachineType(equipment.getMachineType());
|
|
|
-// order.setProductNo(productNo);
|
|
|
-// if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
-// order.setIsSettlement("0");
|
|
|
-// }
|
|
|
-// order.setNote(note.toString());
|
|
|
-//
|
|
|
-// // 订单明细表
|
|
|
-// TOrderDetails orderDetails = new TOrderDetails();
|
|
|
-// orderDetails.setAdminId(admin.getId());
|
|
|
-// orderDetails.setEquipmentId(equipmentId);
|
|
|
-// orderDetails.setCreateDate(new Date());
|
|
|
-// orderDetails.setCompanyType(companyType);
|
|
|
-// orderDetails.setRefundStatus("0");
|
|
|
-// orderDetails.setMachineType(equipment.getMachineType());
|
|
|
-// // 添加到订单明细表
|
|
|
-// for (String key : productMap.keySet()) {
|
|
|
-// Integer productNum = productMap.get(key);
|
|
|
-// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), key));
|
|
|
-// orderDetails.setProductNo(product.getNo());
|
|
|
-// orderDetails.setProductName(key);
|
|
|
-// orderDetails.setPrice(product.getRmbPrice());
|
|
|
-// orderDetails.setProductNumber(productNum);
|
|
|
-// orderDetails.setAmount(product.getRmbPrice().multiply(new BigDecimal(productNum)));
|
|
|
-// orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
-// orderDetails.setOrderSn(sn);
|
|
|
-// orderDetailsService.save(orderDetails);
|
|
|
-// }
|
|
|
-// orderService.save(order);
|
|
|
-// String productName1 = "";
|
|
|
-// if(productNumber > 1) {
|
|
|
-// productName1 = "棉花糖";
|
|
|
-// } else {
|
|
|
-// productName1 = productName.toString();
|
|
|
-// }
|
|
|
-// String result;
|
|
|
-// try {
|
|
|
-// result = orderService.wechatPay(
|
|
|
-// sn, amount, productName1, admin.getWechatPayId(), notifyUrl, clientId, request
|
|
|
-// );
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// return JsonMessage.error("申请支付失败");
|
|
|
-// }
|
|
|
-// // 微信支付支付申请返回支付二维码图片
|
|
|
-// JSONObject kindData = new JSONObject();
|
|
|
-// kindData.put("sn", sn);
|
|
|
-// kindData.put("code_url", result);
|
|
|
-// return JsonMessage.success(kindData.toString());
|
|
|
}
|
|
|
|
|
|
@ApiOperation("微信付款码支付")
|
|
@@ -337,92 +89,20 @@ public class TWechatPayConfigController {
|
|
|
return jsonMessage;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("处理支付宝支付成功回调的通知")
|
|
|
+ @PostMapping("/alipayNotify")
|
|
|
+ public String alipayNotify(@RequestParam Map<String, String> params) {
|
|
|
+ log.info("支付宝支付回调通知:{}", params);
|
|
|
+ String result = alipayConfigService.alipayNotify(params);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("处理微信支付成功回调的通知")
|
|
|
@PostMapping(value = "/notify")
|
|
|
@ResponseBody
|
|
|
public Object notify(HttpServletRequest request) {
|
|
|
String result = wechatPayConfigService.payNotify(request);
|
|
|
return result;
|
|
|
-// Gson gson = new Gson();
|
|
|
-// // 读取请求体中的数据
|
|
|
-// String body = HttpUtils.readData(request);
|
|
|
-// Map<String, Object> bodyMap = gson.fromJson(body, HashMap.class);
|
|
|
-// // 解密支付通知数据
|
|
|
-// String plainText = wechatPayConfigService.decryptFromResource(bodyMap);
|
|
|
-// if(StringUtils.isNotEmpty(plainText)){
|
|
|
-// JSONObject resultJson = JSONObject.parseObject(plainText);
|
|
|
-// // 根据订单号查询订单
|
|
|
-// String sn = resultJson.getString("out_trade_no");
|
|
|
-// if(StringUtils.isNotEmpty(sn)) {
|
|
|
-// LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
-// query.eq(TOrder::getSn, sn);
|
|
|
-// query.eq(TOrder::getStatus, 0);
|
|
|
-// List<TOrder> list = orderService.list(query);
|
|
|
-// // 更新订单状态和支付信息
|
|
|
-// if (list != null && list.size() > 0) {
|
|
|
-// TOrder order = list.get(0);
|
|
|
-// order.setStatus(1);
|
|
|
-// String success_time = resultJson.getString("success_time");
|
|
|
-// Date date = new Date();
|
|
|
-// try {
|
|
|
-// date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(success_time);
|
|
|
-// } catch (ParseException e) {
|
|
|
-// // 忽略时间转换错误
|
|
|
-// }
|
|
|
-// order.setPayDate(date);
|
|
|
-// order.setTrxNo(resultJson.getString("transaction_id"));
|
|
|
-// // 更新订单明细状态
|
|
|
-// LambdaQueryWrapper<TOrderDetails> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
-// lambdaQueryWrapper.eq(TOrderDetails::getOrderSn,sn);
|
|
|
-// List<TOrderDetails> orderDetails = orderDetailsService.list(lambdaQueryWrapper);
|
|
|
-// for (TOrderDetails orderDetail : orderDetails) {
|
|
|
-// orderDetail.setRefundStatus("1");
|
|
|
-// orderDetailsService.updateById(orderDetail);
|
|
|
-// }
|
|
|
-// // 发送支付成功消息给设备
|
|
|
-// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
-// JSONObject kindData = new JSONObject();
|
|
|
-// kindData.put("sn", order.getSn());
|
|
|
-// kindData.put("productName", order.getProductName());
|
|
|
-// if (!order.getIsNotified().equals("1")) {
|
|
|
-// String paySuccess = equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
-// if (paySuccess.equals("success")) {
|
|
|
-// order.setIsNotified("1");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// orderService.updateById(order);
|
|
|
-// try {
|
|
|
-// // 保存订单信息到ES
|
|
|
-// if(order.getProductNumber()==null||order.getProductNumber()==0){
|
|
|
-// order.setProductNumber(1);
|
|
|
-// }
|
|
|
-// orderFeign.saveToEs(order);
|
|
|
-// }catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// LambdaQueryWrapper<TOrder> queryWrapper = Wrappers.lambdaQuery();
|
|
|
-// query.eq(TOrder::getSn, sn);
|
|
|
-// query.eq(TOrder::getStatus, 1);
|
|
|
-// List<TOrder> orderList = orderService.list(queryWrapper);
|
|
|
-// if (list != null && list.size() > 0) {
|
|
|
-// TOrder tOrder = orderList.get(0);
|
|
|
-// try {
|
|
|
-// // 保存订单信息到ES
|
|
|
-// if(tOrder.getProductNumber()==null||tOrder.getProductNumber()==0){
|
|
|
-// tOrder.setProductNumber(1);
|
|
|
-// }
|
|
|
-// orderFeign.saveToEs(tOrder);
|
|
|
-// }catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// return "success";
|
|
|
-// }
|
|
|
-// return "fail";
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return "success";
|
|
|
}
|
|
|
|
|
|
@ApiOperation("发起退款")
|
|
@@ -430,85 +110,11 @@ public class TWechatPayConfigController {
|
|
|
public ResponseModel<?> refund(@RequestBody TOrder torder){
|
|
|
ResponseModel result = wechatPayConfigService.refund(torder);
|
|
|
return result;
|
|
|
-// // 退款金额: refusePrice
|
|
|
-// BigDecimal refusePrice = torder.getPrice().setScale(2, RoundingMode.HALF_DOWN);
|
|
|
-// // 退款数量: refundNumber
|
|
|
-// Integer refundNumber = torder.getProductNumber();
|
|
|
-// // 退款原因: refundReason
|
|
|
-// String refundReason = torder.getRefundReason();
|
|
|
-// // 退款明细:note
|
|
|
-// String note = torder.getNote();
|
|
|
-// String[] refundDetails = note.split(",");
|
|
|
-// Map<String, Integer> refundMap = new HashMap<>();
|
|
|
-// for (String refundDetail : refundDetails) {
|
|
|
-// String[] keyValue = refundDetail.split("-");
|
|
|
-// String key = keyValue[0];
|
|
|
-// String value = keyValue[1];
|
|
|
-// refundMap.put(key, Integer.valueOf(value));
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(refusePrice.compareTo(new BigDecimal("0.00"))<=0){
|
|
|
-// return R.fail(ResponseCodesEnum.A0001,"退款金额非法");
|
|
|
-// }
|
|
|
-//
|
|
|
-// TOrder order = orderService.getById(torder.getId());
|
|
|
-// if(order.getRefundQuantity() != null && order.getRefundQuantity()>0) {
|
|
|
-// order.setRefundQuantity(refundNumber + order.getRefundQuantity());
|
|
|
-// } else {
|
|
|
-// order.setRefundQuantity(refundNumber);
|
|
|
-// }
|
|
|
-//
|
|
|
-// LambdaQueryWrapper<TOrderDetails> wrapper = new LambdaQueryWrapper<>();
|
|
|
-// wrapper.eq(TOrderDetails::getOrderSn, order.getSn());
|
|
|
-// List<TOrderDetails> orderDetails = orderDetailsService.list(wrapper);
|
|
|
-// if (order.getStatus().equals("0")) {
|
|
|
-// return R.fail(ResponseCodesEnum.A0002,"订单非支付状态");
|
|
|
-// }
|
|
|
-//
|
|
|
-// CreateRequest createRequest = new CreateRequest();
|
|
|
-// createRequest.setOutTradeNo(order.getSn());
|
|
|
-// AmountReq amount = new AmountReq();
|
|
|
-// amount.setRefund(refusePrice.multiply(new BigDecimal(100)).longValue());
|
|
|
-// BigDecimal multiply = order.getPrice().multiply(new BigDecimal(100));
|
|
|
-// amount.setTotal(multiply.longValue());
|
|
|
-// amount.setCurrency("CNY");
|
|
|
-// createRequest.setAmount(amount);
|
|
|
-// String refundNo = orderService.initSn(order.getEquipmentId());
|
|
|
-// createRequest.setOutRefundNo(refundNo);
|
|
|
-// // 上线需要修改回调url
|
|
|
-// createRequest.setNotifyUrl(JoinpayConstant.WECHAT_NOTIFY_REFUND_URL);
|
|
|
-//// createRequest.setNotifyUrl("http://evxz5m.natappfree.cc/wechatPay/refundNotify");
|
|
|
-// TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(order.getAdminId())));
|
|
|
-// Refund refund = orderService.weixinRefundApi(createRequest, admin.getWechatPayId());
|
|
|
-// System.out.println("退款参数"+refund.toString());
|
|
|
-// if(refund.getStatus()==PROCESSING){
|
|
|
-// order.setStatus(2);
|
|
|
-// order.setRefundReason(refundReason);
|
|
|
-// orderService.updateById(order);
|
|
|
-// // 修改订单明细
|
|
|
-// for (TOrderDetails orderDetail : orderDetails) {
|
|
|
-// String productNo = orderDetail.getProductNo();
|
|
|
-// Integer productNumber = refundMap.get(productNo);
|
|
|
-// if(productNumber != null) {
|
|
|
-// // 退款中
|
|
|
-// orderDetail.setRefundStatus("4");
|
|
|
-// // 退款数量
|
|
|
-// orderDetail.setRefundQuantity(productNumber);
|
|
|
-// // 退款金额
|
|
|
-// orderDetail.setRefundAmount(orderDetail.getPrice().multiply(new BigDecimal(productNumber)));
|
|
|
-// orderDetailsService.updateById(orderDetail);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return R.ok("申请退款已成功");
|
|
|
-// }else {
|
|
|
-// return R.fail(ResponseCodesEnum.B0001,"申请退款失败,请重试");
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "退款成功回调")
|
|
|
@PostMapping("/refundNotify")
|
|
|
public Object refundNotify(HttpServletRequest request, HttpServletResponse response){
|
|
|
-// String result = orderService.wechatRefund(request,response);
|
|
|
String result = wechatPayConfigService.refundNotify(request,response);
|
|
|
return result;
|
|
|
}
|