yy_dev
胡锐 2 years ago
parent b5bcaabcc3
commit b8ae8a903e
  1. 12
      cweb/src/main/java/com/cweb/controller/BsStoreDiscountActivityPartakeUserController.java
  2. 10
      cweb/src/main/java/com/cweb/controller/TestController.java
  3. 78
      service/src/main/java/com/hfkj/channel/hsg/HsgIntegralService.java
  4. 17
      service/src/main/java/com/hfkj/channel/hsg/config/HsgConfig.java
  5. 35
      service/src/main/java/com/hfkj/channel/hsg/type/RebateProductTypeEnum.java
  6. 18
      service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java
  7. 3
      service/src/main/java/com/hfkj/service/BsTradeOrderProfitSharingService.java
  8. 2
      service/src/main/java/com/hfkj/service/BsTradeOrderService.java
  9. 14
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderProfitSharingServiceImpl.java
  10. 23
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java

@ -65,16 +65,18 @@ public class BsStoreDiscountActivityPartakeUserController {
@RequestParam(value = "type" , required = true) Integer type,
@RequestParam(value = "systemType" , required = true) Integer systemType) {
try {
System.out.println("outTradeNo="+outTradeNo+"&qrCodeSn="+"&type="+type+"&systemType="+systemType);
BsTradeOrder tradeNo = tradeOrderService.getOrderByOutTradeNoOrPlatformTradeNo(outTradeNo);
if (tradeNo == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单");
}
System.out.println("outTradeNo="+tradeNo.getOutTradeNo()+"&qrCodeSn="+"&type="+type+"&systemType="+systemType);
JSONObject response = HttpsUtils.doGet(CommonSysConst.getSysConfig().getHsg_domain_name() + "/v1/wxMsg/getWxToken");
if (StringUtils.isBlank(response.getString("return_data"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败");
}
BsTradeOrder tradeNo = tradeOrderService.getOrderByOutTradeNo(outTradeNo);
if (tradeNo == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单");
}
String param = outTradeNo;
String fileUrl = "/share/" + System.currentTimeMillis() + ".png";
// type 生成类型

@ -156,8 +156,8 @@ public class TestController {
// soundService.sendPayMsg("898604A2192181729951", new BigDecimal("12.99"));
soundService.geSoundInfo("898604A2192181729951");
return ResponseMsgUtil.success("");
// soundService.geSoundInfo("898604A2192181729951");
return ResponseMsgUtil.success(tradeOrderService.getOrderByOutTradeNoOrPlatformTradeNo("ZF1130202304261716539211335407"));
// soundService.geSoundDetail("898604A2192181729951");
// return ResponseMsgUtil.success(AlipayRequest.imageUpload("C:/Users/hurui/Desktop/default_oil_station.jpg"));
@ -270,15 +270,13 @@ public class TestController {
Map<String , Object> mapPost = new HashMap<>();
mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645");
mapPost.put("merchId" , "20230258302");
mapPost.put("productType" , 102);
mapPost.put("productType" , 102); // 101 普通支付 102 商家活动差价返利
mapPost.put("orderNo" , orderNo);
mapPost.put("userId" , 366);
mapPost.put("phone" , 366);
mapPost.put("orderId" , orderId);
mapPost.put("price" , price);
mapPost.put("title" , "南充大饭店");
mapPost.put("createTime" , new Date());
mapPost.put("sign" , WxUtils.generateSignApi(mapPost, MapUtils.getString(mapPost, "apiKey"), WXPayConstants.SignType.MD5));
return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/orderRebate/rebate" , mapPost , new HashMap<>()));
} catch (Exception e) {

@ -0,0 +1,78 @@
package com.hfkj.channel.hsg;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.channel.hsg.config.HsgConfig;
import com.hfkj.channel.hsg.type.RebateProductTypeEnum;
import com.hfkj.channel.weixin.utils.WxUtils;
import com.hfkj.channel.weixin.utils.sdk.WXPayConstants;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.ResponseMsgUtil;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @className: HsgService
* @author: HuRui
* @date: 2023/4/27
**/
public class HsgIntegralService {
private static Logger log = LoggerFactory.getLogger(HsgIntegralService.class);
/**
* 返利
* @param productType
* @param phone
* @param orderNo
* @param orderId
* @param price
* @param storeName
* @param createTime
* @return
* @throws Exception
*/
public static Boolean rebate(RebateProductTypeEnum productType,
String phone,
String orderNo,
Long orderId,
BigDecimal price,
String storeName,
Date createTime) {
try {
Map<String , Object> mapPost = new HashMap<>();
mapPost.put("apiKey" , HsgConfig.apiKey);
mapPost.put("merchId" , HsgConfig.merchId);
mapPost.put("productType" , productType.getNumber()); // 101 普通支付 102 商家活动差价返利
mapPost.put("orderNo" , orderNo);
mapPost.put("phone" , phone);
mapPost.put("orderId" , orderId);
mapPost.put("price" , price);
mapPost.put("title" , storeName);
mapPost.put("createTime" , createTime);
mapPost.put("sign" , WxUtils.generateSignApi(mapPost, MapUtils.getString(mapPost, "apiKey"), WXPayConstants.SignType.MD5));
JSONObject response = HttpsUtils.doPost(HsgConfig.hsgDomainName+"v1/orderRebate/rebate", mapPost, new HashMap<>());
System.out.println(response);
if (response == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时");
}
if (!response.getString("return_code").equals("000000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("return_msg"));
}
return true;
} catch (Exception e) {
return false;
}
}
}

@ -0,0 +1,17 @@
package com.hfkj.channel.hsg.config;
import com.hfkj.config.CommonSysConst;
/**
* @className: HsgConfig
* @author: HuRui
* @date: 2023/4/27
**/
public class HsgConfig {
public final static String apiKey = "0C7897EA3BD96156A5881618FF2FF645";
public final static String merchId = "20230258302";
public final static String hsgDomainName = CommonSysConst.getSysConfig().getHsg_domain_name();
}

@ -0,0 +1,35 @@
package com.hfkj.channel.hsg.type;
/**
*
*/
public enum RebateProductTypeEnum {
type1(101, "普通支付"),
type2(102, "商家活动差价返利"),
;
private Integer number;
private String name;
RebateProductTypeEnum(int number, String name) {
this.number = number;
this.name = name;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -46,6 +46,13 @@ public class LaKaLaTradeService {
@Resource
private BsMerPlatformNoRateService merPlatformNoRateService;
@Resource
private LaKaLaTradeSeparateService laKaLaTradeSeparateService;
@Resource
private BsTradeOrderProfitSharingService tradeOrderProfitSharingService;
/**
* 交易被扫
* @param tradeNo 订单号
@ -317,7 +324,16 @@ public class LaKaLaTradeService {
orderMsg.setRequestContent(JSONObject.toJSONString(requestMap));
tradeOrderMsgService.editTradeOrderMsg(orderMsg);
// 请求拉卡拉接口
// 是否分账
if (order.getProfitSharingStatus().equals(true)) {
// 查询分账记录
BsTradeOrderProfitSharing tradeOrderProfitSharing = tradeOrderProfitSharingService.getProfitSharingByTradeOrderId(ProfitSharingCmdTypeEnum.CMD_TYPE_1, order.getId());
if (tradeOrderProfitSharing != null) {
laKaLaTradeSeparateService.cancel(tradeOrderProfitSharing.getProfitSharingOrderNo());
}
}
// 请求拉卡拉退款接口
JSONObject responseBody = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLkl_request_url() + "/api/v3/labs/relation/refund", commonParam, heard);
orderMsg.setResponseContent(responseBody.toJSONString());
tradeOrderMsgService.editTradeOrderMsg(orderMsg);

@ -2,6 +2,7 @@ package com.hfkj.service;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderProfitSharing;
import com.hfkj.sysenum.ProfitSharingCmdTypeEnum;
import java.util.List;
@ -25,6 +26,8 @@ public interface BsTradeOrderProfitSharingService {
*/
void createProfitSharing(BsTradeOrder tradeOrder);
BsTradeOrderProfitSharing getProfitSharingByTradeOrderId(ProfitSharingCmdTypeEnum profitSharingCmdType,Long tradeOrderId);
/**
* 根据分账单号 查询详情
* @param profitSharingOrderNo

@ -48,6 +48,8 @@ public interface BsTradeOrderService {
*/
BsTradeOrder getOrderByOutTradeNo(String tradeNo);
BsTradeOrder getOrderByOutTradeNoOrPlatformTradeNo(String tradeNo);
/**
* 根据交易订单id查询
* @param tradeOrderId

@ -388,6 +388,20 @@ public class BsTradeOrderProfitSharingServiceImpl implements BsTradeOrderProfitS
}
}
@Override
public BsTradeOrderProfitSharing getProfitSharingByTradeOrderId(ProfitSharingCmdTypeEnum profitSharingCmdType, Long tradeOrderId) {
BsTradeOrderProfitSharingExample example = new BsTradeOrderProfitSharingExample();
BsTradeOrderProfitSharingExample.Criteria criteria = example.createCriteria()
.andCmdTypeEqualTo(profitSharingCmdType.getNumber())
.andTradeOrderIdEqualTo(tradeOrderId);
List<BsTradeOrderProfitSharing> list = tradeOrderProfitSharingMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public BsTradeOrderProfitSharing getDetailByProfitSharingOrderNo(String profitSharingOrderNo) {
BsTradeOrderProfitSharingExample example = new BsTradeOrderProfitSharingExample();

@ -1,6 +1,8 @@
package com.hfkj.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.channel.hsg.HsgIntegralService;
import com.hfkj.channel.hsg.type.RebateProductTypeEnum;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
@ -232,6 +234,15 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
}
if (tradeOrder.getStoreDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
// 支付返积分
HsgIntegralService.rebate(RebateProductTypeEnum.type2,
tradeOrder.getUserPhone(),
tradeOrder.getOutTradeNo(),
tradeOrder.getId(),
tradeOrder.getStoreDiscountActualPrice(),
tradeOrder.getStoreName(),
tradeOrder.getCreateTime());
BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId());
if (partakeUser != null) {
partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() - 1);
@ -262,6 +273,18 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
return null;
}
@Override
public BsTradeOrder getOrderByOutTradeNoOrPlatformTradeNo(String tradeNo) {
BsTradeOrderExample example = new BsTradeOrderExample();
example.createCriteria().andOutTradeNoEqualTo(tradeNo);
example.or().andPlatformTradeNoEqualTo(tradeNo);
List<BsTradeOrder> list = tradeOrderMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
public BsTradeOrder getOrderByTradeNoId(Long tradeOrderId) {
return tradeOrderMapper.selectByPrimaryKey(tradeOrderId);

Loading…
Cancel
Save