Authored by TANLING

Merge branch 'hotfix_0407_skupnotexist2' into test6.9.24

... ... @@ -3,6 +3,7 @@ package com.yohoufo.dal.order;
import java.math.BigDecimal;
import java.util.List;
import com.yohoufo.dal.order.model.SellerWalletCompensate;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.order.model.SellerWallet;
... ... @@ -15,6 +16,8 @@ public interface SellerWalletMapper {
SellerWallet selectByPrimaryKey(Integer id);
List<SellerWalletCompensate> selectByCompensate(@Param("list") List<Integer> uids);
List<SellerWallet> selectByUids(@Param("list") List<Integer> uids);
... ...
... ... @@ -20,6 +20,8 @@ public interface StoredSellerMapper {
int updateByUidSelective(StoredSeller record);
StoredSeller selectByUid(int uid);
List<StoredSeller> selectByUidList(List<Integer> uids);
int clearUserData(@Param("uid") Integer uid);
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
import java.util.List;
@Data
@ToString
public class SellerWalletCompensate {
private Integer uid;
BigDecimal earnestMoney;
List<Integer> skups;
BigDecimal availableAmount;
BigDecimal lockAmount;
}
... ...
... ... @@ -22,6 +22,54 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCompensate" resultType="com.yohoufo.dal.order.model.SellerWalletCompensate">
SELECT
t.earnest_money earnestMoney, t.uid, t.skups, sw.amount availableAmount,
sw.lock_amount lockAmount
FROM
(
SELECT
sum(so.earnest_money) earnest_money,
so.uid,
group_concat(sog.id) skups
FROM
ufo_order.seller_order so,
ufo_order.seller_order_goods sog
WHERE
sog.id = so.skup
AND (
sog. STATUS = 1
OR (
sog. STATUS = 2
AND so.skup IN (
SELECT
bog.skup
FROM
ufo_order.buyer_order bo,
ufo_order.buyer_order_goods bog
WHERE
bo. STATUS IN (0, 1, 2, 3, 32,31)
AND bo.order_code = bog.order_code
)
)
)
AND so.payment = 11
<if test="list != null">
and so.uid in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
so.uid
) t,
ufo_order.seller_wallet sw
WHERE
t.uid = sw.uid
AND t.earnest_money - sw.lock_amount != 0
</select>
<select id="selectByUids" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ...
... ... @@ -116,6 +116,20 @@ public class OrderHelpController {
@IgnoreSignature
@IgnoreSession
@RequestMapping(value = "/compensate")
public ApiResponse compensate(@RequestParam(value = "uids", required = false) List<Integer> uids) {
storedSellerService.compensate(uids);
return new ApiResponse.ApiResponseBuilder()
.code(200)
.message("降级成功")
.build();
}
@IgnoreSignature
@IgnoreSession
@RequestMapping(value = "/orderPay")
public ApiResponse orderPay(@RequestParam(value = "orderCodes") List<Long> orderCodes){
... ...
... ... @@ -13,10 +13,11 @@ import java.util.Map;
*/
public interface IStoredSellerService {
/**
* 增加orderPay记录
* @param uids
*/
void compensate(List<Integer> uids);
public void orderPay(List<Long> orderCodes);
boolean isStoredSeller(Integer uid);
... ...
... ... @@ -46,6 +46,7 @@ import org.springframework.integration.context.Orderable;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.CollationElementIterator;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Arrays;
... ... @@ -388,10 +389,7 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
OrdersPayMapper ordersPayMapper;
/**
* 增加orderPay记录
* @param uids
*/
public void orderPay(List<Long> orderCodes){
// 查询卖家正在上架中的商品 & 支付方式是11 & orderspay中没有记录
... ... @@ -431,6 +429,56 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
}
}
public void compensate(List<Integer> uids){
if (CollectionUtils.isEmpty(uids)){
return;
}
// 超级
List<StoredSeller> storedSellerList = storedSellerMapper.selectByUidList(uids);
if (CollectionUtils.isEmpty(storedSellerList)){
return;
}
List<StoredSeller> filterStoredList = storedSellerList.stream().filter(x->x.getEntryType()==EntrySellerType.COMMON.getCode() && x.getValidStatus()==1).collect(Collectors.toList());
List<SellerWalletCompensate> sellerWalletCompensates = sellerWalletMapper.selectByCompensate(filterStoredList.stream().map(StoredSeller::getUid).collect(Collectors.toList()));
for (SellerWalletCompensate s : sellerWalletCompensates){
double compensate = YHMath.sub(s.getEarnestMoney().doubleValue(), s.getLockAmount().doubleValue());
if (compensate<0){
scriptLogger.info("[{}] no need manual handle1 data {}", s.getUid(), s);
continue;
}
if (compensate<0){
scriptLogger.info("[{}] need manual handle1 data {}", s.getUid(), s);
continue;
}
if (YHMath.sub(s.getAvailableAmount().doubleValue(), compensate) < 0){
scriptLogger.info("[{}] need manual handle2 data {}", s.getUid(), s);
continue;
}
BigDecimal earnestMoney = new BigDecimal(compensate);
earnestMoney = earnestMoney.setScale(2, BigDecimal.ROUND_HALF_UP);
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(s.getUid())
.earnestMoney(earnestMoney)
.type(SellerWalletDetail.Type.PUBLISH.getValue()).build();
merchantOrderPaymentService.useEarnest(s.getUid(), earnestMoney, moai);
scriptLogger.info("[{}] compensate lock money {} success", s.getUid(), s);
}
}
/**
* 将原来的超级卖家降级
*/
... ...