parent
1eec59a4c3
commit
ea35f8d545
@ -0,0 +1,245 @@ |
|||||||
|
package com.cweb.notify; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.channel.lakala.LaKaLaLedgerService; |
||||||
|
import com.hfkj.channel.lakala.LaKaLaWalletService; |
||||||
|
import com.hfkj.channel.llg.config.LLGConfig; |
||||||
|
import com.hfkj.channel.llg.util.AesUtil; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.hfkj.entity.*; |
||||||
|
import com.hfkj.service.*; |
||||||
|
import com.hfkj.sysenum.*; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.io.BufferedOutputStream; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 零零购通知 |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
@Controller |
||||||
|
@Api(value = "零零购通知") |
||||||
|
@RequestMapping(value = "/llgNotify") |
||||||
|
public class LLGController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(LLGController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsTradeOrderService tradeOrderService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsTradeOrderMsgService tradeOrderMsgService; |
||||||
|
@Resource |
||||||
|
private BsMerLedgerService merLedgerService; |
||||||
|
@Resource |
||||||
|
private BsMerLedgerApplyService merLedgerApplyService; |
||||||
|
@Resource |
||||||
|
private BsMerLedgerReceiverService merLedgerReceiverService; |
||||||
|
@Resource |
||||||
|
private BsMerLedgerReceiverApplyService merLedgerReceiverApplyService; |
||||||
|
@Resource |
||||||
|
private LaKaLaLedgerService laKaLaLedgerService; |
||||||
|
@Resource |
||||||
|
private LaKaLaWalletService laKaLaWalletService; |
||||||
|
|
||||||
|
@RequestMapping(value="/trade",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "交易通知") |
||||||
|
public void trade(@RequestBody String reqBody, HttpServletResponse response) { |
||||||
|
try { |
||||||
|
log.info("交易【被扫】通知", reqBody); |
||||||
|
System.out.println(reqBody); |
||||||
|
|
||||||
|
// 解密
|
||||||
|
String decryptData = AesUtil.aesDecrypt(LLGConfig.key, reqBody); |
||||||
|
|
||||||
|
JSONObject body = JSONObject.parseObject(decryptData); |
||||||
|
// 请求记录
|
||||||
|
BsTradeOrderMsg orderMsg = new BsTradeOrderMsg(); |
||||||
|
orderMsg.setOutTradeNo(body.getString("out_trade_no")); |
||||||
|
orderMsg.setType(TradeOrderMsgTypeEnum.type2.getNumber()); |
||||||
|
orderMsg.setResponseContent(reqBody); |
||||||
|
tradeOrderMsgService.editTradeOrderMsg(orderMsg); |
||||||
|
|
||||||
|
BsTradeOrder tradeOrder = tradeOrderService.getOrderByOutTradeNo(body.getString("orderId")); |
||||||
|
if (tradeOrder != null && body.getString("respCode").equals("00")) { |
||||||
|
tradeOrder.setPlatformTradeNo(body.getString("queryId")); |
||||||
|
tradeOrder.setPayTime(new Date()); |
||||||
|
tradeOrder.setStatus(TradeOrderStatusEnum.status3.getNumber()); |
||||||
|
tradeOrderService.editOrder(tradeOrder); |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("login error!",e); |
||||||
|
|
||||||
|
} finally { |
||||||
|
try { |
||||||
|
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); |
||||||
|
out.write("success".getBytes()); |
||||||
|
out.flush(); |
||||||
|
out.close(); |
||||||
|
} catch (Exception e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/applyLedgerMer",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "开通分账业务通知") |
||||||
|
public void applyLedgerMer(@RequestBody String reqBody) { |
||||||
|
try { |
||||||
|
log.info("开通分账业务通知", reqBody); |
||||||
|
System.out.println(reqBody); |
||||||
|
|
||||||
|
JSONObject respData = JSONObject.parseObject(reqBody); |
||||||
|
|
||||||
|
BsMerLedgerApply ledgerApply = merLedgerApplyService.getApplyByApplyId(respData.getString("applyId")); |
||||||
|
if (ledgerApply != null) { |
||||||
|
ledgerApply.setNotifyBody(reqBody); |
||||||
|
merLedgerApplyService.editMerLedgerApply(ledgerApply); |
||||||
|
|
||||||
|
// 查询商户分账信息
|
||||||
|
BsMerLedger merLedger = merLedgerService.getMerLedgerById(ledgerApply.getMerLedgerId()); |
||||||
|
if (merLedger != null) { |
||||||
|
// 审核状态 1:通过,2拒绝
|
||||||
|
if (respData.getString("auditStatus").equals("1")) { |
||||||
|
merLedger.setStatus(MerLedgerStatusEnum.status1.getNumber()); |
||||||
|
merLedgerService.editMerLedger(merLedger); |
||||||
|
// 延迟3秒
|
||||||
|
Thread.sleep(3000); |
||||||
|
|
||||||
|
// 提现通知地址
|
||||||
|
String notifyUrl = CommonSysConst.getSysConfig().getDomainName()+"/crest/merWithdrawal/notify?cupNo="+merLedger.getCupNo(); |
||||||
|
|
||||||
|
// 配置账户自动结算
|
||||||
|
laKaLaWalletService.ewalletSettleProfile(1,merLedger.getCupNo(), "02", "06", notifyUrl); |
||||||
|
|
||||||
|
// 配置分账接收方账户自动结算
|
||||||
|
laKaLaWalletService.ewalletSettleProfile(2,merLedger.getReceiverNo(), "02", "06", notifyUrl); |
||||||
|
|
||||||
|
} else { |
||||||
|
merLedger.setStatus(MerLedgerStatusEnum.status3.getNumber()); |
||||||
|
merLedger.setRejectReason(respData.getString("remark")); |
||||||
|
merLedgerService.editMerLedger(merLedger); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("login error!",e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/applyBindReceiver",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账关系绑定申请") |
||||||
|
public void applyBindReceiver(@RequestBody String reqBody) { |
||||||
|
try { |
||||||
|
log.info("分账关系绑定申请通知", reqBody); |
||||||
|
System.out.println(reqBody); |
||||||
|
|
||||||
|
JSONObject respData = JSONObject.parseObject(reqBody); |
||||||
|
|
||||||
|
// 分手接收方申请记录
|
||||||
|
BsMerLedgerReceiverApply receiverApply = merLedgerReceiverApplyService.getReceiverApplyByApplyId(respData.getString("applyId")); |
||||||
|
if (receiverApply != null) { |
||||||
|
receiverApply.setNotifyBody(reqBody); |
||||||
|
// 1:通过,2拒绝
|
||||||
|
receiverApply.setStatus( |
||||||
|
respData.getString("auditStatus").equals("1") |
||||||
|
?MerLedgerReceiverApplyStatusEnum.status2.getNumber() |
||||||
|
:MerLedgerReceiverApplyStatusEnum.status3.getNumber()); |
||||||
|
receiverApply.setRejectReason(respData.getString("remark")); |
||||||
|
merLedgerReceiverApplyService.editReceiverApply(receiverApply); |
||||||
|
|
||||||
|
// 分账接收方
|
||||||
|
BsMerLedgerReceiver ledgerReceiver = merLedgerReceiverService.getMerLedgerReceiver(receiverApply.getMerId(), receiverApply.getReceiverNo()); |
||||||
|
if (ledgerReceiver != null) { |
||||||
|
ledgerReceiver.setStatus( |
||||||
|
receiverApply.getStatus().equals( |
||||||
|
MerLedgerReceiverApplyStatusEnum.status2.getNumber()) |
||||||
|
?MerLedgerReceiverStatusEnum.status1.getNumber() |
||||||
|
:MerLedgerReceiverStatusEnum.status2.getNumber() |
||||||
|
); |
||||||
|
ledgerReceiver.setAuditStatus( |
||||||
|
receiverApply.getStatus().equals(MerLedgerReceiverApplyStatusEnum.status2.getNumber()) |
||||||
|
?MerLedgerReceiverAuditStatusEnum.status2.getNumber() |
||||||
|
:MerLedgerReceiverAuditStatusEnum.status3.getNumber() |
||||||
|
); |
||||||
|
ledgerReceiver.setRejectReason(receiverApply.getRejectReason()); |
||||||
|
merLedgerReceiverService.editMerLedgerReceiver(ledgerReceiver); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("login error!",e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/applyBindUnReceiver",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "分账关系绑定申请") |
||||||
|
public void applyBindUnReceiver(@RequestBody String reqBody) { |
||||||
|
try { |
||||||
|
log.info("分账关系绑定申请通知", reqBody); |
||||||
|
System.out.println(reqBody); |
||||||
|
|
||||||
|
JSONObject respData = JSONObject.parseObject(reqBody); |
||||||
|
|
||||||
|
// 分手接收方申请记录
|
||||||
|
BsMerLedgerReceiverApply receiverApply = merLedgerReceiverApplyService.getReceiverApplyByApplyId(respData.getString("applyId")); |
||||||
|
if (receiverApply != null) { |
||||||
|
receiverApply.setNotifyBody(reqBody); |
||||||
|
// 1:通过,2拒绝
|
||||||
|
receiverApply.setStatus( |
||||||
|
respData.getString("auditStatus").equals("1") |
||||||
|
?MerLedgerReceiverApplyStatusEnum.status2.getNumber() |
||||||
|
:MerLedgerReceiverApplyStatusEnum.status3.getNumber()); |
||||||
|
receiverApply.setRejectReason(respData.getString("auditStatusText")); |
||||||
|
merLedgerReceiverApplyService.editReceiverApply(receiverApply); |
||||||
|
|
||||||
|
// 分账接收方
|
||||||
|
BsMerLedgerReceiver ledgerReceiver = merLedgerReceiverService.getMerLedgerReceiver(receiverApply.getMerId(), receiverApply.getReceiverNo()); |
||||||
|
if (ledgerReceiver != null) { |
||||||
|
ledgerReceiver.setStatus( |
||||||
|
receiverApply.getStatus().equals( |
||||||
|
MerLedgerReceiverApplyStatusEnum.status2.getNumber()) |
||||||
|
?MerLedgerReceiverStatusEnum.status0.getNumber() |
||||||
|
:MerLedgerReceiverStatusEnum.status2.getNumber() |
||||||
|
); |
||||||
|
ledgerReceiver.setAuditStatus( |
||||||
|
receiverApply.getStatus().equals(MerLedgerReceiverApplyStatusEnum.status2.getNumber()) |
||||||
|
?MerLedgerReceiverAuditStatusEnum.status2.getNumber() |
||||||
|
:MerLedgerReceiverAuditStatusEnum.status5.getNumber() |
||||||
|
); |
||||||
|
ledgerReceiver.setRejectReason(receiverApply.getRejectReason()); |
||||||
|
merLedgerReceiverService.editMerLedgerReceiver(ledgerReceiver); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("login error!",e); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue