Commit 2045babd authored by 张永's avatar 张永

111

parent 957e7cd5
...@@ -175,6 +175,42 @@ public class OrderController { ...@@ -175,6 +175,42 @@ public class OrderController {
map.put("trace_id", trace_id); map.put("trace_id", trace_id);
return orderService.paySubmitV2(map); return orderService.paySubmitV2(map);
} }
@ApiOperation("B2B订单补款(分账支付170)")
@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 = "subOrderID", dataType = "String", required = true, value = "子订单号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/payDebtSubmit",method=RequestMethod.POST)
@IDCLogResource(name="B2B订单补款(分账支付170)")
public String payDebtSubmit(HttpServletRequest request) {
String langID = request.getParameter("langID");
String shopNO = request.getParameter("shopNO");
String subOrderID = request.getParameter("subOrderID");
String trace_id = request.getAttribute("trace_id")+"";
if(!StringUtil.isNotEmpty(shopNO,subOrderID)) {
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("subOrderID", subOrderID);
map.put("ipaddress", ServletUtil.remoteIp(request));
map.put("trace_id", trace_id);
return orderService.payDebtSubmit(map);
}
@ApiOperation("获取主订单列表") @ApiOperation("获取主订单列表")
@ApiImplicitParams({ @ApiImplicitParams({
......
...@@ -20,6 +20,8 @@ public interface OrderService { ...@@ -20,6 +20,8 @@ public interface OrderService {
public String paySubmitV2(Map<String,Object> map); public String paySubmitV2(Map<String,Object> map);
public String payDebtSubmit(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);
......
...@@ -1969,4 +1969,96 @@ public class OrderServiceImpl implements OrderService { ...@@ -1969,4 +1969,96 @@ public class OrderServiceImpl implements OrderService {
return Rjx.jsonErr().setMessage("订单错误").set("errorMsg", "订单错误").toJson(); return Rjx.jsonErr().setMessage("订单错误").set("errorMsg", "订单错误").toJson();
} }
//补款170
public String payDebtSubmit(Map<String,Object> map) {
String shopNO = map.get("shopNO")+"";
String trace_id = map.get("trace_id")+"";
String subOrderID = map.get("subOrderID")+"";
String resultSql = "select OrderStatus = nOrderStatus, \r\n" +
" OrderStatusName = nOrderStatusName, \r\n" +
" DebtAmount = nDebtAmount, \r\n" +
" Status = case when nOrderStatus&1=1 then -2 when nOrderStatus&8192=8192 then -2 else 0 end, \r\n" +
" ErrorMsg = case when nOrderStatus&1=1 then '该订单已被取消!' when nOrderStatus&8192=8192 then '该订单已付款!' else '未付款' end \r\n" +
" from tSalesOrderSub \r\n" +
" where sSubOrderID = ?";
String sqlAll = "exec up_B2BQuerySalesOrderPay '"+subOrderID+"'";
List<Map<String, Object>> resultMap = jdbcTemplate.executeMutil(sqlAll).getDatas().get(0);
String lcswcbdkTimesSql = "SELECT sValue4 FROM tSystemCtrl WHERE sCode = 'LcswCBKMasterAccount'"; //扫呗分账重试次数
int cbkTimes = 3;
try {
cbkTimes = jdbcTemplate.queryForInt(lcswcbdkTimesSql);
}catch (Exception e) {
}
if(resultMap != null && resultMap.size() >0) {
for(Map<String,Object> pmap : resultMap) {
String payTypeID = pmap.get("PayTypeID")+"";
String transTraceNO = pmap.get("TransTraceNO")+"";
if(payTypeID.equals("170") && StringUtil.isEmpty(transTraceNO)) {
String account_out = pmap.get("CBKAccountOut")+""; //出账方
String account_in = pmap.get("CBKAccountIn")+""; //入账方
String come_from = "shop";
String appId = pmap.get("AppID")+"";
String agentID = pmap.get("AgentID")+"";
String outTradeNO = pmap.get("OutTradeNO")+"";
BigDecimal PayAmount = (BigDecimal)pmap.get("PayAmount");
BigDecimal pay_bd = new BigDecimal("100"); //表里为正数
int total_fee = PayAmount.multiply(pay_bd).intValue(); //支付金额分
Map<String,Object> params = new HashMap<String,Object>();
params.put("trade_no", outTradeNO);
params.put("total_fee",total_fee);
params.put("appId",appId);
params.put("order_body","补款支付分账");
params.put("account_in",account_in);
params.put("account_out",account_out);
params.put("come_from",come_from);
params.put("agentID",agentID);
params.put("onlinePayTypeId", payTypeID);
for(int ii = 1;ii<= cbkTimes ;ii++) { //需求 #17427 失败了遍历100次,
logger.info("订单号:{},第:{} 次进行扫呗补款分账支付 ,请求:{} ",subOrderID,ii,GsonUtil.toJson(pmap));
String cbkResult = payClient.post("/lcsw/fz_cbk_dotrans_f", params,map.get("trace_id")+"");
logger.info("订单号:{},第:{} 次进行扫呗补款分账支付 ,结果:{} ",subOrderID,ii,cbkResult);
JSONObject cbkJsonResult = JSONObject.parseObject(cbkResult);
if(cbkJsonResult.getBooleanValue("isValid")) {
String cbk_out_trade_no = cbkJsonResult.getString("out_trade_no"); //CBK的支付结果单号
String finish_time = cbkJsonResult.getString("finish_time"); //完成时间
String sql = "exec up_B2BSalesOrderDebtPayCallBack '" + outTradeNO + "' ,'" + cbk_out_trade_no + "' ,'', '" + PayAmount
+ "' , '" + finish_time + "' , '" + payTypeID + "' ,0,'' ";
List<Map<String, Object>> returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
String returnStr = GsonUtil.toJson(returnMap);
logger.info("订单号:{},第:{} 次进行扫呗补款分账支付成功 ,回写结果:{} ",subOrderID,ii,returnStr);
break;
}else {
try {
String statusName = cbkJsonResult.containsKey("err_code_des")?cbkJsonResult.getString("err_code_des"):cbkJsonResult.getString("message");
if(StringUtil.isBlank(statusName)) {
statusName = "补款分账支付失败.";
}
//支付失败
String sql = "exec up_B2BSalesOrderDebtPayCallBack '" + subOrderID + "' ,'','', '0' , '' , '" + payTypeID + "' ,1,'"+statusName+"' ";
List<Map<String, Object>> returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
String returnStr = GsonUtil.toJson(returnMap);
logger.info("订单号:{},第:{} 次进行扫呗分账支付失败 ,回写结果:{} ",subOrderID,ii,returnStr);
} catch (Exception e) {
logger.info("订单号:{},第:{} 次进行扫呗分账支付失败 ,回写结果异常:{} ",subOrderID,ii,e);
}
}
}
}
}
}
return Rjx.jsonOk().setData(jdbcTemplate.queryForMap(resultSql, subOrderID)).toJson();
}
} }
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