Commit 5829c685 authored by 张永's avatar 张永

V1.1.7.8.4

parent 869e05d2
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
</executions> </executions>
<configuration> <configuration>
<repository>dockerhub.linkfern.com/b2c/shopapi</repository> <repository>dockerhub.linkfern.com/b2c/shopapi</repository>
<tag>V1.1.7.8.3</tag> <tag>V1.1.7.8.4</tag>
<buildArgs> <buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE> <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs> </buildArgs>
......
...@@ -26,10 +26,12 @@ import com.egolm.common.HttpUtil; ...@@ -26,10 +26,12 @@ import com.egolm.common.HttpUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.common.web.ServletUtil;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.RespObject; import com.egolm.shop.bean.RespObject;
import com.egolm.shop.common.XException; import com.egolm.shop.common.XException;
import com.egolm.shop.common.component.IDCLogResource; import com.egolm.shop.common.component.IDCLogResource;
import com.egolm.shop.common.utils.I18NUtils;
import com.egolm.shop.common.utils.XmlUtil; import com.egolm.shop.common.utils.XmlUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -91,6 +93,79 @@ public class OrderController { ...@@ -91,6 +93,79 @@ public class OrderController {
return orderService.submit(jsonObj); return orderService.submit(jsonObj);
} }
//https://showdoc.linkfern.com/web/#/38/895
@ApiOperation("B2B订单提交V2")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = true, value = "店铺编码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "payTypeID", dataType = "String", required = true, value = "订单付款类型", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "addrID", dataType = "String", required = true, value = "收货人地址ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "orderMemo", dataType = "String", required = true, value = "订单备注", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "balanceAmount", dataType = "String", required = false, value = "分账余额", defaultValue = "需求 #17203"),
@ApiImplicitParam(paramType = "query", name = "payDetails", dataType = "String", required = false, value = "付款详情JSON格式", defaultValue = "需求 #17402"),
})
@RequestMapping(value = "/submitV2",method=RequestMethod.POST,produces = "application/json")
@IDCLogResource(name="B2B订单提交V2")
public String submitV2(HttpServletRequest request) {
String shopNO = request.getParameter("shopNO");
String langID = request.getParameter("langID");
String payTypeID = request.getParameter("payTypeID");
String terminal = request.getParameter("terminal");
String addrID = request.getParameter("addrID");
String orderMemo = request.getParameter("orderMemo");
String balanceAmount = request.getParameter("balanceAmount");
String payDetails = request.getParameter("payDetails");
if(StringUtil.isNotUndefinedAndNull(balanceAmount)) {
}else {
balanceAmount = "0";
}
if(!StringUtil.isNotEmpty(shopNO,payTypeID,addrID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).toJson();
}
Map<String,Object> map = new HashMap<String,Object>();
map.put("shopNO", shopNO);
map.put("payTypeID", payTypeID);
map.put("terminal", terminal);
map.put("addrID", addrID);
map.put("orderMemo", orderMemo);
map.put("balanceAmount", balanceAmount);
map.put("payDetails", payDetails);
return orderService.submitV2(map);
}
//https://showdoc.linkfern.com/web/#/38/896
@ApiOperation("B2B订单支付提交V2")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = true, value = "店铺编码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "salesOrderID", dataType = "String", required = true, value = "订单号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "goodsList", dataType = "String", required = true, value = "商品列表", defaultValue = ""),
})
@RequestMapping(value = "/paySubmitV2",method=RequestMethod.POST)
@IDCLogResource(name="B2B订单支付提交V2")
public String paySubmitV2(HttpServletRequest request) {
String langID = request.getParameter("langID");
String shopNO = request.getParameter("shopNO");
String salesOrderID = request.getParameter("salesOrderID");
String goodsList = request.getParameter("goodsList");
if(!StringUtil.isNotEmpty(shopNO,salesOrderID)) {
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).toJson();
}
Map<String,Object> map = new HashMap<String,Object>();
map.put("shopNO", shopNO);
map.put("salesOrderID", salesOrderID);
map.put("goodsList", goodsList);
map.put("ipaddress", ServletUtil.remoteIp(request));
return orderService.paySubmitV2(map);
}
@ApiOperation("获取主订单列表") @ApiOperation("获取主订单列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true),
......
package com.egolm.shop.api.service;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONObject;
public interface CrmService {
public void vUpdateAcceptCoupon(String StoreNO, String CouponNO, BigDecimal PayAmount, BigDecimal TotalRealSaleAmount, String OutTradeNO, String cashier, String hostname, String ipaddress);
public void couponVerification(String StoreNO, String CouponNO, String SalesOrderID, BigDecimal AcceptAmount, BigDecimal TotalRealSaleAmount, String OutTradeNO, String GoodsList, String cashier,String isOnline,String payTypeID);
public void vUpdateMemPoint(int TradeType, String StoreNO, String CardNO, BigDecimal PayPoint, String OutTradeNO, String cashier, String hostname, String ipaddress);
public JSONObject getVCardInfo(String StoreNO, String CardNO) ;
public void vCardPay(String StoreNO, String CardNO, BigDecimal PayAmount, String PosNO, String OutTradeNO, String cashier, String hostname, String ipaddress);
public void vCardRefund(String StoreNO, String PayCardNO, BigDecimal PayAmount, String PosNO, String OutTradeNO, String OldTransTraceNO, String cashier, String hostname, String ipaddress);
public void vCancelAcceptCoupon(String StoreNO, String PayCardNO, String OutTradeNO, String cashier, String hostname, String ipaddress) ;
}
...@@ -16,6 +16,10 @@ public interface OrderService { ...@@ -16,6 +16,10 @@ public interface OrderService {
public String submit(JSONObject submitObj); public String submit(JSONObject submitObj);
public String submitV2(Map<String,Object> map);
public String paySubmitV2(Map<String,Object> map);
public String queryOrderList(String orgNo, String shopNo,String agentID, Integer status, String[] orderType, String langID, Page page); public String queryOrderList(String orgNo, String shopNo,String agentID, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId,String agentID); public String queryOrderDetailList(String salesOrderId,String agentID);
......
package com.egolm.shop.api.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.CrmService;
import com.egolm.shop.common.XException;
import com.egolm.shop.common.config.CrmClient;
@Service
public class CrmServiceImpl implements CrmService{
@Autowired
private CrmClient crmClient;
/**
* 优惠券核销2
* @param StoreNO
* @param CouponNO
* @param PayAmount
* @param TotalRealSaleAmount
* @param OutTradeNO
* @param cashier
* @param hostname
* @param ipaddress
*/
public void vUpdateAcceptCoupon(String StoreNO, String CouponNO, BigDecimal PayAmount, BigDecimal TotalRealSaleAmount, String OutTradeNO, String cashier, String hostname, String ipaddress) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("couponno", CouponNO);
parameters.put("acceptamount", PayAmount);
parameters.put("saleamount", TotalRealSaleAmount);
parameters.put("acceptcouponno", OutTradeNO);
parameters.put("storeno", StoreNO);
parameters.put("receiptid", OutTradeNO);
parameters.put("tradetime", this.getFormatDatetimeString());
parameters.put("cashier", cashier);
parameters.put("hostname", hostname);
parameters.put("ipaddress", ipaddress);
String json = crmClient.post("/api/member/vUpdateAcceptCoupon", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = "优惠券核销异常";
if(jsonObject.getString("message") != null) {
message += "." + jsonObject.getString("message");
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = "优惠券核销失败";
}
throw new XException(StatusName);
}
}
/**
* 优惠券核销2
* @param StoreNO
* @param CouponNO
* @param PayAmount
* @param TotalRealSaleAmount
* @param OutTradeNO
* @param cashier
* @param hostname
* @param ipaddress
*/
public void couponVerification(String StoreNO, String CouponNO, String SalesOrderID, BigDecimal AcceptAmount, BigDecimal TotalRealSaleAmount, String OutTradeNO, String GoodsList, String cashier,String isOnline,String payTypeID) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("storeNO", StoreNO);
parameters.put("couponNO", CouponNO);
parameters.put("salesOrderID", SalesOrderID);
parameters.put("outTradeNO", OutTradeNO);
parameters.put("acceptAmount", AcceptAmount);
parameters.put("cashier", cashier);
parameters.put("saleAmount", TotalRealSaleAmount);
parameters.put("goodsList", GoodsList);
parameters.put("isOnline", isOnline);
parameters.put("payTypeID", payTypeID);
String json = crmClient.post("/api/member/couponVerification", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = payTypeID.equals("81")?"优惠券核销异常":"提货券核销异常";
if(jsonObject.getString("message") != null) {
message += "." + jsonObject.getString("message");
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = payTypeID.equals("81")?"优惠券核销失败":"提货券核销失败";
}
throw new XException(StatusName);
}
}
/**
*
* @param TradeType 0支付, 1退回
* @param StoreNO
* @param CardNO
* @param PayPoint
* @param OutTradeNO
* @param cashier
* @param hostname
* @param ipaddress
*/
public void vUpdateMemPoint(int TradeType, String StoreNO, String CardNO, BigDecimal PayPoint, String OutTradeNO, String cashier, String hostname, String ipaddress) {
Map<String, Object> parameters = new HashMap<String, Object>();
String TradeTypeName = "操作";
if(TradeType == 0) {
TradeTypeName = "支付";
} else if(TradeType == 2) {
TradeTypeName = "回退";
}
parameters.put("storeno", StoreNO);
parameters.put("cardno", CardNO);
parameters.put("tradetype", TradeType);
parameters.put("updatepoint", PayPoint.toString());
parameters.put("beginpoint", "0");
parameters.put("receiptid", OutTradeNO);
parameters.put("tradetime", this.getFormatDatetimeString());
parameters.put("cashier", cashier);
parameters.put("hostname", hostname);
parameters.put("ipaddress", ipaddress);
String json = crmClient.post("/api/member/vUpdateMemPoint", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = jsonObject.getString("message");
if(message == null) {
message = "积分" + TradeTypeName + "异常";
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = "积分" + TradeTypeName + "失败";
}
throw new XException(StatusName);
}
}
public JSONObject getVCardInfo(String StoreNO, String CardNO) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("storeno", StoreNO);
parameters.put("cardno", CardNO);
String json = crmClient.post("/api/member/getVCardInfo", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = jsonObject.getString("message");
if(message == null) {
message = "储值余额异常";
}
throw new XException(message);
}
return jsonObject.getJSONObject("data");
}
public void vCardPay(String StoreNO, String CardNO, BigDecimal PayAmount, String PosNO, String OutTradeNO, String cashier, String hostname, String ipaddress) {
JSONObject vCardInfo = this.getVCardInfo(StoreNO, CardNO);
BigDecimal Money = vCardInfo.getBigDecimal("Money");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("cardno", CardNO);
parameters.put("subamount", PayAmount);
parameters.put("beginamount", Money);
parameters.put("storeno", StoreNO);
parameters.put("posno", PosNO);
parameters.put("receiptid", OutTradeNO);
parameters.put("tradetime", this.getFormatDatetimeString());
parameters.put("cashier", cashier);
parameters.put("hostname", hostname);
parameters.put("ipaddress", ipaddress);
String json = crmClient.post("/api/member/vCardPay", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = jsonObject.getString("message");
if(message == null) {
message = "储值余额支付异常";
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = "储值余额支付失败";
}
throw new XException(StatusName);
}
}
public void vCardRefund(String StoreNO, String PayCardNO, BigDecimal PayAmount, String PosNO, String OutTradeNO, String OldTransTraceNO, String cashier, String hostname, String ipaddress) {
JSONObject vCardInfo = this.getVCardInfo(StoreNO, PayCardNO);
BigDecimal Money = vCardInfo.getBigDecimal("Money");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("cardno", PayCardNO);
parameters.put("subamount", PayAmount);
parameters.put("beginamount", Money);
parameters.put("storeno", StoreNO);
parameters.put("posno", PosNO);
parameters.put("receiptid", OutTradeNO);
parameters.put("oldouttradeno", OldTransTraceNO);
parameters.put("tradetime", this.getFormatDatetimeString());
parameters.put("cashier", cashier);
parameters.put("hostname", hostname);
parameters.put("ipaddress", ipaddress);
String json = crmClient.post("/api/member/vCardRefund", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = jsonObject.getString("message");
if(message == null) {
message = "储值卡退款异常";
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = "储值卡退款失败";
}
throw new XException(StatusName);
}
}
public void vCancelAcceptCoupon(String StoreNO, String PayCardNO, String OutTradeNO, String cashier, String hostname, String ipaddress) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("storeno", StoreNO);
parameters.put("couponno", PayCardNO);
parameters.put("receiptid", OutTradeNO);
parameters.put("cashier", cashier);
parameters.put("hostname", hostname);
parameters.put("ipaddress", ipaddress);
String json = crmClient.post("/api/member/vCancelAcceptCoupon", parameters);
JSONObject jsonObject = JSON.parseObject(json);
int code = jsonObject.getIntValue("code");
if(code != 200) {
String message = jsonObject.getString("message");
if(message == null) {
message = "卡券反核销异常";
}
throw new XException(message);
}
JSONObject dataObject = jsonObject.getJSONObject("data");
int Status = dataObject.getIntValue("Status");
if(Status != 0) {
String StatusName = dataObject.getString("StatusName");
if(StringUtil.isBlank(StatusName)) {
StatusName = "卡券反核销失败";
}
throw new XException(StatusName);
}
}
private String getFormatDatetimeString() {
return DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
}
...@@ -2,6 +2,7 @@ package com.egolm.shop.api.service.impl; ...@@ -2,6 +2,7 @@ package com.egolm.shop.api.service.impl;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Types;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
...@@ -12,6 +13,8 @@ import java.util.Map; ...@@ -12,6 +13,8 @@ import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -20,9 +23,15 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,9 +23,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.FileUtil; import com.egolm.common.FileUtil;
...@@ -34,9 +43,12 @@ import com.egolm.common.Util; ...@@ -34,9 +43,12 @@ import com.egolm.common.Util;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.JdbcTemplate.OutParameter;
import com.egolm.common.jdbc.dialect.Dialect; import com.egolm.common.jdbc.dialect.Dialect;
import com.egolm.common.jdbc.dialect.SqlServerDialect; import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.common.jdbc.dialect.bean.Sql; import com.egolm.common.jdbc.dialect.bean.Sql;
import com.egolm.common.web.ServletUtil;
import com.egolm.shop.api.service.CrmService;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.bean.RespObject; import com.egolm.shop.bean.RespObject;
import com.egolm.shop.bean.TSalesOrder; import com.egolm.shop.bean.TSalesOrder;
...@@ -51,7 +63,8 @@ public class OrderServiceImpl implements OrderService { ...@@ -51,7 +63,8 @@ public class OrderServiceImpl implements OrderService {
protected final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class); protected final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private CrmService crmService;
@Autowired @Autowired
@Qualifier("readonly") @Qualifier("readonly")
...@@ -1557,4 +1570,265 @@ public class OrderServiceImpl implements OrderService { ...@@ -1557,4 +1570,265 @@ public class OrderServiceImpl implements OrderService {
a.delPayFile("111","120","D:\\data\\erp\\callback\\"); a.delPayFile("111","120","D:\\data\\erp\\callback\\");
} }
@Override
public String submitV2(Map<String,Object> map) {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
jdbcTemplate.setDialect(new SqlServerDialect());
DataSource dataSource = jdbcTemplate.getDataSource();
// 此处PlatformTransactionManager对象初始化,应单独用一个类管理,不应每次都创建一个新的
PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
TransactionStatus status = transactionManager.getTransaction(def);
String LangID = "" + map.get("langID");
try {
String shopNO = "" + map.get("shopNO");
String payID = "" + map.get("payTypeID");
String terminalTypeID = "" + map.get("terminal");
String addrID = "" + map.get("addrID");
String orderMemo = "" + map.get("orderMemo");
String balanceAmount = map.containsKey("balanceAmount")?map.get("balanceAmount")+"":"0"; //需求 #17203
String payDetails = map.get("payDetails")+""; //付款详情
String sql = "exec up_NewCreatetSalesOrder '" + shopNO + "','', '" + payID + "', '" + terminalTypeID
+ "', '" + addrID + "', '" + orderMemo + "', '','', '', '1', '', '', '', '', '', '','0','','' ,'','"+balanceAmount+"' ";
List<Map<String, Object>> commitMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
logger.info("提交订单V2:{}, 提交结果: {}",GsonUtil.toJson(map),GsonUtil.toJson(commitMap));
if (commitMap != null && commitMap.size() > 0 && commitMap.get(0) != null
&& Util.objTo(commitMap.get(0).get("Status"), Integer.class) == 0
&& Util.objTo(commitMap.get(commitMap.size() - 1).get("Status"), Integer.class) == 0) {
String sSalesOrderID = (String) commitMap.get(0).get("SalesOrderID");
JSONArray payDetailsArray = JSONArray.parseArray(payDetails);
/**
* [
{"PayTypeID" : "120","PayType" : "微信支付","PayAmount" : 100.00,"PayPoint" : 0.00,"PayCardNO" : "800001000184"},
{"PayTypeID" : "81","PayType" : "优惠券","PayAmount" : 100.00,"PayPoint" : 0.00,"PayCardNO" : "800001000184"}
]*/
if(payDetailsArray != null && payDetailsArray.size()>0) {
for(int i =0;i<payDetailsArray.size();i++) {
JSONObject paydetail = payDetailsArray.getJSONObject(i);
String PayTypeID = paydetail.getString("PayTypeID");
String PayType = paydetail.getString("PayType");
String PayAmount = paydetail.getString("PayAmount");
String PayCardNO = paydetail.getString("PayCardNO");
String psql = "exec up_B2BSalesOrderPrePay '"+sSalesOrderID+"','"+PayTypeID+"','"+PayType+"','"+PayAmount+"','"+PayCardNO+"' ";
List<Map<String,Object>> pcommitMap = jdbcTemplate.executeMutil(psql).getDatas().get(0);
logger.info("提交订单V2付款明细:{}, 提交结果: {}",paydetail,GsonUtil.toJson(pcommitMap));
if (pcommitMap != null && pcommitMap.size() > 0 && pcommitMap.get(0) != null
&& Util.objTo(pcommitMap.get(0).get("Status"), Integer.class) == 0
&& Util.objTo(pcommitMap.get(pcommitMap.size() - 1).get("Status"), Integer.class) == 0) {
//成功
}else {
//失败 则返回
String errorMsg = "";
if (pcommitMap.size() > 1) {
errorMsg = (String) pcommitMap.get(0).get("StatusName") + ";"
+ (String) pcommitMap.get(1).get("StatusName");
} else {
errorMsg = (String) pcommitMap.get(0).get("StatusName");
}
transactionManager.rollback(status);
return Rjx.jsonErr().setMessage(errorMsg).set("errorMsg", errorMsg).setData(pcommitMap).toJson();
}
}
}
transactionManager.commit(status);
return Rjx.jsonOk().setData(commitMap).toJson();
} else {
String errorMsg = "";
if (commitMap.size() > 1) {
errorMsg = (String) commitMap.get(0).get("StatusName") + ";"
+ (String) commitMap.get(1).get("StatusName");
} else {
errorMsg = (String) commitMap.get(0).get("StatusName");
}
return Rjx.jsonErr().setMessage(errorMsg).set("errorMsg", errorMsg).setData(commitMap).toJson();
}
} catch (Exception e) {
e.printStackTrace();
logger.info("提交订单:{}, 发生异常: {}",GsonUtil.toJson(map),e);
return Rjx.jsonErr().set("errorMsg", e.getMessage())
.setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_error")).toJson();
}
}
@Override
public String paySubmitV2(Map<String, Object> map) {
String shopNO = map.get("shopNO")+"";
String salesOrderID = map.get("salesOrderID")+"";
String ipaddress = map.get("ipaddress")+"";
String goodsList = map.get("goodsList")+"";
Date now = new Date();
//查询订单状态
String sqlOrderQuery = "select\r\n" +
" OrderStatus = nOrderStatus, OrderStatusName = sOrderStatusName,\r\n" +
" TotalRealSaleAmount = nTotalRealSaleAmount,\r\n" +
" TotalPayAmount = nTotalRealSaleAmount + ISNULL(nExpressFee,0),\r\n" +
" Status = case when nOrderStatus&1=1 then -2\r\n" +
" when nOrderStatus&32=32 then -2 else 0 end,\r\n" +
" ErrorMsg = case when nOrderStatus&1=1 then '该订单已被取消!'\r\n" +
" when nOrderStatus&32=32 then '该订单已付款!' else '未付款' end\r\n" +
" from tSalesOrder where sSalesOrderID = ? ";
Map<String,Object> orderStatusMap = jdbcTemplate.queryForMap(sqlOrderQuery,salesOrderID);
Integer OrderStatus = (Integer)orderStatusMap.get("Status");
if(OrderStatus != null) {
if(OrderStatus > 0) {
String ErrorMsg = orderStatusMap.get("ErrorMsg")+"";
return Rjx.jsonErr().setMessage(ErrorMsg).set("errorMsg", ErrorMsg).setData(orderStatusMap).toJson();
}else if(OrderStatus == 0) {
BigDecimal TotalRealSaleAmount = (BigDecimal)orderStatusMap.get("TotalRealSaleAmount");
String psql = "exec up_B2BQuerySalesOrderPay '"+salesOrderID+"'";
List<Map<String,Object>> payList = jdbcTemplate.executeMutil(psql).getDatas().get(0);
Map<String, Integer> sorts = new HashMap<String, Integer>();
sorts.put("81", 1);
sorts.put("882", 2);
sorts.put("103", 3);
sorts.put("112", 4);
sorts.put("1", 888888888);
sorts.put("120", 999999999);
sorts.put("121", 999999999);
sorts.put("122", 999999999);
sorts.put("170", 999999999);
sorts.put("130", 999999999);
sorts.put("900", 999999999);
sorts.put("901", 999999999);
sorts.put("902", 999999999);
sorts.put("903", 999999999);
payList.sort(new Comparator<Object>() {
public int compare(Object o1, Object o2) {
Map<?, ?> map1 = (Map<?, ?>)o1;
Map<?, ?> map2 = (Map<?, ?>)o2;
String PayTypeID1 = (String)map1.get("PayTypeID");
String PayTypeID2 = (String)map2.get("PayTypeID");
if(PayTypeID1 != null && PayTypeID2 != null) {
Integer s1 = sorts.get(PayTypeID1);
Integer s2 = sorts.get(PayTypeID2);
return s1.compareTo(s2);
}
return 0;
}
});
for(Map<String,Object> payObj : payList) {
String PayCardNO = (String)payObj.get("PayCardNO");
String PayTypeID = (String)payObj.get("PayTypeID");
BigDecimal PayAmount = (BigDecimal)payObj.get("PayAmount");
String OutTradeNO = (String)payObj.get("OutTradeNO");
BigDecimal PayPoint = (BigDecimal)payObj.get("PayPoint");
Date PayDateTime = (Date)payObj.get("PayDateTime");
if(PayDateTime == null) {
PayDateTime = now;
}
String posno = "999";
String cashier = PayCardNO;
String hostname = "localhost";
Number Tag = (Number)payObj.get("Tag");
OutParameter pOrderStatus = new OutParameter(Types.VARCHAR);
OutParameter pOrderStatusName = new OutParameter(Types.VARCHAR);
OutParameter pStatus = new OutParameter(Types.INTEGER);
OutParameter pErrorMsg = new OutParameter(Types.VARCHAR);
if(PayTypeID != null && Tag != null && ( PayTypeID.equals("81") || PayTypeID.equals("882") ) && Tag.intValue() == 0) { //优会券和提货券
crmService.couponVerification(shopNO, PayCardNO, salesOrderID, PayAmount, TotalRealSaleAmount, OutTradeNO, goodsList, cashier,"1",PayTypeID);
jdbcTemplate.exec("exec up_B2BSalesOrderPayConfirm ?, ?, ?, ?, ?, ?, ?, ?, ?, ?", new Object[] {salesOrderID, PayTypeID, PayAmount, PayCardNO, PayDateTime, OutTradeNO, pOrderStatus, pOrderStatusName, pStatus, pErrorMsg});
Integer rStatus = (Integer)pStatus.getValue();
String rErrorMsg = (String)pErrorMsg.getValue();
String rOrderStatus = (String)pOrderStatus.getValue();
if(rStatus <= 0 && rOrderStatus.equals("2")) {
payObj.put("Status", rStatus);
payObj.put("ErrorMsg", rErrorMsg);
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
return Rjx.jsonOk().setData(payObj).toJson();
} else if(rStatus > 0) {
payObj.put("Status", 1);
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
payObj.put("ErrorMsg", PayTypeID.equals("81") ? "优惠券核销确认异常" :"提货券核销确认异常" );
return Rjx.jsonOk().setData(payObj).toJson();
}
} else if(PayTypeID != null && Tag != null && PayTypeID.equals("103") && Tag.intValue() == 0) {
crmService.vUpdateMemPoint(0, shopNO, shopNO, PayPoint, OutTradeNO, cashier, hostname, ipaddress);
jdbcTemplate.exec("EXEC up_B2BSalesOrderPayConfirm ?, ?, ?, ?, ?, ?, ?, ?, ?, ?", new Object[] {salesOrderID, PayTypeID, PayAmount, PayCardNO, PayDateTime, OutTradeNO, pOrderStatus, pOrderStatusName, pStatus, pErrorMsg});
Integer rStatus = (Integer)pStatus.getValue();
String rErrorMsg = (String)pErrorMsg.getValue();
String rOrderStatus = (String)pOrderStatus.getValue();
if(rStatus <= 0 && rOrderStatus.equals("2")) {
payObj.put("Status", rStatus);
payObj.put("ErrorMsg", rErrorMsg);
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
return Rjx.jsonOk().setData(payObj).toJson();
} else if(rStatus > 0) {
payObj.put("Status", 1);
payObj.put("ErrorMsg", "积分扣减确认异常");
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
return Rjx.jsonOk().setData(payObj).toJson();
}
} else if(PayTypeID != null && Tag != null && PayTypeID.equals("112") && Tag.intValue() == 0) {
crmService.vCardPay(shopNO, shopNO, PayAmount, posno, OutTradeNO, cashier, hostname, ipaddress);
jdbcTemplate.exec("EXEC up_B2BSalesOrderPayConfirm ?, ?, ?, ?, ?, ?, ?, ?, ?, ?", new Object[] {salesOrderID, PayTypeID, PayAmount, PayCardNO, PayDateTime, OutTradeNO, pOrderStatus, pOrderStatusName, pStatus, pErrorMsg});
Integer rStatus = (Integer)pStatus.getValue();
String rErrorMsg = (String)pErrorMsg.getValue();
String rOrderStatus = (String)pOrderStatus.getValue();
if(rStatus <= 0 && rOrderStatus.equals("2")) {
payObj.put("Status", rStatus);
payObj.put("ErrorMsg", rErrorMsg);
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
return Rjx.jsonOk().setData(payObj).toJson();
} else if(rStatus > 0) {
payObj.put("Status", 1);
payObj.put("ErrorMsg", "储值余额支付确认异常");
payObj.put("OrderStatus", rOrderStatus);
payObj.put("OrderStatusName", pOrderStatusName.getValue());
return Rjx.jsonOk().setData(payObj).toJson();
}
} else if(PayTypeID != null && Tag != null && Tag.intValue() == 0 && (PayTypeID.equals("120") ||PayTypeID.equals("121") || PayTypeID.equals("170") || PayTypeID.equals("122") || PayTypeID.equals("130") || PayTypeID.equals("900") || PayTypeID.equals("901") || PayTypeID.equals("902") || PayTypeID.equals("903"))) {
payObj.putAll(jdbcTemplate.queryForMap(sqlOrderQuery, salesOrderID));
return Rjx.jsonOk().setData(payObj).toJson();
}
}
return Rjx.jsonOk().setData(orderStatusMap).toJson();
}
}
return Rjx.jsonErr().setMessage("订单错误").set("errorMsg", "订单错误").toJson();
}
} }
package com.egolm.shop.common.config;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.egolm.common.HttpUtil;
import com.egolm.common.StringUtil;
@Component
public class CrmClient {
@Value("${crm.baseUrl}")
private String baseUrl;
@Value("${crm.appid}")
private String appid;
@Value("${crm.secret}")
private String secret;
private static final Log log = LogFactory.getLog(CrmClient.class);
public String post(String url, Map<String, Object> parameters) {
for(String key : parameters.keySet()) {
Object val = parameters.get(key);
if(val == null) {
parameters.put(key, "");
}
}
String requestUrl = this.baseUrl + "/" + url;
log.debug("RequestUrl: " + requestUrl);
String timestamp = String.valueOf(System.currentTimeMillis()/1000L);
parameters.put("appid", this.appid);
parameters.put("timestamp", timestamp);
Map<String, Object> signMap = new TreeMap<String, Object>(parameters);
String queryString = HttpUtil.formatToQueryString(signMap) + "&APP_SECRET=" + this.secret;
log.debug("SignQueryString: " + queryString);
String md5String = StringUtil.toMD5HexString(queryString);
parameters.put("sign", md5String);
//String result = HttpCommon.post(requestUrl, parameters);
String result = HttpUtil.post(requestUrl, parameters);
log.debug("Result: " + result);
return result;
}
public String get(String url, Map<String, Object> parameters) {
for(String key : parameters.keySet()) {
Object val = parameters.get(key);
if(val == null) {
parameters.put(key, "");
}
}
String requestUrl = this.baseUrl + "/" + url;
log.debug("RequestUrl: " + requestUrl);
String timestamp = String.valueOf(System.currentTimeMillis()/1000L);
parameters.put(appid, this.appid);
parameters.put(timestamp, timestamp);
Map<String, Object> signMap = new TreeMap<String, Object>(parameters);
String signString = HttpUtil.formatToQueryString(signMap) + "&APP_SECRET=" + this.secret;
log.debug("SignQueryString: " + signString);
String md5String = StringUtil.toMD5HexString(signString);
parameters.put("sign", md5String);
String result = HttpUtil.get(requestUrl, parameters);
log.debug("Result: " + result);
return result;
}
public static void main(String[] args) {
String appid = "d30cde80e5ac42479c5551a5c00f3717";
String secret = "d0ca67eebe6c4c53996b9b310999fccd";
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("beginpoint", "0");
parameters.put("cardno", "8800168722");
parameters.put("cashier", "wxuser");
parameters.put("hostname", "wxhost");
parameters.put("ipaddress", "127.0.0.1");
parameters.put("receiptid", "");
parameters.put("storeno", "E800");
parameters.put("tradetime", "2020-07-15 17:45:00");
parameters.put("tradetype", "2");
parameters.put("updatepoint", "-250.00");
parameters.put("timestamp", "1594806300");
parameters.put("appid", appid);
Map<String, Object> signMap = new TreeMap<String, Object>(parameters);
String queryString = HttpUtil.formatToQueryString(signMap) + "&APP_SECRET=" + secret;
System.out.println(queryString);
String md5String = StringUtil.toMD5HexString(queryString);
parameters.put("sign", md5String);
System.out.println(JSON.toJSONString(parameters));
}
}
logging.level.com.egolm=debug logging.level.com.egolm=debug
...@@ -101,8 +101,9 @@ log.datasource.filters=stat,log4j ...@@ -101,8 +101,9 @@ log.datasource.filters=stat,log4j
crm.baseUrl: https://dev.linkfern.com/b2b-crm/
crm.appid: d30cde80e5ac42479c5551a5c00f3717
crm.secret: d0ca67eebe6c4c53996b9b310999fccd
opt.express.url=https://service-5ptj62bx-1257101137.ap-shanghai.apigateway.myqcloud.com/release/express/query opt.express.url=https://service-5ptj62bx-1257101137.ap-shanghai.apigateway.myqcloud.com/release/express/query
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<el-divider content-position="left">V1.1.7.8.4 2024-9-18</el-divider>
<p class="title">1.需求 #17402</p>
<el-divider content-position="left">V1.1.7.8.3 2024-8-23</el-divider> <el-divider content-position="left">V1.1.7.8.3 2024-8-23</el-divider>
<p class="title">1.需求 #17240</p> <p class="title">1.需求 #17240</p>
<p class="title">2. 订单提交增加参数,需求 #17203,需求 #17271</p> <p class="title">2. 订单提交增加参数,需求 #17203,需求 #17271</p>
......
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