Helius
2021-06-03 a3f86d22b6b9d5ab4a335488ddaf8edf3aa5f787
modify
10 files modified
81 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/member/mapper/MemberWalletCoinMapper.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/controller/OtcController.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/entity/OtcOrderEntity.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/mapper/OtcOrderMapper.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/service/OtcService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
src/main/resources/application-dev.yml 10 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/MemberWalletCoinMapper.xml 15 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/OtcOrderMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/resources/templates/febs/views/modules/otc/otcOrderList.html 13 ●●●●● patch | view | raw | blame | history
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);
}
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();
    }
}
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;
}
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);
}
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);
}
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;
    }
}
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:
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>
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>
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 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'}
                ]]