Authored by LUOXC

Merge branch 'hotfix-invite-activity' into test6.9.0

# Conflicts:
#	order/src/main/java/com/yohoufo/order/controller/InviteSettlementController.java
#	order/src/main/java/com/yohoufo/order/service/IInviteSettlementService.java
#	order/src/main/java/com/yohoufo/order/service/impl/InviteSettlementServiceImpl.java
... ... @@ -17,6 +17,9 @@ public interface InviteSettlementItemMapper {
@Param("tagStatus") Integer tagStatus,
@Param("inviteSettlementId") Integer inviteSettlementId);
int updateStatusByUidAndInviteSettlementId(@Param("uid") Integer uid, @Param("inviteSettlementId") Integer inviteSettlementId,
@Param("status") Integer status);
InviteSettlementItem selectByUidAndBuyerOrderCode(@Param("uid") Integer uid, @Param("buyerOrderCode") Long buyerOrderCode);
InviteSettlementItem selectOneByUidAndStatus(@Param("uid") Integer uid,
... ...
... ... @@ -19,4 +19,6 @@ public interface InviteSettlementMapper {
List<InviteSettlement> selectByUidAndIds(@Param("uid") Integer uid, @Param("ids") List<Integer> ids);
List<InviteSettlement> selectBySettleCodes(@Param("settleCodes") List<Integer> settleCodes);
}
\ No newline at end of file
... ...
... ... @@ -59,6 +59,13 @@
and status = #{srcStatus,jdbcType=INTEGER}
</update>
<update id="updateStatusByUidAndInviteSettlementId">
update invite_settlement_item
set status = #{status,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER}
and invite_settlement_id = #{inviteSettlementId,jdbcType=INTEGER}
</update>
<select id="selectByUidAndBuyerOrderCode" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
... ...
... ... @@ -70,4 +70,14 @@
</foreach>
</select>
<select id="selectBySettleCodes" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from invite_settlement
where settle_code in
<foreach collection="settleCodes" item="settleCode" open="(" separator="," close=")">
#{settleCode}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,17 +2,19 @@ package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.model.InviteSettlementItemListVO;
import com.yohoufo.order.model.InviteSettlementItemListVO;
import com.yohoufo.order.model.InviteSettlementListVO;
import com.yohoufo.order.service.IInviteSettlementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
import java.util.List;
/**
* @author LUOXC
* @date 2019/4/2 14:58
... ... @@ -63,5 +65,11 @@ public class InviteSettlementController {
return new ApiResponse.ApiResponseBuilder().code(200).message("ok").build();
}
@RequestMapping(value = "/erp/invite/settlement/help/paid")
public ApiResponse paid(@RequestBody List<Integer> settleCodes) {
inviteSettlementService.paid(settleCodes);
return new ApiResponse.ApiResponseBuilder().code(200).message("ok").build();
}
}
... ...
... ... @@ -3,6 +3,8 @@ package com.yohoufo.order.service;
import com.yohoufo.order.model.InviteSettlementItemListVO;
import com.yohoufo.order.model.InviteSettlementListVO;
import java.util.List;
public interface IInviteSettlementService {
/**
... ... @@ -26,6 +28,12 @@ public interface IInviteSettlementService {
void settle(int uid);
/**
* 将结算单和结算项标志成已付款
* @param settleCodes
*/
void paid(List<Integer> settleCodes);
/**
* 创建结算项
*
* @param buyerOrderCode
... ...
... ... @@ -135,9 +135,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
.map(item -> new InviteSettlementItemListVO.InviteSettlementItemVO()
.setBuyerOrderCode(item.getBuyerOrderCode().toString())
.setSellerName(sellerUidNickNameMap.get(item.getSellerUid()))
.setOrderAmount(formatAmount(item.getOrderAmount()))
.setOrderAmount(formatAmount("¥%s", item.getOrderAmount()))
.setOrderCreateTime(formatYYMMddHHmmssPoint(item.getOrderCreateTime()))
.setSettleAmount(formatAmount(item.getSettleAmount()))
.setSettleAmount(formatAmount("¥%s", item.getSettleAmount()))
.setStatusDesc(itemHasPaid.test(item) ? "已付款" : "待付款"))
.collect(Collectors.toList()))
.build();
... ... @@ -183,6 +183,21 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
}
@Override
public void paid(List<Integer> settleCodes) {
if (CollectionUtils.isEmpty(settleCodes)) {
return;
}
List<InviteSettlement> settlements = inviteSettlementMapper.selectBySettleCodes(settleCodes);
settlements.stream().forEach(settlement -> {
log.info("mark settlement to paid, settle code is {}", settlement.getSettleCode());
settlement.setStatus(InviteSettlement.STATUS_PAID);
inviteSettlementMapper.updateByUidAndId(settlement);
inviteSettlementItemMapper.updateStatusByUidAndInviteSettlementId(settlement.getUid(), settlement.getId(), InviteSettlementItem.STATUS_PAID);
});
}
@Override
public void createInviteSettlementItem(Long buyerOrderCode, Integer status) {
inviteSettlementItemCreator.createInviteSettlementItem(buyerOrderCode, status);
}
... ...