Commit 58a704cf authored by 张永's avatar 张永

需求 #14327

parent 07c8f8ef
......@@ -13,6 +13,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp>${maven.build.timestamp}</maven.build.timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<xstream.version>1.4.1</xstream.version>
<jdom.version>2.0.2</jdom.version>
</properties>
<parent>
......@@ -103,6 +105,17 @@
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>${xstream.version}</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>${jdom.version}</version>
</dependency>
<!-- 阿里云 start -->
<dependency>
<groupId>com.aliyun</groupId>
......
......@@ -371,4 +371,23 @@ public class OrderController {
return Rjx.jsonOk().toJson();
}
@ApiOperation("提交补款记录")
@RequestMapping(value = "/createSalesOrderDebtPay",method=RequestMethod.POST)
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="salesOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="subOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="payTypeID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="payType", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="payAmount", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="payCardNO", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
public String createSalesOrderDebtPay(String shopNO, String salesOrderID,String subOrderID,String payTypeID,String payType,String payAmount,String payCardNO) {
List<Map<String,Object>> list = orderService.createSalesOrderDebtPay(shopNO, salesOrderID,subOrderID,payTypeID,payType,payAmount,payCardNO);
return Rjx.jsonOk().set("list", list).toJson();
}
}
package com.egolm.shop.api;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.dom4j.DocumentHelper;
import org.json.XML;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.DateUtil;
import com.egolm.common.GsonUtil;
import com.egolm.common.HttpsUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.WxPayResponse;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@Api(tags={"支付相关接口"})
@RestController
@RequestMapping("pay")
public class PayNotifyController {
protected final Logger logger = LoggerFactory.getLogger(PayNotifyController.class);
@Autowired
private OrderService orderService;
@ApiOperation("支付回调通知接口")
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public Object callback(HttpServletRequest req, HttpServletResponse resp) {
WxPayResponse postData = null;
try {
// 转换微信post过来的xml内容
ServletInputStream in = req.getInputStream();
XStream xs = new XStream(new DomDriver());
xs.setClassLoader(WxPayResponse.class.getClassLoader());
xs.alias("xml", WxPayResponse.class);
String xmlMsg = StringUtil.inputStream2String(in);
logger.info("接收到回调信息 {}",xmlMsg);
postData = (WxPayResponse) xs.fromXML(xmlMsg);
List<Map<String, Object>> returnMap = orderService.payCallback(postData);
logger.info("处理回调信息结果 {}",GsonUtil.toJson(returnMap));
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
public static void main(String[] args) {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n" +
"<xml>\r\n" +
"<appid><![CDATA[wxb934522389d47388]]></appid>\r\n" +
"<bank_type><![CDATA[OTHERS]]></bank_type>\r\n" +
"<cash_fee><![CDATA[1]]></cash_fee>\r\n" +
"<fee_type><![CDATA[CNY]]></fee_type>\r\n" +
"<is_subscribe><![CDATA[N]]></is_subscribe>\r\n" +
"<mch_id><![CDATA[829004816000155]]></mch_id>\r\n" +
"<nonce_str><![CDATA[1677568978015]]></nonce_str>\r\n" +
"<openid><![CDATA[o-8AO5C3MIpEWiMQqlWTSvbnUhtQ]]></openid>\r\n" +
"<out_trade_no><![CDATA[16775689551728_967438]]></out_trade_no>\r\n" +
"<pay_type><![CDATA[120]]></pay_type>\r\n" +
"<result_code><![CDATA[SUCCESS]]></result_code>\r\n" +
"<return_code><![CDATA[SUCCESS]]></return_code>\r\n" +
"<sign><![CDATA[017EC9868E1BD27A1BF786F69605E8FF]]></sign>\r\n" +
"<time_end><![CDATA[20230228152257]]></time_end>\r\n" +
"<total_fee><![CDATA[1]]></total_fee>\r\n" +
"<trade_type><![CDATA[LCSW_+010]]></trade_type>\r\n" +
"<transaction_id><![CDATA[4200001803202302280221844190]]></transaction_id>\r\n" +
"</xml>";
String url = "http://localhost:30005/shop/pay/callback";
String result = HttpsUtil.doPostForXml(url, xml);
System.out.println(result);
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.bean.RespObject;
import com.egolm.shop.bean.WxPayResponse;
public interface OrderService {
......@@ -40,5 +41,8 @@ public interface OrderService {
public RespObject queryRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID, Page page);
public List<Map<String, Object>> createSalesOrderDebtPay(String shopNO, String salesOrderID,String subOrderID,String payTypeID,String payType,String payAmount,String payCardNO) ;
public List<Map<String, Object>> payCallback(WxPayResponse postData);
}
......@@ -9,6 +9,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.UncategorizedSQLException;
......@@ -29,11 +31,13 @@ import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.RespObject;
import com.egolm.shop.bean.TSalesOrder;
import com.egolm.shop.bean.TSalesOrderDtl;
import com.egolm.shop.bean.WxPayResponse;
import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils;
import com.qcloud.cos.utils.DateUtils;
@Service
public class OrderServiceImpl implements OrderService {
private static final Log logger = LogFactory.getLog(OrderServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
......@@ -1042,4 +1046,38 @@ public class OrderServiceImpl implements OrderService {
return new RespObject(result);
}
//提交补款记录
public List<Map<String, Object>> createSalesOrderDebtPay(String shopNO, String salesOrderID,String subOrderID,String payTypeID,String payType,String payAmount,String payCardNO) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
try {
String sql = "exec up_CreateSalesOrderDebtPay '"+shopNO+"' ,'"+salesOrderID+"' , '"+subOrderID+"' , '"+payTypeID+"' , '"+payType+"' , '"+payAmount+"' , '"+payCardNO+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
return returnMap;
} catch (Exception e) {
e.printStackTrace();
}
return returnMap;
}
//回调标记已补款
public List<Map<String, Object>> payCallback(WxPayResponse postData) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
String OutTradeNO = postData.getOut_trade_no();
String TransactionID = postData.getTransaction_id();
String PayCardNO = postData.getOpenid();
String PayAmount= postData.getTotal_fee().toString();
String PayDate = postData.getTime_end();
String PayChannel = postData.getPay_type();
String paydate = DateUtil.format(DateUtil.parse(PayDate,DateUtil.FMT_YYYYMMddHHMMSS),DateUtil.FMT_DATE_SECOND);
try {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} catch (Exception e) {
e.printStackTrace();
}
return returnMap;
}
}
This diff is collapsed.
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