update 财务中心 计算金额

This commit is contained in:
Guoqs
2025-07-14 15:55:14 +08:00
parent 174b70cb46
commit 54bd952894
5 changed files with 39 additions and 17 deletions

View File

@@ -132,4 +132,6 @@ public interface AdapayMemberAccountMapper {
* @return * @return
*/ */
AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId); AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId);
}
List<String> selectUsedAdapayMemberIdByMerchantId(String merchantId);
}

View File

@@ -122,4 +122,6 @@ public interface AdapayMemberAccountService {
* @return * @return
*/ */
AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId); AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId);
List<String> selectUsedAdapayMemberIdByMerchantId(String merchantId);
} }

View File

@@ -273,5 +273,13 @@ public class AdapayMemberAccountServiceImpl implements AdapayMemberAccountServic
public AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId) { public AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId) {
return adapayMemberAccountMapper.selectRecentInfoByMerchantId(merchantId); return adapayMemberAccountMapper.selectRecentInfoByMerchantId(merchantId);
} }
/**
* 根据运营商id 查询该运营商所有使用过的AdapayMemberId
*/
@Override
public List<String> selectUsedAdapayMemberIdByMerchantId(String merchantId) {
return adapayMemberAccountMapper.selectUsedAdapayMemberIdByMerchantId(merchantId);
}
} }

View File

@@ -187,6 +187,7 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService {
} }
// 根据merchantId查询汇付账户信息 // 根据merchantId查询汇付账户信息
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId); AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
List<String> usedAdapayMemberIdList = adapayMemberAccountService.selectUsedAdapayMemberIdByMerchantId(merchantId);
// 按天分组, 组装结果集 key 为 tradeDate, value 为该天的订单分账记录 // 按天分组, 组装结果集 key 为 tradeDate, value 为该天的订单分账记录
Map<String, List<OrderSplitRecord>> dailyRecordMap = orderSplitRecords.stream().collect(Collectors.groupingBy(OrderSplitRecord::getTradeDate)); Map<String, List<OrderSplitRecord>> dailyRecordMap = orderSplitRecords.stream().collect(Collectors.groupingBy(OrderSplitRecord::getTradeDate));
// 按天分组 key 为 tradeDate, value 为该天的订单分账记录 // 按天分组 key 为 tradeDate, value 为该天的订单分账记录
@@ -216,7 +217,9 @@ public class OrderSplitRecordServiceImpl implements OrderSplitRecordService {
orderCodeSet.remove(record.getOrderCode()); orderCodeSet.remove(record.getOrderCode());
} }
// 区分运营商自己分账的金额, 和他人的分账金额 // 区分运营商自己分账的金额, 和他人的分账金额
if (adapayMemberAccount != null && adapayMemberAccount.getAdapayMemberId().equals(record.getAdapayMemberId())) { // if (adapayMemberAccount != null && adapayMemberAccount.getAdapayMemberId().equals(record.getAdapayMemberId())) {
// record.getAdapayMemberId() 存在usedAdapayMemberIdList
if (CollectionUtils.isNotEmpty(usedAdapayMemberIdList) && usedAdapayMemberIdList.contains(record.getAdapayMemberId())) {
totalMerchantSplitAmount = totalMerchantSplitAmount.add(record.getElectricitySplitAmount()).add(record.getServiceSplitAmount()); totalMerchantSplitAmount = totalMerchantSplitAmount.add(record.getElectricitySplitAmount()).add(record.getServiceSplitAmount());
} else { } else {
totalOtherSplitAmount = totalOtherSplitAmount.add(record.getElectricitySplitAmount()).add(record.getServiceSplitAmount()); totalOtherSplitAmount = totalOtherSplitAmount.add(record.getElectricitySplitAmount()).add(record.getServiceSplitAmount());

View File

@@ -18,12 +18,12 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, `status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time, id, `status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time,
create_by, update_time, update_by, del_flag create_by, update_time, update_by, del_flag
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated--> <!--@mbg.generated-->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from adapay_member_account from adapay_member_account
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@@ -35,13 +35,13 @@
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into adapay_member_account (`status`, merchant_id, adapay_member_id, insert into adapay_member_account (`status`, merchant_id, adapay_member_id,
settle_account_id, remark, create_time, settle_account_id, remark, create_time,
create_by, update_time, update_by, create_by, update_time, update_by,
del_flag) del_flag)
values (#{status,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{adapayMemberId,jdbcType=VARCHAR}, values (#{status,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{adapayMemberId,jdbcType=VARCHAR},
#{settleAccountId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{settleAccountId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{delFlag,jdbcType=VARCHAR}) #{delFlag,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
@@ -227,13 +227,13 @@
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true"> <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into adapay_member_account insert into adapay_member_account
(`status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time, (`status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time,
create_by, update_time, update_by, del_flag) create_by, update_time, update_by, del_flag)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.status,jdbcType=VARCHAR}, #{item.merchantId,jdbcType=VARCHAR}, #{item.adapayMemberId,jdbcType=VARCHAR}, (#{item.status,jdbcType=VARCHAR}, #{item.merchantId,jdbcType=VARCHAR}, #{item.adapayMemberId,jdbcType=VARCHAR},
#{item.settleAccountId,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.settleAccountId,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
#{item.createBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR},
#{item.delFlag,jdbcType=VARCHAR}) #{item.delFlag,jdbcType=VARCHAR})
</foreach> </foreach>
</insert> </insert>
@@ -271,7 +271,7 @@
#{updateBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
#{delFlag,jdbcType=VARCHAR}, #{delFlag,jdbcType=VARCHAR},
</trim> </trim>
on duplicate key update on duplicate key update
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="id != null"> <if test="id != null">
id = #{id,jdbcType=INTEGER}, id = #{id,jdbcType=INTEGER},
@@ -362,7 +362,7 @@
#{delFlag,jdbcType=VARCHAR}, #{delFlag,jdbcType=VARCHAR},
</if> </if>
</trim> </trim>
on duplicate key update on duplicate key update
<trim suffixOverrides=","> <trim suffixOverrides=",">
<if test="id != null"> <if test="id != null">
id = #{id,jdbcType=INTEGER}, id = #{id,jdbcType=INTEGER},
@@ -544,4 +544,11 @@
order by create_time desc order by create_time desc
limit 1 limit 1
</select> </select>
</mapper>
<select id="selectUsedAdapayMemberIdByMerchantId" resultType="java.lang.String">
select
adapay_member_id
from adapay_member_account
where merchant_id = #{merchantId,jdbcType=VARCHAR}
</select>
</mapper>