提交代码

yy_dev
胡锐 2 years ago
parent 0e9752e055
commit aa756ddf1c
  1. 10
      cweb/src/main/java/com/cweb/controller/TestController.java
  2. 112
      open-api/src/main/java/com/api/controller/v1/NotifyController.java
  3. 45
      open-api/src/main/java/com/api/controller/v1/TradeController.java
  4. 12
      service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java
  5. 1
      service/src/main/java/com/hfkj/config/CommonSysConfig.java
  6. 16
      service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java
  7. 28
      service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java
  8. 56
      service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java
  9. 32
      service/src/main/java/com/hfkj/entity/BsTradeOrder.java
  10. 140
      service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java
  11. 41
      service/src/main/java/com/hfkj/openapi/v1/model/RequestTradeBillsModel.java
  12. 2
      service/src/main/java/com/hfkj/openapi/v1/model/RequestTradePreorderModel.java
  13. 70
      service/src/main/java/com/hfkj/openapi/v1/model/TradeBillsModel.java
  14. 11
      service/src/main/java/com/hfkj/openapi/v1/service/OpenApiTradeOrderService.java
  15. 17
      service/src/main/java/com/hfkj/openapi/v1/service/impl/OpenApiTradeOrderServiceImpl.java
  16. 16
      service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java
  17. 82
      service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java
  18. 1
      service/src/main/resources/dev/commonConfig.properties
  19. 1
      service/src/main/resources/prod/commonConfig.properties

@ -462,16 +462,14 @@ public class TestController {
// return ResponseMsgUtil.success(saasActivityService.queryCustomerActivityStatus("73", "8226900445800HB"));
/*********** 活动报名 *************/
/* List<String> externalCustomerNos = new ArrayList<>();
externalCustomerNos.add("8226900549903LG");
externalCustomerNos.add("8226900445800HQ");
List<String> externalCustomerNos = new ArrayList<>();
externalCustomerNos.add("8226900723007E8");
return ResponseMsgUtil.success(saasActivityService.customerRegisterActivity("73", null, externalCustomerNos));
*/
/******* 配置活动费率 *******/
String activityId = "73";
/* String activityId = "73";
String externalCustomerNo = code;
JSONArray jsonArray = saasActivityService.queryCustomerRates(activityId, externalCustomerNo);
return ResponseMsgUtil.success(jsonArray);
return ResponseMsgUtil.success(jsonArray);*/
/* Map<String, Object> rate;
List<Map<String,Object>> rates = new ArrayList<>();

@ -0,0 +1,112 @@
package com.api.controller.v1;
import com.alibaba.fastjson.JSONObject;
import com.ccb.wlpt.util.StringUtil;
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 com.hfkj.entity.BsMer;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderMsg;
import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.model.ResponseData;
import com.hfkj.openapi.v1.model.*;
import com.hfkj.openapi.v1.service.OpenApiTradeOrderService;
import com.hfkj.openapi.v1.utils.SignatureUtil;
import com.hfkj.service.BsMerKeyService;
import com.hfkj.service.BsMerService;
import com.hfkj.service.BsTradeOrderService;
import com.hfkj.sysenum.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.protocol.HTTP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
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.HashMap;
import java.util.Map;
@Controller
@Api(value = "交易订单")
@RequestMapping(value = "/v1/payNotify")
public class NotifyController {
private static Logger log = LoggerFactory.getLogger(NotifyController.class);
@Resource
private BsTradeOrderService tradeOrderService;
@Resource
private OpenApiTradeOrderService openApiTradeOrderService;
@Resource
private BsMerKeyService merKeyService;
@RequestMapping(value="/lakala",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "拉卡拉交易通知")
public void lakala(@RequestBody String reqBody, HttpServletResponse response) {
try {
log.info("拉卡拉交易通知:", reqBody);
System.out.println(reqBody);
JSONObject body = JSONObject.parseObject(reqBody);
// 查询订单
BsTradeOrder order = tradeOrderService.getOrderByOutTradeNo(body.getString("out_trade_no"));
if (order != null && order.getStatus().equals(TradeOrderStatusEnum.status1.getNumber())) {
Map<String,Object> other = new HashMap<>();
other.put("log_no", body.getString("log_no"));
other.put("acc_trade_no", body.getString("acc_trade_no"));
other.put("card_type", body.getString("card_type"));
tradeOrderService.paySuccess(
body.getString("out_trade_no"),
body.getString("trade_no"),
PlatformTypeEnum.type1,
TradeOrderPayModeEnum.getNameByCode(body.getString("account_type")),
body.getBigDecimal("payer_amount").divide(new BigDecimal("100")),
body.getString("merchant_no"),
other
);
}
if (StringUtils.isNotBlank(order.getPayNotifyUrl())) {
BsTradeOrder tradeOrder = openApiTradeOrderService.getOrderByOutTradeNo(order.getOutTradeNo());
ResponseQueryTradeModel responseQueryTradeModel = new ResponseQueryTradeModel();
responseQueryTradeModel.setMerchantNo(tradeOrder.getMerNo());
responseQueryTradeModel.setOutTradeNo(tradeOrder.getOutTradeNo());
responseQueryTradeModel.setAccTradeNo(tradeOrder.getAccTradeNo());
responseQueryTradeModel.setUserId(tradeOrder.getPayUserId());
responseQueryTradeModel.setPayMode(tradeOrder.getPayMode());
responseQueryTradeModel.setTradeAmount(tradeOrder.getTradeAmount());
responseQueryTradeModel.setTradeActualAmount(tradeOrder.getTradeActualAmount());
responseQueryTradeModel.setStatus(tradeOrder.getStatus());
responseQueryTradeModel.setCreateTime(tradeOrder.getCreateTime());
responseQueryTradeModel.setPayTime(tradeOrder.getPayTime());
responseQueryTradeModel.setSign(SignatureUtil.createSign(responseQueryTradeModel, merKeyService.getKeyByMerNo(tradeOrder.getMerNo())));
JSONObject result = HttpsUtils.doPost(order.getPayNotifyUrl(), JSONObject.toJSONString(responseQueryTradeModel));
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
out.write(result.toJSONString().getBytes());
out.flush();
out.close();
}
} catch (Exception e) {
log.error("login error!",e);
}
}
}

@ -1,10 +1,14 @@
package com.api.controller.v1;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.api.config.SysConst;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsMer;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund;
@ -25,6 +29,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Controller
@ -94,6 +100,7 @@ public class TradeController {
tradeOrder.setPayAppid(body.getSubAppid());
tradeOrder.setPayUserId(body.getUserId());
tradeOrder.setTimeoutExpress(body.getTimeoutExpress());
tradeOrder.setPayNotifyUrl(body.getNotifyUrl());
// 创建交易订单
Map<String, Object> returnParam = openApiTradeOrderService.createOrder(tradeOrder);
@ -219,6 +226,44 @@ public class TradeController {
}
}
@RequestMapping(value="/tradeBills",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "账单下载")
public ResponseData tradeBills(@RequestBody RequestTradeBillsModel body) {
log.info("========= Start 账单下载 Start ===========");
log.info("请求参数:" + JSONObject.toJSONString(body));
try {
// 验证签名
if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, "");
}
if (body.getBillDateS().compareTo(body.getBillDateE()) >= 0) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "开始时间必须大于结束时间");
}
// 最大周期范围3个月 90天
Long maxTime = 60*24*90L;
if (maxTime.compareTo(DateUtil.getMinutesDiff(new Date(body.getBillDateS()), new Date(body.getBillDateE()))) < 0) {
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "时间范围大于3个月");
}
List<TradeBillsModel> tradeBills = openApiTradeOrderService.tradeBills(body.getMerchantNo(), body.getBillDateS(), body.getBillDateE());
String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx";
EasyExcel.write(CommonSysConst.getSysConfig().getFilesystem() + fileName, TradeBillsModel.class)
.sheet(body.getMerchantNo())
.doWrite(tradeBills);
String fileUrl = CommonSysConst.getSysConfig().getDomainName() + "/filesystem" + fileName;
log.info("返回参数:" + fileUrl);
return ResponseMsgUtil.success(fileUrl);
} catch (Exception e) {
log.info("出现异常:", e);
return ResponseMsgUtil.exception(e);
} finally {
log.info("========= END 账单下载 END ===========");
}
}
}

@ -209,9 +209,17 @@ public class LaKaLaTradeService {
map.put("account_type", order.getPayMode());
map.put("trans_type", "51");
map.put("total_amount", order.getTradeActualAmount().multiply(new BigDecimal("100")).intValue());
map.put("subject", mer.getMerAbbreviate());
map.put("notify_url", CommonSysConst.getSysConfig().getLkl_micro_pay_ret_url());
if (StringUtils.isNotBlank(order.getSubject())) {
map.put("subject", order.getSubject());
} else {
map.put("subject", mer.getMerAbbreviate());
}
if (order.getCreateType() != null && order.getCreateType().equals(TradeOrderCreateTypeEnum.type3.getCode())) {
map.put("notify_url", CommonSysConst.getSysConfig().getLkl_open_api_pay_notify_url());
} else {
map.put("notify_url", CommonSysConst.getSysConfig().getLkl_micro_pay_ret_url());
}
Map<String, Object> locationInfo = new HashMap<>();
locationInfo.put("request_ip", "0.0.0.0");
map.put("location_info", locationInfo);

@ -88,6 +88,7 @@ public class CommonSysConfig {
* 拉卡拉交易被扫回调地址
*/
private String lkl_micro_pay_ret_url;
private String lkl_open_api_pay_notify_url;
private String lkl_saas_client_id;
private String lkl_saas_client_secret;

@ -64,7 +64,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"acc_discount_amount, acc_payment_code, ",
"card_type, `status`, ",
"profit_sharing_status, pay_time, ",
"timeout_express, create_type, ",
"timeout_express, subject, ",
"pay_notify_url, create_type, ",
"create_time, cancel_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
@ -93,7 +94,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"#{accDiscountAmount,jdbcType=DECIMAL}, #{accPaymentCode,jdbcType=VARCHAR}, ",
"#{cardType,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
"#{profitSharingStatus,jdbcType=BIT}, #{payTime,jdbcType=TIMESTAMP}, ",
"#{timeoutExpress,jdbcType=INTEGER}, #{createType,jdbcType=INTEGER}, ",
"#{timeoutExpress,jdbcType=INTEGER}, #{subject,jdbcType=VARCHAR}, ",
"#{payNotifyUrl,jdbcType=VARCHAR}, #{createType,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
@ -160,6 +162,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
@Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT),
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="timeout_express", property="timeoutExpress", jdbcType=JdbcType.INTEGER),
@Result(column="subject", property="subject", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_notify_url", property="payNotifyUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -182,8 +186,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"user_discount_id, user_discount_name, user_discount_type, user_discount_price, ",
"user_discount_actual_price, trade_actual_amount, income_amout, acc_trade_no, ",
"acc_mdiscount_amount, acc_discount_amount, acc_payment_code, card_type, `status`, ",
"profit_sharing_status, pay_time, timeout_express, create_type, create_time, ",
"cancel_time, update_time, ext_1, ext_2, ext_3",
"profit_sharing_status, pay_time, timeout_express, subject, pay_notify_url, create_type, ",
"create_time, cancel_time, update_time, ext_1, ext_2, ext_3",
"from bs_trade_order",
"where id = #{id,jdbcType=BIGINT}"
})
@ -241,6 +245,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
@Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT),
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="timeout_express", property="timeoutExpress", jdbcType=JdbcType.INTEGER),
@Result(column="subject", property="subject", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_notify_url", property="payNotifyUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -314,6 +320,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt {
"profit_sharing_status = #{profitSharingStatus,jdbcType=BIT},",
"pay_time = #{payTime,jdbcType=TIMESTAMP},",
"timeout_express = #{timeoutExpress,jdbcType=INTEGER},",
"subject = #{subject,jdbcType=VARCHAR},",
"pay_notify_url = #{payNotifyUrl,jdbcType=VARCHAR},",
"create_type = #{createType,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"cancel_time = #{cancelTime,jdbcType=TIMESTAMP},",

@ -236,6 +236,14 @@ public class BsTradeOrderSqlProvider {
sql.VALUES("timeout_express", "#{timeoutExpress,jdbcType=INTEGER}");
}
if (record.getSubject() != null) {
sql.VALUES("subject", "#{subject,jdbcType=VARCHAR}");
}
if (record.getPayNotifyUrl() != null) {
sql.VALUES("pay_notify_url", "#{payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getCreateType() != null) {
sql.VALUES("create_type", "#{createType,jdbcType=INTEGER}");
}
@ -326,6 +334,8 @@ public class BsTradeOrderSqlProvider {
sql.SELECT("profit_sharing_status");
sql.SELECT("pay_time");
sql.SELECT("timeout_express");
sql.SELECT("subject");
sql.SELECT("pay_notify_url");
sql.SELECT("create_type");
sql.SELECT("create_time");
sql.SELECT("cancel_time");
@ -562,6 +572,14 @@ public class BsTradeOrderSqlProvider {
sql.SET("timeout_express = #{record.timeoutExpress,jdbcType=INTEGER}");
}
if (record.getSubject() != null) {
sql.SET("subject = #{record.subject,jdbcType=VARCHAR}");
}
if (record.getPayNotifyUrl() != null) {
sql.SET("pay_notify_url = #{record.payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getCreateType() != null) {
sql.SET("create_type = #{record.createType,jdbcType=INTEGER}");
}
@ -651,6 +669,8 @@ public class BsTradeOrderSqlProvider {
sql.SET("profit_sharing_status = #{record.profitSharingStatus,jdbcType=BIT}");
sql.SET("pay_time = #{record.payTime,jdbcType=TIMESTAMP}");
sql.SET("timeout_express = #{record.timeoutExpress,jdbcType=INTEGER}");
sql.SET("subject = #{record.subject,jdbcType=VARCHAR}");
sql.SET("pay_notify_url = #{record.payNotifyUrl,jdbcType=VARCHAR}");
sql.SET("create_type = #{record.createType,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("cancel_time = #{record.cancelTime,jdbcType=TIMESTAMP}");
@ -876,6 +896,14 @@ public class BsTradeOrderSqlProvider {
sql.SET("timeout_express = #{timeoutExpress,jdbcType=INTEGER}");
}
if (record.getSubject() != null) {
sql.SET("subject = #{subject,jdbcType=VARCHAR}");
}
if (record.getPayNotifyUrl() != null) {
sql.SET("pay_notify_url = #{payNotifyUrl,jdbcType=VARCHAR}");
}
if (record.getCreateType() != null) {
sql.SET("create_type = #{createType,jdbcType=INTEGER}");
}

@ -0,0 +1,56 @@
package com.hfkj.dao;
import com.hfkj.openapi.v1.model.TradeBillsModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className: OpenApiTradeOrderMapper
* @author: HuRui
* @date: 2023/5/25
**/
@Repository
public interface OpenApiTradeOrderMapper {
@Select({
"<script>" +
" SELECT " +
" a.pay_time payTime," +
" a.mer_no merchantNo," +
" a.platform_trade_no platformTradeNo," +
" a.out_trade_no outTradeNo, " +
" a.pay_user_id payUserId, " +
" \"JSAPI\" as tradeType," +
" case a.pay_mode" +
" when \"WECHAT\" then '微信'" +
" when \"ALIPAY\" then '支付宝'" +
" when \"UQRCODEPAY\" then '云闪付'" +
" end payMode," +
" \"交易成功\" as tradeStatus," +
" a.trade_amount tradeAmount," +
" a.trade_actual_amount tradeActualAmount," +
" case a.refund_type" +
" when 1 then '全额退款' " +
" when 2 then '部分退款'" +
" end refundType," +
" a.refund_price refundPrice," +
" subject subject," +
" case a.create_type" +
" when 1 then '扫一扫'" +
" when 2 then '被扫'" +
" when 3 then 'API'" +
" end createType" +
" FROM `bs_trade_order` a" +
" where a.mer_no = #{merNo} " +
" <![CDATA[ and pay_time >= #{billDateS} ]]>" +
" <![CDATA[ and pay_time <= #{billDateE} ]]>" +
" and a.`status` in (3,6)" +
" GROUP BY a.id" +
" </script>"
})
List<TradeBillsModel> queryTradeBills(@Param("merNo") String merNo,@Param("billDateS") String billDateS, @Param("billDateE") String billDateE);
}

@ -283,6 +283,16 @@ public class BsTradeOrder implements Serializable {
*/
private Integer timeoutExpress;
/**
* 标题
*/
private String subject;
/**
* 支付通知地址
*/
private String payNotifyUrl;
/**
* 创建方式 1扫一扫 2被扫 3API
*/
@ -735,6 +745,22 @@ public class BsTradeOrder implements Serializable {
this.timeoutExpress = timeoutExpress;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getPayNotifyUrl() {
return payNotifyUrl;
}
public void setPayNotifyUrl(String payNotifyUrl) {
this.payNotifyUrl = payNotifyUrl;
}
public Integer getCreateType() {
return createType;
}
@ -856,6 +882,8 @@ public class BsTradeOrder implements Serializable {
&& (this.getProfitSharingStatus() == null ? other.getProfitSharingStatus() == null : this.getProfitSharingStatus().equals(other.getProfitSharingStatus()))
&& (this.getPayTime() == null ? other.getPayTime() == null : this.getPayTime().equals(other.getPayTime()))
&& (this.getTimeoutExpress() == null ? other.getTimeoutExpress() == null : this.getTimeoutExpress().equals(other.getTimeoutExpress()))
&& (this.getSubject() == null ? other.getSubject() == null : this.getSubject().equals(other.getSubject()))
&& (this.getPayNotifyUrl() == null ? other.getPayNotifyUrl() == null : this.getPayNotifyUrl().equals(other.getPayNotifyUrl()))
&& (this.getCreateType() == null ? other.getCreateType() == null : this.getCreateType().equals(other.getCreateType()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime()))
@ -922,6 +950,8 @@ public class BsTradeOrder implements Serializable {
result = prime * result + ((getProfitSharingStatus() == null) ? 0 : getProfitSharingStatus().hashCode());
result = prime * result + ((getPayTime() == null) ? 0 : getPayTime().hashCode());
result = prime * result + ((getTimeoutExpress() == null) ? 0 : getTimeoutExpress().hashCode());
result = prime * result + ((getSubject() == null) ? 0 : getSubject().hashCode());
result = prime * result + ((getPayNotifyUrl() == null) ? 0 : getPayNotifyUrl().hashCode());
result = prime * result + ((getCreateType() == null) ? 0 : getCreateType().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode());
@ -991,6 +1021,8 @@ public class BsTradeOrder implements Serializable {
sb.append(", profitSharingStatus=").append(profitSharingStatus);
sb.append(", payTime=").append(payTime);
sb.append(", timeoutExpress=").append(timeoutExpress);
sb.append(", subject=").append(subject);
sb.append(", payNotifyUrl=").append(payNotifyUrl);
sb.append(", createType=").append(createType);
sb.append(", createTime=").append(createTime);
sb.append(", cancelTime=").append(cancelTime);

@ -3506,6 +3506,146 @@ public class BsTradeOrderExample {
return (Criteria) this;
}
public Criteria andSubjectIsNull() {
addCriterion("subject is null");
return (Criteria) this;
}
public Criteria andSubjectIsNotNull() {
addCriterion("subject is not null");
return (Criteria) this;
}
public Criteria andSubjectEqualTo(String value) {
addCriterion("subject =", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotEqualTo(String value) {
addCriterion("subject <>", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThan(String value) {
addCriterion("subject >", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThanOrEqualTo(String value) {
addCriterion("subject >=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThan(String value) {
addCriterion("subject <", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThanOrEqualTo(String value) {
addCriterion("subject <=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLike(String value) {
addCriterion("subject like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotLike(String value) {
addCriterion("subject not like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectIn(List<String> values) {
addCriterion("subject in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotIn(List<String> values) {
addCriterion("subject not in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectBetween(String value1, String value2) {
addCriterion("subject between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotBetween(String value1, String value2) {
addCriterion("subject not between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andPayNotifyUrlIsNull() {
addCriterion("pay_notify_url is null");
return (Criteria) this;
}
public Criteria andPayNotifyUrlIsNotNull() {
addCriterion("pay_notify_url is not null");
return (Criteria) this;
}
public Criteria andPayNotifyUrlEqualTo(String value) {
addCriterion("pay_notify_url =", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlNotEqualTo(String value) {
addCriterion("pay_notify_url <>", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlGreaterThan(String value) {
addCriterion("pay_notify_url >", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlGreaterThanOrEqualTo(String value) {
addCriterion("pay_notify_url >=", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlLessThan(String value) {
addCriterion("pay_notify_url <", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlLessThanOrEqualTo(String value) {
addCriterion("pay_notify_url <=", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlLike(String value) {
addCriterion("pay_notify_url like", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlNotLike(String value) {
addCriterion("pay_notify_url not like", value, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlIn(List<String> values) {
addCriterion("pay_notify_url in", values, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlNotIn(List<String> values) {
addCriterion("pay_notify_url not in", values, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlBetween(String value1, String value2) {
addCriterion("pay_notify_url between", value1, value2, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andPayNotifyUrlNotBetween(String value1, String value2) {
addCriterion("pay_notify_url not between", value1, value2, "payNotifyUrl");
return (Criteria) this;
}
public Criteria andCreateTypeIsNull() {
addCriterion("create_type is null");
return (Criteria) this;

@ -0,0 +1,41 @@
package com.hfkj.openapi.v1.model;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* 请求账单下载模型
* @className: TradePreorderModel
* @author: HuRui
* @date: 2023/5/23
**/
@Data
public class RequestTradeBillsModel {
/**
* 商户号
*/
@NotBlank(message = "商户号必填项")
private String merchantNo;
/**
* 报表开始时间
*/
@NotBlank(message = "开始时间必填项")
private Long billDateS;
/**
* 报表结束时间
*/
@NotBlank(message = "结束时间必填项")
private Long billDateE;
/**
* 签名参数
*/
@NotBlank(message = "签名必填项")
private String sign;
}

@ -52,11 +52,13 @@ public class RequestTradePreorderModel {
/**
* 订单标题
*/
@Length(max = 30, message = "订单标题长度限制在30字符以内")
private String subject;
/**
* 通知地址
*/
@Length(max = 300, message = "通知地址长度限制在300字符以内")
private String notifyUrl;
/**

@ -0,0 +1,70 @@
package com.hfkj.openapi.v1.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 交易账单模型
* @className: TradeBillsModel
* @author: HuRui
* @date: 2023/5/25
**/
@Data
public class TradeBillsModel {
@ColumnWidth(25)
@ExcelProperty("交易时间")
private Date payTime;
@ColumnWidth(25)
@ExcelProperty("商户号")
private String merchantNo;
@ColumnWidth(25)
@ExcelProperty("平台交易单号")
private String platformTradeNo;
@ColumnWidth(25)
@ExcelProperty("商户交易单号")
private String outTradeNo;
@ColumnWidth(25)
@ExcelProperty("用户标识")
private String payUserId;
@ColumnWidth(20)
@ExcelProperty("交易类型")
private String tradeType;
@ColumnWidth(15)
@ExcelProperty("交易方式")
private String payMode;
@ColumnWidth(15)
@ExcelProperty("交易方式")
private String tradeStatus;
@ColumnWidth(15)
@ExcelProperty("交易金额")
private BigDecimal tradeAmount;
@ColumnWidth(20)
@ExcelProperty("交易实付金额")
private BigDecimal tradeActualAmount;
@ColumnWidth(15)
@ExcelProperty("退款类型")
private String refundType;
@ColumnWidth(15)
@ExcelProperty("退款金额")
private BigDecimal refundPrice;
@ColumnWidth(15)
@ExcelProperty("交易标题")
private String subject;
@ColumnWidth(15)
@ExcelProperty("创建方式")
private String createType;
}

@ -4,7 +4,9 @@ import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.openapi.v1.model.RequestRefundTradeModel;
import com.hfkj.openapi.v1.model.ResponseRefundTradeModel;
import com.hfkj.openapi.v1.model.TradeBillsModel;
import java.util.List;
import java.util.Map;
/**
@ -40,4 +42,13 @@ public interface OpenApiTradeOrderService {
* @return
*/
BsTradeOrderRefund getRefundByNo(String refundNo);
/**
* 交易账单
* @param merNo
* @param billDateS
* @param billDateE
* @return
*/
List<TradeBillsModel> tradeBills(String merNo, Long billDateS, Long billDateE);
}

@ -5,11 +5,13 @@ import com.hfkj.channel.lakala.LaKaLaTradeService;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.entity.BsTradeOrderExample;
import com.hfkj.entity.BsTradeOrderRefund;
import com.hfkj.dao.OpenApiTradeOrderMapper;
import com.hfkj.openapi.v1.model.RequestRefundTradeModel;
import com.hfkj.openapi.v1.model.ResponseRefundTradeModel;
import com.hfkj.openapi.v1.model.TradeBillsModel;
import com.hfkj.openapi.v1.service.OpenApiTradeOrderService;
import com.hfkj.openapi.v1.utils.SignatureUtil;
import com.hfkj.service.BsMerKeyService;
@ -24,6 +26,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -34,6 +38,9 @@ import java.util.Map;
@Service("openApiTradeOrderService")
public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService {
@Resource
private OpenApiTradeOrderMapper openApiTradeOrderMapper;
@Resource
private BsTradeOrderService bsTradeOrderService;
@ -118,4 +125,12 @@ public class OpenApiTradeOrderServiceImpl implements OpenApiTradeOrderService {
return bsTradeOrderRefundService.getRefundByRefundNo(refundNo);
}
@Override
public List<TradeBillsModel> tradeBills(String merNo, Long billDateS, Long billDateE) {
return openApiTradeOrderMapper.queryTradeBills(merNo,
DateUtil.date2String(new Date(billDateS), DateUtil.Y_M_D_HMS),
DateUtil.date2String(new Date(billDateE), DateUtil.Y_M_D_HMS)
);
}
}

@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
@ -37,7 +38,7 @@ public class SignatureUtil {
Map map = JSONObject.parseObject(JSONObject.toJSONString(param), Map.class);
// 去除签名
map.remove("sign");
if (checkSign.equals(md5Encode(paramSort(map, key).getBytes()))) {
if (checkSign.equals(createSign(map, key))) {
return true;
}
return false;
@ -51,6 +52,7 @@ public class SignatureUtil {
public static String paramSort(final Map<String, Object> param, String key) {
Set<String> keySet = param.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (StringUtils.isBlank(sb.toString())) {
@ -80,8 +82,16 @@ public class SignatureUtil {
public static void main(String[] args) throws Exception {
String paramStr = "{\n" +
" \"merchantNo\": \"2023030909414450700\",\n" +
" \"refundTradeNo\": \"1170202305051137247442194606\"" +
" \"merchantNo\": \"2023030909414450700\",\n" +
" \"outTradeNo\": \"ZF1130202305051459532538978812\",\n" +
" \"payMode\": \"ALIPAY\",\n" +
" \"totalAmount\": 0.01,\n" +
" \"transType\": \"JSAPI\",\n" +
" \"subject\": \"支付测试\",\n" +
" \"userId\": \"2088612673845396\",\n" +
" \"profitSharing\": 0,\n" +
" \"timeoutExpress\": \"5\",\n" +
" \"notifyUrl\": \"https://gratia-pay.dctpay.com/crest/laKaLaNotify/microPay\"\n" +
"}";
String sign = createSign(JSONObject.parseObject(paramStr), "LRL9uflTQGeyp9yVWDD6orhBp2VhYDvP");
System.out.println(sign);

@ -231,51 +231,53 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
}
editOrder(tradeOrder);
Map<String,Object> param = new HashMap<>();
param.put("storeId", tradeOrder.getStoreId());
param.put("deviceType", DeviceTypeEnum.type1.getNumber());
param.put("status", DeviceStatusEnum.status1.getNumber());
List<BsDevice> deviceList = deviceService.getDeviceList(param);
for (BsDevice device : deviceList) {
soundService.sendPayMsg(device.getDeviceNo(), tradeOrder.getTradeAmount());
}
if (tradeOrder.getCreateType() != null && !tradeOrder.getCreateType().equals(TradeOrderCreateTypeEnum.type3.getCode())) {
Map<String,Object> param = new HashMap<>();
param.put("storeId", tradeOrder.getStoreId());
param.put("deviceType", DeviceTypeEnum.type1.getNumber());
param.put("status", DeviceStatusEnum.status1.getNumber());
List<BsDevice> deviceList = deviceService.getDeviceList(param);
for (BsDevice device : deviceList) {
soundService.sendPayMsg(device.getDeviceNo(), tradeOrder.getTradeAmount());
}
if (tradeOrder.getStoreDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
// 支付返积分
HsgIntegralService.rebate(RebateProductTypeEnum.type2,
tradeOrder.getUserPhone(),
tradeOrder.getOutTradeNo(),
tradeOrder.getId(),
tradeOrder.getStoreDiscountProfitPrice(),
tradeOrder.getStoreName(),
tradeOrder.getCreateTime());
BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId());
if (partakeUser != null) {
partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() - 1);
partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() + 1);
discountActivityPartakeUserService.editData(partakeUser);
if (tradeOrder.getStoreDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
// 支付返积分
HsgIntegralService.rebate(RebateProductTypeEnum.type2,
tradeOrder.getUserPhone(),
tradeOrder.getOutTradeNo(),
tradeOrder.getId(),
tradeOrder.getStoreDiscountProfitPrice(),
tradeOrder.getStoreName(),
tradeOrder.getCreateTime());
BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId());
if (partakeUser != null) {
partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() - 1);
partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() + 1);
discountActivityPartakeUserService.editData(partakeUser);
}
}
}
if (tradeOrder.getUserDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
userDiscountService.userDiscountUse(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone());
}
if (tradeOrder.getUserDiscountId() != null && StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
userDiscountService.userDiscountUse(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone());
}
if (StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
// 支付返积分
HsgIntegralService.rebate(RebateProductTypeEnum.type1,
tradeOrder.getUserPhone(),
tradeOrder.getOutTradeNo(),
tradeOrder.getId(),
tradeOrder.getTradeActualAmount(),
tradeOrder.getStoreName(),
tradeOrder.getCreateTime());
}
if (StringUtils.isNotBlank(tradeOrder.getUserPhone())) {
// 支付返积分
HsgIntegralService.rebate(RebateProductTypeEnum.type1,
tradeOrder.getUserPhone(),
tradeOrder.getOutTradeNo(),
tradeOrder.getId(),
tradeOrder.getTradeActualAmount(),
tradeOrder.getStoreName(),
tradeOrder.getCreateTime());
}
// 创建分账
if (tradeOrder.getProfitSharingStatus().equals(true)) {
tradeOrderProfitSharingService.createProfitSharing(tradeOrder);
// 创建分账
if (tradeOrder.getProfitSharingStatus().equals(true)) {
tradeOrderProfitSharingService.createProfitSharing(tradeOrder);
}
}
}
}

@ -19,6 +19,7 @@ lkl_v2_serial_no=00dfba8194c41b84cf
lkl_v2_private_key=/home/project/gratia-pay/cert/lakala/v2/OP00000003_private_key.text
lkl_mer_contract_ret_url=https://gratia-pay.dctpay.com/brest/laKaLaNotify/merContract
lkl_micro_pay_ret_url=https://gratia-pay.dctpay.com/crest/laKaLaNotify/microPay
lkl_open_api_pay_notify_url=https://gratia-pay.dctpay.com/openApi/v1/payNotify/lakala
lkl_saas_client_id=testsit
lkl_saas_client_secret=EguwEckByf2I6u6z

@ -16,6 +16,7 @@ lkl_v2_serial_no=01752b7386f8
lkl_v2_private_key=/home/project/gratia-pay/cert/lakala/v2/prod_private.text
lkl_mer_contract_ret_url=https://pay.dctpay.com/brest/laKaLaNotify/merContract
lkl_micro_pay_ret_url=https://pay.dctpay.com/crest/laKaLaNotify/microPay
lkl_open_api_pay_notify_url=https://pay.dctpay.com/openApi/v1/payNotify/lakala
lkl_saas_client_id=huifu
lkl_saas_client_secret=f65VVjqJfLtc177F

Loading…
Cancel
Save