From a3f86d22b6b9d5ab4a335488ddaf8edf3aa5f787 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 03 Jun 2021 16:45:08 +0800
Subject: [PATCH] modify
---
src/main/resources/mapper/modules/OtcOrderMapper.xml | 5 ++
src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java | 4 ++
src/main/resources/templates/febs/views/modules/otc/otcOrderList.html | 15 ++++++-
src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java | 12 ++++++
src/main/resources/mapper/modules/MemberWalletCoinMapper.xml | 15 +++++++
src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java | 5 ++
src/main/resources/application-dev.yml | 10 +++-
src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java | 1
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java | 14 +++++++
src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java | 2 +
10 files changed, 78 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java b/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java
index 1c61502..830e044 100644
--- a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java
+++ b/src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java
@@ -5,8 +5,13 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
+import java.math.BigDecimal;
+
public interface MemberWalletCoinMapper extends BaseMapper<MemberWalletCoinEntity> {
MemberWalletCoinEntity findWalletCoinByMemberIdAndWalletCode(@Param("memberId")Long memberId, @Param("walletCode")String walletCode);
+ int updateBlockBalance(@Param("availableBalance") BigDecimal availableBalance, @Param("id") Long id);
+
+ int reduceFrozenBalance(@Param("amount") BigDecimal amount, @Param("id") Long id);
}
diff --git a/src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java b/src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java
index a202774..11c2544 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java
@@ -9,6 +9,7 @@
import com.xcong.excoin.modules.otc.entity.*;
import com.xcong.excoin.modules.otc.service.OtcService;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -16,6 +17,7 @@
import javax.validation.constraints.NotNull;
import java.util.Map;
+@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@@ -138,4 +140,14 @@
return otcService.updateOtcSetting(otcSettingEntity);
}
+ /**
+ * 放币
+ */
+ @PostMapping("/reduceCoin/{id}")
+ @ControllerEndpoint(operation = "放币", exceptionMessage = "失败")
+ public FebsResponse reduceCoin(@PathVariable("id") Long id) {
+ otcService.reduceCoin(id);
+ return new FebsResponse().success();
+ }
+
}
diff --git a/src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java b/src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java
index d1993bc..fca7632 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java
@@ -73,5 +73,9 @@
@TableField(exist = false)
private String nickname;
+ /**
+ * 对面的用户ID
+ */
+ private Long oppositeMemberId;
}
diff --git a/src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java b/src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java
index d91bbb4..63948b8 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java
@@ -11,4 +11,5 @@
IPage<OtcOrderEntity> otcOrderList(Page<OtcOrderEntity> page,
@Param("record")OtcOrderEntity otcOrderEntity);
+ int updateOrderStatusByOrderNo(@Param("status") Integer status, @Param("orderNo") String orderNo);
}
diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java b/src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java
index 23d4ab2..df0ac3b 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java
@@ -40,4 +40,6 @@
OtcSettingEntity otcSettingUpdate(long id);
FebsResponse updateOtcSetting(OtcSettingEntity otcSettingEntity);
+
+ int reduceCoin(Long id);
}
diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java
index bf070e3..2259c8d 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java
@@ -298,4 +298,18 @@
return new FebsResponse().success();
}
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public int reduceCoin(Long id) {
+ OtcOrderEntity order = otcOrderMapper.selectById(id);
+
+ MemberWalletCoinEntity saleWallet = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(order.getMemberId(), "USDT");
+ MemberWalletCoinEntity buyWallet = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(order.getOppositeMemberId(), "USDT");
+
+ memberWalletCoinMapper.updateBlockBalance(order.getCoinAmount(), buyWallet.getId());
+ memberWalletCoinMapper.reduceFrozenBalance(order.getCoinAmount(), saleWallet.getId());
+
+ otcOrderMapper.updateOrderStatusByOrderNo(OtcOrderEntity.STATUS_THREE, order.getOrderNo());
+ return 1;
+ }
}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index c7f2eb3..e6c1466 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -15,10 +15,14 @@
datasource:
# 数据源-1,名称为 base
base:
- username: db_hibit
- password: hibit123!@#
+# username: yd_otc
+# password: yd_otc123!@#
+# driver-class-name: com.mysql.cj.jdbc.Driver
+# url: jdbc:mysql://154.91.195.170:3306/db_otc?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
+ username: ct_test
+ password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://124.70.222.34:3306/db_hibit?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
+ url: jdbc:mysql://120.27.238.55:3306/db_otc?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
redis:
diff --git a/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml b/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml
index 5980ed9..fabdfd6 100644
--- a/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml
+++ b/src/main/resources/mapper/modules/MemberWalletCoinMapper.xml
@@ -7,4 +7,19 @@
select * from member_wallet_coin where member_id = #{memberId} and wallet_code = #{walletCode}
</select>
+
+ <update id="updateBlockBalance">
+ update member_wallet_coin
+ set
+ available_balance = IFNULL(available_balance, 0) + #{availableBalance},
+ total_balance = IFNULL(total_balance, 0) + #{availableBalance}
+ where id=#{id}
+ </update>
+
+ <update id="reduceFrozenBalance">
+ update member_wallet_coin
+ set frozen_balance = frozen_balance - #{amount},
+ total_balance = total_balance - #{amount}
+ where id=#{id}
+ </update>
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/modules/OtcOrderMapper.xml b/src/main/resources/mapper/modules/OtcOrderMapper.xml
index 1b16d40..4b9b5b6 100644
--- a/src/main/resources/mapper/modules/OtcOrderMapper.xml
+++ b/src/main/resources/mapper/modules/OtcOrderMapper.xml
@@ -23,4 +23,9 @@
order by a.create_time desc
</select>
+ <update id="updateOrderStatusByOrderNo">
+ update otc_order
+ set status=#{status}
+ where order_no=#{orderNo}
+ </update>
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/otc/otcOrderList.html b/src/main/resources/templates/febs/views/modules/otc/otcOrderList.html
index bd0fda3..395e639 100644
--- a/src/main/resources/templates/febs/views/modules/otc/otcOrderList.html
+++ b/src/main/resources/templates/febs/views/modules/otc/otcOrderList.html
@@ -85,6 +85,15 @@
}
});
}
+
+ if (layEvent === 'reduceCoin') {
+ febs.modal.confirm('放币', '确定直接放币?', function () {
+ febs.post(ctx + 'otc/reduceCoin/' + data.id, null, function () {
+ febs.alert.success('放币成功');
+ $query.click();
+ });
+ });
+ }
});
// 查询按钮
@@ -144,8 +153,10 @@
// return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="dealIng" shiro:hasPermission="user:update">付款</button>'
if(d.status === 1){
return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="dealIng" shiro:hasPermission="user:update">付款</button>'
- }else{
- return ''
+ }else if (d.status === 2 && d.orderType === 'S'){
+ return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="reduceCoin">放币</button>'
+ } else {
+ return '';
}
},minWidth: 100,align:'center'}
]]
--
Gitblit v1.9.1