| | |
| | | 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);
|
| | | }
|
| | |
| | | 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.*; |
| | | |
| | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Validated |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | |
| | | return otcService.updateOtcSetting(otcSettingEntity); |
| | | } |
| | | |
| | | /** |
| | | * 放币 |
| | | */ |
| | | @PostMapping("/reduceCoin/{id}") |
| | | @ControllerEndpoint(operation = "放币", exceptionMessage = "失败") |
| | | public FebsResponse reduceCoin(@PathVariable("id") Long id) { |
| | | otcService.reduceCoin(id); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | private String nickname; |
| | | |
| | | /** |
| | | * 对面的用户ID |
| | | */ |
| | | private Long oppositeMemberId; |
| | | |
| | | } |
| | |
| | | IPage<OtcOrderEntity> otcOrderList(Page<OtcOrderEntity> page, |
| | | @Param("record")OtcOrderEntity otcOrderEntity); |
| | | |
| | | int updateOrderStatusByOrderNo(@Param("status") Integer status, @Param("orderNo") String orderNo); |
| | | } |
| | |
| | | OtcSettingEntity otcSettingUpdate(long id); |
| | | |
| | | FebsResponse updateOtcSetting(OtcSettingEntity otcSettingEntity); |
| | | |
| | | int reduceCoin(Long id); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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:
|
| | |
| | | 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> |
| | |
| | | order by a.create_time desc |
| | | </select> |
| | | |
| | | <update id="updateOrderStatusByOrderNo"> |
| | | update otc_order |
| | | set status=#{status} |
| | | where order_no=#{orderNo} |
| | | </update> |
| | | </mapper> |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (layEvent === 'reduceCoin') { |
| | | febs.modal.confirm('放币', '确定直接放币?', function () { |
| | | febs.post(ctx + 'otc/reduceCoin/' + data.id, null, function () { |
| | | febs.alert.success('放币成功'); |
| | | $query.click(); |
| | | }); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 查询按钮 |
| | |
| | | // 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 if (d.status === 2 && d.orderType === 'S'){ |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="reduceCoin">放币</button>' |
| | | }else{ |
| | | return '' |
| | | return ''; |
| | | } |
| | | },minWidth: 100,align:'center'} |
| | | ]] |