分销分钱具体逻辑
This commit is contained in:
@@ -5,7 +5,9 @@ import com.czg.account.dto.shopinfo.ShopInfoSubVO;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -17,4 +19,7 @@ import java.util.List;
|
||||
public interface ShopInfoMapper extends BaseMapper<ShopInfo> {
|
||||
|
||||
List<ShopInfoSubVO> getSubList(@Param("lng") String lng, @Param("lat") String lat, @Param("distance") float distance);
|
||||
|
||||
@Update("update tb_shop_info set amount = amount + #{amount} where id = #{id} and amount + #{amount} >= 0")
|
||||
boolean updateAmount(@Param("id") Long id, @Param("amount") BigDecimal amount);
|
||||
}
|
||||
|
||||
@@ -453,9 +453,11 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
if (shopInfo.getAmount() == null) {
|
||||
shopInfo.setAmount(BigDecimal.ZERO);
|
||||
}
|
||||
shopInfo.setAmount(shopInfo.getAmount().add(amount));
|
||||
updateById(shopInfo);
|
||||
return shopInfo.getAmount();
|
||||
boolean flag = mapper.updateAmount(id, amount);
|
||||
if (!flag) {
|
||||
throw new CzgException("更新失败");
|
||||
}
|
||||
return shopInfo.getAmount().add(amount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user