Helius
2021-05-14 a1560583ab4dba589acb64238970fdebdea20233
modify
3 files modified
15 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/yunding/YdOrderDao.xml 5 ●●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/XchTest.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
@@ -17,6 +17,7 @@
import com.xcong.excoin.modules.yunding.entity.YdProductEntity;
import com.xcong.excoin.modules.yunding.service.XchProfitService;
import com.xcong.excoin.utils.LogRecordUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -24,6 +25,7 @@
import java.math.BigDecimal;
import java.util.*;
@Slf4j
@Service
public class XchProfitServiceImpl implements XchProfitService {
@@ -203,6 +205,7 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void xchProfitDistributor(BigDecimal totalProfit) {
        Date currentDate = new Date();
        List<YdProductEntity> products = ydProductDao.selectList(null);
@@ -219,6 +222,7 @@
            // 单位XCH收益
            BigDecimal unitProfit = totalProfit.divide(totalCount, 8, BigDecimal.ROUND_DOWN);
            log.info("单位XCH收益:{}", unitProfit);
            List<YdOrderEntity> orders = ydOrderDao.selectAllValidOrders();
            if (CollUtil.isNotEmpty(orders)) {
@@ -253,6 +257,7 @@
                        }
                    }
                    remainProfit = remainProfit.subtract(orderProfit.subtract(orderProfit.multiply(order.getYdProductEntity().getManageExpense())));
                    String content = "XCH收益";
                    LogRecordUtils.insertMemberAccountMoneyChangeWithId(order.getMemberId(), content, remainProfit, "XCH", 1, 4, order.getId());
                    MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(order.getMemberId(), "XCH");
src/main/resources/mapper/yunding/YdOrderDao.xml
@@ -47,13 +47,14 @@
        <association property="ydProductEntity" javaType="com.xcong.excoin.modules.yunding.entity.YdProductEntity">
            <id column="p_id" property="id" />
            <result column="pro_unit" property="proUnit" />
            <result column="manage_expense" property="manageExpense" />
        </association>
    </resultMap>
    <select id="selectAllValidOrders" resultMap="orderMap">
        select a.*, b.id p_id, b.pro_unit from yd_order a
        select a.*, b.id p_id, b.pro_unit, b.manage_expense from yd_order a
        inner join yd_product b on a.product_id=b.id
        where a.state=2
        where a.state=2 and a.type = 1
    </select>
    <update id="UpdateByIdAndState">
src/test/java/com/xcong/excoin/XchTest.java
@@ -60,4 +60,9 @@
        orderEntity.setAmount(BigDecimal.TEN);
        ydOrderDao.insert(orderEntity);
    }
    @Test
    public void xchProfitTest() {
        xchProfitService.xchProfitDistributor(BigDecimal.valueOf(1));
    }
}