冲减金额部分 -- 支付的核心功能

平台冲减原型

Controller层

@GetMapping("/deductAccountBalance")@ApiOperation(value = "80103冲减金额", response = MemberAccountBillDO.class)public AjaxJson deductAccountBalance(@Valid DeductAccountBalanceDTO deductAccountBalanceDTO) {log.info("deductAccountBalance...deductAccountBalanceDTO = " + JSON.toJSONString(deductAccountBalanceDTO));memberAccountManager.deductAccountBalance(deductAccountBalanceDTO);return new AjaxJson(null, true, "操作成功", 0);}

Mapper层

/*** 平台冲减--扣除账户余额** @return MemberAccountDO* @date 2021/2/25*/void deductAccountBalance(DeductAccountBalanceDTO deductAccountBalanceDTO);

Service层

@Override@Transactional(value = "tradeTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)public void deductAccountBalance(DeductAccountBalanceDTO deductAccountBalanceDTO) {log.info("deductAccountBalance...");int memberId = null == deductAccountBalanceDTO.getMemberId() ? 0 : deductAccountBalanceDTO.getMemberId();if (memberId < 1) {throw new ServiceException("500", "会员ID信息不合法");}/** 获取页面传值加工处理 */BigDecimal amount = deductAccountBalanceDTO.getAmount();// 账户类型:1-余额,2-积分,3-金币,4-保证金,5-股份;int accountTypeCode = deductAccountBalanceDTO.getAccountTypeCode();String accountTypeName = AccountTypeEnum.getValue(accountTypeCode + "");// 流水方向:0-默认;1-业务收入;2-业务支出;3-系统收入;4-系统支出;5-平台服务费; int billTypeCode = 0;String billTypeName = "";// 账单类型int busiTypeCode = 0;String busiTypeName = "";String busiDescribe = deductAccountBalanceDTO.getBusiDescribe();    // 页面备注/** 充值或扣减判断,业务类型和流水类型赋值处理 */if (5050 == deductAccountBalanceDTO.getBusiTypeCode()) {// 流水类型:0-默认;1-业务收入;2-业务支出;billTypeCode = AccountBillTypeEnum.ACCOUNT_BILL_BUSI_IN.getCode();billTypeName = AccountBillTypeEnum.ACCOUNT_BILL_BUSI_IN.getMsg();// 账单类型busiTypeCode = AccountBusiTypeEnum.PLATFORM_SERVE_SYS_RECHARGE.getCode();busiTypeName = AccountBusiTypeEnum.PLATFORM_SERVE_SYS_RECHARGE.getMsg();} else if (5060 == deductAccountBalanceDTO.getBusiTypeCode()) {// 流水类型:0-默认;1-业务收入;2-业务支出;billTypeCode = AccountBillTypeEnum.ACCOUNT_BILL_BUSI_OUT.getCode();billTypeName = AccountBillTypeEnum.ACCOUNT_BILL_BUSI_OUT.getMsg();// 账单类型busiTypeCode = AccountBusiTypeEnum.PLATFORM_SERVE_SYS_DEDUCT.getCode();busiTypeName = AccountBusiTypeEnum.PLATFORM_SERVE_SYS_DEDUCT.getMsg();} else {// 抛出异常throw new ServiceException("500", "冲减类型不合法");}log.info("memberId = " + memberId + "amount = " + amount + "accountTypeCode = " + accountTypeCode+ "accountTypeName = " + accountTypeName + "billTypeCode = " + billTypeCode + "busiTypeCode = " + busiTypeCode);/** 数据库操作 */accountRechargeOrDeduct(memberId, amount, accountTypeCode, accountTypeName, billTypeCode, billTypeName,busiTypeCode, busiTypeName, busiDescribe);}/*** @param @param memberId* @param @param amount* @param @param accountTypeCode* @param @param accountTypeName* @param @param billTypeCode* @param @param billTypeName* @param @param busiTypeCode* @param @param busiTypeName* @param @param busiDescribe    参数* @return void    返回类型* @throws* @Title: accountRechargeOrDeduct* @Description: 2021年3月1日 上午11:18:57 账户充值或扣减*/public void accountRechargeOrDeduct(int memberId, BigDecimal amount, int accountTypeCode, String accountTypeName,int billTypeCode, String billTypeName, int busiTypeCode, String busiTypeName, String busiDescribe) {log.info("accountRecharge...");// SQL 和 参数String sql = "";List<Object> params = new ArrayList<Object>();if (1 == billTypeCode) {// 充值sql = "update es_member_account set blance_total = blance_total + " + amount + ", "+ "blance_useable = blance_useable + " + amount + " "+ "where member_id = " + memberId + " and account_type_code = " + accountTypeCode + " ";}if (2 == billTypeCode) {/** 如果是扣减,先判断扣减金额是否超出现有的可用金额,友好提示 */MemberAccountVO memberAccountVO = getByAccountTypeCode(memberId, accountTypeCode);log.info("amount = " + amount + "blanceUseable = " + memberAccountVO.getBlanceUseable());if (amount.compareTo(memberAccountVO.getBlanceUseable()) <= 0) {// 扣减sql = "update es_member_account set blance_total = blance_total - " + amount + ", "+ "blance_useable = blance_useable - " + amount + " "+ "where member_id = " + memberId + " and account_type_code = " + accountTypeCode+ " and blance_useable - " + amount + " >= 0 ";} else {throw new ServiceException("500", "扣减金额应小于当前可用金额");}}log.info("sql = " + sql);// 更新主表daoSupport.execute(sql, params.toArray());sql = "insert into es_member_account_bill ("+ "member_id, member_name, account_type_code, account_type_name, "+ "bill_type_code, bill_type_name, busi_type_code, busi_type_name, "+ "amount, balance, fee, "+ "exchange_amount, busi_sn, busi_describe, busi_date, bill_date ) "+ "select "+ "member_id, member_name, " + accountTypeCode + ", '" + accountTypeName + "', "+ "" + billTypeCode + ", '" + billTypeName + "', " + busiTypeCode + ", '" + busiTypeName + "', "+ "" + amount + ", (blance_useable + balance_unsettle + order_freeze + withdraw_freeze), 0, "+ "0, id, '" + busiDescribe + "', now(), now() "+ "from es_member_account "+ "where member_id = " + memberId + " and account_type_code = " + accountTypeCode + " for update ";log.info("sql = " + sql);// 插入流水表daoSupport.execute(sql, params.toArray());}public static void main(String[] args) {log.info("main...");int accountTypeCode = 2;String accountTypeName = AccountTypeEnum.getValue(accountTypeCode + "");log.info("accountTypeCode = " + accountTypeCode + ", accountTypeName = " + accountTypeName);}

2021-03-12相关推荐

  1. 2021.03.12——学习公司项目

    1 uni.navigateTo 保留当前页跳转 可带参跳转 uni.navigateTo({url: '/pages/login/getSms?mobile=' + this.phone}); 2 ...

  2. E.03.12 For Planet Earth, No Tourism is a Curse and a Blessing

    2021.03.12 文章目录 [课程导读] [英文原文] [外刊原文] [课程导读] 受疫情影响,全球的旅游业几乎陷入停滞,却也给地球环境带来了一些积极影响.比如,二氧化碳的排放量锐减,邮轮引擎造成 ...

  3. 3D打印机硬件驱动-马林固件最新版本2.0.X中文注释(1)marlin 2.0.9.2 截至发稿时间2021年12月16日

    马林固件最新版本翻译注释 /*============================================================================== Marlin ...

  4. 2021.03.24正则匹配符号

    2021.03.24 正则表达式 from re import fullmatch 正则是一种用来处理文本数据的一种工具.(一般用于处理复杂的文本问题) 1)检测输入的数据是否是手机号? 2)检查输入 ...

  5. 2021.03.30【2021省赛】模拟 比赛总结

    2021.03.30[2021省赛]模拟 比赛总结 地址: https://gmoj.net/senior/#contest/home/3350 T1: 神奇纸牌(uno) T2: 凌乱平衡树 (tr ...

  6. 2021年12月中国汽车企业出口量排行榜:特斯拉上海12月出口量仅245辆,占比其全年出口总量的0.15%(附月榜TOP39详单)

    榜单解读: 2021年12月,中国98家汽车企业共生产汽车2907173辆,其中51家企业累计出口222571辆,出口量占总产量的7.7%.12月只有39家汽车企业有出口量,出口量环比增长11.44% ...

  7. 2021年12月中国汽车发动机生产企业销售量排行榜:排名前三的企业销量环比均有所增长,且只销售汽油发动机(附月榜TOP58详单)

    榜单解读: 2021年12月65家汽车发动机生产企业共销售242.73万台发动机,环比上升了10.7%,同比下滑了2.78%,其中商品量占销量比重为37.69%,自配量占销量比重为62.31%,产销比 ...

  8. 电动力学每日一题 2021/10/12

    电动力学每日一题 2021/10/12 (a) To make the EM field trapped inside a perfectly electric conducting cavity, ...

  9. 2021年12届蓝桥杯C++B组省赛

    2021年12届蓝桥杯C++B组省赛 路径 自己的写法 #include <cstring> #include <cstdio> #include <cmath> ...

  10. 书籍《循环经济之道》-观后感-2021年12月

    路虽远矣,行则将至. 事虽难矣,做则必成. 本次分享<循环经济之道-通向可持续发展>读书有感. THE CIRCULAR ECONOMY HANDBOOK-Realizing the Ci ...

最新文章

  1. 11 款可替代 top 命令的工具!
  2. 解决VirtualBox 上的XP 关机时重启 , 启动时蓝屏 ,点击电源选项蓝屏
  3. Selenium3自动化测试——21.数据驱动应用
  4. BP神经网络 语音信号分类
  5. conscience ['kɔnʃəns]
  6. 基于curl的php多线程类(异步请求)
  7. JQUERY的html()
  8. Java ObjectOutputStream flush()方法与示例
  9. MongoDB解决“Error parsing YAML config file: yaml-cpp: error at line 2, column value(安装服务)
  10. nginx引入自定义的配置文件
  11. 因为此网站使用了 hsts_HSTS原理及实践
  12. 前端复习笔记(三)——JavaScript和JQuery
  13. 多媒体计算机技术的核心技术是,计算机多媒体的核心技术与发展
  14. vmware 虚拟机恢复ghost镜像文件
  15. 聊聊生活中的一些仪式感
  16. 位置不可用无法访问介质受写入保护怎样解决?
  17. 【异常检测论文】Anomaly Detection综述
  18. java双开_修改Android源码实现原生应用双开,应用多开
  19. UninstallToo卸载软件
  20. 四年级下册计算机技术做福字,四年级写福字作文

热门文章

  1. AB PLC Modbus TCP通讯测试
  2. 做自己最好的生活大师
  3. 认识QA, 游戏测试工程师究竟是做什么的?
  4. 微信小程序实现文件上传
  5. 基于51单片机220V交流电流检测系统过流阈值报警方案原理图
  6. 微信小程序tab切换效果
  7. c++学习 | MFC —— 控件介绍
  8. 【React】利用Dooringx快速制作H5搭建平台
  9. 0001 工作业务问题_滞纳金公式计算区别实例
  10. 如何在电脑端同时登录多个企业微信或微信