扫码王业务代码
This commit is contained in:
@@ -46,6 +46,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -388,7 +389,7 @@ public class MerchantOrderController {
|
||||
@ApiOperation(value = "会员充值", notes = "APP扫码-会员充值", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "MemberRechargeDTO", value = "MemberRechargeDTO", paramType = "MemberRechargeDTO", dataType = "MemberRechargeDTO", required = true)})
|
||||
public Result<Map<String, Object>> memberRecharge(@RequestBody MemberRechargeDTO memberRechargeDTO) {
|
||||
public Result<Map<String, Object>> memberRecharge(@RequestBody MemberRechargeDTO memberRechargeDTO, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
@@ -398,7 +399,7 @@ public class MerchantOrderController {
|
||||
memberRechargeDTO.setMerchantCode(userApp.getMerchantCode());
|
||||
memberRechargeDTO.setUserId(String.valueOf(userApp.getUserId()));
|
||||
memberRechargeDTO.setUserName(userApp.getUserName());
|
||||
return merchantOrderService.toMemberRecharge(memberRechargeDTO);
|
||||
return merchantOrderService.toMemberRecharge(memberRechargeDTO, request);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
MsgException.throwException(e.getMessage());
|
||||
@@ -417,7 +418,7 @@ public class MerchantOrderController {
|
||||
@ApiOperation(tags = {"页面-收款"}, value = "扫码支付", notes = "扫码支付", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "MerchantOrderVo", value = "扫码支付需要传递的参数实例", paramType = "body", dataType = "MerchantOrderVo", required = true)})
|
||||
public Result<Object> scanPay(@RequestBody MerChantOrderDTO merchantOrderDTO) {
|
||||
public Result<Object> scanPay(@RequestBody MerChantOrderDTO merchantOrderDTO, HttpServletRequest req) {
|
||||
UserApp tokenUa = userAppService.queryUserAppByToken();
|
||||
merchantOrderDTO.setMerchantCode(tokenUa.getMerchantCode());
|
||||
//校验金额
|
||||
@@ -425,7 +426,7 @@ public class MerchantOrderController {
|
||||
MsgException.throwException("金额异常");
|
||||
}
|
||||
try {
|
||||
return merchantOrderService.toActivePay(merchantOrderDTO);
|
||||
return merchantOrderService.toActivePay(merchantOrderDTO, req);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return ResultGenerator.genFailResult(e.getMessage());
|
||||
@@ -437,7 +438,7 @@ public class MerchantOrderController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/posScanPay")
|
||||
public Result<Object> posScanPay(@RequestBody MerChantOrderDTO merchantOrderDTO) {
|
||||
public Result<Object> posScanPay(@RequestBody MerChantOrderDTO merchantOrderDTO, HttpServletRequest request) {
|
||||
//首先验签
|
||||
verify(merchantOrderDTO.getTimestamp(), merchantOrderDTO.getRequestId(), merchantOrderDTO.getAppId(), merchantOrderDTO.getToken());
|
||||
//通过后查询商户信息
|
||||
@@ -451,7 +452,7 @@ public class MerchantOrderController {
|
||||
}
|
||||
//进行支付操作
|
||||
try {
|
||||
Result<Object> activePay = merchantOrderService.toActivePay(merchantOrderDTO);
|
||||
Result<Object> activePay = merchantOrderService.toActivePay(merchantOrderDTO, request);
|
||||
String result = activePay.toString();
|
||||
JSONObject jsonData = JSONObject.parseObject(result);
|
||||
Object orderNumber = jsonData.getJSONObject("data").get("orderNumber");
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
package cn.pluss.platform.controller.access;
|
||||
|
||||
import cn.pluss.platform.access.AccessService;
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
import cn.pluss.platform.access.exception.AccessException;
|
||||
import cn.pluss.platform.access.service.AccessBizService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RequestMapping("/access")
|
||||
@RestController
|
||||
public class AccessController {
|
||||
|
||||
@Autowired
|
||||
private AccessService accessService;
|
||||
|
||||
@Autowired
|
||||
private AccessBizService accessBizService;
|
||||
|
||||
@PostMapping("/storeInfoByDeviceNo")
|
||||
public RespEntity machineStoreInfo(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Object bizResult = accessBizService.machineStoreInfo(deviceNo);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/scanPay")
|
||||
public RespEntity scanPay(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.scanPay(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderStatus")
|
||||
public RespEntity orderStatus(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
String orderNumber = reqData.getString("orderNumber");
|
||||
String mercOrderNo = reqData.getString("mercOrderNo");
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.orderStatus(orderNumber, mercOrderNo);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderRefund")
|
||||
public RespEntity orderRefund(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.refund(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderRefundList")
|
||||
public RespEntity orderRefundList(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.refundList(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderList")
|
||||
public RespEntity orderList(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.orderList(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/dataAnalysis")
|
||||
public RespEntity dataAnalysis(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.dataAnalysis(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package cn.pluss.platform.interceptor;
|
||||
|
||||
import cn.pluss.platform.access.AccessService;
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.api.ResultCode;
|
||||
import cn.pluss.platform.constants.CommonError;
|
||||
@@ -10,14 +14,20 @@ import cn.pluss.platform.merchant.MerchantStaffConnService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.ComUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,6 +45,9 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
|
||||
@Resource
|
||||
private MerchantStaffConnService staffConnService;
|
||||
|
||||
@Autowired
|
||||
private AccessService accessService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String requestUri = request.getRequestURI();
|
||||
@@ -75,6 +88,46 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
|
||||
String contentType = request.getContentType();
|
||||
|
||||
|
||||
if (contentType != null
|
||||
&& contentType.contains("application/json")
|
||||
&& requestUri.startsWith("/api/access")) {
|
||||
StringBuilder responseStrBuilder = new StringBuilder();
|
||||
InputStream is = request.getInputStream();
|
||||
BufferedReader streamReader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||
String inputStr;
|
||||
while ((inputStr = streamReader.readLine()) != null) {
|
||||
responseStrBuilder.append(inputStr);
|
||||
}
|
||||
|
||||
ReqEntity reqEntity;
|
||||
try {
|
||||
reqEntity = JSON.toJavaObject(JSON.parseObject(responseStrBuilder.toString()), ReqEntity.class);
|
||||
} catch (Exception e) {
|
||||
RespEntity entity = new RespEntity(null, CodeEnum.PARAM_ERROR, null, null);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqEntity == null || reqEntity.getOrgId() == null) {
|
||||
RespEntity entity = new RespEntity(null, CodeEnum.ORG_ID_NOT_FOUND, null, null);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean signCheck = accessService.checkSign(reqEntity);
|
||||
|
||||
// 操作
|
||||
if (signCheck) {
|
||||
return true;
|
||||
} else {
|
||||
RespEntity entity = new RespEntity(reqEntity.getOrgId(), CodeEnum.SIGN_ERROR, null, reqEntity.getRequestId());
|
||||
accessService.addSign(entity);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
synchronized (this) {
|
||||
String requestToken = request.getHeader("token");
|
||||
// 登录账号
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ComUtil {
|
||||
public static boolean equalsIgnoreCase(String str1, String str2) {
|
||||
return str1 != null ? str1.equalsIgnoreCase(str2) : str2 == null;
|
||||
}
|
||||
|
||||
|
||||
public static String getIpAddress(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
@@ -165,7 +165,7 @@ public class ComUtil {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public static void responseResult(HttpServletResponse response, Result result) {
|
||||
public static void responseResult(HttpServletResponse response, Object result) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");
|
||||
response.setStatus(200);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.pluss.platform.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.pluss.platform.entity.AccessChannelCipherCode;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
public interface AccessChannelCipherCodeMapper extends BaseMapper<AccessChannelCipherCode> {
|
||||
|
||||
default AccessChannelCipherCode selectAllByOrgId(String orgId) {
|
||||
LambdaQueryWrapper<AccessChannelCipherCode> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.eq(AccessChannelCipherCode::getOrgId, orgId);
|
||||
|
||||
return selectOne(qWrapper);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.pluss.platform.entity.UserProfit;
|
||||
import cn.pluss.platform.vo.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -22,6 +23,14 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
|
||||
|
||||
@Select("SELECT SUM(mro.refundAmt) refundFee FROM tb_pluss_merchant_order mo LEFT JOIN \n" +
|
||||
"tb_pluss_merchant_refund_order mro ON (mo.orderNumber = mro.orderNumber OR mo.orderNumber = mro.refundNo)\n" +
|
||||
"WHERE mo.snNo = #{snNo} AND mo.`status` = '1' AND mro.`status` = '1' " +
|
||||
"AND mo.merchantCode = #{merchantCode} AND mro.refundTime LIKE CONCAT(#{date}, '%')")
|
||||
BigDecimal selectRefundAmt(@Param("merchantCode") String merchantCode, @Param("snNo") String snNo, @Param("date") String date);
|
||||
|
||||
Page<MerchantOrder> page(IPage<MerchantOrder> page, @Param("map") Map<String, Object> map, @Param("statusList") List<String> statusList);
|
||||
|
||||
/**
|
||||
* 统计一些数值的合计值
|
||||
* @return .
|
||||
@@ -37,43 +46,43 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
|
||||
Integer queryMerchantOrderPageCount(Map map);
|
||||
|
||||
void saveMerchantOrderBatch(List<MerchantOrder> merchantOrderList);
|
||||
|
||||
|
||||
/**
|
||||
* 可提现总金额(提现规则 超过一个月的时间)推广
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
Double sumMerchantAllowCashMoney(@Param(value = "memberCode") String memberCode);
|
||||
|
||||
|
||||
/**
|
||||
* 不可提现总金额(提现规则 不超过一个月)推广
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
Double sumMerchantNotAllowCashMoney(@Param(value = "memberCode") String memberCode);
|
||||
|
||||
|
||||
/**
|
||||
* 今日分润 推广
|
||||
* @param merchantCode
|
||||
* @return
|
||||
*/
|
||||
Double sumNowDayShareMoney(@Param(value = "memberCode") String merchantCode);
|
||||
|
||||
|
||||
/**
|
||||
* 累计总分润 推广
|
||||
* @return
|
||||
*/
|
||||
Double sumAllShareMoney(@Param(value = "memberCode") String memberCode);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 供 商户推广- 交易明细 接口使用
|
||||
* 供 商户推广- 交易明细 接口使用
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<MerchantOrder> queryMerchantOrderPageApp(Map map);
|
||||
|
||||
|
||||
/**
|
||||
* 供 商户推广- 交易明细 接口使用
|
||||
* @param map
|
||||
@@ -82,23 +91,23 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
|
||||
Integer queryMerchantOrderPageCountApp(Map map);
|
||||
|
||||
Integer queryMerchantOrderPageCountByTime(Map map);
|
||||
|
||||
|
||||
Double queryMerchantOrdeFeeByTime(Map map);
|
||||
|
||||
List<MerchantOrder> queryMerchantOrderPageByTime(Map map);
|
||||
|
||||
|
||||
/**
|
||||
* 汇总流水(manage)
|
||||
*/
|
||||
SummaryOfWaterVO querySummaryOfWater(Map map);
|
||||
|
||||
|
||||
/**
|
||||
* 订单退款信息
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
List<MerchantOrder> queryMerchantOrderRefundPage(Map map);
|
||||
|
||||
|
||||
/**
|
||||
* 订单退款统计
|
||||
* @param map
|
||||
@@ -107,111 +116,111 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
|
||||
Integer queryMerchantOrderRefundPageCount(Map map);
|
||||
|
||||
Double queryMerchantOrderShareMoney(Map map);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* queryOrderTask:(给wap端的定时任务使用的 暂定查3天内状态为5待支付的订单). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* queryOrderTask:(给wap端的定时任务使用的 暂定查3天内状态为5待支付的订单). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param merchantOrder
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
List<MerchantOrder> queryOrderTask(MerchantOrder merchantOrder);
|
||||
|
||||
|
||||
/**
|
||||
* 7日交易数统计
|
||||
* @param s
|
||||
* @param s
|
||||
*/
|
||||
List<OrderStatisticsVO> queryOrderStatistics(MerchantOrder s);
|
||||
|
||||
|
||||
/**
|
||||
* 支付通道统计
|
||||
* @param s
|
||||
* @param s
|
||||
*/
|
||||
List<PayTypeStatisticsVO> queryPayTypeStatistics(MerchantOrder s);
|
||||
|
||||
|
||||
|
||||
|
||||
Double queryMerchantOrderEnterFeeByTime(Map map);
|
||||
|
||||
|
||||
Double queryMerchantOrderShareMoneyByTime(Map map);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* queryMerchantOrderPageShuju:(最新统计订单方法). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* queryMerchantOrderPageShuju:(最新统计订单方法). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param map
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
List<MerchantMangeOrderVO> queryMerchantOrderPageShuju(Map<String, Object> map);
|
||||
|
||||
// List<MerchantMangeOrderVO> queryMerchantOrderNoPageShuju(Map<String, Object> map);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* queryMerchantOrderPageCountShuju:(最新统计订单方法). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* queryMerchantOrderPageCountShuju:(最新统计订单方法). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param map
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
Integer queryMerchantOrderPageCountShuju(Map<String, Object> map);
|
||||
|
||||
// Integer queryMerchantOrderNoPageCountShuju(Map<String, Object> map);
|
||||
/**
|
||||
*
|
||||
* querySumEarnings:(统计总的收益 根据时间). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* querySumEarnings:(统计总的收益 根据时间). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param map
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
List<MerchantMangeOrderVO> querySumEarnings(Map<String, Object> map);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* promoterSumCash:(推广员退关分润余额信息统计). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* promoterSumCash:(推广员退关分润余额信息统计). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param userId
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
PromoterSumVO promoterSumCash(@Param(value = "userId") Long userId);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* PlatformSum:(统计平台大屏的门店数量 商户数量 交易总额 交易笔数 会员数量 推广员数量 推广分润总额 粉丝奖励总额 收益总计). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
*
|
||||
* PlatformSum:(统计平台大屏的门店数量 商户数量 交易总额 交易笔数 会员数量 推广员数量 推广分润总额 粉丝奖励总额 收益总计). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
PlatformSumVO PlatformSum(@Param(value = "timeStatus") String timeStatus);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* sumConsumeFeebystoreId:(查询门店的今日流水 跟总流水). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
* sumConsumeFeebystoreId:(查询门店的今日流水 跟总流水). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @param storeId
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
StoreVO sumConsumeFeebystoreId(String storeId);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* sumConsumeFeebystoreId:(查询商户的今日流水 跟总流水). <br/>
|
||||
*
|
||||
*
|
||||
* sumConsumeFeebystoreId:(查询商户的今日流水 跟总流水). <br/>
|
||||
*
|
||||
* @author Administrator
|
||||
* @return
|
||||
* @return
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
StoreVO sumConsumeFeebymerchantCode(String merchantCode);
|
||||
@@ -222,7 +231,7 @@ public interface MerchantOrderMapper extends BaseMapper<MerchantOrder> {
|
||||
* @return
|
||||
*/
|
||||
Double getOrderFeeSum1(Map<String, Object> orderMap);
|
||||
|
||||
|
||||
Double getToDayTransSum1(Map<String, Object> orderMap);
|
||||
|
||||
@Select("SELECT SUM(consumeFee) fee, status FROM tb_pluss_merchant_order ${ew.customSqlSegment}")
|
||||
|
||||
@@ -15,6 +15,51 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="page" resultType="cn.pluss.platform.entity.MerchantOrder">
|
||||
SELECT
|
||||
IFNULL(mro.orderNumber, mo.orderNumber) orderNumber, mo.merchantCode, mo.merchantName, mo.payTypeCode,
|
||||
mo.thirdTransNo, mo.consumeFee, mo.createDt, mo.transDt, mo.staffCode, mo.staffName, mo.`status`,
|
||||
mo.enterFee, mo.remark, mo.updateTime, mo.rate, mo.mercOrderNo, mo.isRecharge, mo.snNo, mo.cashPlaceId,
|
||||
mo.settlementType, mo.drType, mro.refundAmt, mro.refundTime
|
||||
FROM
|
||||
tb_pluss_merchant_order mo
|
||||
LEFT JOIN tb_pluss_merchant_refund_order mro ON mo.merchantCode = mro.merchantCode
|
||||
AND (mo.orderNumber = mro.orderNumber OR mo.orderNumber = mro.refundNo) AND mo.`status` = '2'
|
||||
<where>
|
||||
<if test="map.merchantCode != null and map.merchantCode != ''">
|
||||
AND mo.merchantCode = #{map.merchantCode}
|
||||
</if>
|
||||
<if test="map.snNo != null and map.snNo != ''">
|
||||
AND mo.snNo = #{map.snNo}
|
||||
</if>
|
||||
<if test="map.createDate != null">
|
||||
AND (
|
||||
(mo.createDate LIKE CONCAT(#{map.createDate}, '%') AND mo.status = '1')
|
||||
OR (mro.refundTime LIKE CONCAT(#{map.createDate}, '%') AND mo.status IN ('2', '6'))
|
||||
)
|
||||
</if>
|
||||
<if test="map.startTime != null">
|
||||
AND (
|
||||
(mo.transTime > #{map.startTime} AND mo.status = '1')
|
||||
OR (mro.refundTime > #{map.startTime} AND mo.status IN ('2', '6'))
|
||||
)
|
||||
</if>
|
||||
<if test="map.endTime != null">
|
||||
AND (
|
||||
(mo.transTime < #{map.endTime} AND mo.status = '1')
|
||||
OR (mro.refundTime < #{map.endTime} AND mo.status IN ('2', '6'))
|
||||
)
|
||||
</if>
|
||||
<if test="statusList != null and statusList.size > 0">
|
||||
AND mo.`status` IN
|
||||
<foreach collection="statusList" item="item" close=")" separator="," open="(">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY mo.updateTime
|
||||
</select>
|
||||
|
||||
<select id="queryMerchantOrder"
|
||||
parameterType="cn.pluss.platform.entity.MerchantOrder"
|
||||
resultType="cn.pluss.platform.entity.MerchantOrder">
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.pluss.platform.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* CREATE TABLE `tb_pluss_access_channel_cipher_code` (
|
||||
* `id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
* `orgId` varchar(50) DEFAULT NULL COMMENT '机构号id',
|
||||
* `priKey` longtext COMMENT '私钥,用于返回(回调)数据签名;以及渠道数据解密',
|
||||
* `pubKey` longtext COMMENT '公钥加密,给到渠道接口数据加密',
|
||||
* `orgPubKey` longtext COMMENT '机构公钥',
|
||||
* `orgPriKey` longtext COMMENT '机构私钥,测试使用字段',
|
||||
* `createTime` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
* PRIMARY KEY (`id`) USING BTREE,
|
||||
* KEY `uniq` (`orgId`) USING BTREE
|
||||
* ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='接入渠道秘钥表';
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class AccessChannelCipherCode {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 平台私钥
|
||||
*/
|
||||
private String priKey;
|
||||
|
||||
/**
|
||||
* 平台公钥
|
||||
*/
|
||||
private String pubKey;
|
||||
|
||||
/**
|
||||
* 机构公钥
|
||||
*/
|
||||
private String orgPubKey;
|
||||
|
||||
/**
|
||||
* 机构私钥
|
||||
*/
|
||||
private String orgPriKey;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.pluss.platform.access;
|
||||
|
||||
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
|
||||
public interface AccessService {
|
||||
|
||||
boolean checkSign(ReqEntity reqEntity);
|
||||
|
||||
void addSign(RespEntity respEntity);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.pluss.platform.access.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CodeEnum {
|
||||
|
||||
SUCCESS("0000", "操作成功"),
|
||||
|
||||
PARAM_ERROR("0001", "参数不正确"),
|
||||
|
||||
SIGN_ERROR("0002", "签名校验异常"),
|
||||
|
||||
ORG_ID_NOT_FOUND("0003", "缺少机构ID"),
|
||||
|
||||
STORE_NOT_FOUND("1001", "未找到机具"),
|
||||
|
||||
ORDER_NOT_FOUND("2001", "未找到订单"),
|
||||
|
||||
ORDER_REFUND_ERROR("2002", "订单退款异常"),
|
||||
|
||||
REFUND_ORDER_NOT_FOUND("2003", "未找到退款订单"),
|
||||
|
||||
PASSWORD_NOT_INIT("2011", "安全密码未初始化,请前往收银呗APP进行初始化"),
|
||||
PASSWORD_ERROR("2021", "安全密码错误,若忘记密码,可前往收银呗APP进行重置"),
|
||||
;
|
||||
|
||||
private final String val;
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.pluss.platform.access.domain;
|
||||
|
||||
import cn.pluss.platform.access.exception.AccessException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class ReqEntity {
|
||||
|
||||
private String orgId;
|
||||
|
||||
private String requestId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String timestamp;
|
||||
|
||||
private String reqData;
|
||||
|
||||
public JSONObject initJSONData() {
|
||||
if (reqData == null) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR);
|
||||
}
|
||||
return JSON.parseObject(reqData);
|
||||
}
|
||||
|
||||
private String signType;
|
||||
|
||||
private String sign;
|
||||
|
||||
public static String getSignContent(ReqEntity entity) {
|
||||
return "orgId=" + entity.getOrgId() + "&" +
|
||||
"reqData=" + entity.getReqData() + "&" +
|
||||
"requestId=" + entity.getRequestId() + "&" +
|
||||
"signType=" + entity.getSignType() + "&" +
|
||||
"timestamp=" + entity.getTimestamp() + "&" +
|
||||
"version=" + entity.getVersion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.pluss.platform.access.domain;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class RespEntity {
|
||||
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String respData;
|
||||
|
||||
private String sign;
|
||||
|
||||
private String signType;
|
||||
|
||||
private String orgId;
|
||||
|
||||
private String requestId;
|
||||
|
||||
public RespEntity(String orgId, CodeEnum codeEnum, Object respData, String requestId) {
|
||||
this(orgId, codeEnum, respData, requestId, null);
|
||||
}
|
||||
|
||||
public RespEntity(String orgId, String code, Object respData, String requestId) {
|
||||
this(orgId, code, respData, requestId, null);
|
||||
}
|
||||
|
||||
public RespEntity(String orgId, CodeEnum codeEnum, Object respData, String requestId, String msg) {
|
||||
this.code = codeEnum.getVal();
|
||||
this.requestId = requestId;
|
||||
if (!ObjectUtils.isEmpty(msg)) {
|
||||
this.msg = msg;
|
||||
} else {
|
||||
this.msg = codeEnum.getDesc();
|
||||
}
|
||||
|
||||
this.signType = "RSA";
|
||||
this.respData = JSON.toJSONString(respData, (ValueFilter) (object, name, value) -> {
|
||||
if (value instanceof BigDecimal) {
|
||||
return ((BigDecimal) value).toPlainString();
|
||||
}
|
||||
|
||||
if (value instanceof Double || value instanceof Float) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
public RespEntity(String orgId, String code, Object respData, String requestId, String msg) {
|
||||
this.code = code;
|
||||
this.requestId = requestId;
|
||||
this.msg = msg;
|
||||
this.signType = "RSA";
|
||||
this.respData = JSON.toJSONString(respData, (ValueFilter) (object, name, value) -> {
|
||||
if (value instanceof BigDecimal) {
|
||||
return ((BigDecimal) value).toPlainString();
|
||||
}
|
||||
|
||||
if (value instanceof Double || value instanceof Float) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
public static String getSignContent(RespEntity entity) {
|
||||
String signContent = "code=" + entity.getCode() + "&"
|
||||
+ "msg=" + entity.getMsg() + "&"
|
||||
+ "orgId=" + entity.getOrgId() + "&"
|
||||
+ "requestId=" + entity.getRequestId() + "&";
|
||||
|
||||
if (entity.getRespData() != null) {
|
||||
signContent += "respData=" + entity.getRespData() + "&";
|
||||
}
|
||||
|
||||
signContent += "signType=" + entity.getSignType();
|
||||
|
||||
return signContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.pluss.platform.access.exception;
|
||||
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class AccessException extends RuntimeException {
|
||||
|
||||
private String code;
|
||||
|
||||
public AccessException(CodeEnum codeEnum, String msg) {
|
||||
super(ObjectUtils.isEmpty(msg)? codeEnum.getDesc(): msg);
|
||||
this.code = codeEnum.getVal();
|
||||
}
|
||||
|
||||
public AccessException(CodeEnum codeEnum) {
|
||||
this(codeEnum, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.pluss.platform.access.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AccessBizService {
|
||||
|
||||
Object machineStoreInfo(String snNo);
|
||||
|
||||
Object scanPay(JSONObject param);
|
||||
|
||||
Object orderStatus(String orderNum, String mercOrderNo);
|
||||
|
||||
Object refund(JSONObject param);
|
||||
|
||||
<T> List<T> refundList(JSONObject param);
|
||||
|
||||
Page<Object> orderList(JSONObject param);
|
||||
|
||||
Object dataAnalysis(JSONObject param);
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
package cn.pluss.platform.access.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import cn.pluss.platform.access.exception.AccessException;
|
||||
import cn.pluss.platform.access.service.AccessBizService;
|
||||
import cn.pluss.platform.api.ResultGenerator;
|
||||
import cn.pluss.platform.deviceStock.DeviceStockService;
|
||||
import cn.pluss.platform.dto.MerChantOrderDTO;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.mapper.MerchantChannelStatusMapper;
|
||||
import cn.pluss.platform.merchant.MerchantBaseInfoService;
|
||||
import cn.pluss.platform.merchantOrder.MerchantOrderService;
|
||||
import cn.pluss.platform.merchantStore.MerchantStoreService;
|
||||
import cn.pluss.platform.pay.ApiPayService;
|
||||
import cn.pluss.platform.pay.PayService;
|
||||
import cn.pluss.platform.refundOrder.MerchantRefundOrderService;
|
||||
import cn.pluss.platform.ryx.pay.RyxPayService;
|
||||
import cn.pluss.platform.sxf.pay.SxfPayService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class AccessBizServiceImpl implements AccessBizService {
|
||||
|
||||
@Autowired
|
||||
private DeviceStockService deviceStockService;
|
||||
|
||||
@Autowired
|
||||
private MerchantBaseInfoService mbiService;
|
||||
|
||||
@Autowired
|
||||
private MerchantOrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private MerchantStoreService merchantStoreService;
|
||||
|
||||
@Resource
|
||||
private MerchantChannelStatusMapper mcsMapper;
|
||||
|
||||
@Autowired
|
||||
private SxfPayService sxfPayService;
|
||||
|
||||
@Autowired
|
||||
private RyxPayService ryxPayService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ysPayOldService")
|
||||
private PayService ysPayOldService;
|
||||
|
||||
@Autowired
|
||||
private ApiPayService apiPayService;
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
private MerchantRefundOrderService refundOrderService;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private MerchantBaseInfo getByDeviceNo(String deviceNo) {
|
||||
DeviceStock deviceStock = deviceStockService.getDevicebyNo(deviceNo);
|
||||
if (deviceStock == null) {
|
||||
deviceStock = deviceStockService.getDeviceBySnNo(deviceNo);
|
||||
}
|
||||
|
||||
if (deviceStock == null || !"3".equals(deviceStock.getStatus())) {
|
||||
throw new AccessException(CodeEnum.STORE_NOT_FOUND);
|
||||
}
|
||||
|
||||
MerchantBaseInfo mbi = mbiService.getById(deviceStock.getActMercId());
|
||||
|
||||
if (mbi == null) {
|
||||
throw new AccessException(CodeEnum.STORE_NOT_FOUND);
|
||||
}
|
||||
|
||||
return mbi;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object machineStoreInfo(String deviceNo) {
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
DeviceStock deviceStock = deviceStockService.getDevicebyNo(deviceNo);
|
||||
if (deviceStock == null) {
|
||||
deviceStock = deviceStockService.getDeviceBySnNo(deviceNo);
|
||||
}
|
||||
|
||||
// 未入库
|
||||
result.put("status", "-3");
|
||||
result.put("remark", "机具未入库");
|
||||
|
||||
if (deviceStock == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 未绑定商户
|
||||
result.put("status", "-2");
|
||||
result.put("remark", "未绑定商户");
|
||||
|
||||
if (!"3".equals(deviceStock.getStatus())) {
|
||||
return result;
|
||||
} else {
|
||||
result.put("status", "-1");
|
||||
result.put("remark", "未获取到商户信息");
|
||||
}
|
||||
|
||||
String actMercId = deviceStock.getActMercId();
|
||||
if (ObjectUtils.isEmpty(actMercId)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
MerchantBaseInfo mbi = mbiService.getById(actMercId);
|
||||
|
||||
if (mbi == null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 已绑定商户
|
||||
result.put("status", "1");
|
||||
result.put("remark", "商户信息获取成功");
|
||||
result.put("merchantName", mbi.getMerchantName());
|
||||
result.put("alias", mbi.getAlias());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object scanPay(JSONObject param) {
|
||||
String authCode = param.getString("authCode");
|
||||
BigDecimal consumeFee = param.getBigDecimal("consumeFee");
|
||||
String type = param.getString("type");
|
||||
String deviceNo = param.getString("deviceNo");
|
||||
String remark = param.getString("remark");
|
||||
String mercOrderNo = param.getString("mercOrderNo");
|
||||
|
||||
// 必传参数
|
||||
if (ObjectUtils.isEmpty(authCode)
|
||||
|| ObjectUtils.isEmpty(consumeFee)
|
||||
|| ObjectUtils.isEmpty(type)
|
||||
|| ObjectUtils.isEmpty(deviceNo)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR);
|
||||
}
|
||||
|
||||
MerchantBaseInfo mbi = getByDeviceNo(deviceNo);
|
||||
MerchantStore merchantStore = merchantStoreService.getStoreByMerchantCode(mbi.getMerchantCode());
|
||||
|
||||
MerChantOrderDTO dto = new MerChantOrderDTO();
|
||||
dto.setType(type);
|
||||
dto.setConsumeFee(consumeFee.doubleValue());
|
||||
dto.setAuthCode(authCode);
|
||||
dto.setUserId(mbi.getUserId());
|
||||
dto.setDeviceNo(deviceNo);
|
||||
dto.setStoreId(merchantStore.getStoreId());
|
||||
dto.setMerchantCode(mbi.getMerchantCode());
|
||||
dto.setRemark(remark);
|
||||
dto.setMercOrderNo(mercOrderNo);
|
||||
|
||||
return orderService.toActivePayV2(dto, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object orderStatus(String orderNum, String mercOrderNo) {
|
||||
// 校验参数是否完整
|
||||
if (ObjectUtils.isEmpty(orderNum) && ObjectUtils.isEmpty(mercOrderNo)) {
|
||||
return ResultGenerator.genFailResult("订单号不能为空");
|
||||
}
|
||||
|
||||
QueryWrapper<MerchantOrder> queryWrapper = new QueryWrapper<MerchantOrder>()
|
||||
.eq(!ObjectUtils.isEmpty(orderNum), "orderNumber", orderNum)
|
||||
.eq(!ObjectUtils.isEmpty(mercOrderNo), "mercOrderNo", mercOrderNo);
|
||||
|
||||
MerchantOrder order = orderService.getOne(queryWrapper);
|
||||
if (order == null) {
|
||||
throw new AccessException(CodeEnum.ORDER_NOT_FOUND);
|
||||
}
|
||||
//支付成功
|
||||
if ("1".equals(order.getStatus())) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", "1");
|
||||
result.put("orderNumber", order.getOrderNumber());
|
||||
result.put("mercOrderNo", order.getMercOrderNo());
|
||||
result.put("transTime", DateUtil.format(order.getCreateDt(), DatePattern.NORM_DATETIME_FORMAT));
|
||||
result.put("consumeFee", order.getConsumeFee());
|
||||
result.put("payType", order.getPayTypeCode());
|
||||
|
||||
return result;
|
||||
}
|
||||
String aisleSwitch = order.getAisleSwitch();
|
||||
MerchantChannelStatus channel = null;
|
||||
switch (aisleSwitch) {
|
||||
case "2":
|
||||
channel = mcsMapper.getByMerchantCode(order.getMerchantCode(), 1);
|
||||
break;
|
||||
default:
|
||||
channel = mcsMapper.getByMerchantCode(order.getMerchantCode(), Integer.valueOf(aisleSwitch));
|
||||
break;
|
||||
}
|
||||
if (channel != null) {
|
||||
JSONObject result = null;
|
||||
switch (channel.getChannel()) {
|
||||
case 1:
|
||||
result = sxfPayService.tradeQuery(order, channel.getMerchantId());
|
||||
break;
|
||||
case 3:
|
||||
result = ryxPayService.tradeQuery(order, channel.getMerchantId());
|
||||
break;
|
||||
case 4:
|
||||
result = ysPayOldService.tradeQuery(order, channel.getMerchantId());
|
||||
break;
|
||||
}
|
||||
if (result != null) {
|
||||
orderService.updateOrderStatus(result, order);
|
||||
String status = result.getString("payStatus");
|
||||
if ("1".equals(status)) {
|
||||
order.setStatus("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", order.getStatus());
|
||||
result.put("orderNumber", order.getOrderNumber());
|
||||
result.put("mercOrderNo", order.getMercOrderNo());
|
||||
result.put("transTime", DateUtil.format(order.getCreateDt(), DatePattern.NORM_DATETIME_FORMAT));
|
||||
result.put("consumeFee", order.getConsumeFee());
|
||||
result.put("payType", order.getPayTypeCode());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object refund(JSONObject param) {
|
||||
String deviceNo = param.getString("deviceNo");
|
||||
String orderNumber = param.getString("orderNumber");
|
||||
param.put("thirdSendNo", param.getString("channelTransNo"));
|
||||
BigDecimal refundAmt = param.getBigDecimal("refundAmt");
|
||||
String refundFlag = param.getString("refundFlag");
|
||||
// String pwd = param.getString("pwd");
|
||||
|
||||
MerchantBaseInfo mbi = getByDeviceNo(deviceNo);
|
||||
// UserInfo userInfo = userInfoService.getById(mbi.getUserId());
|
||||
|
||||
// if (ObjectUtils.isEmpty(pwd)) {
|
||||
// throw new AccessException(CodeEnum.PARAM_ERROR, "安全密码不能为空");
|
||||
// }
|
||||
|
||||
// String payPassword = userInfo.getPayPassword();
|
||||
// if (payPassword == null) {
|
||||
// throw new AccessException(CodeEnum.PASSWORD_NOT_INIT);
|
||||
// }
|
||||
//
|
||||
// if (!payPassword.equalsIgnoreCase(MD5Util.MD5Encode(pwd, "utf-8"))) {
|
||||
// throw new AccessException(CodeEnum.PASSWORD_ERROR);
|
||||
// }
|
||||
|
||||
param.put("merchant", mbi);
|
||||
|
||||
if (!"1".equals(refundFlag)) {
|
||||
if (ObjectUtils.isEmpty(refundAmt)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "未选择全额退款时,退款金额不能为空");
|
||||
}
|
||||
|
||||
if (!StringUtil.isNumber(param.getString("refundAmt"))) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "退款金额格式有误,小数点保留后两位");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = apiPayService.apiRefundPay(param);
|
||||
jsonObject.remove("sign");
|
||||
return jsonObject;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new AccessException(CodeEnum.ORDER_REFUND_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> refundList(JSONObject param) {
|
||||
String deviceNo = param.getString("deviceNo");
|
||||
|
||||
String orderNumber = param.getString("orderNumber");
|
||||
String mercOrderNo = param.getString("mercOrderNo");
|
||||
String thirdTransNo = param.getString("thirdTransNo");
|
||||
String channelTransNo = param.getString("channelTransNo");
|
||||
|
||||
String refundNo = param.getString("refundNo");
|
||||
String mercRefundNo = param.getString("mercRefundNo");
|
||||
|
||||
if (ObjectUtils.isEmpty(deviceNo)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "缺少设备编号");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(orderNumber)
|
||||
&& ObjectUtils.isEmpty(mercOrderNo)
|
||||
&& ObjectUtils.isEmpty(thirdTransNo)
|
||||
&& ObjectUtils.isEmpty(channelTransNo)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "缺少原交易订单号");
|
||||
}
|
||||
|
||||
MerchantBaseInfo mbi = getByDeviceNo(deviceNo);
|
||||
LambdaQueryWrapper<MerchantRefundOrder> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.eq(!ObjectUtils.isEmpty(orderNumber), MerchantRefundOrder::getOrderNumber, orderNumber);
|
||||
qWrapper.eq(!ObjectUtils.isEmpty(refundNo), MerchantRefundOrder::getRefundNo, refundNo);
|
||||
qWrapper.eq(MerchantRefundOrder::getMerchantCode, mbi.getMerchantCode());
|
||||
qWrapper.eq(!ObjectUtils.isEmpty(mercRefundNo), MerchantRefundOrder::getMercRefundNo, mercRefundNo);
|
||||
qWrapper.orderByDesc(MerchantRefundOrder::getRefundTime);
|
||||
|
||||
List<MerchantRefundOrder> refundOrderList = refundOrderService.list(qWrapper);
|
||||
|
||||
if (CollectionUtil.isEmpty(refundOrderList)) {
|
||||
throw new AccessException(CodeEnum.REFUND_ORDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
|
||||
for (MerchantRefundOrder item : refundOrderList) {
|
||||
JSONObject jsonItem = new JSONObject();
|
||||
jsonItem.put("orderNumber", item.getOrderNumber());
|
||||
jsonItem.put("refundNo", item.getRefundNo());
|
||||
jsonItem.put("mercRefundNo", item.getMercRefundNo());
|
||||
jsonItem.put("refundTime", DateUtil.format(item.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
jsonItem.put("status", item.getStatus());
|
||||
jsonItem.put("oPayAmt", item.getPayAmt());
|
||||
jsonItem.put("refundAmt", item.getRefundAmt());
|
||||
jsonItem.put("payType", item.getPayTypeCode());
|
||||
|
||||
result.add(jsonItem);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Object> orderList(JSONObject param) {
|
||||
String deviceNo = param.getString("deviceNo");
|
||||
Integer page = param.getInteger("page");
|
||||
Integer size = param.getInteger("size");
|
||||
String date = param.getString("date");
|
||||
// 1: 日; 2: 月
|
||||
String type = param.getString("type");
|
||||
|
||||
Map<String, Object> condition = new HashMap<>();
|
||||
condition.put("createDate", date);
|
||||
condition.put("snNo", deviceNo);
|
||||
|
||||
List<String> statusList = CollectionUtil.list(false, "1", "2", "6");
|
||||
|
||||
IPage<MerchantOrder> pageInfo = new Page<>(page, size);
|
||||
|
||||
if (ObjectUtils.isEmpty(type)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "类型不能为空");
|
||||
}
|
||||
|
||||
if (!ArrayUtil.contains(new String[]{"1", "2"}, type)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "类型只能为1(日)或者2(月)");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(date)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "日期不能为空");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(page)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "页码不能为空");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(size)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "页长不能为空");
|
||||
}
|
||||
|
||||
if (size > 1000) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "查询单次不能超过1000条");
|
||||
}
|
||||
|
||||
MerchantBaseInfo mbi = getByDeviceNo(deviceNo);
|
||||
|
||||
condition.put("merchantCode", mbi.getMerchantCode());
|
||||
orderService.pageData(pageInfo, condition, statusList);
|
||||
|
||||
Page<Object> resultPage = new Page<>(page, size);
|
||||
resultPage.setTotal(pageInfo.getTotal());
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (MerchantOrder item : pageInfo.getRecords()) {
|
||||
JSONObject orderItem = new JSONObject();
|
||||
orderItem.put("orderNumber", item.getOrderNumber());
|
||||
orderItem.put("consumeFee", item.getConsumeFee());
|
||||
orderItem.put("status", item.getStatus());
|
||||
orderItem.put("alias", item.getMerchantName());
|
||||
orderItem.put("channelTransNo", item.getThirdSendNo());
|
||||
orderItem.put("thirdTransNo", item.getThirdTransNo());
|
||||
orderItem.put("transTime", DateUtil.format(item.getTransDt(), DatePattern.NORM_DATETIME_FORMAT));
|
||||
if (item.getStatus().equals("2")) {
|
||||
orderItem.put("refundAmt", item.getRefundAmt());
|
||||
orderItem.put("refundTime", DateUtil.format(item.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT));
|
||||
}
|
||||
orderItem.put("payType", item.getPayTypeCode());
|
||||
|
||||
result.add(orderItem);
|
||||
}
|
||||
|
||||
resultPage.setPages(pageInfo.getPages());
|
||||
resultPage.setRecords(result);
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object dataAnalysis(JSONObject param) {
|
||||
String deviceNo = param.getString("deviceNo");
|
||||
MerchantBaseInfo mbi = getByDeviceNo(deviceNo);
|
||||
String type = param.getString("type");
|
||||
String date = param.getString("date");
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
if (ObjectUtils.isEmpty(type)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "类型不能为空");
|
||||
}
|
||||
|
||||
if (!ArrayUtil.contains(new String[]{"1", "2"}, type)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "类型只能为1(日)或者2(月)");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(date)) {
|
||||
throw new AccessException(CodeEnum.PARAM_ERROR, "日期不能为空");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MerchantOrder> qWrapper = Wrappers.lambdaQuery();
|
||||
qWrapper.likeRight(MerchantOrder::getCreateDate, date)
|
||||
.eq(MerchantOrder::getMerchantCode, mbi.getMerchantCode())
|
||||
.eq(MerchantOrder::getSnNo, deviceNo)
|
||||
.eq(MerchantOrder::getStatus, "1");
|
||||
|
||||
int transCount = orderService.count(qWrapper);
|
||||
result.put("transCount", transCount);
|
||||
|
||||
qWrapper.clear();
|
||||
qWrapper.likeRight(MerchantOrder::getCreateDate, date)
|
||||
.eq(MerchantOrder::getMerchantCode, mbi.getMerchantCode())
|
||||
.eq(MerchantOrder::getSnNo, deviceNo)
|
||||
.eq(MerchantOrder::getStatus, "2");
|
||||
|
||||
int refundCount = orderService.count(qWrapper);
|
||||
result.put("refundCount", refundCount);
|
||||
|
||||
QueryWrapper<MerchantOrder> qWrapper2 = Wrappers.query();
|
||||
qWrapper2.likeRight("createDate", date)
|
||||
.eq("merchantCode", mbi.getMerchantCode())
|
||||
.eq("snNo", deviceNo)
|
||||
.eq("status", "1")
|
||||
.select("SUM(consumeFee) transFee");
|
||||
|
||||
BigDecimal transFee = orderService.getObj(qWrapper2, (SFunction<Object, BigDecimal>) o -> {
|
||||
if (o == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
if (o instanceof BigDecimal) {
|
||||
return (BigDecimal) o;
|
||||
}
|
||||
|
||||
return new BigDecimal(o.toString());
|
||||
});
|
||||
|
||||
if (transFee == null) {
|
||||
transFee = BigDecimal.ZERO;
|
||||
}
|
||||
result.put("transFee", transFee);
|
||||
|
||||
BigDecimal refundFee = orderService.getRefundAmt(mbi.getMerchantCode(), deviceNo, date);
|
||||
if (refundFee == null) {
|
||||
refundFee = BigDecimal.ZERO;
|
||||
}
|
||||
result.put("refundFee", refundFee);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.pluss.platform.access.service.impl;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.crypto.SignUtil;
|
||||
import cn.hutool.crypto.asymmetric.Sign;
|
||||
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
||||
import cn.pluss.platform.access.AccessService;
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
import cn.pluss.platform.entity.AccessChannelCipherCode;
|
||||
import cn.pluss.platform.mapper.AccessChannelCipherCodeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Service
|
||||
public class AccessServiceImpl implements AccessService {
|
||||
|
||||
@Resource
|
||||
private AccessChannelCipherCodeMapper acccMapper;
|
||||
|
||||
@Override
|
||||
public boolean checkSign(ReqEntity reqEntity) {
|
||||
AccessChannelCipherCode accc = acccMapper.selectAllByOrgId(reqEntity.getOrgId());
|
||||
String orgPubKey = accc.getOrgPubKey();
|
||||
|
||||
Sign sign = SignUtil.sign(SignAlgorithm.SHA256withRSA, null, orgPubKey);
|
||||
String signContent = ReqEntity.getSignContent(reqEntity);
|
||||
return sign.verify(signContent.getBytes(StandardCharsets.UTF_8), Base64.decode(reqEntity.getSign()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSign(RespEntity respEntity) {
|
||||
String signContent = RespEntity.getSignContent(respEntity);
|
||||
|
||||
AccessChannelCipherCode accc = acccMapper.selectAllByOrgId(respEntity.getOrgId());
|
||||
Sign sign = SignUtil.sign(SignAlgorithm.SHA256withRSA, accc.getPriKey(), null);
|
||||
byte[] signBytes = sign.sign(signContent);
|
||||
respEntity.setSign(Base64.encode(signBytes));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -65,6 +66,9 @@ public class AliScanCodeDeviceServiceImpl implements AliDeviceService {
|
||||
@Resource
|
||||
private MerchantChannelStatusService channelService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public RespDeviceEntity getDeviceStatusV1(String deviceNo) {
|
||||
if(StringUtil.isEmpty(deviceNo)){
|
||||
@@ -139,7 +143,7 @@ public class AliScanCodeDeviceServiceImpl implements AliDeviceService {
|
||||
dto.setDeviceNo(entity.getCode());
|
||||
dto.setRemark(entity.getRemark());
|
||||
try {
|
||||
Result<Object> mapResult = merchantOrderService.toActivePay(dto);
|
||||
Result<Object> mapResult = merchantOrderService.toActivePay(dto, request);
|
||||
Object data = mapResult.getData();
|
||||
if (ResultCode.TRANSUNKNOW.code() == mapResult.getCode()) {
|
||||
return RespDeviceEntity.await(mapResult.getMessage(),((Map)data).get("orderNumber"));
|
||||
|
||||
@@ -9,9 +9,11 @@ import cn.pluss.platform.mapper.MerchantOrderMapper;
|
||||
import cn.pluss.platform.vo.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -21,6 +23,14 @@ import java.util.Map;
|
||||
*/
|
||||
public interface MerchantOrderService extends IService<MerchantOrder> {
|
||||
|
||||
default Page<MerchantOrder> pageData(IPage<MerchantOrder> page, Map<String, Object> map, List<String> statusList) {
|
||||
return ((MerchantOrderMapper) getBaseMapper()).page(page, map, statusList);
|
||||
}
|
||||
|
||||
default BigDecimal getRefundAmt(String merchantCode, String snNo, String date) {
|
||||
return ((MerchantOrderMapper) getBaseMapper()).selectRefundAmt(merchantCode, snNo, date);
|
||||
}
|
||||
|
||||
default MerchantOrder queryMerchantOrder(MerchantOrder merchantOrder) {
|
||||
return getBaseMapper().selectOne(new QueryWrapper<>(merchantOrder));
|
||||
}
|
||||
@@ -261,7 +271,15 @@ public interface MerchantOrderService extends IService<MerchantOrder> {
|
||||
* @param merchantOrderDTO ignored
|
||||
* @return ignored
|
||||
*/
|
||||
Result<Object> toActivePay(MerChantOrderDTO merchantOrderDTO);
|
||||
Result<Object> toActivePay(MerChantOrderDTO merchantOrderDTO, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 扫用户二维码支付
|
||||
*
|
||||
* @param merchantOrderDTO ignored
|
||||
* @return ignored
|
||||
*/
|
||||
JSONObject toActivePayV2(MerChantOrderDTO merchantOrderDTO, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 主扫会员卡支付
|
||||
@@ -275,7 +293,7 @@ public interface MerchantOrderService extends IService<MerchantOrder> {
|
||||
* @param memberRechargeDTO ignored
|
||||
* @return ignored
|
||||
*/
|
||||
Result<Map<String, Object>> toMemberRecharge(MemberRechargeDTO memberRechargeDTO);
|
||||
Result<Map<String, Object>> toMemberRecharge(MemberRechargeDTO memberRechargeDTO, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 退款
|
||||
|
||||
@@ -18,6 +18,7 @@ import cn.pluss.platform.entitiy.SettleTypeEnum;
|
||||
import cn.pluss.platform.entity.*;
|
||||
import cn.pluss.platform.enums.UserRoleEnum;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.ipLocation.IpLocationService;
|
||||
import cn.pluss.platform.mapper.*;
|
||||
import cn.pluss.platform.memberOrder.MemberOrderService;
|
||||
import cn.pluss.platform.merchant.MerchantCashPlaceService;
|
||||
@@ -81,6 +82,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -98,6 +100,10 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
@Autowired
|
||||
private GeneralPushUtil generalPushUtil;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private IpLocationService ipLocationService;
|
||||
|
||||
|
||||
@Setter(onMethod_ = {@Autowired})
|
||||
private MerchantOrderVOMapper merchantOrderVOMapper;
|
||||
@@ -439,7 +445,7 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
BigDecimal todayConsumeFee = BigDecimal.ZERO;
|
||||
int orderCount = 0;// 今日订单数量
|
||||
Integer fanCount = 0;// 今日粉丝数量
|
||||
|
||||
|
||||
|
||||
LambdaQueryWrapper<MerchantOrder> queryWrapperTotal = Wrappers.lambdaQuery();
|
||||
Date dayBegin = DateUtils.getDayBegin();
|
||||
@@ -684,7 +690,7 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
@@ -771,7 +777,7 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
|
||||
|
||||
@Override
|
||||
public Result<Object> toActivePay(MerChantOrderDTO dto) {
|
||||
public Result<Object> toActivePay(MerChantOrderDTO dto, HttpServletRequest request) {
|
||||
//校验参数
|
||||
checkActivePayParamsMap(dto);
|
||||
//组装订单参数
|
||||
@@ -786,11 +792,42 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
result.put("message", "交易成功");
|
||||
return ResultGenerator.genSuccessResult("支付成功", result);
|
||||
}else{
|
||||
MerchantOrder order = getMerchantOrder(dto, dto.getConsumeFee(), "1","1");
|
||||
MerchantOrder order = getMerchantOrder(dto, dto.getConsumeFee(), "1","1", request);
|
||||
return activePay(order, dto);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject toActivePayV2(MerChantOrderDTO dto, HttpServletRequest request) {
|
||||
//校验参数
|
||||
checkActivePayParamsMap(dto);
|
||||
//组装订单参数
|
||||
if (StringUtils.isNotEmpty(dto.getType()) && "3".equals(dto.getType())) {
|
||||
MerchantMemberCode menberCode = dto.getMercMenberCode();
|
||||
MerchantMenber menber = merchantMenberMapper.getByCardNo(menberCode.getCardNo());
|
||||
MemberScanPayDTO memberScanPayDTO = new MemberScanPayDTO(dto, menber);
|
||||
MemberScanVO vo = getMemberPayOrder(memberScanPayDTO, menber);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("orderNumber", vo.getOrderNumber());
|
||||
result.put("consumeFee", vo.getConsumeFee());
|
||||
result.put("status", "1");
|
||||
|
||||
return result;
|
||||
} else {
|
||||
MerchantOrder order = getMerchantOrder(dto, dto.getConsumeFee(), "1", "1", request);
|
||||
Result<Object> objectResult = activePay(order, dto);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
result.put("orderNumber", order.getOrderNumber());
|
||||
result.put("consumeFee", order.getConsumeFee());
|
||||
result.put("status", order.getStatus());
|
||||
result.put("remark", objectResult.getMessage());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 主扫会员卡支付
|
||||
*
|
||||
@@ -814,11 +851,11 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class,propagation = Propagation.NOT_SUPPORTED)
|
||||
public Result<Map<String, Object>> toMemberRecharge(MemberRechargeDTO dto) {
|
||||
public Result<Map<String, Object>> toMemberRecharge(MemberRechargeDTO dto, HttpServletRequest req) {
|
||||
// 校验参数
|
||||
checkActivePayParamsMap(dto);
|
||||
|
||||
MerchantOrder order = getMerchantOrder(dto, Double.parseDouble(dto.getRechargeMoney()), "1","5");
|
||||
MerchantOrder order = getMerchantOrder(dto, Double.parseDouble(dto.getRechargeMoney()), "1","5", req);
|
||||
|
||||
QueryWrapper<MerchantMenber> menberWrapper = new QueryWrapper<MerchantMenber>()
|
||||
.eq("phone", dto.getPhone()).eq("merchantCode", dto.getMerchantCode()).eq("storeId", dto.getStoreId());
|
||||
@@ -1218,7 +1255,7 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
/**
|
||||
* merchantIncome:(添加收益记录). <br/>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Administrator
|
||||
* @since JDK 1.8
|
||||
*/
|
||||
@@ -1244,7 +1281,7 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
* @param orderType 订单类型 5 APP扫码充值
|
||||
* @return
|
||||
*/
|
||||
private MerchantOrder getMerchantOrder(MerChantOrderDTO dto, Double amt, String type,String orderType) {
|
||||
private MerchantOrder getMerchantOrder(MerChantOrderDTO dto, Double amt, String type,String orderType, HttpServletRequest request) {
|
||||
|
||||
MerchantOrder merchantOrder = new MerchantOrder();
|
||||
MerchantCashPlaceStaff cashPlaceStaff = new MerchantCashPlaceStaff();
|
||||
@@ -1305,6 +1342,12 @@ public class MerchantOrderServiceImpl extends ServiceImpl<MerchantOrderMapper, M
|
||||
}else{
|
||||
merchantOrder.setSettlementType(SettleTypeEnum.D1.getValue());
|
||||
}
|
||||
//主扫记录商户交易ip 不一定准确
|
||||
String ip = IpUtils.getIpAddr(request);
|
||||
merchantOrder.setIp(ip);
|
||||
String ipAddress = IpUtils.getIpLoactionAddress(ipLocationService.getLocation(ip));
|
||||
merchantOrder.setIpAddress(ipAddress);
|
||||
|
||||
return merchantOrder;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ public interface ApiPayService {
|
||||
*/
|
||||
Result<Object> refundQuery(JSONObject params);
|
||||
|
||||
JSONObject apiRefundPay(JSONObject params);
|
||||
|
||||
/**
|
||||
* @description:api退款
|
||||
* @date: 2021/11/22 10:48
|
||||
|
||||
@@ -801,11 +801,11 @@ public class ApiPayServiceImpl implements ApiPayService {
|
||||
}
|
||||
return ResultGenerator.genFailResult("订单号有误,退款订单不存在!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description:api退款功能
|
||||
* @date: 2021/11/22 10:49
|
||||
* @param params:
|
||||
* @param params:
|
||||
* @return cn.pluss.platform.api.Result<com.alibaba.fastjson.JSONObject>
|
||||
*/
|
||||
@Override
|
||||
@@ -844,7 +844,7 @@ public class ApiPayServiceImpl implements ApiPayService {
|
||||
}
|
||||
|
||||
//退款操作
|
||||
private JSONObject apiRefundPay(JSONObject params) {
|
||||
public JSONObject apiRefundPay(JSONObject params) {
|
||||
MerchantBaseInfo merchant = params.getObject("merchant", MerchantBaseInfo.class);
|
||||
String refundReason = StringUtil.isEmpty(params.getString("refundReason")) ? "订单退款" : params.getString("refundReason");
|
||||
String mercOrderNo = params.getString("mercOrderNo");
|
||||
|
||||
Reference in New Issue
Block a user