From 08dad6795acce4a3e43487f34366f0a5f33b677c Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Mon, 14 Apr 2025 09:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cweb/config/AuthConfig.java | 2 + .../BsUserSpreadAccountController.java | 56 +- .../com/cweb/controller/TestController.java | 113 ++ .../controller/WeiXinNotifyController.java | 86 ++ .../hfkj/schedule/OrderSettleSchedule.java | 20 + service/pom.xml | 2 +- .../main/java/com/hfkj/common/Base64Util.java | 12 +- .../java/com/hfkj/common/utils/WxUtils.java | 480 +++----- .../com/hfkj/dao/BsGasOrderSpreadMapper.java | 36 +- .../hfkj/dao/BsGasOrderSpreadMapperExt.java | 35 +- .../hfkj/dao/BsGasOrderSpreadSqlProvider.java | 28 - .../BsUserSpreadAccountRecordMapperExt.java | 8 +- .../BsUserSpreadAccountTransferMapper.java | 130 ++ .../BsUserSpreadAccountTransferMapperExt.java | 7 + ...sUserSpreadAccountTransferSqlProvider.java | 346 ++++++ .../com/hfkj/entity/BsGasOrderSpread.java | 32 - .../hfkj/entity/BsGasOrderSpreadExample.java | 120 -- .../entity/BsUserSpreadAccountTransfer.java | 249 ++++ .../BsUserSpreadAccountTransferExample.java | 1064 +++++++++++++++++ .../service/gas/BsGasOrderSpreadService.java | 2 +- .../gas/impl/BsGasOrderSpreadServiceImpl.java | 6 +- .../service/order/OrderCreateService.java | 2 +- .../BsUserSpreadAccountRecordService.java | 15 + .../spread/BsUserSpreadAccountService.java | 23 + .../BsUserSpreadAccountTransferService.java | 31 + .../BsUserSpreadAccountRecordServiceImpl.java | 25 + .../impl/BsUserSpreadAccountServiceImpl.java | 91 +- ...sUserSpreadAccountTransferServiceImpl.java | 49 + .../BsUserSpreadOilChannelServiceImpl.java | 2 +- ...UserSpreadAccountRecordSourceTypeEnum.java | 4 + 30 files changed, 2495 insertions(+), 581 deletions(-) create mode 100644 cweb/src/main/java/com/cweb/controller/TestController.java create mode 100644 cweb/src/main/java/com/cweb/controller/WeiXinNotifyController.java create mode 100644 service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapper.java create mode 100644 service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapperExt.java create mode 100644 service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferSqlProvider.java create mode 100644 service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransfer.java create mode 100644 service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransferExample.java create mode 100644 service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountTransferService.java create mode 100644 service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountTransferServiceImpl.java diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index bedb297..876213c 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -101,6 +101,8 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/phg/*") .excludePathPatterns("/weiXinSub/*") .excludePathPatterns("/userMsg/*") + .excludePathPatterns("/test/*") + .excludePathPatterns("/wexinNotify/*") ; } diff --git a/cweb/src/main/java/com/cweb/controller/BsUserSpreadAccountController.java b/cweb/src/main/java/com/cweb/controller/BsUserSpreadAccountController.java index a0806b6..f466dac 100644 --- a/cweb/src/main/java/com/cweb/controller/BsUserSpreadAccountController.java +++ b/cweb/src/main/java/com/cweb/controller/BsUserSpreadAccountController.java @@ -1,5 +1,6 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; @@ -10,17 +11,16 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsUserSpreadAccount; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; +import com.hfkj.service.gas.BsGasOrderSpreadService; import com.hfkj.service.spread.BsUserSpreadAccountRecordService; import com.hfkj.service.spread.BsUserSpreadAccountService; 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; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; @@ -41,6 +41,8 @@ public class BsUserSpreadAccountController { @Resource private BsUserSpreadAccountService userSpreadAccountService; @Resource + private BsGasOrderSpreadService gasOrderSpreadService; + @Resource private BsUserSpreadAccountRecordService userSpreadAccountRecordService; @RequestMapping(value = "/getAccount", method = RequestMethod.GET) @@ -62,7 +64,7 @@ public class BsUserSpreadAccountController { // 账户余额 map.put("amount", userSpreadAccount.getAmount()); map.put("cashOutAmount", userSpreadAccount.getCashOutAmount()); - map.put("notCashOutAmount", userSpreadAccount.getCashOutAmount()); + map.put("notCashOutAmount", gasOrderSpreadService.getNotCashOutAmount(userSpreadAccount.getUserId())); return ResponseMsgUtil.success(map); } catch (Exception e) { @@ -70,6 +72,50 @@ public class BsUserSpreadAccountController { } } + @RequestMapping(value = "/withdraw", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "提现") + public ResponseData withdraw(@RequestBody JSONObject body) { + try { + if (body == null + || body.getBigDecimal("amount") == null + || StringUtils.isBlank(body.getString("openId"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 用户session + UserSessionObject userSessionObject = userCenter.getSessionModel(UserSessionObject.class); + if (userSessionObject == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + return ResponseMsgUtil.success(userSpreadAccountService.withdraw(userSessionObject.getUser().getId(),body.getString("openId"), body.getBigDecimal("amount"))); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/cancelWithdraw", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "撤销提现") + public ResponseData cancelWithdraw(@RequestBody JSONObject body) { + try { + if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 用户session + UserSessionObject userSessionObject = userCenter.getSessionModel(UserSessionObject.class); + if (userSessionObject == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 撤销提现 + userSpreadAccountService.cancelWithdraw(body.getString("orderNo")); + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } @RequestMapping(value = "/getRecordList", method = RequestMethod.GET) @ResponseBody diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java new file mode 100644 index 0000000..3f3e32e --- /dev/null +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -0,0 +1,113 @@ +package com.cweb.controller; + + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.common.utils.WxUtils; +import com.hfkj.entity.BsUserSpreadAccount; +import com.hfkj.model.ResponseData; +import com.hfkj.model.UserSessionObject; +import com.hfkj.service.gas.BsGasOrderSpreadService; +import com.hfkj.service.spread.BsUserSpreadAccountRecordService; +import com.hfkj.service.spread.BsUserSpreadAccountService; +import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * @className: BsUserSpreadAccountController + * @author: HuRui + * @date: 2025/3/31 + **/ +@Controller +@RequestMapping(value = "/test") +@Api(value = "个人推广账户业务") +public class TestController { + private static Logger log = LoggerFactory.getLogger(TestController.class); + @Resource + private UserCenter userCenter; + @Resource + private BsUserSpreadAccountService userSpreadAccountService; + @Resource + private BsGasOrderSpreadService gasOrderSpreadService; + + @RequestMapping(value = "/settleOrder", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "结算订单") + public ResponseData settleOrder() { + try { + gasOrderSpreadService.settleOrder(4L); + + return ResponseMsgUtil.success(""); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/transferBills", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "转账交易") + public ResponseData transferBills() { + try { + + JSONObject obj = WxUtils.transferBills("oUGn_4unIjp90MY-oEXluY4laDrQ",""+System.currentTimeMillis(), new BigDecimal("0.1"), "推广佣金提现"); + + System.out.println("响应内容:"+obj); + return ResponseMsgUtil.success(obj); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/cancelTransferBills", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "取消转账") + public ResponseData cancelTransferBills(@RequestParam(value = "outBillNo", required = true) String outBillNo) { + try { + + return ResponseMsgUtil.success(WxUtils.cancelTransferBills(outBillNo)); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/queryTransferBills", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询转账详情") + public ResponseData queryTransferBills(@RequestParam(value = "outBillNo", required = true) String outBillNo) { + try { + + return ResponseMsgUtil.success(WxUtils.queryTransferBills(outBillNo)); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/cweb/src/main/java/com/cweb/controller/WeiXinNotifyController.java b/cweb/src/main/java/com/cweb/controller/WeiXinNotifyController.java new file mode 100644 index 0000000..442ebac --- /dev/null +++ b/cweb/src/main/java/com/cweb/controller/WeiXinNotifyController.java @@ -0,0 +1,86 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.Base64Util; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsUserSpreadAccountRecord; +import com.hfkj.model.ResponseData; +import com.hfkj.service.spread.BsUserSpreadAccountRecordService; +import com.hfkj.service.spread.BsUserSpreadAccountService; +import com.hfkj.sysenum.spread.UserSpreadAccountRecordSourceTypeEnum; +import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedOutputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @className: WeiXinNotifyController + * @author: HuRui + * @date: 2025/4/10 + **/ +@Controller +@RequestMapping(value = "/wexinNotify") +@Api(value = "微信通知") +public class WeiXinNotifyController { + @Resource + private BsUserSpreadAccountRecordService userSpreadAccountRecordService; + @Resource + private BsUserSpreadAccountService userSpreadAccountService; + + @RequestMapping(value = "/withdraw", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "提现通知") + public void withdraw(@RequestBody JSONObject body, HttpServletResponse response) { + try { + System.out.println("提现通知:"+body.toJSONString()); + + JSONObject resource = body.getJSONObject("resource"); + // 解析后的数据 + String dataStr = new AesUtil("UXt3EGM5X6P71EXcNmszV1ONk7LX9IEj".getBytes()) + .decryptToString( + resource.getString("associated_data").getBytes(), + resource.getString("nonce").getBytes(), + resource.getString("ciphertext")); + + JSONObject data = JSONObject.parseObject(dataStr); + String outBillNo = data.getString("out_bill_no"); + + // 记录 + BsUserSpreadAccountRecord record = userSpreadAccountRecordService.getRecordByOrderNo(outBillNo); + if (record != null) { + String state = data.getString("state"); + if (state.equals("CANCELLED") || state.equals("FAIL")) { + // 充值余账户余额 + Map otherParam = new HashMap<>(); + otherParam.put("sourceContent", state.equals("CANCELLED")?"撤销提现":"转账失败"); + otherParam.put("sourceOrderNo", DateUtil.date2String(new Date(), DateUtil.YMDHMS)); + userSpreadAccountService.increase(record.getUserId(), record.getTransactionAmount(), UserSpreadAccountRecordSourceTypeEnum.type4, otherParam); + } + } + + BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); + JSONObject result = new JSONObject(); + result.put("code", "SUCCESS"); + result.put("message", ""); + out.write(result.toJSONString().getBytes()); + out.flush(); + out.close(); + + } catch (Exception e) { + System.out.println("提现通知出现异常:"+e.getMessage()); + } + } + +} diff --git a/schedule/src/main/java/com/hfkj/schedule/OrderSettleSchedule.java b/schedule/src/main/java/com/hfkj/schedule/OrderSettleSchedule.java index 7206ebf..a7e1ab0 100644 --- a/schedule/src/main/java/com/hfkj/schedule/OrderSettleSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/OrderSettleSchedule.java @@ -3,9 +3,12 @@ package com.hfkj.schedule; import com.alibaba.fastjson.JSONObject; import com.hfkj.entity.BsOrderSettle; import com.hfkj.entity.BsOrderSettleLedger; +import com.hfkj.entity.BsUserSpreadAccount; import com.hfkj.pay.HuiPayService; +import com.hfkj.service.gas.BsGasOrderSpreadService; import com.hfkj.service.order.BsOrderSettleLedgerService; import com.hfkj.service.order.BsOrderSettleService; +import com.hfkj.service.spread.BsUserSpreadAccountService; import com.hfkj.sysenum.order.OrderSettleLedgerStatusEnum; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -27,6 +30,22 @@ public class OrderSettleSchedule { private BsOrderSettleService orderSettleService; @Resource private BsOrderSettleLedgerService orderSettleLedgerService; + @Resource + private BsUserSpreadAccountService userSpreadAccountService; + @Resource + private BsGasOrderSpreadService gasOrderSpreadService; + + @Scheduled(cron = "0 0 0 * * ?") // 每日凌晨00:00:00执行一次 + public void userSpread() { + List accountList = userSpreadAccountService.getList(new HashMap<>()); + for (BsUserSpreadAccount account : accountList) { + try { + gasOrderSpreadService.settleOrder(account.getUserId()); + } catch (Exception e) { + System.out.println("用户ID:"+account.getUserId()+",账户结算异常"); + } + } + } @Scheduled(cron="0 0/3 * * * ?") //每3分钟执行一次 public void getBlxCoupon() { @@ -55,4 +74,5 @@ public class OrderSettleSchedule { } } } + } diff --git a/service/pom.xml b/service/pom.xml index 2a46783..8e344cb 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -243,7 +243,7 @@ com.github.wechatpay-apiv3 wechatpay-apache-httpclient - 0.2.2 + 0.4.7 com.sun.jersey diff --git a/service/src/main/java/com/hfkj/common/Base64Util.java b/service/src/main/java/com/hfkj/common/Base64Util.java index 9c0d71e..b885ee5 100644 --- a/service/src/main/java/com/hfkj/common/Base64Util.java +++ b/service/src/main/java/com/hfkj/common/Base64Util.java @@ -1,5 +1,7 @@ package com.hfkj.common; +import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; + import java.util.Base64; public class Base64Util { @@ -36,7 +38,13 @@ public class Base64Util { } public static void main(String[] args) throws Exception { - System.out.println(encode("abcd1234")); - System.out.println(decode("YWJjZDEyMzQ")); + //System.out.println(encode("abcd1234")); + String data = new AesUtil("UXt3EGM5X6P71EXcNmszV1ONk7LX9IEj".getBytes()) + .decryptToString( + "mch_payment".getBytes(), + "pNkl4m74gbiO".getBytes(), + "HuOlyjwpF9fes1TAgOw5zzBER/YdGcxUWw3U+o3HXpN8CrporigxRPQNjV6N1Ksmhx9hhAaAnA+7k+1rkOd6SBi2xT6/g3HI6VszUrjSKN77BxWBh4q0gLTLdqyBTp1N3wKZh3Pg8d2Vktvf5nHzzoeTGNZ6llMsxME6qP5muCIbjelOBUq3LR/DNO+AjQHFaR/rkne0f+TT8kUcY51qhBAVGY4JRt5Y358OGkQqvMNCo/jp2DD1WlV0g1v4PEpjMlkWC/lqYvUbtrvOU52Y+olnrFVusuvLhsBP6AxUOTYlTuIA1UKtizSIfyGM+yAOuKbrQmAJCWUIda0Flo71h+r1N+TC31l1tOGTQgJca+4XT9JEENMVmxTh2lGM47abIyab6GbQezjD9Q6JzK7QZ2eINU57NY48+1oK12mcmM8M2OeYKyqu0vL+RC1hQltyshU="); + System.out.println(data); + // System.out.println(new AesUt("HuOlyjwpF9fes1TAgOw5zzBER/YdGcxUWw3U+o3HXpN8CrporigxRPQNjV6N1Ksmhx9hhAaAnA+7k+1rkOd6SBi2xT6/g3HI6VszUrjSKN77BxWBh4q0gLTLdqyBTp1N3wKZh3Pg8d2Vktvf5nHzzoeTGNZ6llMsxME6qP5muCIbjelOBUq3LR/DNO+AjQHFaR/rkne0f+TT8kUcY51qhBAVGY4JRt5Y358OGkQqvMNCo/jp2DD1WlV0g1v4PEpjMlkWC/lqYvUbtrvOU52Y+olnrFVusuvLhsBP6AxUOTYlTuIA1UKtizSIfyGM+yAOuKbrQmAJCWUIda0Flo71h+r1N+TC31l1tOGTQgJca+4XT9JEENMVmxTh2lGM47abIyab6GbQezjD9Q6JzK7QZ2eINU57NY48+1oK12mcmM8M2OeYKyqu0vL+RC1hQltyshU=")); } } diff --git a/service/src/main/java/com/hfkj/common/utils/WxUtils.java b/service/src/main/java/com/hfkj/common/utils/WxUtils.java index 0dbb81d..8eb38d1 100644 --- a/service/src/main/java/com/hfkj/common/utils/WxUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/WxUtils.java @@ -1,373 +1,163 @@ package com.hfkj.common.utils; -import com.google.common.collect.Maps; -import com.hfkj.common.pay.util.sdk.WXPayConstants; -import com.hfkj.common.pay.util.sdk.WXPayXmlUtil; -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.naming.NoNameCoder; -import com.thoughtworks.xstream.io.xml.XppDriver; -import net.sf.cglib.beans.BeanMap; -import org.apache.commons.lang3.StringUtils; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.StringWriter; -import java.security.MessageDigest; -import java.security.SecureRandom; -import java.util.*; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.config.CommonSysConst; +import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder; +import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner; +import com.wechat.pay.contrib.apache.httpclient.auth.Verifier; +import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials; +import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator; +import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager; +import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException; +import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException; +import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.util.EntityUtils; + +import java.io.FileInputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.PrivateKey; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; public class WxUtils { - - private static final Random RANDOM = new SecureRandom(); - - private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - + // 微信请求地址 + private final static String REQ_URL = "https://api.mch.weixin.qq.com"; + // 商户号 + private final static String merchantId = "1614670195"; + // 商户证书编号 + private final static String merchantSerialNumber = "6E73923625A838DEA31C7BAA66938AD6281D698F"; + // APIv3密钥 + private final static String apiV3Key = "UXt3EGM5X6P71EXcNmszV1ONk7LX9IEj"; /** - * 生成签名 - * - * @param signMaps + * 获取请求 * @return - * @throws Exception + * @throws GeneralSecurityException + * @throws IOException + * @throws HttpCodeException + * @throws NotFoundException */ - public static String generateSign(SortedMap signMaps, String mchKey) { - StringBuffer sb = new StringBuffer(); - - // 字典序 - for (Map.Entry signMap : signMaps.entrySet()) { - String key = (String) signMap.getKey(); - String value = (String) signMap.getValue(); - - // 为空不参与签名、参数名区分大小写 - if (null != value && !"".equals(value) && !"sign".equals(key) && !"key".equals(key)) { - sb.append(key).append("=").append(value).append("&"); - } - } - - // 拼接key - sb.append("key=").append(mchKey); - // MD5加密 - String sign = MD5Encode(sb.toString(), "UTF-8").toUpperCase(); - return sign; - } - - public static String generateSignSHA256(SortedMap signMaps,String mchKey)throws Exception{ - StringBuffer sb = new StringBuffer(); - - // 字典序 - for (Map.Entry signMap : signMaps.entrySet()) { - String key = (String) signMap.getKey(); - String value = (String) signMap.getValue(); - - // 为空不参与签名、参数名区分大小写 - if (null != value && !"".equals(value) && !"sign".equals(key) && !"key".equals(key)) { - sb.append(key).append("=").append(value).append("&"); - } - } - - // 拼接key - sb.append("key=").append(mchKey); - // HMACSHA256加密 - String sign = HMACSHA256(sb.toString(), mchKey).toUpperCase(); - return sign; - } - - private static String byteArrayToHexString(byte b[]) { - StringBuffer resultSb = new StringBuffer(); - for (int i = 0; i < b.length; i++) - resultSb.append(byteToHexString(b[i])); - - return resultSb.toString(); - } - - private static String byteToHexString(byte b) { - int n = b; - if (n < 0) - n += 256; - int d1 = n / 16; - int d2 = n % 16; - return hexDigits[d1] + hexDigits[d2]; - } - - public static String MD5Encode(String origin, String charsetname) { - String resultString = null; - try { - resultString = new String(origin); - MessageDigest md = MessageDigest.getInstance("MD5"); - if (charsetname == null || "".equals(charsetname)) - resultString = byteArrayToHexString(md.digest(resultString - .getBytes())); - else - resultString = byteArrayToHexString(md.digest(resultString - .getBytes(charsetname))); - } catch (Exception exception) { - } - return resultString; - } - - private static final String[] hexDigits = { "0", "1", "2", "3", "4", "5", - "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; - - - - private static HashMap sortAsc(Map map) { - HashMap tempMap = new LinkedHashMap(); - List> infoIds = new ArrayList>(map.entrySet()); - //排序 - infoIds.sort(new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }); - - for (int i = 0; i < infoIds.size(); i++) { - Map.Entry item = infoIds.get(i); - tempMap.put(item.getKey(), item.getValue()); - } - return tempMap; - } - - - - /** - * 生成 HMACSHA256 - * @param data 待处理数据 - * @param key 密钥 - * @return 加密结果 - * @throws Exception - */ - public static String HMACSHA256(String data, String key) throws Exception { - Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); - SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256"); - sha256_HMAC.init(secret_key); - byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (byte item : array) { - sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); - } - return sb.toString().toUpperCase(); - } - - /** - * 获取随机字符串 Nonce Str - * - * @return String 随机字符串 - */ - public static String makeNonStr() { - char[] nonceChars = new char[32]; - for (int index = 0; index < nonceChars.length; ++index) { - nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); - } - return new String(nonceChars); + public static CloseableHttpClient getHttpClient() throws GeneralSecurityException, IOException, HttpCodeException, NotFoundException { + // 私钥文件路径 + PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(new FileInputStream("/home/project/oil/cert/wechat/1614670195/apiclient_key.pem")); + CertificatesManager certificatesManager = CertificatesManager.getInstance(); + certificatesManager.putMerchant(merchantId, new WechatPay2Credentials(merchantId, + new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey)), + apiV3Key.getBytes(StandardCharsets.UTF_8)); + Verifier verifier = certificatesManager.getVerifier(merchantId); + WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create() + .withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey) + .withValidator(new WechatPay2Validator(verifier)); + return builder.build(); } /** - * 拼接签名数据 - * - */ - public static String makeSign(BeanMap beanMap, String mchKey, String signType)throws Exception { - SortedMap signMaps = Maps.newTreeMap(); - - for (Object key : beanMap.keySet()) { - Object value = beanMap.get(key); - - // 排除空数据 - if (value == null) { - continue; - } - signMaps.put(key + "", String.valueOf(value)); - } - if(signType.equals("MD5")) { - // 生成签名 - return generateSign(signMaps, mchKey); - }else if(signType.equals("SHA256")){ - return generateSignSHA256(signMaps, mchKey); - }else{ - return null; - } - } - - /** - * 数据转换为xml格式 - * - * @param object - * @param obj + * 商家转账 + * @param openId + * @param transferAmount * @return + * @throws GeneralSecurityException + * @throws NotFoundException + * @throws IOException + * @throws HttpCodeException */ - public static String truncateDataToXML(Class object, Object obj) { - XStream xStream = new XStream(new XppDriver(new NoNameCoder())); - xStream.alias("xml", object); - return xStream.toXML(obj); - } - - - /** - * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。 - * - * @param data 待签名数据 - * @param key API密钥 - * @param signType 签名方式 - * @return 签名 - */ - public static String generateSignature(final Map data, String key, WXPayConstants.SignType signType) throws Exception { - Set keySet = data.keySet(); - String[] keyArray = keySet.toArray(new String[keySet.size()]); - Arrays.sort(keyArray); - StringBuilder sb = new StringBuilder(); - for (String k : keyArray) { - if (k.equals(WXPayConstants.FIELD_SIGN)) { - continue; - } - if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名 - sb.append(k).append("=").append(data.get(k).trim()).append("&"); - } - sb.append("key=").append(key); - if (WXPayConstants.SignType.MD5.equals(signType)) { - return MD5(sb.toString() , true); - } - else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) { - return HMACSHA256(sb.toString(), key); - } - else { - throw new Exception(String.format("Invalid sign_type: %s", signType)); - } - } - - public static String generateSignature(final Map data) throws Exception { - Set keySet = data.keySet(); - String[] keyArray = keySet.toArray(new String[keySet.size()]); - Arrays.sort(keyArray); - StringBuilder sb = new StringBuilder(); - for (String k : keyArray) { - if (k.equals(WXPayConstants.FIELD_SIGN)) { - continue; - } - if (StringUtils.isBlank(sb.toString())) { - sb.append(k).append("=").append(data.get(k)); - } else { - sb.append("&").append(k).append("=").append(data.get(k)); - } - } - return sb.toString(); - } - - public static String generateSignature2(final Map data, String sign, String key) throws Exception { - Set keySet = data.keySet(); - String[] keyArray = keySet.toArray(new String[keySet.size()]); - Arrays.sort(keyArray); - StringBuilder sb = new StringBuilder(); - for (String k : keyArray) { - if (k.equals(WXPayConstants.FIELD_SIGN)) { - continue; - } - if (data.get(k) != null) // 参数值为空,则不参与签名 - sb.append(k).append("=").append(data.get(k)).append("&"); - } - if (key != null) { - sb.append("app_secret=").append(key); - } - return sb.toString(); + public static JSONObject transferBills(String openId,String outBillNo, BigDecimal transferAmount, String transferRemark) throws GeneralSecurityException, NotFoundException, IOException, HttpCodeException { + JSONObject body = new JSONObject(); + body.put("appid", CommonSysConst.getSysConfig().getWxMaAppId()); + body.put("out_bill_no", outBillNo); + body.put("transfer_scene_id", "1000"); + body.put("openid", openId); + body.put("transfer_amount", transferAmount.multiply(new BigDecimal("100")).intValue()); + // body.put("openid", "oUGn_4unIjp90MY-oEXluY4laDrQ"); + // body.put("transfer_amount", 1); + body.put("transfer_remark", transferRemark); + body.put("notify_url", CommonSysConst.getSysConfig().getDomainName()+"/crest/wexinNotify/withdraw"); + + List> transferSceneReportInfosList = new LinkedList<>(); + Map transferSceneReportInfos = new HashMap<>(); + transferSceneReportInfos.put("info_type","活动名称"); + transferSceneReportInfos.put("info_content","推广有礼"); + transferSceneReportInfosList.add(transferSceneReportInfos); + Map transferSceneReportInfos2 = new HashMap<>(); + transferSceneReportInfos2.put("info_type","奖励说明"); + transferSceneReportInfos2.put("info_content","推广佣金"); + transferSceneReportInfosList.add(transferSceneReportInfos2); + body.put("transfer_scene_report_infos", transferSceneReportInfosList); + + HttpPost httpPost = new HttpPost(REQ_URL+"/v3/fund-app/mch-transfer/transfer-bills"); + httpPost.setEntity(new StringEntity(body.toJSONString(), "utf-8")); + httpPost.setHeader(HttpHeaders.ACCEPT, "application/json"); + httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + + CloseableHttpResponse httpResponse = WxUtils.getHttpClient().execute(httpPost); + HttpEntity entity = httpResponse.getEntity(); + JSONObject responseData = JSONObject.parseObject(EntityUtils.toString(entity)); + if (httpResponse.getStatusLine().getStatusCode() != 200) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseData.getString("message")); + } + return responseData; } /** - * 生成 MD5 - * - * @param data 待处理数据 - * @return MD5结果 + * 撤销转账 + * @param outBillNo + * @return + * @throws GeneralSecurityException + * @throws NotFoundException + * @throws IOException + * @throws HttpCodeException */ - public static String MD5(String data , Boolean isUpperCase) throws Exception { - java.security.MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] array = md.digest(data.getBytes("UTF-8")); - StringBuilder sb = new StringBuilder(); - for (byte item : array) { - sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); - } - if (isUpperCase) { - return sb.toString().toUpperCase(); - } else { - return sb.toString(); - } - } - - + public static JSONObject cancelTransferBills(String outBillNo) throws GeneralSecurityException, NotFoundException, IOException, HttpCodeException { + HttpPost httpPost = new HttpPost(REQ_URL+"/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/"+outBillNo+"/cancel"); + httpPost.setHeader(HttpHeaders.ACCEPT, "application/json"); + httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - /** - * 将Map转换为XML格式的字符串 - * - * @param data Map类型数据 - * @return XML格式的字符串 - * @throws Exception - */ - public static String mapToXml(Map data) throws Exception { - org.w3c.dom.Document document = WXPayXmlUtil.newDocument(); - org.w3c.dom.Element root = document.createElement("xml"); - document.appendChild(root); - for (String key: data.keySet()) { - String value = data.get(key); - if (value == null) { - value = ""; - } - value = value.trim(); - org.w3c.dom.Element filed = document.createElement(key); - filed.appendChild(document.createTextNode(value)); - root.appendChild(filed); - } - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - DOMSource source = new DOMSource(document); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - transformer.transform(source, result); - String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", ""); - try { - writer.close(); + httpPost.setEntity(new StringEntity("", "utf-8")); + CloseableHttpResponse httpResponse = WxUtils.getHttpClient().execute(httpPost); + HttpEntity entity = httpResponse.getEntity(); + JSONObject responseData = JSONObject.parseObject(EntityUtils.toString(entity)); + if (httpResponse.getStatusLine().getStatusCode() != 200) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseData.getString("message")); } - catch (Exception ex) { - } - return output; + return responseData; } /** - * 千猪生成签名。 - * - * @param data 待签名数据 - * @param secret API密钥 - * @param signType 签名方式 - * @return 签名 + * 查询转账详情 + * @param outBillNo + * @return + * @throws GeneralSecurityException + * @throws NotFoundException + * @throws IOException + * @throws HttpCodeException */ - public static String generateSignaturePig(final Map data, String secret, WXPayConstants.SignType signType) throws Exception { - Set keySet = data.keySet(); - String[] keyArray = keySet.toArray(new String[keySet.size()]); - Arrays.sort(keyArray); - StringBuilder sb = new StringBuilder(); - for (String k : keyArray) { - if (k.equals(WXPayConstants.FIELD_SIGN)) { - continue; - } - if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名 - sb.append(k).append("=").append(data.get(k).trim()).append("&"); - } - String s = sb.substring(0, sb.length() - 1) + secret; + public static JSONObject queryTransferBills(String outBillNo) throws GeneralSecurityException, NotFoundException, IOException, HttpCodeException { + HttpGet httpGet = new HttpGet(REQ_URL+"/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/"+outBillNo); + httpGet.setHeader(HttpHeaders.ACCEPT, "application/json"); + httpGet.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - if (WXPayConstants.SignType.MD5.equals(signType)) { - return MD5(sb.toString() , false); - } - else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) { - return HMACSHA256(s, secret); - } - else { - throw new Exception(String.format("Invalid sign_type: %s", signType)); + CloseableHttpResponse httpResponse = WxUtils.getHttpClient().execute(httpGet); + HttpEntity entity = httpResponse.getEntity(); + JSONObject responseData = JSONObject.parseObject(EntityUtils.toString(entity)); + if (httpResponse.getStatusLine().getStatusCode() != 200) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseData.getString("message")); } + return responseData; } - - } diff --git a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapper.java b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapper.java index 1816159..be0a27f 100644 --- a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapper.java @@ -39,21 +39,19 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into bs_gas_order_spread (order_id, order_no, ", - "gains_rebate_user_id, gains_rebate_rate, ", - "gains_rebate_amount, gains_rebate_one_user_id, ", - "gains_rebate_one_rate, gains_rebate_one_amount, ", - "gains_rebate_two_user_id, gains_rebate_two_rate, ", - "gains_rebate_two_amount, settle_status, ", + "insert into bs_gas_order_spread (order_no, gains_rebate_user_id, ", + "gains_rebate_rate, gains_rebate_amount, ", + "gains_rebate_one_user_id, gains_rebate_one_rate, ", + "gains_rebate_one_amount, gains_rebate_two_user_id, ", + "gains_rebate_two_rate, gains_rebate_two_amount, ", "`status`, create_time, ", "update_time, ext_1, ", "ext_2, ext_3)", - "values (#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, ", - "#{gainsRebateUserId,jdbcType=BIGINT}, #{gainsRebateRate,jdbcType=DECIMAL}, ", - "#{gainsRebateAmount,jdbcType=DECIMAL}, #{gainsRebateOneUserId,jdbcType=BIGINT}, ", - "#{gainsRebateOneRate,jdbcType=DECIMAL}, #{gainsRebateOneAmount,jdbcType=DECIMAL}, ", - "#{gainsRebateTwoUserId,jdbcType=BIGINT}, #{gainsRebateTwoRate,jdbcType=DECIMAL}, ", - "#{gainsRebateTwoAmount,jdbcType=DECIMAL}, #{settleStatus,jdbcType=INTEGER}, ", + "values (#{orderNo,jdbcType=VARCHAR}, #{gainsRebateUserId,jdbcType=BIGINT}, ", + "#{gainsRebateRate,jdbcType=DECIMAL}, #{gainsRebateAmount,jdbcType=DECIMAL}, ", + "#{gainsRebateOneUserId,jdbcType=BIGINT}, #{gainsRebateOneRate,jdbcType=DECIMAL}, ", + "#{gainsRebateOneAmount,jdbcType=DECIMAL}, #{gainsRebateTwoUserId,jdbcType=BIGINT}, ", + "#{gainsRebateTwoRate,jdbcType=DECIMAL}, #{gainsRebateTwoAmount,jdbcType=DECIMAL}, ", "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" @@ -68,7 +66,6 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { @SelectProvider(type=BsGasOrderSpreadSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), - @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="gains_rebate_user_id", property="gainsRebateUserId", jdbcType=JdbcType.BIGINT), @Result(column="gains_rebate_rate", property="gainsRebateRate", jdbcType=JdbcType.DECIMAL), @@ -79,7 +76,6 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { @Result(column="gains_rebate_two_user_id", property="gainsRebateTwoUserId", jdbcType=JdbcType.BIGINT), @Result(column="gains_rebate_two_rate", property="gainsRebateTwoRate", jdbcType=JdbcType.DECIMAL), @Result(column="gains_rebate_two_amount", property="gainsRebateTwoAmount", jdbcType=JdbcType.DECIMAL), - @Result(column="settle_status", property="settleStatus", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -91,16 +87,15 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { @Select({ "select", - "id, order_id, order_no, gains_rebate_user_id, gains_rebate_rate, gains_rebate_amount, ", + "id, order_no, gains_rebate_user_id, gains_rebate_rate, gains_rebate_amount, ", "gains_rebate_one_user_id, gains_rebate_one_rate, gains_rebate_one_amount, gains_rebate_two_user_id, ", - "gains_rebate_two_rate, gains_rebate_two_amount, settle_status, `status`, create_time, ", - "update_time, ext_1, ext_2, ext_3", + "gains_rebate_two_rate, gains_rebate_two_amount, `status`, create_time, update_time, ", + "ext_1, ext_2, ext_3", "from bs_gas_order_spread", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), - @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="gains_rebate_user_id", property="gainsRebateUserId", jdbcType=JdbcType.BIGINT), @Result(column="gains_rebate_rate", property="gainsRebateRate", jdbcType=JdbcType.DECIMAL), @@ -111,7 +106,6 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { @Result(column="gains_rebate_two_user_id", property="gainsRebateTwoUserId", jdbcType=JdbcType.BIGINT), @Result(column="gains_rebate_two_rate", property="gainsRebateTwoRate", jdbcType=JdbcType.DECIMAL), @Result(column="gains_rebate_two_amount", property="gainsRebateTwoAmount", jdbcType=JdbcType.DECIMAL), - @Result(column="settle_status", property="settleStatus", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -132,8 +126,7 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { @Update({ "update bs_gas_order_spread", - "set order_id = #{orderId,jdbcType=INTEGER},", - "order_no = #{orderNo,jdbcType=VARCHAR},", + "set order_no = #{orderNo,jdbcType=VARCHAR},", "gains_rebate_user_id = #{gainsRebateUserId,jdbcType=BIGINT},", "gains_rebate_rate = #{gainsRebateRate,jdbcType=DECIMAL},", "gains_rebate_amount = #{gainsRebateAmount,jdbcType=DECIMAL},", @@ -143,7 +136,6 @@ public interface BsGasOrderSpreadMapper extends BsGasOrderSpreadMapperExt { "gains_rebate_two_user_id = #{gainsRebateTwoUserId,jdbcType=BIGINT},", "gains_rebate_two_rate = #{gainsRebateTwoRate,jdbcType=DECIMAL},", "gains_rebate_two_amount = #{gainsRebateTwoAmount,jdbcType=DECIMAL},", - "settle_status = #{settleStatus,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapperExt.java b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapperExt.java index 88796d3..e616035 100644 --- a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadMapperExt.java @@ -14,28 +14,35 @@ import java.util.Map; public interface BsGasOrderSpreadMapperExt { @Select(" select " + - " DATE_SUB(CURDATE(), INTERVAL 7 DAY) settle_date," + + " DATE_SUB(CURDATE(), INTERVAL 1 DAY) settle_date," + " case when sum(b.gains_rebate_amount) is not null then sum(b.gains_rebate_amount) else 0 end gains_rebate_amount," + " case when sum(b.gains_rebate_one_amount) is not null then sum(b.gains_rebate_one_amount) else 0 end gains_rebate_one_amount," + " case when sum(b.gains_rebate_two_amount) is not null then sum(b.gains_rebate_two_amount) else 0 end gains_rebate_two_amount" + " from bs_gas_order a" + " LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" + - " WHERE DATE_FORMAT(a.pay_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 7 DAY)" + + " WHERE DATE_FORMAT(a.pay_time, '%Y-%m-%d') = DATE_SUB(CURDATE(), INTERVAL 1 DAY)" + " and (gains_rebate_user_id = #{param.userId} or gains_rebate_one_user_id = #{param.userId} or gains_rebate_two_user_id = #{param.userId})" + - " and a.`status` = 2 and b.settle_status = 0") + " and a.`status` = 2") HashMap querySettleOrderList(@Param("param") Map param); - @Select(" SELECT " + - " a.gains_rebate_amount+a.gains_rebate_one_amount+a.gains_rebate_two_amount totalRebateAmount" + - " FROM (select " + - " case when sum(b.gains_rebate_amount) is not null then sum(b.gains_rebate_amount) else 0 end gains_rebate_amount," + - " case when sum(b.gains_rebate_one_amount) is not null then sum(b.gains_rebate_one_amount) else 0 end gains_rebate_one_amount," + - " case when sum(b.gains_rebate_two_amount) is not null then sum(b.gains_rebate_two_amount) else 0 end gains_rebate_two_amount" + - " from bs_gas_order a" + - " LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" + - " WHERE DATE_SUB(CURDATE(), INTERVAL 6 DAY)" + - " and (gains_rebate_user_id = #{userId} or gains_rebate_one_user_id = #{userId} or gains_rebate_two_user_id = #{userId})" + - " and a.`status` = 2 and b.settle_status = 0) a") + @Select(" select " + + " case when sum(totalAmount) is not null then sum(totalAmount) else 0 end" + + " from (" + + " select " + + " sum(b.gains_rebate_amount) totalAmount" + + " from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" + + " WHERE DATE(a.pay_time) = CURDATE() and a.`status` = 2 and b.gains_rebate_user_id = #{userId}" + + " union all" + + " select " + + " sum(b.gains_rebate_one_amount) totalAmount" + + " from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" + + " WHERE DATE(a.pay_time) = CURDATE() and a.`status` = 2 and b.gains_rebate_one_user_id = #{userId}" + + " union all" + + " select " + + " sum(b.gains_rebate_two_amount) totalAmount" + + " from bs_gas_order a LEFT JOIN bs_gas_order_spread b on a.order_no = b.order_no" + + " WHERE DATE(a.pay_time) = CURDATE() and a.`status` = 2 and b.gains_rebate_two_user_id = #{userId}" + + " ) a") BigDecimal queryNotCashOutAmount(@Param("userId") Long userId); } diff --git a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadSqlProvider.java index a723ab6..25426bf 100644 --- a/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsGasOrderSpreadSqlProvider.java @@ -28,10 +28,6 @@ public class BsGasOrderSpreadSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("bs_gas_order_spread"); - if (record.getOrderId() != null) { - sql.VALUES("order_id", "#{orderId,jdbcType=INTEGER}"); - } - if (record.getOrderNo() != null) { sql.VALUES("order_no", "#{orderNo,jdbcType=VARCHAR}"); } @@ -72,10 +68,6 @@ public class BsGasOrderSpreadSqlProvider { sql.VALUES("gains_rebate_two_amount", "#{gainsRebateTwoAmount,jdbcType=DECIMAL}"); } - if (record.getSettleStatus() != null) { - sql.VALUES("settle_status", "#{settleStatus,jdbcType=INTEGER}"); - } - if (record.getStatus() != null) { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } @@ -110,7 +102,6 @@ public class BsGasOrderSpreadSqlProvider { } else { sql.SELECT("id"); } - sql.SELECT("order_id"); sql.SELECT("order_no"); sql.SELECT("gains_rebate_user_id"); sql.SELECT("gains_rebate_rate"); @@ -121,7 +112,6 @@ public class BsGasOrderSpreadSqlProvider { sql.SELECT("gains_rebate_two_user_id"); sql.SELECT("gains_rebate_two_rate"); sql.SELECT("gains_rebate_two_amount"); - sql.SELECT("settle_status"); sql.SELECT("`status`"); sql.SELECT("create_time"); sql.SELECT("update_time"); @@ -149,10 +139,6 @@ public class BsGasOrderSpreadSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } - if (record.getOrderId() != null) { - sql.SET("order_id = #{record.orderId,jdbcType=INTEGER}"); - } - if (record.getOrderNo() != null) { sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); } @@ -193,10 +179,6 @@ public class BsGasOrderSpreadSqlProvider { sql.SET("gains_rebate_two_amount = #{record.gainsRebateTwoAmount,jdbcType=DECIMAL}"); } - if (record.getSettleStatus() != null) { - sql.SET("settle_status = #{record.settleStatus,jdbcType=INTEGER}"); - } - if (record.getStatus() != null) { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } @@ -230,7 +212,6 @@ public class BsGasOrderSpreadSqlProvider { sql.UPDATE("bs_gas_order_spread"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); - sql.SET("order_id = #{record.orderId,jdbcType=INTEGER}"); sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("gains_rebate_user_id = #{record.gainsRebateUserId,jdbcType=BIGINT}"); sql.SET("gains_rebate_rate = #{record.gainsRebateRate,jdbcType=DECIMAL}"); @@ -241,7 +222,6 @@ public class BsGasOrderSpreadSqlProvider { sql.SET("gains_rebate_two_user_id = #{record.gainsRebateTwoUserId,jdbcType=BIGINT}"); sql.SET("gains_rebate_two_rate = #{record.gainsRebateTwoRate,jdbcType=DECIMAL}"); sql.SET("gains_rebate_two_amount = #{record.gainsRebateTwoAmount,jdbcType=DECIMAL}"); - sql.SET("settle_status = #{record.settleStatus,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); @@ -258,10 +238,6 @@ public class BsGasOrderSpreadSqlProvider { SQL sql = new SQL(); sql.UPDATE("bs_gas_order_spread"); - if (record.getOrderId() != null) { - sql.SET("order_id = #{orderId,jdbcType=INTEGER}"); - } - if (record.getOrderNo() != null) { sql.SET("order_no = #{orderNo,jdbcType=VARCHAR}"); } @@ -302,10 +278,6 @@ public class BsGasOrderSpreadSqlProvider { sql.SET("gains_rebate_two_amount = #{gainsRebateTwoAmount,jdbcType=DECIMAL}"); } - if (record.getSettleStatus() != null) { - sql.SET("settle_status = #{settleStatus,jdbcType=INTEGER}"); - } - if (record.getStatus() != null) { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } diff --git a/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountRecordMapperExt.java b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountRecordMapperExt.java index a86d5c3..3faf17c 100644 --- a/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountRecordMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountRecordMapperExt.java @@ -1,7 +1,13 @@ package com.hfkj.dao; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + /** * mapper扩展类 */ public interface BsUserSpreadAccountRecordMapperExt { -} \ No newline at end of file + + @Select("select count(1) from bs_user_spread_account_record where user_id = #{userId} and DATE(create_time) = DATE(NOW()) and source_type = 2") + Integer withdrawChance(@Param("userId") Long userId); +} diff --git a/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapper.java b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapper.java new file mode 100644 index 0000000..3127e59 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapper.java @@ -0,0 +1,130 @@ +package com.hfkj.dao; + +import com.hfkj.entity.BsUserSpreadAccountTransfer; +import com.hfkj.entity.BsUserSpreadAccountTransferExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface BsUserSpreadAccountTransferMapper extends BsUserSpreadAccountTransferMapperExt { + @SelectProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="countByExample") + long countByExample(BsUserSpreadAccountTransferExample example); + + @DeleteProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="deleteByExample") + int deleteByExample(BsUserSpreadAccountTransferExample example); + + @Delete({ + "delete from bs_user_spread_account_transfer", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into bs_user_spread_account_transfer (user_spread_account_id, user_id, ", + "out_bill_no, transfer_bill_no, ", + "transfer_amount, `status`, ", + "fail_reason, create_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", + "values (#{userSpreadAccountId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ", + "#{outBillNo,jdbcType=VARCHAR}, #{transferBillNo,jdbcType=VARCHAR}, ", + "#{transferAmount,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, ", + "#{failReason,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(BsUserSpreadAccountTransfer record); + + @InsertProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(BsUserSpreadAccountTransfer record); + + @SelectProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_spread_account_id", property="userSpreadAccountId", jdbcType=JdbcType.BIGINT), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="out_bill_no", property="outBillNo", jdbcType=JdbcType.VARCHAR), + @Result(column="transfer_bill_no", property="transferBillNo", jdbcType=JdbcType.VARCHAR), + @Result(column="transfer_amount", property="transferAmount", jdbcType=JdbcType.DECIMAL), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="fail_reason", property="failReason", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectByExample(BsUserSpreadAccountTransferExample example); + + @Select({ + "select", + "id, user_spread_account_id, user_id, out_bill_no, transfer_bill_no, transfer_amount, ", + "`status`, fail_reason, create_time, update_time, ext_1, ext_2, ext_3", + "from bs_user_spread_account_transfer", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_spread_account_id", property="userSpreadAccountId", jdbcType=JdbcType.BIGINT), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="out_bill_no", property="outBillNo", jdbcType=JdbcType.VARCHAR), + @Result(column="transfer_bill_no", property="transferBillNo", jdbcType=JdbcType.VARCHAR), + @Result(column="transfer_amount", property="transferAmount", jdbcType=JdbcType.DECIMAL), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="fail_reason", property="failReason", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + BsUserSpreadAccountTransfer selectByPrimaryKey(Long id); + + @UpdateProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") BsUserSpreadAccountTransfer record, @Param("example") BsUserSpreadAccountTransferExample example); + + @UpdateProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") BsUserSpreadAccountTransfer record, @Param("example") BsUserSpreadAccountTransferExample example); + + @UpdateProvider(type=BsUserSpreadAccountTransferSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(BsUserSpreadAccountTransfer record); + + @Update({ + "update bs_user_spread_account_transfer", + "set user_spread_account_id = #{userSpreadAccountId,jdbcType=BIGINT},", + "user_id = #{userId,jdbcType=BIGINT},", + "out_bill_no = #{outBillNo,jdbcType=VARCHAR},", + "transfer_bill_no = #{transferBillNo,jdbcType=VARCHAR},", + "transfer_amount = #{transferAmount,jdbcType=DECIMAL},", + "`status` = #{status,jdbcType=INTEGER},", + "fail_reason = #{failReason,jdbcType=VARCHAR},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "update_time = #{updateTime,jdbcType=TIMESTAMP},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(BsUserSpreadAccountTransfer record); +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapperExt.java b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapperExt.java new file mode 100644 index 0000000..a6543b0 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferMapperExt.java @@ -0,0 +1,7 @@ +package com.hfkj.dao; + +/** + * mapper扩展类 + */ +public interface BsUserSpreadAccountTransferMapperExt { +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferSqlProvider.java new file mode 100644 index 0000000..70639c1 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/BsUserSpreadAccountTransferSqlProvider.java @@ -0,0 +1,346 @@ +package com.hfkj.dao; + +import com.hfkj.entity.BsUserSpreadAccountTransfer; +import com.hfkj.entity.BsUserSpreadAccountTransferExample.Criteria; +import com.hfkj.entity.BsUserSpreadAccountTransferExample.Criterion; +import com.hfkj.entity.BsUserSpreadAccountTransferExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class BsUserSpreadAccountTransferSqlProvider { + + public String countByExample(BsUserSpreadAccountTransferExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("bs_user_spread_account_transfer"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(BsUserSpreadAccountTransferExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("bs_user_spread_account_transfer"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(BsUserSpreadAccountTransfer record) { + SQL sql = new SQL(); + sql.INSERT_INTO("bs_user_spread_account_transfer"); + + if (record.getUserSpreadAccountId() != null) { + sql.VALUES("user_spread_account_id", "#{userSpreadAccountId,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); + } + + if (record.getOutBillNo() != null) { + sql.VALUES("out_bill_no", "#{outBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferBillNo() != null) { + sql.VALUES("transfer_bill_no", "#{transferBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferAmount() != null) { + sql.VALUES("transfer_amount", "#{transferAmount,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getFailReason() != null) { + sql.VALUES("fail_reason", "#{failReason,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(BsUserSpreadAccountTransferExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("user_spread_account_id"); + sql.SELECT("user_id"); + sql.SELECT("out_bill_no"); + sql.SELECT("transfer_bill_no"); + sql.SELECT("transfer_amount"); + sql.SELECT("`status`"); + sql.SELECT("fail_reason"); + sql.SELECT("create_time"); + sql.SELECT("update_time"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("bs_user_spread_account_transfer"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + BsUserSpreadAccountTransfer record = (BsUserSpreadAccountTransfer) parameter.get("record"); + BsUserSpreadAccountTransferExample example = (BsUserSpreadAccountTransferExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("bs_user_spread_account_transfer"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getUserSpreadAccountId() != null) { + sql.SET("user_spread_account_id = #{record.userSpreadAccountId,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + } + + if (record.getOutBillNo() != null) { + sql.SET("out_bill_no = #{record.outBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferBillNo() != null) { + sql.SET("transfer_bill_no = #{record.transferBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferAmount() != null) { + sql.SET("transfer_amount = #{record.transferAmount,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getFailReason() != null) { + sql.SET("fail_reason = #{record.failReason,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("bs_user_spread_account_transfer"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("user_spread_account_id = #{record.userSpreadAccountId,jdbcType=BIGINT}"); + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + sql.SET("out_bill_no = #{record.outBillNo,jdbcType=VARCHAR}"); + sql.SET("transfer_bill_no = #{record.transferBillNo,jdbcType=VARCHAR}"); + sql.SET("transfer_amount = #{record.transferAmount,jdbcType=DECIMAL}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("fail_reason = #{record.failReason,jdbcType=VARCHAR}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + BsUserSpreadAccountTransferExample example = (BsUserSpreadAccountTransferExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(BsUserSpreadAccountTransfer record) { + SQL sql = new SQL(); + sql.UPDATE("bs_user_spread_account_transfer"); + + if (record.getUserSpreadAccountId() != null) { + sql.SET("user_spread_account_id = #{userSpreadAccountId,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{userId,jdbcType=BIGINT}"); + } + + if (record.getOutBillNo() != null) { + sql.SET("out_bill_no = #{outBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferBillNo() != null) { + sql.SET("transfer_bill_no = #{transferBillNo,jdbcType=VARCHAR}"); + } + + if (record.getTransferAmount() != null) { + sql.SET("transfer_amount = #{transferAmount,jdbcType=DECIMAL}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getFailReason() != null) { + sql.SET("fail_reason = #{failReason,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, BsUserSpreadAccountTransferExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/BsGasOrderSpread.java b/service/src/main/java/com/hfkj/entity/BsGasOrderSpread.java index 702979d..0042ff6 100644 --- a/service/src/main/java/com/hfkj/entity/BsGasOrderSpread.java +++ b/service/src/main/java/com/hfkj/entity/BsGasOrderSpread.java @@ -19,11 +19,6 @@ public class BsGasOrderSpread implements Serializable { */ private Long id; - /** - * 订单id - */ - private Integer orderId; - /** * 订单号 */ @@ -74,11 +69,6 @@ public class BsGasOrderSpread implements Serializable { */ private BigDecimal gainsRebateTwoAmount; - /** - * 结算状态: 0:未结算 1:已结算 - */ - private Integer settleStatus; - /** * 状态 0:删除 1:正常 */ @@ -110,14 +100,6 @@ public class BsGasOrderSpread implements Serializable { this.id = id; } - public Integer getOrderId() { - return orderId; - } - - public void setOrderId(Integer orderId) { - this.orderId = orderId; - } - public String getOrderNo() { return orderNo; } @@ -198,14 +180,6 @@ public class BsGasOrderSpread implements Serializable { this.gainsRebateTwoAmount = gainsRebateTwoAmount; } - public Integer getSettleStatus() { - return settleStatus; - } - - public void setSettleStatus(Integer settleStatus) { - this.settleStatus = settleStatus; - } - public Integer getStatus() { return status; } @@ -267,7 +241,6 @@ public class BsGasOrderSpread implements Serializable { } BsGasOrderSpread other = (BsGasOrderSpread) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) - && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo())) && (this.getGainsRebateUserId() == null ? other.getGainsRebateUserId() == null : this.getGainsRebateUserId().equals(other.getGainsRebateUserId())) && (this.getGainsRebateRate() == null ? other.getGainsRebateRate() == null : this.getGainsRebateRate().equals(other.getGainsRebateRate())) @@ -278,7 +251,6 @@ public class BsGasOrderSpread implements Serializable { && (this.getGainsRebateTwoUserId() == null ? other.getGainsRebateTwoUserId() == null : this.getGainsRebateTwoUserId().equals(other.getGainsRebateTwoUserId())) && (this.getGainsRebateTwoRate() == null ? other.getGainsRebateTwoRate() == null : this.getGainsRebateTwoRate().equals(other.getGainsRebateTwoRate())) && (this.getGainsRebateTwoAmount() == null ? other.getGainsRebateTwoAmount() == null : this.getGainsRebateTwoAmount().equals(other.getGainsRebateTwoAmount())) - && (this.getSettleStatus() == null ? other.getSettleStatus() == null : this.getSettleStatus().equals(other.getSettleStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) @@ -292,7 +264,6 @@ public class BsGasOrderSpread implements Serializable { final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); - result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode()); result = prime * result + ((getGainsRebateUserId() == null) ? 0 : getGainsRebateUserId().hashCode()); result = prime * result + ((getGainsRebateRate() == null) ? 0 : getGainsRebateRate().hashCode()); @@ -303,7 +274,6 @@ public class BsGasOrderSpread implements Serializable { result = prime * result + ((getGainsRebateTwoUserId() == null) ? 0 : getGainsRebateTwoUserId().hashCode()); result = prime * result + ((getGainsRebateTwoRate() == null) ? 0 : getGainsRebateTwoRate().hashCode()); result = prime * result + ((getGainsRebateTwoAmount() == null) ? 0 : getGainsRebateTwoAmount().hashCode()); - result = prime * result + ((getSettleStatus() == null) ? 0 : getSettleStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); @@ -320,7 +290,6 @@ public class BsGasOrderSpread implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); - sb.append(", orderId=").append(orderId); sb.append(", orderNo=").append(orderNo); sb.append(", gainsRebateUserId=").append(gainsRebateUserId); sb.append(", gainsRebateRate=").append(gainsRebateRate); @@ -331,7 +300,6 @@ public class BsGasOrderSpread implements Serializable { sb.append(", gainsRebateTwoUserId=").append(gainsRebateTwoUserId); sb.append(", gainsRebateTwoRate=").append(gainsRebateTwoRate); sb.append(", gainsRebateTwoAmount=").append(gainsRebateTwoAmount); - sb.append(", settleStatus=").append(settleStatus); sb.append(", status=").append(status); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); diff --git a/service/src/main/java/com/hfkj/entity/BsGasOrderSpreadExample.java b/service/src/main/java/com/hfkj/entity/BsGasOrderSpreadExample.java index 5ba72e5..a872e90 100644 --- a/service/src/main/java/com/hfkj/entity/BsGasOrderSpreadExample.java +++ b/service/src/main/java/com/hfkj/entity/BsGasOrderSpreadExample.java @@ -186,66 +186,6 @@ public class BsGasOrderSpreadExample { return (Criteria) this; } - public Criteria andOrderIdIsNull() { - addCriterion("order_id is null"); - return (Criteria) this; - } - - public Criteria andOrderIdIsNotNull() { - addCriterion("order_id is not null"); - return (Criteria) this; - } - - public Criteria andOrderIdEqualTo(Integer value) { - addCriterion("order_id =", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdNotEqualTo(Integer value) { - addCriterion("order_id <>", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdGreaterThan(Integer value) { - addCriterion("order_id >", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdGreaterThanOrEqualTo(Integer value) { - addCriterion("order_id >=", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdLessThan(Integer value) { - addCriterion("order_id <", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdLessThanOrEqualTo(Integer value) { - addCriterion("order_id <=", value, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdIn(List values) { - addCriterion("order_id in", values, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdNotIn(List values) { - addCriterion("order_id not in", values, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdBetween(Integer value1, Integer value2) { - addCriterion("order_id between", value1, value2, "orderId"); - return (Criteria) this; - } - - public Criteria andOrderIdNotBetween(Integer value1, Integer value2) { - addCriterion("order_id not between", value1, value2, "orderId"); - return (Criteria) this; - } - public Criteria andOrderNoIsNull() { addCriterion("order_no is null"); return (Criteria) this; @@ -856,66 +796,6 @@ public class BsGasOrderSpreadExample { return (Criteria) this; } - public Criteria andSettleStatusIsNull() { - addCriterion("settle_status is null"); - return (Criteria) this; - } - - public Criteria andSettleStatusIsNotNull() { - addCriterion("settle_status is not null"); - return (Criteria) this; - } - - public Criteria andSettleStatusEqualTo(Integer value) { - addCriterion("settle_status =", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusNotEqualTo(Integer value) { - addCriterion("settle_status <>", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusGreaterThan(Integer value) { - addCriterion("settle_status >", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusGreaterThanOrEqualTo(Integer value) { - addCriterion("settle_status >=", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusLessThan(Integer value) { - addCriterion("settle_status <", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusLessThanOrEqualTo(Integer value) { - addCriterion("settle_status <=", value, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusIn(List values) { - addCriterion("settle_status in", values, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusNotIn(List values) { - addCriterion("settle_status not in", values, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusBetween(Integer value1, Integer value2) { - addCriterion("settle_status between", value1, value2, "settleStatus"); - return (Criteria) this; - } - - public Criteria andSettleStatusNotBetween(Integer value1, Integer value2) { - addCriterion("settle_status not between", value1, value2, "settleStatus"); - return (Criteria) this; - } - public Criteria andStatusIsNull() { addCriterion("`status` is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransfer.java b/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransfer.java new file mode 100644 index 0000000..4720e4d --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransfer.java @@ -0,0 +1,249 @@ +package com.hfkj.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * bs_user_spread_account_transfer + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class BsUserSpreadAccountTransfer implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 推广账户id + */ + private Long userSpreadAccountId; + + /** + * 用户id + */ + private Long userId; + + /** + * 提现单号 + */ + private String outBillNo; + + /** + * 微信转账单号 + */ + private String transferBillNo; + + /** + * 转账金额 + */ + private BigDecimal transferAmount; + + /** + * 状态 1:转账中 2:转账成功 3:转账失败 4:撤销转账 + */ + private Integer status; + + /** + * 失败原因 + */ + private String failReason; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + private String ext1; + + private String ext2; + + private String ext3; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserSpreadAccountId() { + return userSpreadAccountId; + } + + public void setUserSpreadAccountId(Long userSpreadAccountId) { + this.userSpreadAccountId = userSpreadAccountId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getOutBillNo() { + return outBillNo; + } + + public void setOutBillNo(String outBillNo) { + this.outBillNo = outBillNo; + } + + public String getTransferBillNo() { + return transferBillNo; + } + + public void setTransferBillNo(String transferBillNo) { + this.transferBillNo = transferBillNo; + } + + public BigDecimal getTransferAmount() { + return transferAmount; + } + + public void setTransferAmount(BigDecimal transferAmount) { + this.transferAmount = transferAmount; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getFailReason() { + return failReason; + } + + public void setFailReason(String failReason) { + this.failReason = failReason; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + BsUserSpreadAccountTransfer other = (BsUserSpreadAccountTransfer) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getUserSpreadAccountId() == null ? other.getUserSpreadAccountId() == null : this.getUserSpreadAccountId().equals(other.getUserSpreadAccountId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getOutBillNo() == null ? other.getOutBillNo() == null : this.getOutBillNo().equals(other.getOutBillNo())) + && (this.getTransferBillNo() == null ? other.getTransferBillNo() == null : this.getTransferBillNo().equals(other.getTransferBillNo())) + && (this.getTransferAmount() == null ? other.getTransferAmount() == null : this.getTransferAmount().equals(other.getTransferAmount())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getFailReason() == null ? other.getFailReason() == null : this.getFailReason().equals(other.getFailReason())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getUserSpreadAccountId() == null) ? 0 : getUserSpreadAccountId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getOutBillNo() == null) ? 0 : getOutBillNo().hashCode()); + result = prime * result + ((getTransferBillNo() == null) ? 0 : getTransferBillNo().hashCode()); + result = prime * result + ((getTransferAmount() == null) ? 0 : getTransferAmount().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getFailReason() == null) ? 0 : getFailReason().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userSpreadAccountId=").append(userSpreadAccountId); + sb.append(", userId=").append(userId); + sb.append(", outBillNo=").append(outBillNo); + sb.append(", transferBillNo=").append(transferBillNo); + sb.append(", transferAmount=").append(transferAmount); + sb.append(", status=").append(status); + sb.append(", failReason=").append(failReason); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransferExample.java b/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransferExample.java new file mode 100644 index 0000000..3280949 --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/BsUserSpreadAccountTransferExample.java @@ -0,0 +1,1064 @@ +package com.hfkj.entity; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class BsUserSpreadAccountTransferExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public BsUserSpreadAccountTransferExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdIsNull() { + addCriterion("user_spread_account_id is null"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdIsNotNull() { + addCriterion("user_spread_account_id is not null"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdEqualTo(Long value) { + addCriterion("user_spread_account_id =", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdNotEqualTo(Long value) { + addCriterion("user_spread_account_id <>", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdGreaterThan(Long value) { + addCriterion("user_spread_account_id >", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_spread_account_id >=", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdLessThan(Long value) { + addCriterion("user_spread_account_id <", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdLessThanOrEqualTo(Long value) { + addCriterion("user_spread_account_id <=", value, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdIn(List values) { + addCriterion("user_spread_account_id in", values, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdNotIn(List values) { + addCriterion("user_spread_account_id not in", values, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdBetween(Long value1, Long value2) { + addCriterion("user_spread_account_id between", value1, value2, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserSpreadAccountIdNotBetween(Long value1, Long value2) { + addCriterion("user_spread_account_id not between", value1, value2, "userSpreadAccountId"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andOutBillNoIsNull() { + addCriterion("out_bill_no is null"); + return (Criteria) this; + } + + public Criteria andOutBillNoIsNotNull() { + addCriterion("out_bill_no is not null"); + return (Criteria) this; + } + + public Criteria andOutBillNoEqualTo(String value) { + addCriterion("out_bill_no =", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoNotEqualTo(String value) { + addCriterion("out_bill_no <>", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoGreaterThan(String value) { + addCriterion("out_bill_no >", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoGreaterThanOrEqualTo(String value) { + addCriterion("out_bill_no >=", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoLessThan(String value) { + addCriterion("out_bill_no <", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoLessThanOrEqualTo(String value) { + addCriterion("out_bill_no <=", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoLike(String value) { + addCriterion("out_bill_no like", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoNotLike(String value) { + addCriterion("out_bill_no not like", value, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoIn(List values) { + addCriterion("out_bill_no in", values, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoNotIn(List values) { + addCriterion("out_bill_no not in", values, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoBetween(String value1, String value2) { + addCriterion("out_bill_no between", value1, value2, "outBillNo"); + return (Criteria) this; + } + + public Criteria andOutBillNoNotBetween(String value1, String value2) { + addCriterion("out_bill_no not between", value1, value2, "outBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoIsNull() { + addCriterion("transfer_bill_no is null"); + return (Criteria) this; + } + + public Criteria andTransferBillNoIsNotNull() { + addCriterion("transfer_bill_no is not null"); + return (Criteria) this; + } + + public Criteria andTransferBillNoEqualTo(String value) { + addCriterion("transfer_bill_no =", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoNotEqualTo(String value) { + addCriterion("transfer_bill_no <>", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoGreaterThan(String value) { + addCriterion("transfer_bill_no >", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoGreaterThanOrEqualTo(String value) { + addCriterion("transfer_bill_no >=", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoLessThan(String value) { + addCriterion("transfer_bill_no <", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoLessThanOrEqualTo(String value) { + addCriterion("transfer_bill_no <=", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoLike(String value) { + addCriterion("transfer_bill_no like", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoNotLike(String value) { + addCriterion("transfer_bill_no not like", value, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoIn(List values) { + addCriterion("transfer_bill_no in", values, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoNotIn(List values) { + addCriterion("transfer_bill_no not in", values, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoBetween(String value1, String value2) { + addCriterion("transfer_bill_no between", value1, value2, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferBillNoNotBetween(String value1, String value2) { + addCriterion("transfer_bill_no not between", value1, value2, "transferBillNo"); + return (Criteria) this; + } + + public Criteria andTransferAmountIsNull() { + addCriterion("transfer_amount is null"); + return (Criteria) this; + } + + public Criteria andTransferAmountIsNotNull() { + addCriterion("transfer_amount is not null"); + return (Criteria) this; + } + + public Criteria andTransferAmountEqualTo(BigDecimal value) { + addCriterion("transfer_amount =", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountNotEqualTo(BigDecimal value) { + addCriterion("transfer_amount <>", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountGreaterThan(BigDecimal value) { + addCriterion("transfer_amount >", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("transfer_amount >=", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountLessThan(BigDecimal value) { + addCriterion("transfer_amount <", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountLessThanOrEqualTo(BigDecimal value) { + addCriterion("transfer_amount <=", value, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountIn(List values) { + addCriterion("transfer_amount in", values, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountNotIn(List values) { + addCriterion("transfer_amount not in", values, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("transfer_amount between", value1, value2, "transferAmount"); + return (Criteria) this; + } + + public Criteria andTransferAmountNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("transfer_amount not between", value1, value2, "transferAmount"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andFailReasonIsNull() { + addCriterion("fail_reason is null"); + return (Criteria) this; + } + + public Criteria andFailReasonIsNotNull() { + addCriterion("fail_reason is not null"); + return (Criteria) this; + } + + public Criteria andFailReasonEqualTo(String value) { + addCriterion("fail_reason =", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonNotEqualTo(String value) { + addCriterion("fail_reason <>", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonGreaterThan(String value) { + addCriterion("fail_reason >", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonGreaterThanOrEqualTo(String value) { + addCriterion("fail_reason >=", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonLessThan(String value) { + addCriterion("fail_reason <", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonLessThanOrEqualTo(String value) { + addCriterion("fail_reason <=", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonLike(String value) { + addCriterion("fail_reason like", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonNotLike(String value) { + addCriterion("fail_reason not like", value, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonIn(List values) { + addCriterion("fail_reason in", values, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonNotIn(List values) { + addCriterion("fail_reason not in", values, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonBetween(String value1, String value2) { + addCriterion("fail_reason between", value1, value2, "failReason"); + return (Criteria) this; + } + + public Criteria andFailReasonNotBetween(String value1, String value2) { + addCriterion("fail_reason not between", value1, value2, "failReason"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Date value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Date value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Date value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Date value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Date value1, Date value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/service/gas/BsGasOrderSpreadService.java b/service/src/main/java/com/hfkj/service/gas/BsGasOrderSpreadService.java index 55d111b..2bd6293 100644 --- a/service/src/main/java/com/hfkj/service/gas/BsGasOrderSpreadService.java +++ b/service/src/main/java/com/hfkj/service/gas/BsGasOrderSpreadService.java @@ -19,7 +19,7 @@ public interface BsGasOrderSpreadService { void editData(BsGasOrderSpread data); /** - * 创建订单分销 + * 创建推广佣金 * @param order */ void createOrderSpread(BsGasOrder order); diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderSpreadServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderSpreadServiceImpl.java index cd644c5..fe05767 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderSpreadServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderSpreadServiceImpl.java @@ -56,21 +56,21 @@ public class BsGasOrderSpreadServiceImpl implements BsGasOrderSpreadService { gasOrderSpread.setOrderNo(order.getOrderNo()); gasOrderSpread.setGainsRebateUserId(userSpreadRel.getParentUserId()); gasOrderSpread.setGainsRebateRate(channel.getRebate()); - gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebate()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); + gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebate().divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_DOWN)); // 查询一级 BsUserSpreadRel userSpreadOneRel = userSpreadRelService.getDetailByUser(userSpreadRel.getParentUserId()); if (userSpreadOneRel != null) { gasOrderSpread.setGainsRebateUserId(userSpreadOneRel.getParentUserId()); gasOrderSpread.setGainsRebateRate(channel.getRebateOne()); - gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebateOne()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); + gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebateOne().divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_DOWN)); // 查询二级 BsUserSpreadRel userSpreadTwoRel = userSpreadRelService.getDetailByUser(userSpreadOneRel.getParentUserId()); if (userSpreadTwoRel != null) { gasOrderSpread.setGainsRebateUserId(userSpreadTwoRel.getParentUserId()); gasOrderSpread.setGainsRebateRate(channel.getRebateTwo()); - gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebateTwo()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); + gasOrderSpread.setGainsRebateAmount(order.getPayablePrice().multiply(channel.getRebateTwo().divide(new BigDecimal("100"))).setScale(2, BigDecimal.ROUND_HALF_DOWN)); } } editData(gasOrderSpread); diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index ba54179..21365e8 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -235,7 +235,7 @@ public class OrderCreateService { gasOrder.setCreateType(GasOrderCreateType.TYPE1.getNumber()); gasOrderService.addGasOrder(gasOrder); - // 分销 + // 推广佣金 gasOrderSpreadService.createOrderSpread(gasOrder); orderChild.setMerNo(merchant.getMerNo()); diff --git a/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountRecordService.java b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountRecordService.java index dd3da50..7b3f26f 100644 --- a/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountRecordService.java +++ b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountRecordService.java @@ -18,10 +18,25 @@ public interface BsUserSpreadAccountRecordService { */ void create(BsUserSpreadAccountRecord data); + /** + * 查询记录 + * @param orderNo + * @return + */ + BsUserSpreadAccountRecord getRecordByOrderNo(String orderNo); + /** * 查询列表 * @param param * @return */ List getList(Map param); + + /** + * 每日可提现次数 + * @param userId + * @return + */ + int withdrawChance(Long userId); + } diff --git a/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountService.java b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountService.java index 9334e9c..d913049 100644 --- a/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountService.java +++ b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountService.java @@ -1,9 +1,11 @@ package com.hfkj.service.spread; +import com.alibaba.fastjson.JSONObject; import com.hfkj.entity.BsUserSpreadAccount; import com.hfkj.sysenum.spread.UserSpreadAccountRecordSourceTypeEnum; import java.math.BigDecimal; +import java.util.List; import java.util.Map; /** @@ -32,6 +34,27 @@ public interface BsUserSpreadAccountService { */ BsUserSpreadAccount getDetailByUser(Long userId); + /** + * 查询列表 + * @param param + * @return + */ + List getList(Map param); + + /** + * 提现 + * @param userId 用户id + * @param amount 提现金额 + */ + JSONObject withdraw(Long userId, String openId,BigDecimal amount) throws Exception; + + /** + * 取消提现 + * @param orderNo 提现单号 + * @return + */ + void cancelWithdraw(String orderNo) throws Exception; + /** * 增加余额 * @param userId 用户id diff --git a/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountTransferService.java b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountTransferService.java new file mode 100644 index 0000000..6d8e185 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/spread/BsUserSpreadAccountTransferService.java @@ -0,0 +1,31 @@ +package com.hfkj.service.spread; + +import com.hfkj.entity.BsUserSpreadAccountTransfer; + +/** + * @className: BsUserSpreadAccountTransferService + * @author: HuRui + * @date: 2025/4/10 + **/ +public interface BsUserSpreadAccountTransferService { + + /** + * 编辑数据 + * @param data + */ + void editData(BsUserSpreadAccountTransfer data); + + /** + * 根据提现单号查询详情 + * @param outBillNo + * @return + */ + BsUserSpreadAccountTransfer getDetailByOutBillNo(String outBillNo); + + /** + * 每日可提现次数 + * @param userId + * @return + */ + int withdrawChance(Long userId); +} diff --git a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountRecordServiceImpl.java index aa0a40e..8c96371 100644 --- a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.hfkj.service.spread.impl; +import com.hfkj.common.utils.DateUtil; import com.hfkj.dao.BsUserSpreadAccountRecordMapper; import com.hfkj.entity.BsUserSpreadAccount; import com.hfkj.entity.BsUserSpreadAccountRecord; @@ -32,6 +33,17 @@ public class BsUserSpreadAccountRecordServiceImpl implements BsUserSpreadAccount userSpreadAccountRecordMapper.insert(data); } + @Override + public BsUserSpreadAccountRecord getRecordByOrderNo(String orderNo) { + BsUserSpreadAccountRecordExample example = new BsUserSpreadAccountRecordExample(); + example.createCriteria().andStatusNotEqualTo(0).andSourceOrderNoEqualTo(orderNo); + List list = userSpreadAccountRecordMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public List getList(Map param) { BsUserSpreadAccountRecordExample example = new BsUserSpreadAccountRecordExample(); @@ -49,7 +61,20 @@ public class BsUserSpreadAccountRecordServiceImpl implements BsUserSpreadAccount criteria.andSourceTypeEqualTo(MapUtils.getInteger(param, "sourceType")); } + if (MapUtils.getLong(param, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS"))); + } + + if (MapUtils.getLong(param, "createTimeE") != null) { + criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeE"))); + } + example.setOrderByClause("create_time desc"); return userSpreadAccountRecordMapper.selectByExample(example); } + + @Override + public int withdrawChance(Long userId) { + return userSpreadAccountRecordMapper.withdrawChance(userId); + } } diff --git a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountServiceImpl.java b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountServiceImpl.java index a16e9cf..abd93f7 100644 --- a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountServiceImpl.java @@ -1,23 +1,31 @@ package com.hfkj.service.spread.impl; +import com.alibaba.fastjson.JSONObject; 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.WxUtils; +import com.hfkj.config.CommonSysConst; import com.hfkj.dao.BsUserSpreadAccountMapper; import com.hfkj.entity.*; import com.hfkj.service.spread.BsUserSpreadAccountRecordService; import com.hfkj.service.spread.BsUserSpreadAccountService; +import com.hfkj.service.user.BsUserService; import com.hfkj.sysenum.merchant.MerchantAccountRecordTypeEnum; import com.hfkj.sysenum.spread.UserSpreadAccountRecordSourceTypeEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,6 +39,8 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic @Resource private BsUserSpreadAccountMapper userSpreadAccountMapper; @Resource + private BsUserService userService; + @Resource private BsUserSpreadAccountRecordService userSpreadAccountRecordService; @Resource private RedisTemplate redisTemplate; @@ -64,6 +74,63 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic return null; } + @Override + public List getList(Map param) { + BsUserSpreadAccountExample example = new BsUserSpreadAccountExample(); + example.createCriteria().andStatusNotEqualTo(0); + + example.setOrderByClause("create_time desc"); + return userSpreadAccountMapper.selectByExample(example); + } + + @Override + public JSONObject withdraw(Long userId, String openId,BigDecimal amount) throws Exception { + /* if (amount.compareTo(new BigDecimal("20")) < 0 || amount.compareTo(new BigDecimal("200")) > 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "提现金额20-200之间"); + }*/ + // 推广账户 + BsUserSpreadAccount userSpreadAccount = getDetailByUser(userId); + if (userSpreadAccount == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到账户"); + } + if (userSpreadAccount.getAmount().compareTo(amount) < 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "余额不足"); + } + if (userSpreadAccountRecordService.withdrawChance(userId) > 5) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达每日提现次数上限"); + } + // 查询用户信息 + BsUser user = userService.getUser(userId); + if (user == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息未完善"); + } + // 提现订单号 + String outBillNo = DateUtil.date2String(new Date(), DateUtil.YMDHMS); + // 微信商家转账 + JSONObject data = WxUtils.transferBills(openId,outBillNo, amount, "佣金提现"); + // 扣除余账户余额 + Map otherParam = new HashMap<>(); + otherParam.put("sourceContent", "提现"+amount+"元"); + otherParam.put("sourceOrderNo", outBillNo); + otherParam.put("ext1", data.getString("transferBillNo")); + minus(userId, amount, UserSpreadAccountRecordSourceTypeEnum.type2, otherParam); + + data.put("appId", CommonSysConst.getSysConfig().getWxMaAppId()); + data.put("mchId", "1614670195"); + return data; + } + + @Override + public void cancelWithdraw(String orderNo) throws Exception { + // 记录 + BsUserSpreadAccountRecord record = userSpreadAccountRecordService.getRecordByOrderNo(orderNo); + if (record == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到提现记录"); + } + // 微信商家转账 + WxUtils.cancelTransferBills(orderNo); + } + @Override public void increase(Long userId, BigDecimal amount, UserSpreadAccountRecordSourceTypeEnum sourceType, Map otherParam) throws Exception { // 锁编号 @@ -82,6 +149,10 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic BigDecimal beforeAmount = account.getAmount(); // 计算金额 account.setAmount(account.getAmount().add(amount)); + // 累积提现金额 + if (UserSpreadAccountRecordSourceTypeEnum.type2.getType().equals(sourceType.getType())) { + account.setCashOutAmount(account.getCashOutAmount().add(amount)); + } update(account); // 变更后金额 BigDecimal afterAmount = account.getAmount(); @@ -102,6 +173,9 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic if (StringUtils.isNotBlank(MapUtils.getString(otherParam, "sourceContent"))) { record.setSourceContent(MapUtils.getString(otherParam, "sourceContent")); } + if (StringUtils.isNotBlank(MapUtils.getString(otherParam, "ext1"))) { + record.setExt1(MapUtils.getString(otherParam, "ext1")); + } userSpreadAccountRecordService.create(record); // 释放锁 redisTemplate.delete(lockKey); @@ -135,6 +209,10 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic BigDecimal beforeAmount = account.getAmount(); // 计算金额 account.setAmount(account.getAmount().subtract(amount)); + // 累积提现金额 + if (UserSpreadAccountRecordSourceTypeEnum.type4.getType().equals(sourceType.getType())) { + account.setCashOutAmount(account.getCashOutAmount().subtract(amount)); + } update(account); // 变更后金额 BigDecimal afterAmount = account.getAmount(); @@ -147,14 +225,17 @@ public class BsUserSpreadAccountServiceImpl implements BsUserSpreadAccountServic record.setBeforeAmount(beforeAmount); record.setAfterAmount(afterAmount); record.setSourceType(sourceType.getType()); - try { - record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); - } catch (Exception e) { - e.printStackTrace(); - } if (StringUtils.isNotBlank(MapUtils.getString(otherParam, "sourceContent"))) { record.setSourceContent(MapUtils.getString(otherParam, "sourceContent")); } + if (StringUtils.isNotBlank(MapUtils.getString(otherParam, "sourceOrderNo"))) { + record.setSourceOrderNo(MapUtils.getString(otherParam, "sourceOrderNo")); + } else { + record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); + } + if (StringUtils.isNotBlank(MapUtils.getString(otherParam, "ext1"))) { + record.setExt1(MapUtils.getString(otherParam, "ext1")); + } userSpreadAccountRecordService.create(record); // 释放锁 redisTemplate.delete(lockKey); diff --git a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountTransferServiceImpl.java b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountTransferServiceImpl.java new file mode 100644 index 0000000..a839e0a --- /dev/null +++ b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadAccountTransferServiceImpl.java @@ -0,0 +1,49 @@ +package com.hfkj.service.spread.impl; + +import com.hfkj.dao.BsUserSpreadAccountTransferMapper; +import com.hfkj.entity.BsUserSpreadAccountTransfer; +import com.hfkj.entity.BsUserSpreadAccountTransferExample; +import com.hfkj.service.spread.BsUserSpreadAccountTransferService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * @className: BsUserSpreadAccountTransferServiceImpl + * @author: HuRui + * @date: 2025/4/10 + **/ +@Service("userSpreadAccountTransferService") +public class BsUserSpreadAccountTransferServiceImpl implements BsUserSpreadAccountTransferService { + @Resource + private BsUserSpreadAccountTransferMapper userSpreadAccountTransferMapper; + + @Override + public void editData(BsUserSpreadAccountTransfer data) { + data.setUpdateTime(new Date()); + if (data.getId() == null) { + data.setCreateTime(new Date()); + userSpreadAccountTransferMapper.insert(data); + } else { + userSpreadAccountTransferMapper.updateByPrimaryKey(data); + } + } + + @Override + public BsUserSpreadAccountTransfer getDetailByOutBillNo(String outBillNo) { + BsUserSpreadAccountTransferExample example = new BsUserSpreadAccountTransferExample(); + example.createCriteria().andOutBillNoEqualTo(outBillNo).andStatusNotEqualTo(0); + List list = userSpreadAccountTransferMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + + @Override + public int withdrawChance(Long userId) { + return 0; + } +} diff --git a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadOilChannelServiceImpl.java b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadOilChannelServiceImpl.java index 8fe9356..34b2199 100644 --- a/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadOilChannelServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/spread/impl/BsUserSpreadOilChannelServiceImpl.java @@ -72,7 +72,7 @@ public class BsUserSpreadOilChannelServiceImpl implements BsUserSpreadOilChannel criteria.andChannelEqualTo(MapUtils.getInteger(param,"channel")); } - example.setOrderByClause("create_time desc"); + example.setOrderByClause("channel"); return userSpreadOilChannelMapper.selectByExample(example); } } diff --git a/service/src/main/java/com/hfkj/sysenum/spread/UserSpreadAccountRecordSourceTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/spread/UserSpreadAccountRecordSourceTypeEnum.java index e37ac5c..5df1055 100644 --- a/service/src/main/java/com/hfkj/sysenum/spread/UserSpreadAccountRecordSourceTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/spread/UserSpreadAccountRecordSourceTypeEnum.java @@ -20,6 +20,10 @@ public enum UserSpreadAccountRecordSourceTypeEnum { * 订单退款 */ type3(3 , "订单退款"), + /** + * 取消提现 + */ + type4(4 , "取消提现"), ; private Integer type;