diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index d2deebe..e3b5a41 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -91,6 +91,20 @@ public class TestController { @Resource private LaKaLaTradeService laKaLaTradeService; + @RequestMapping(value="/preorder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "preorder") + public ResponseData preorder(@RequestParam(value = "tradeNo", required = true) String tradeNo) { + try { + + return ResponseMsgUtil.success(laKaLaTradeService.preorder(tradeNo)); + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/brushOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "saasUpdateFee") diff --git a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java index 173fe87..8bee99f 100644 --- a/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java +++ b/cweb/src/main/java/com/cweb/controller/BsTradeOrderController.java @@ -283,6 +283,7 @@ public class BsTradeOrderController { param.put("qrCodeId", payQrCode.getId()); param.put("payMode", body.getString("payMode")); param.put("payUserId", body.getString("payUserId")); + param.put("transType", "JSAPI"); // 创建交易订单 return ResponseMsgUtil.success(tradeOrderService.createOrder( @@ -300,56 +301,6 @@ public class BsTradeOrderController { } } - @RequestMapping(value="/createOrder",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "创建交易订单") - public ResponseData createOrder(@RequestBody JSONObject body, HttpServletRequest request) { - try { - - if (body == null - || body.getLong("storeNo") == null - || body.getBigDecimal("totalAmount") == null - ) { - log.error("configStore error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - if (body.getBigDecimal("totalAmount").compareTo(new BigDecimal("0.01")) == -1) { - log.error("configStore error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付金额不能小于0.01"); - } - - // 查询门店 - BsStore store = storeService.getStoreByStoreNo(body.getLong("storeNo")); - if (store == null) { - log.error("configStore error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的门店"); - } - if (!store.getStatus().equals(StoreStatusEnum.status1.getNumber())) { - log.error("configStore error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "创建交易失败!门店状态异常"); - } - - // 商户 - BsMer mer = merService.getMer(store.getMerId()); - if (mer == null) { - log.error("configStore error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); - } - if (!mer.getMerStatus().equals(MerStatusEnum.status1.getNumber())) { - log.error("configStore error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "创建交易失败!商户状态异常"); - } - - // 创建交易订单 - return ResponseMsgUtil.success(tradeOrderService.createOrder(store.getId(), body.getBigDecimal("totalAmount"), null, null,null,new HashMap<>(),request)); - - } catch (Exception e) { - log.error(e.getMessage(), e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value="/getOrderByOutTradeOrder",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据交易订单号 查询订单信息") diff --git a/open-api/src/main/java/com/api/controller/v1/TradeController.java b/open-api/src/main/java/com/api/controller/v1/TradeController.java index 8f91d99..cc111d6 100644 --- a/open-api/src/main/java/com/api/controller/v1/TradeController.java +++ b/open-api/src/main/java/com/api/controller/v1/TradeController.java @@ -24,6 +24,7 @@ import com.hfkj.service.BsMerService; import com.hfkj.sysenum.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.validation.constraints.NotBlank; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -65,9 +67,12 @@ public class TradeController { if (!SignatureUtil.checkSign(body.getSign(), body, merKeyService.getKeyByMerNo(body.getMerchantNo()))) { throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); } - if (!body.getTransType().equals("JSAPI")) { + if (!body.getTransType().equals("JSAPI") && !body.getTransType().equals("NATIVE")) { throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "接入方式错误"); } + if (body.getTransType().equals("JSAPI") && StringUtils.isBlank(body.getUserId())) { + throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "用户标识必填项"); + } // 查询支付方式 TradeOrderPayModeEnum payMode = TradeOrderPayModeEnum.getNameByCode(body.getPayMode()); if (payMode == null) { @@ -88,6 +93,7 @@ public class TradeController { } BsTradeOrder tradeOrder = new BsTradeOrder(); + tradeOrder.setTransType(body.getTransType()); tradeOrder.setCompanyId(mer.getCompanyId()); tradeOrder.setAgentId(mer.getAgentId()); tradeOrder.setSalesmanId(mer.getSalesmanId()); diff --git a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java index 24bcc17..4258eab 100644 --- a/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java +++ b/service/src/main/java/com/hfkj/channel/lakala/LaKaLaTradeService.java @@ -212,7 +212,7 @@ public class LaKaLaTradeService { map.put("term_no", merPlatformTerm.getTermNo()); map.put("out_trade_no", order.getOutTradeNo()); map.put("account_type", order.getPayMode()); - map.put("trans_type", 51); + map.put("trans_type", order.getTransType().equals("JSAPI")?51:41); map.put("total_amount", order.getTradeActualAmount().multiply(new BigDecimal("100")).intValue()); map.put("settle_type", order.getProfitSharingStatus()==true?1:0); if (StringUtils.isNotBlank(order.getSubject())) { @@ -226,7 +226,11 @@ public class LaKaLaTradeService { map.put("notify_url", CommonSysConst.getSysConfig().getLkl_micro_pay_ret_url()); } Map locationInfo = new HashMap<>(); - locationInfo.put("request_ip", "0.0.0.0"); + if (StringUtils.isNotBlank(order.getRequestIp())) { + locationInfo.put("request_ip", order.getRequestIp()); + } else { + locationInfo.put("request_ip", "0.0.0.0"); + } map.put("location_info", locationInfo); Map accBusiFieldsMap = new HashMap<>(); diff --git a/service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java b/service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java index 7bc8414..3c17f6e 100644 --- a/service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsTradeOrderMapper.java @@ -70,10 +70,10 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { "subject, pay_notify_url, ", "attach, special_field, ", "refund_type, refund_price, ", - "create_type, create_time, ", - "cancel_time, update_time, ", - "request_ip, ext_1, ", - "ext_2, ext_3)", + "create_type, trans_type, ", + "create_time, cancel_time, ", + "update_time, request_ip, ", + "ext_1, ext_2, ext_3)", "values (#{companyId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", "#{salesmanId,jdbcType=BIGINT}, #{salesmanName,jdbcType=VARCHAR}, ", "#{merId,jdbcType=BIGINT}, #{merName,jdbcType=VARCHAR}, #{merAbbreviate,jdbcType=VARCHAR}, ", @@ -105,10 +105,10 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { "#{subject,jdbcType=VARCHAR}, #{payNotifyUrl,jdbcType=VARCHAR}, ", "#{attach,jdbcType=VARCHAR}, #{specialField,jdbcType=VARCHAR}, ", "#{refundType,jdbcType=INTEGER}, #{refundPrice,jdbcType=DECIMAL}, ", - "#{createType,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{cancelTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{requestIp,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", - "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{createType,jdbcType=INTEGER}, #{transType,jdbcType=VARCHAR}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{requestIp,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(BsTradeOrder record); @@ -185,6 +185,7 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { @Result(column="refund_type", property="refundType", jdbcType=JdbcType.INTEGER), @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), @Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER), + @Result(column="trans_type", property="transType", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -209,8 +210,8 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { "acc_settle_amount, acc_mdiscount_amount, acc_discount_amount, shd_fee_amt, fee_rate, ", "settle_amount, settle_date, acc_payment_code, card_type, `status`, profit_sharing_status, ", "pay_time, timeout_express, subject, pay_notify_url, attach, special_field, refund_type, ", - "refund_price, create_type, create_time, cancel_time, update_time, request_ip, ", - "ext_1, ext_2, ext_3", + "refund_price, create_type, trans_type, create_time, cancel_time, update_time, ", + "request_ip, ext_1, ext_2, ext_3", "from bs_trade_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -281,6 +282,7 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { @Result(column="refund_type", property="refundType", jdbcType=JdbcType.INTEGER), @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), @Result(column="create_type", property="createType", jdbcType=JdbcType.INTEGER), + @Result(column="trans_type", property="transType", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -367,6 +369,7 @@ public interface BsTradeOrderMapper extends BsTradeOrderMapperExt { "refund_type = #{refundType,jdbcType=INTEGER},", "refund_price = #{refundPrice,jdbcType=DECIMAL},", "create_type = #{createType,jdbcType=INTEGER},", + "trans_type = #{transType,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "cancel_time = #{cancelTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java index a91384d..a5b0533 100644 --- a/service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsTradeOrderSqlProvider.java @@ -288,6 +288,10 @@ public class BsTradeOrderSqlProvider { sql.VALUES("create_type", "#{createType,jdbcType=INTEGER}"); } + if (record.getTransType() != null) { + sql.VALUES("trans_type", "#{transType,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } @@ -391,6 +395,7 @@ public class BsTradeOrderSqlProvider { sql.SELECT("refund_type"); sql.SELECT("refund_price"); sql.SELECT("create_type"); + sql.SELECT("trans_type"); sql.SELECT("create_time"); sql.SELECT("cancel_time"); sql.SELECT("update_time"); @@ -679,6 +684,10 @@ public class BsTradeOrderSqlProvider { sql.SET("create_type = #{record.createType,jdbcType=INTEGER}"); } + if (record.getTransType() != null) { + sql.SET("trans_type = #{record.transType,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); } @@ -781,6 +790,7 @@ public class BsTradeOrderSqlProvider { sql.SET("refund_type = #{record.refundType,jdbcType=INTEGER}"); sql.SET("refund_price = #{record.refundPrice,jdbcType=DECIMAL}"); sql.SET("create_type = #{record.createType,jdbcType=INTEGER}"); + sql.SET("trans_type = #{record.transType,jdbcType=VARCHAR}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("cancel_time = #{record.cancelTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); @@ -1058,6 +1068,10 @@ public class BsTradeOrderSqlProvider { sql.SET("create_type = #{createType,jdbcType=INTEGER}"); } + if (record.getTransType() != null) { + sql.SET("trans_type = #{transType,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } diff --git a/service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java b/service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java index 70db9c9..c0e420f 100644 --- a/service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java +++ b/service/src/main/java/com/hfkj/dao/OpenApiTradeOrderMapper.java @@ -24,7 +24,7 @@ public interface OpenApiTradeOrderMapper { " a.acc_trade_no accTradeNo," + " a.out_trade_no outTradeNo, " + " a.pay_user_id payUserId, " + - " \"JSAPI\" as tradeType," + + " a.trans_type tradeType," + " case a.pay_mode" + " when \"WECHAT\" then '微信'" + " when \"ALIPAY\" then '支付宝'" + diff --git a/service/src/main/java/com/hfkj/entity/BsTradeOrder.java b/service/src/main/java/com/hfkj/entity/BsTradeOrder.java index 532eba5..16f3e70 100644 --- a/service/src/main/java/com/hfkj/entity/BsTradeOrder.java +++ b/service/src/main/java/com/hfkj/entity/BsTradeOrder.java @@ -348,6 +348,11 @@ public class BsTradeOrder implements Serializable { */ private Integer createType; + /** + * 接入方式 JSAPI,NATIVE + */ + private String transType; + /** * 创建时间 */ @@ -904,6 +909,14 @@ public class BsTradeOrder implements Serializable { this.createType = createType; } + public String getTransType() { + return transType; + } + + public void setTransType(String transType) { + this.transType = transType; + } + public Date getCreateTime() { return createTime; } @@ -1038,6 +1051,7 @@ public class BsTradeOrder implements Serializable { && (this.getRefundType() == null ? other.getRefundType() == null : this.getRefundType().equals(other.getRefundType())) && (this.getRefundPrice() == null ? other.getRefundPrice() == null : this.getRefundPrice().equals(other.getRefundPrice())) && (this.getCreateType() == null ? other.getCreateType() == null : this.getCreateType().equals(other.getCreateType())) + && (this.getTransType() == null ? other.getTransType() == null : this.getTransType().equals(other.getTransType())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) @@ -1117,6 +1131,7 @@ public class BsTradeOrder implements Serializable { result = prime * result + ((getRefundType() == null) ? 0 : getRefundType().hashCode()); result = prime * result + ((getRefundPrice() == null) ? 0 : getRefundPrice().hashCode()); result = prime * result + ((getCreateType() == null) ? 0 : getCreateType().hashCode()); + result = prime * result + ((getTransType() == null) ? 0 : getTransType().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); @@ -1199,6 +1214,7 @@ public class BsTradeOrder implements Serializable { sb.append(", refundType=").append(refundType); sb.append(", refundPrice=").append(refundPrice); sb.append(", createType=").append(createType); + sb.append(", transType=").append(transType); sb.append(", createTime=").append(createTime); sb.append(", cancelTime=").append(cancelTime); sb.append(", updateTime=").append(updateTime); diff --git a/service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java b/service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java index 24c5088..f8181da 100644 --- a/service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java +++ b/service/src/main/java/com/hfkj/entity/BsTradeOrderExample.java @@ -4363,6 +4363,76 @@ public class BsTradeOrderExample { return (Criteria) this; } + public Criteria andTransTypeIsNull() { + addCriterion("trans_type is null"); + return (Criteria) this; + } + + public Criteria andTransTypeIsNotNull() { + addCriterion("trans_type is not null"); + return (Criteria) this; + } + + public Criteria andTransTypeEqualTo(String value) { + addCriterion("trans_type =", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeNotEqualTo(String value) { + addCriterion("trans_type <>", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeGreaterThan(String value) { + addCriterion("trans_type >", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeGreaterThanOrEqualTo(String value) { + addCriterion("trans_type >=", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeLessThan(String value) { + addCriterion("trans_type <", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeLessThanOrEqualTo(String value) { + addCriterion("trans_type <=", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeLike(String value) { + addCriterion("trans_type like", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeNotLike(String value) { + addCriterion("trans_type not like", value, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeIn(List values) { + addCriterion("trans_type in", values, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeNotIn(List values) { + addCriterion("trans_type not in", values, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeBetween(String value1, String value2) { + addCriterion("trans_type between", value1, value2, "transType"); + return (Criteria) this; + } + + public Criteria andTransTypeNotBetween(String value1, String value2) { + addCriterion("trans_type not between", value1, value2, "transType"); + return (Criteria) this; + } + public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java index 30c9baa..f8fe6d5 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java +++ b/service/src/main/java/com/hfkj/openapi/v1/model/request/RequestTradePreorderModel.java @@ -64,7 +64,6 @@ public class RequestTradePreorderModel { /** * 用户id */ - @NotBlank(message = "用户标识必填项") private String userId; /** diff --git a/service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java b/service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java index 49d5e9f..50fa4e1 100644 --- a/service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java +++ b/service/src/main/java/com/hfkj/openapi/v1/utils/SignatureUtil.java @@ -83,11 +83,10 @@ public class SignatureUtil { public static void main(String[] args) throws Exception { String paramStr = "{\n" + " \"merchantNo\": \"2023041916292112804\",\n" + - " \"outTradeNo\": \"ZF1130202305051459532538970007\",\n" + - " \"payMode\": \"WECHAT\",\n" + + " \"outTradeNo\": \"ZF1130202305051459532538970009\",\n" + + " \"payMode\": \"UQRCODEPAY\",\n" + " \"totalAmount\": 0.01,\n" + - " \"transType\": \"JSAPI\",\n" + - " \"userId\": \"od8qG06bHnTsDWklsB2VsssLZYcQ\",\n" + + " \"transType\": \"NATIVE\",\n" + " \"profitSharing\": 0,\n" + " \"specialField\": \"测试\"" + "}"; diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java index 2aa2be7..f89e4d6 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderServiceImpl.java @@ -205,6 +205,10 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService { tradeOrder.setQrCodeId(MapUtils.getLong(param, "qrCodeId")); } + if (StringUtils.isNotBlank(MapUtils.getString(param, "transType"))) { + tradeOrder.setTransType(MapUtils.getString(param, "transType")); + } + editOrder(tradeOrder); Map returnParam = new HashMap<>();