Authored by qinchao

Merge branch 'test6.8.2' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.2

... ... @@ -32,5 +32,7 @@ public interface EntrySellerRechargeOrderMapper {
EntrySellerRechargeOrder selectByOrderCodeUid(@Param("orderCode")long orderCode, @Param("uid")int uid);
EntrySellerRechargeOrder selectByOrderCode(@Param("orderCode")long orderCode);
EntrySellerRechargeOrder selectAllRechargeByUid(@Param("uid") Integer uid);
}
\ No newline at end of file
... ...
... ... @@ -22,4 +22,7 @@ public interface SellerWalletDetailMapper {
int selectUserDetailCount(@Param("uid") Integer uid);
List<SellerWalletDetail> selectUserDetail(@Param("uid") Integer uid, @Param("start") Integer start, @Param("count") Integer count);
SellerWalletDetail selectUserPunishAmount(@Param("uid") Integer uid);
}
\ No newline at end of file
... ...
... ... @@ -200,5 +200,12 @@
order by id desc
limit #{start,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
</select>
<select id="selectAllRechargeByUid" resultMap="BaseResultMap">
select
uid, sum(amount) as amount
from entry_seller_recharge_order
where status = 1 and uid = #{uid,jdbcType=INTEGER} and type in(1,2)
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -194,5 +194,11 @@
where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (1,31,32,33,61) order by id desc limit #{start},#{count}
</select>
<select id="selectUserPunishAmount" resultMap="BaseResultMap" >
select
uid, sum(amount) as amount
from seller_wallet_detail
where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (31,32,33)
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -388,8 +388,8 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
// 处罚保证金:总账修改
// 卖家取消、鉴定失败
public SellerWallet punishEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach, SellerWalletDetail.Type type) {
return changeEarnest(uid, money, 0L, attach, type);
public SellerWallet punishEarnest(Integer uid, BigDecimal money, MerchantOrderAttachInfo attach, long orderCode, SellerWalletDetail.Type type) {
return changeEarnest(uid, money, orderCode, attach, type);
}
// 支付保证金:明细记录+orders_pay记录
... ... @@ -454,6 +454,16 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.changeEarnest", "钱包不可用uid=" + uid+", 退还金额为:"+amount);
return null;
}
//////////////////////////////////////
// 核算总账
BigDecimal checkMoney = checkMoney(sw,0);
if (checkMoney == null) {
logger.info("uid={}退出入驻账目简要核对,结果失败", uid);
return null;
}
// 查询充值表,查询明细表
//////////////////////////////////////
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
if (sellerWalletMapper.returnMoney(sw) == 0) {
... ... @@ -482,6 +492,40 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
return amount;
}
private BigDecimal checkMoney(SellerWallet sw, Integer uid0) {
if(sw==null) {
sw = sellerWalletMapper.selectByUidAndType(uid0, 1);
}
Integer uid = sw.getUid();
logger.info("uid={}退出入驻账目简要核对", uid);
logger.info("uid={}退出入驻账目简要核对,保证金余额={},锁定余额={}", uid, sw.getAmount(), sw.getLockAmount());
if (sw.getLockAmount().compareTo(BigDecimal.ZERO) != 0) {
logger.error("uid={}退出入驻账目简要核对,锁定余额{}不为0", uid, sw.getLockAmount());
return null;
}
EntrySellerRechargeOrder recharge = entrySellerRechargeOrderMapper.selectAllRechargeByUid(uid);
if (recharge == null) {
logger.error("uid={}退出入驻账目简要核对,未找到充值订单");
return null;
}
BigDecimal allMoney = recharge.getAmount();
logger.info("uid={}退出入驻账目简要核对,保证金充值总额为={}", uid, recharge.getAmount());
SellerWalletDetail punish = sellerWalletDetailMapper.selectUserPunishAmount(uid);
if (punish != null) {
logger.info("uid={}退出入驻账目简要核对,处罚总额为={}", uid, punish.getAmount().abs());
allMoney = allMoney.subtract(punish.getAmount().abs());
} else {
logger.info("uid={}退出入驻账目简要核对,无处罚记录", uid);
}
if (allMoney.compareTo(sw.getAmount()) != 0) {
logger.error("uid={}退出入驻账目简要核对,总账-处罚={},与余额{}不一致", uid, allMoney, sw.getAmount());
return null;
}
logger.info("uid={}退出入驻账目简要核对,保证金余额={},核对成功", uid, sw.getAmount());
return sw.getAmount();
}
// 增加:明细
private SellerWalletDetail addWalletDetail(SellerWallet sw, long orderCode, BigDecimal amount, SellerWalletDetail.Type type) {
Integer uid = sw.getUid();
... ...
... ... @@ -93,6 +93,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
private static final List<Long> SELLER_TYPES = Arrays.asList(OrderCodeType.SELLER_TYPE.getType());
private static final List<Integer> SHOW_OVER_FLOW_PRICE_STATUS ;
static {
SHOW_OVER_FLOW_PRICE_STATUS = Arrays.asList(SkupStatus.CAN_SELL.getCode());
}
@Override
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
int uid;
... ... @@ -336,10 +342,14 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
orderDetailInfo.setUserAddress(addressInfo);
//卖家
assembleSoldPrdCompute(orderDetailInfo, order.getUid(), sellerOrderGoods.getId());
String tips = buildOverPriceTips(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice());
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(order, skupStatus);
if (StringUtils.isNotBlank(tips)){
statusDetail.setDetailDesc(tips);
if(SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())) {
String tips = buildOverPriceTips(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice());
if (StringUtils.isNotBlank(tips)) {
statusDetail.setDetailDesc(tips);
}
}
orderDetailInfo.setStatusDetail(statusDetail);
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
... ...